]> git.saurik.com Git - apple/javascriptcore.git/blame - runtime/MathObject.cpp
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / runtime / MathObject.cpp
CommitLineData
9dae56ea
A
1/*
2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
81345200 3 * Copyright (C) 2007, 2008, 2013 Apple Inc. All Rights Reserved.
9dae56ea
A
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21#include "config.h"
22#include "MathObject.h"
23
4e4e5a6f 24#include "Lookup.h"
ed1e77d3 25#include "MathCommon.h"
9dae56ea 26#include "ObjectPrototype.h"
81345200 27#include "JSCInlines.h"
9dae56ea
A
28#include <time.h>
29#include <wtf/Assertions.h>
30#include <wtf/MathExtras.h>
31#include <wtf/RandomNumber.h>
32#include <wtf/RandomNumberSeed.h>
81345200 33#include <wtf/Vector.h>
9dae56ea
A
34
35namespace JSC {
36
81345200 37STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(MathObject);
9dae56ea 38
ed1e77d3
A
39EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*);
40EncodedJSValue JSC_HOST_CALL mathProtoFuncACosh(ExecState*);
41EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*);
42EncodedJSValue JSC_HOST_CALL mathProtoFuncASinh(ExecState*);
43EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*);
44EncodedJSValue JSC_HOST_CALL mathProtoFuncATanh(ExecState*);
45EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*);
46EncodedJSValue JSC_HOST_CALL mathProtoFuncCbrt(ExecState*);
47EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*);
48EncodedJSValue JSC_HOST_CALL mathProtoFuncClz32(ExecState*);
49EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*);
50EncodedJSValue JSC_HOST_CALL mathProtoFuncCosh(ExecState*);
51EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*);
52EncodedJSValue JSC_HOST_CALL mathProtoFuncExpm1(ExecState*);
53EncodedJSValue JSC_HOST_CALL mathProtoFuncFround(ExecState*);
54EncodedJSValue JSC_HOST_CALL mathProtoFuncHypot(ExecState*);
55EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*);
56EncodedJSValue JSC_HOST_CALL mathProtoFuncLog1p(ExecState*);
57EncodedJSValue JSC_HOST_CALL mathProtoFuncLog10(ExecState*);
58EncodedJSValue JSC_HOST_CALL mathProtoFuncLog2(ExecState*);
59EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*);
60EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*);
61EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*);
62EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*);
63EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*);
64EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState*);
65EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*);
66EncodedJSValue JSC_HOST_CALL mathProtoFuncSinh(ExecState*);
67EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*);
68EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*);
69EncodedJSValue JSC_HOST_CALL mathProtoFuncTanh(ExecState*);
70EncodedJSValue JSC_HOST_CALL mathProtoFuncTrunc(ExecState*);
71EncodedJSValue JSC_HOST_CALL mathProtoFuncIMul(ExecState*);
9dae56ea
A
72
73}
74
9dae56ea
A
75namespace JSC {
76
ed1e77d3 77const ClassInfo MathObject::s_info = { "Math", &Base::s_info, 0, CREATE_METHOD_TABLE(MathObject) };
9dae56ea 78
81345200
A
79MathObject::MathObject(VM& vm, Structure* structure)
80 : JSNonFinalObject(vm, structure)
9dae56ea 81{
f9bf01c6 82}
9dae56ea 83
81345200 84void MathObject::finishCreation(VM& vm, JSGlobalObject* globalObject)
f9bf01c6 85{
81345200
A
86 Base::finishCreation(vm);
87 ASSERT(inherits(info()));
88
ed1e77d3
A
89 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "E"), jsNumber(exp(1.0)), DontDelete | DontEnum | ReadOnly);
90 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LN2"), jsNumber(log(2.0)), DontDelete | DontEnum | ReadOnly);
91 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LN10"), jsNumber(log(10.0)), DontDelete | DontEnum | ReadOnly);
92 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LOG2E"), jsNumber(1.0 / log(2.0)), DontDelete | DontEnum | ReadOnly);
93 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LOG10E"), jsNumber(0.4342944819032518), DontDelete | DontEnum | ReadOnly);
94 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "PI"), jsNumber(piDouble), DontDelete | DontEnum | ReadOnly);
95 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "SQRT1_2"), jsNumber(sqrt(0.5)), DontDelete | DontEnum | ReadOnly);
96 putDirectWithoutTransition(vm, Identifier::fromString(&vm, "SQRT2"), jsNumber(sqrt(2.0)), DontDelete | DontEnum | ReadOnly);
97
98 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "abs"), 1, mathProtoFuncAbs, AbsIntrinsic, DontEnum | Function);
99 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "acos"), 1, mathProtoFuncACos, NoIntrinsic, DontEnum | Function);
100 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "asin"), 1, mathProtoFuncASin, NoIntrinsic, DontEnum | Function);
101 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "atan"), 1, mathProtoFuncATan, NoIntrinsic, DontEnum | Function);
102 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "acosh"), 1, mathProtoFuncACosh, NoIntrinsic, DontEnum | Function);
103 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "asinh"), 1, mathProtoFuncASinh, NoIntrinsic, DontEnum | Function);
104 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "atanh"), 1, mathProtoFuncATanh, NoIntrinsic, DontEnum | Function);
105 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "atan2"), 2, mathProtoFuncATan2, NoIntrinsic, DontEnum | Function);
106 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "cbrt"), 1, mathProtoFuncCbrt, NoIntrinsic, DontEnum | Function);
107 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "ceil"), 1, mathProtoFuncCeil, CeilIntrinsic, DontEnum | Function);
108 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "clz32"), 1, mathProtoFuncClz32, Clz32Intrinsic, DontEnum | Function);
109 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "cos"), 1, mathProtoFuncCos, CosIntrinsic, DontEnum | Function);
110 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "cosh"), 1, mathProtoFuncCosh, NoIntrinsic, DontEnum | Function);
111 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "exp"), 1, mathProtoFuncExp, ExpIntrinsic, DontEnum | Function);
112 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "expm1"), 1, mathProtoFuncExpm1, NoIntrinsic, DontEnum | Function);
113 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "floor"), 1, mathProtoFuncFloor, FloorIntrinsic, DontEnum | Function);
114 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "fround"), 1, mathProtoFuncFround, FRoundIntrinsic, DontEnum | Function);
115 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "hypot"), 2, mathProtoFuncHypot, NoIntrinsic, DontEnum | Function);
116 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log"), 1, mathProtoFuncLog, LogIntrinsic, DontEnum | Function);
117 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log10"), 1, mathProtoFuncLog10, NoIntrinsic, DontEnum | Function);
118 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log1p"), 1, mathProtoFuncLog1p, NoIntrinsic, DontEnum | Function);
119 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log2"), 1, mathProtoFuncLog2, NoIntrinsic, DontEnum | Function);
120 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "max"), 2, mathProtoFuncMax, MaxIntrinsic, DontEnum | Function);
121 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "min"), 2, mathProtoFuncMin, MinIntrinsic, DontEnum | Function);
122 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "pow"), 2, mathProtoFuncPow, PowIntrinsic, DontEnum | Function);
123 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "random"), 0, mathProtoFuncRandom, NoIntrinsic, DontEnum | Function);
124 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "round"), 1, mathProtoFuncRound, RoundIntrinsic, DontEnum | Function);
125 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sign"), 1, mathProtoFuncSign, NoIntrinsic, DontEnum | Function);
126 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sin"), 1, mathProtoFuncSin, SinIntrinsic, DontEnum | Function);
127 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sinh"), 1, mathProtoFuncSinh, NoIntrinsic, DontEnum | Function);
128 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sqrt"), 1, mathProtoFuncSqrt, SqrtIntrinsic, DontEnum | Function);
129 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "tan"), 1, mathProtoFuncTan, NoIntrinsic, DontEnum | Function);
130 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "tanh"), 1, mathProtoFuncTanh, NoIntrinsic, DontEnum | Function);
131 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "trunc"), 1, mathProtoFuncTrunc, NoIntrinsic, DontEnum | Function);
132 putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "imul"), 2, mathProtoFuncIMul, IMulIntrinsic, DontEnum | Function);
9dae56ea
A
133}
134
135// ------------------------------ Functions --------------------------------
136
14957cd0 137EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec)
9dae56ea 138{
14957cd0 139 return JSValue::encode(jsNumber(fabs(exec->argument(0).toNumber(exec))));
9dae56ea
A
140}
141
14957cd0 142EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec)
9dae56ea 143{
14957cd0 144 return JSValue::encode(jsDoubleNumber(acos(exec->argument(0).toNumber(exec))));
9dae56ea
A
145}
146
14957cd0 147EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec)
9dae56ea 148{
14957cd0 149 return JSValue::encode(jsDoubleNumber(asin(exec->argument(0).toNumber(exec))));
9dae56ea
A
150}
151
14957cd0 152EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec)
9dae56ea 153{
14957cd0 154 return JSValue::encode(jsDoubleNumber(atan(exec->argument(0).toNumber(exec))));
9dae56ea
A
155}
156
14957cd0 157EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec)
9dae56ea 158{
14957cd0
A
159 double arg0 = exec->argument(0).toNumber(exec);
160 double arg1 = exec->argument(1).toNumber(exec);
161 return JSValue::encode(jsDoubleNumber(atan2(arg0, arg1)));
9dae56ea
A
162}
163
14957cd0 164EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec)
9dae56ea 165{
14957cd0 166 return JSValue::encode(jsNumber(ceil(exec->argument(0).toNumber(exec))));
9dae56ea
A
167}
168
ed1e77d3
A
169EncodedJSValue JSC_HOST_CALL mathProtoFuncClz32(ExecState* exec)
170{
171 uint32_t value = exec->argument(0).toUInt32(exec);
172 if (exec->hadException())
173 return JSValue::encode(jsNull());
174 return JSValue::encode(JSValue(clz32(value)));
175}
176
14957cd0 177EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec)
9dae56ea 178{
14957cd0 179 return JSValue::encode(jsDoubleNumber(cos(exec->argument(0).toNumber(exec))));
9dae56ea
A
180}
181
14957cd0 182EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec)
9dae56ea 183{
14957cd0 184 return JSValue::encode(jsDoubleNumber(exp(exec->argument(0).toNumber(exec))));
9dae56ea
A
185}
186
14957cd0 187EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec)
9dae56ea 188{
14957cd0 189 return JSValue::encode(jsNumber(floor(exec->argument(0).toNumber(exec))));
9dae56ea
A
190}
191
81345200
A
192EncodedJSValue JSC_HOST_CALL mathProtoFuncHypot(ExecState* exec)
193{
194 unsigned argsCount = exec->argumentCount();
195 double max = 0;
196 Vector<double, 8> args;
197 args.reserveInitialCapacity(argsCount);
198 for (unsigned i = 0; i < argsCount; ++i) {
199 args.uncheckedAppend(exec->uncheckedArgument(i).toNumber(exec));
200 if (exec->hadException())
201 return JSValue::encode(jsNull());
202 if (std::isinf(args[i]))
203 return JSValue::encode(jsDoubleNumber(+std::numeric_limits<double>::infinity()));
204 max = std::max(fabs(args[i]), max);
205 }
206 if (!max)
207 max = 1;
208 // Kahan summation algorithm significantly reduces the numerical error in the total obtained.
209 double sum = 0;
210 double compensation = 0;
211 for (double argument : args) {
212 double scaledArgument = argument / max;
213 double summand = scaledArgument * scaledArgument - compensation;
214 double preliminary = sum + summand;
215 compensation = (preliminary - sum) - summand;
216 sum = preliminary;
217 }
218 return JSValue::encode(jsDoubleNumber(sqrt(sum) * max));
219}
220
14957cd0 221EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec)
9dae56ea 222{
14957cd0 223 return JSValue::encode(jsDoubleNumber(log(exec->argument(0).toNumber(exec))));
9dae56ea
A
224}
225
14957cd0 226EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec)
9dae56ea 227{
14957cd0 228 unsigned argsCount = exec->argumentCount();
6fe7ccc8 229 double result = -std::numeric_limits<double>::infinity();
9dae56ea 230 for (unsigned k = 0; k < argsCount; ++k) {
81345200 231 double val = exec->uncheckedArgument(k).toNumber(exec);
93a37866 232 if (std::isnan(val)) {
81345200
A
233 result = PNaN;
234 } else if (val > result || (!val && !result && !std::signbit(val)))
9dae56ea
A
235 result = val;
236 }
14957cd0 237 return JSValue::encode(jsNumber(result));
9dae56ea
A
238}
239
14957cd0 240EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec)
9dae56ea 241{
14957cd0 242 unsigned argsCount = exec->argumentCount();
6fe7ccc8 243 double result = +std::numeric_limits<double>::infinity();
9dae56ea 244 for (unsigned k = 0; k < argsCount; ++k) {
81345200 245 double val = exec->uncheckedArgument(k).toNumber(exec);
93a37866 246 if (std::isnan(val)) {
81345200
A
247 result = PNaN;
248 } else if (val < result || (!val && !result && std::signbit(val)))
9dae56ea
A
249 result = val;
250 }
14957cd0 251 return JSValue::encode(jsNumber(result));
9dae56ea
A
252}
253
14957cd0 254EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec)
9dae56ea
A
255{
256 // ECMA 15.8.2.1.13
257
14957cd0
A
258 double arg = exec->argument(0).toNumber(exec);
259 double arg2 = exec->argument(1).toNumber(exec);
9dae56ea 260
ed1e77d3 261 return JSValue::encode(JSValue(operationMathPow(arg, arg2)));
9dae56ea
A
262}
263
14957cd0 264EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec)
9dae56ea 265{
14957cd0 266 return JSValue::encode(jsDoubleNumber(exec->lexicalGlobalObject()->weakRandomNumber()));
9dae56ea
A
267}
268
14957cd0 269EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec)
ed1e77d3
A
270{
271 return JSValue::encode(jsNumber(jsRound(exec->argument(0).toNumber(exec))));
272}
273
274EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState* exec)
9dae56ea 275{
14957cd0 276 double arg = exec->argument(0).toNumber(exec);
ed1e77d3
A
277 if (std::isnan(arg))
278 return JSValue::encode(jsNaN());
279 if (!arg)
280 return JSValue::encode(std::signbit(arg) ? jsNumber(-0.0) : jsNumber(0));
281 return JSValue::encode(jsNumber(std::signbit(arg) ? -1 : 1));
9dae56ea
A
282}
283
14957cd0 284EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec)
9dae56ea 285{
81345200 286 return JSValue::encode(jsDoubleNumber(sin(exec->argument(0).toNumber(exec))));
9dae56ea
A
287}
288
14957cd0 289EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec)
9dae56ea 290{
14957cd0 291 return JSValue::encode(jsDoubleNumber(sqrt(exec->argument(0).toNumber(exec))));
9dae56ea
A
292}
293
14957cd0 294EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec)
9dae56ea 295{
14957cd0 296 return JSValue::encode(jsDoubleNumber(tan(exec->argument(0).toNumber(exec))));
9dae56ea
A
297}
298
93a37866
A
299EncodedJSValue JSC_HOST_CALL mathProtoFuncIMul(ExecState* exec)
300{
301 int32_t left = exec->argument(0).toInt32(exec);
302 if (exec->hadException())
303 return JSValue::encode(jsNull());
304 int32_t right = exec->argument(1).toInt32(exec);
305 return JSValue::encode(jsNumber(left * right));
306}
307
81345200
A
308EncodedJSValue JSC_HOST_CALL mathProtoFuncACosh(ExecState* exec)
309{
310 return JSValue::encode(jsDoubleNumber(acosh(exec->argument(0).toNumber(exec))));
311}
312
313EncodedJSValue JSC_HOST_CALL mathProtoFuncASinh(ExecState* exec)
314{
315 return JSValue::encode(jsDoubleNumber(asinh(exec->argument(0).toNumber(exec))));
316}
317
318EncodedJSValue JSC_HOST_CALL mathProtoFuncATanh(ExecState* exec)
319{
320 return JSValue::encode(jsDoubleNumber(atanh(exec->argument(0).toNumber(exec))));
321}
322
323EncodedJSValue JSC_HOST_CALL mathProtoFuncCbrt(ExecState* exec)
324{
325 return JSValue::encode(jsDoubleNumber(cbrt(exec->argument(0).toNumber(exec))));
326}
327
328EncodedJSValue JSC_HOST_CALL mathProtoFuncCosh(ExecState* exec)
329{
330 return JSValue::encode(jsDoubleNumber(cosh(exec->argument(0).toNumber(exec))));
331}
332
333EncodedJSValue JSC_HOST_CALL mathProtoFuncExpm1(ExecState* exec)
334{
335 return JSValue::encode(jsDoubleNumber(expm1(exec->argument(0).toNumber(exec))));
336}
337
338EncodedJSValue JSC_HOST_CALL mathProtoFuncFround(ExecState* exec)
339{
340 return JSValue::encode(jsDoubleNumber(static_cast<float>(exec->argument(0).toNumber(exec))));
341}
342
343EncodedJSValue JSC_HOST_CALL mathProtoFuncLog1p(ExecState* exec)
344{
345 double value = exec->argument(0).toNumber(exec);
346 if (value == 0)
347 return JSValue::encode(jsDoubleNumber(value));
348 return JSValue::encode(jsDoubleNumber(log1p(value)));
349}
350
351EncodedJSValue JSC_HOST_CALL mathProtoFuncLog10(ExecState* exec)
352{
353 return JSValue::encode(jsDoubleNumber(log10(exec->argument(0).toNumber(exec))));
354}
355
356EncodedJSValue JSC_HOST_CALL mathProtoFuncLog2(ExecState* exec)
357{
358 return JSValue::encode(jsDoubleNumber(log2(exec->argument(0).toNumber(exec))));
359}
360
361EncodedJSValue JSC_HOST_CALL mathProtoFuncSinh(ExecState* exec)
362{
363 return JSValue::encode(jsDoubleNumber(sinh(exec->argument(0).toNumber(exec))));
364}
365
366EncodedJSValue JSC_HOST_CALL mathProtoFuncTanh(ExecState* exec)
367{
368 return JSValue::encode(jsDoubleNumber(tanh(exec->argument(0).toNumber(exec))));
369}
370
371EncodedJSValue JSC_HOST_CALL mathProtoFuncTrunc(ExecState*exec)
372{
373 return JSValue::encode(jsNumber(exec->argument(0).toIntegerPreserveNaN(exec)));
374}
375
9dae56ea 376} // namespace JSC