kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 1 | /* |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 2 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) |
mark.lam@apple.com | e1ab17c | 2016-09-26 19:11:17 +0000 | [diff] [blame] | 3 | * Copyright (C) 2007-2008, 2013, 2015-2016 Apple Inc. All Rights Reserved. |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 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 |
mjs | cdff33b | 2006-01-23 21:41:36 +0000 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 18 | * |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
mjs | b64c50a | 2005-10-03 21:13:12 +0000 | [diff] [blame] | 21 | #include "config.h" |
darin@apple.com | 5c0863d | 2008-06-16 04:17:44 +0000 | [diff] [blame] | 22 | #include "MathObject.h" |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 23 | |
fpizlo@apple.com | afa9d88 | 2016-11-01 03:10:00 +0000 | [diff] [blame] | 24 | #include "JSCInlines.h" |
benjamin@webkit.org | 28b4f2d | 2015-02-18 08:01:01 +0000 | [diff] [blame] | 25 | #include "MathCommon.h" |
weinig@apple.com | ee8c780 | 2008-06-28 21:40:47 +0000 | [diff] [blame] | 26 | #include "ObjectPrototype.h" |
darin | 36d1136 | 2006-04-11 16:30:21 +0000 | [diff] [blame] | 27 | #include <time.h> |
ggaren | 7213ee0 | 2007-10-16 23:25:33 +0000 | [diff] [blame] | 28 | #include <wtf/Assertions.h> |
darin | deaf059 | 2007-10-27 19:10:40 +0000 | [diff] [blame] | 29 | #include <wtf/MathExtras.h> |
commit-queue@webkit.org | 4510bff | 2014-03-18 03:21:22 +0000 | [diff] [blame] | 30 | #include <wtf/Vector.h> |
darin | 36d1136 | 2006-04-11 16:30:21 +0000 | [diff] [blame] | 31 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 32 | namespace JSC { |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 33 | |
andersca@apple.com | 7de5aae | 2013-09-05 20:12:23 +0000 | [diff] [blame] | 34 | STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(MathObject); |
ggaren@apple.com | fea4353 | 2008-08-17 20:23:49 +0000 | [diff] [blame] | 35 | |
dbatyai.u-szeged@partner.samsung.com | b107a6e | 2014-10-21 10:18:13 +0000 | [diff] [blame] | 36 | EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState*); |
| 37 | EncodedJSValue JSC_HOST_CALL mathProtoFuncACosh(ExecState*); |
| 38 | EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState*); |
| 39 | EncodedJSValue JSC_HOST_CALL mathProtoFuncASinh(ExecState*); |
| 40 | EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState*); |
| 41 | EncodedJSValue JSC_HOST_CALL mathProtoFuncATanh(ExecState*); |
| 42 | EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState*); |
| 43 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCbrt(ExecState*); |
| 44 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState*); |
benjamin@webkit.org | e324d43 | 2015-04-26 19:55:18 +0000 | [diff] [blame] | 45 | EncodedJSValue JSC_HOST_CALL mathProtoFuncClz32(ExecState*); |
dbatyai.u-szeged@partner.samsung.com | b107a6e | 2014-10-21 10:18:13 +0000 | [diff] [blame] | 46 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState*); |
| 47 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCosh(ExecState*); |
| 48 | EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState*); |
| 49 | EncodedJSValue JSC_HOST_CALL mathProtoFuncExpm1(ExecState*); |
dbatyai.u-szeged@partner.samsung.com | b107a6e | 2014-10-21 10:18:13 +0000 | [diff] [blame] | 50 | EncodedJSValue JSC_HOST_CALL mathProtoFuncFround(ExecState*); |
| 51 | EncodedJSValue JSC_HOST_CALL mathProtoFuncHypot(ExecState*); |
| 52 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState*); |
| 53 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog1p(ExecState*); |
| 54 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog10(ExecState*); |
| 55 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog2(ExecState*); |
| 56 | EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState*); |
| 57 | EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState*); |
| 58 | EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState*); |
| 59 | EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState*); |
| 60 | EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState*); |
| 61 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState*); |
| 62 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState*); |
| 63 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSinh(ExecState*); |
| 64 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState*); |
| 65 | EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState*); |
| 66 | EncodedJSValue JSC_HOST_CALL mathProtoFuncTanh(ExecState*); |
dbatyai.u-szeged@partner.samsung.com | b107a6e | 2014-10-21 10:18:13 +0000 | [diff] [blame] | 67 | EncodedJSValue JSC_HOST_CALL mathProtoFuncIMul(ExecState*); |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 68 | |
utatane.tea@gmail.com | a5544f1 | 2017-05-19 09:23:20 +0000 | [diff] [blame] | 69 | const ClassInfo MathObject::s_info = { "Math", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(MathObject) }; |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 70 | |
akling@apple.com | 3828a86 | 2013-09-30 21:41:04 +0000 | [diff] [blame] | 71 | MathObject::MathObject(VM& vm, Structure* structure) |
| 72 | : JSNonFinalObject(vm, structure) |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 73 | { |
commit-queue@webkit.org | 6e5671b | 2011-09-01 23:49:23 +0000 | [diff] [blame] | 74 | } |
| 75 | |
akling@apple.com | 3828a86 | 2013-09-30 21:41:04 +0000 | [diff] [blame] | 76 | void MathObject::finishCreation(VM& vm, JSGlobalObject* globalObject) |
commit-queue@webkit.org | 6e5671b | 2011-09-01 23:49:23 +0000 | [diff] [blame] | 77 | { |
akling@apple.com | 3828a86 | 2013-09-30 21:41:04 +0000 | [diff] [blame] | 78 | Base::finishCreation(vm); |
keith_miller@apple.com | 45da760 | 2017-01-27 01:47:52 +0000 | [diff] [blame] | 79 | ASSERT(inherits(vm, info())); |
barraclough@apple.com | 737a158 | 2011-02-21 19:31:42 +0000 | [diff] [blame] | 80 | |
achristensen@apple.com | 5c6da6e | 2017-09-25 22:37:03 +0000 | [diff] [blame] | 81 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "E"), jsNumber(Math::exp(1.0)), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 82 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LN2"), jsNumber(Math::log(2.0)), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 83 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LN10"), jsNumber(Math::log(10.0)), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 84 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LOG2E"), jsNumber(1.0 / Math::log(2.0)), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 85 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "LOG10E"), jsNumber(0.4342944819032518), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 86 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "PI"), jsNumber(piDouble), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 87 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "SQRT1_2"), jsNumber(sqrt(0.5)), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 88 | putDirectWithoutTransition(vm, Identifier::fromString(&vm, "SQRT2"), jsNumber(sqrt(2.0)), PropertyAttribute::DontDelete | PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
| 89 | putDirectWithoutTransition(vm, vm.propertyNames->toStringTagSymbol, jsString(&vm, "Math"), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 90 | |
achristensen@apple.com | 5c6da6e | 2017-09-25 22:37:03 +0000 | [diff] [blame] | 91 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "abs"), 1, mathProtoFuncAbs, AbsIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 92 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "acos"), 1, mathProtoFuncACos, ACosIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 93 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "asin"), 1, mathProtoFuncASin, ASinIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 94 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "atan"), 1, mathProtoFuncATan, ATanIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 95 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "acosh"), 1, mathProtoFuncACosh, ACoshIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 96 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "asinh"), 1, mathProtoFuncASinh, ASinhIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 97 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "atanh"), 1, mathProtoFuncATanh, ATanhIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 98 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "atan2"), 2, mathProtoFuncATan2, NoIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 99 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "cbrt"), 1, mathProtoFuncCbrt, CbrtIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 100 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "ceil"), 1, mathProtoFuncCeil, CeilIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 101 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "clz32"), 1, mathProtoFuncClz32, Clz32Intrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 102 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "cos"), 1, mathProtoFuncCos, CosIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 103 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "cosh"), 1, mathProtoFuncCosh, CoshIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 104 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "exp"), 1, mathProtoFuncExp, ExpIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 105 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "expm1"), 1, mathProtoFuncExpm1, Expm1Intrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 106 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "floor"), 1, mathProtoFuncFloor, FloorIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 107 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "fround"), 1, mathProtoFuncFround, FRoundIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 108 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "hypot"), 2, mathProtoFuncHypot, NoIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 109 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log"), 1, mathProtoFuncLog, LogIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 110 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log10"), 1, mathProtoFuncLog10, Log10Intrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 111 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log1p"), 1, mathProtoFuncLog1p, Log1pIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 112 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "log2"), 1, mathProtoFuncLog2, Log2Intrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 113 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "max"), 2, mathProtoFuncMax, MaxIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 114 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "min"), 2, mathProtoFuncMin, MinIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 115 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "pow"), 2, mathProtoFuncPow, PowIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 116 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "random"), 0, mathProtoFuncRandom, RandomIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 117 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "round"), 1, mathProtoFuncRound, RoundIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 118 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sign"), 1, mathProtoFuncSign, NoIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 119 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sin"), 1, mathProtoFuncSin, SinIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 120 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sinh"), 1, mathProtoFuncSinh, SinhIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 121 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "sqrt"), 1, mathProtoFuncSqrt, SqrtIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 122 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "tan"), 1, mathProtoFuncTan, TanIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 123 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "tanh"), 1, mathProtoFuncTanh, TanhIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 124 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "trunc"), 1, mathProtoFuncTrunc, TruncIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
| 125 | putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier::fromString(&vm, "imul"), 2, mathProtoFuncIMul, IMulIntrinsic, static_cast<unsigned>(PropertyAttribute::DontEnum)); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 126 | } |
| 127 | |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 128 | // ------------------------------ Functions -------------------------------- |
| 129 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 130 | EncodedJSValue JSC_HOST_CALL mathProtoFuncAbs(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 131 | { |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 132 | return JSValue::encode(jsNumber(fabs(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 133 | } |
| 134 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 135 | EncodedJSValue JSC_HOST_CALL mathProtoFuncACos(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 136 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 137 | return JSValue::encode(jsDoubleNumber(Math::acos(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 138 | } |
| 139 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 140 | EncodedJSValue JSC_HOST_CALL mathProtoFuncASin(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 141 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 142 | return JSValue::encode(jsDoubleNumber(Math::asin(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 143 | } |
| 144 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 145 | EncodedJSValue JSC_HOST_CALL mathProtoFuncATan(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 146 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 147 | return JSValue::encode(jsDoubleNumber(Math::atan(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 148 | } |
| 149 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 150 | EncodedJSValue JSC_HOST_CALL mathProtoFuncATan2(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 151 | { |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 152 | VM& vm = exec->vm(); |
| 153 | auto scope = DECLARE_THROW_SCOPE(vm); |
commit-queue@webkit.org | 4bf477e | 2010-09-26 21:38:31 +0000 | [diff] [blame] | 154 | double arg0 = exec->argument(0).toNumber(exec); |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 155 | RETURN_IF_EXCEPTION(scope, encodedJSValue()); |
jfbastien@apple.com | 762a370 | 2017-12-05 07:51:33 +0000 | [diff] [blame] | 156 | scope.release(); |
commit-queue@webkit.org | 4bf477e | 2010-09-26 21:38:31 +0000 | [diff] [blame] | 157 | double arg1 = exec->argument(1).toNumber(exec); |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 158 | return JSValue::encode(jsDoubleNumber(atan2(arg0, arg1))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 159 | } |
| 160 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 161 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCeil(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 162 | { |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 163 | return JSValue::encode(jsNumber(ceil(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 164 | } |
| 165 | |
benjamin@webkit.org | e324d43 | 2015-04-26 19:55:18 +0000 | [diff] [blame] | 166 | EncodedJSValue JSC_HOST_CALL mathProtoFuncClz32(ExecState* exec) |
| 167 | { |
mark.lam@apple.com | 451de99 | 2016-09-07 22:10:50 +0000 | [diff] [blame] | 168 | VM& vm = exec->vm(); |
| 169 | auto scope = DECLARE_THROW_SCOPE(vm); |
benjamin@webkit.org | e324d43 | 2015-04-26 19:55:18 +0000 | [diff] [blame] | 170 | uint32_t value = exec->argument(0).toUInt32(exec); |
mark.lam@apple.com | e1ab17c | 2016-09-26 19:11:17 +0000 | [diff] [blame] | 171 | RETURN_IF_EXCEPTION(scope, encodedJSValue()); |
benjamin@webkit.org | e324d43 | 2015-04-26 19:55:18 +0000 | [diff] [blame] | 172 | return JSValue::encode(JSValue(clz32(value))); |
| 173 | } |
| 174 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 175 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCos(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 176 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 177 | return JSValue::encode(jsDoubleNumber(Math::cos(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 178 | } |
| 179 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 180 | EncodedJSValue JSC_HOST_CALL mathProtoFuncExp(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 181 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 182 | return JSValue::encode(jsDoubleNumber(Math::exp(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 183 | } |
| 184 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 185 | EncodedJSValue JSC_HOST_CALL mathProtoFuncFloor(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 186 | { |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 187 | return JSValue::encode(jsNumber(floor(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 188 | } |
| 189 | |
commit-queue@webkit.org | 4510bff | 2014-03-18 03:21:22 +0000 | [diff] [blame] | 190 | EncodedJSValue JSC_HOST_CALL mathProtoFuncHypot(ExecState* exec) |
| 191 | { |
mark.lam@apple.com | 451de99 | 2016-09-07 22:10:50 +0000 | [diff] [blame] | 192 | VM& vm = exec->vm(); |
| 193 | auto scope = DECLARE_THROW_SCOPE(vm); |
commit-queue@webkit.org | 4510bff | 2014-03-18 03:21:22 +0000 | [diff] [blame] | 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)); |
mark.lam@apple.com | e1ab17c | 2016-09-26 19:11:17 +0000 | [diff] [blame] | 200 | RETURN_IF_EXCEPTION(scope, encodedJSValue()); |
commit-queue@webkit.org | 4510bff | 2014-03-18 03:21:22 +0000 | [diff] [blame] | 201 | if (std::isinf(args[i])) |
| 202 | return JSValue::encode(jsDoubleNumber(+std::numeric_limits<double>::infinity())); |
| 203 | max = std::max(fabs(args[i]), max); |
| 204 | } |
| 205 | if (!max) |
| 206 | max = 1; |
| 207 | // Kahan summation algorithm significantly reduces the numerical error in the total obtained. |
| 208 | double sum = 0; |
| 209 | double compensation = 0; |
| 210 | for (double argument : args) { |
| 211 | double scaledArgument = argument / max; |
| 212 | double summand = scaledArgument * scaledArgument - compensation; |
| 213 | double preliminary = sum + summand; |
| 214 | compensation = (preliminary - sum) - summand; |
| 215 | sum = preliminary; |
| 216 | } |
| 217 | return JSValue::encode(jsDoubleNumber(sqrt(sum) * max)); |
| 218 | } |
| 219 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 220 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 221 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 222 | return JSValue::encode(jsDoubleNumber(Math::log(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 223 | } |
| 224 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 225 | EncodedJSValue JSC_HOST_CALL mathProtoFuncMax(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 226 | { |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 227 | VM& vm = exec->vm(); |
| 228 | auto scope = DECLARE_THROW_SCOPE(vm); |
ggaren@apple.com | fea29f1 | 2010-05-29 06:33:05 +0000 | [diff] [blame] | 229 | unsigned argsCount = exec->argumentCount(); |
barraclough@apple.com | f1fa579 | 2011-06-11 02:03:00 +0000 | [diff] [blame] | 230 | double result = -std::numeric_limits<double>::infinity(); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 231 | for (unsigned k = 0; k < argsCount; ++k) { |
darin@apple.com | d9b2213 | 2013-09-22 04:02:59 +0000 | [diff] [blame] | 232 | double val = exec->uncheckedArgument(k).toNumber(exec); |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 233 | RETURN_IF_EXCEPTION(scope, encodedJSValue()); |
zandobersek@gmail.com | 9182d47 | 2013-02-13 23:01:21 +0000 | [diff] [blame] | 234 | if (std::isnan(val)) { |
fpizlo@apple.com | beef452 | 2014-04-16 22:44:00 +0000 | [diff] [blame] | 235 | result = PNaN; |
commit-queue@webkit.org | b471d14 | 2014-02-27 19:39:42 +0000 | [diff] [blame] | 236 | } else if (val > result || (!val && !result && !std::signbit(val))) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 237 | result = val; |
| 238 | } |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 239 | return JSValue::encode(jsNumber(result)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 240 | } |
| 241 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 242 | EncodedJSValue JSC_HOST_CALL mathProtoFuncMin(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 243 | { |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 244 | VM& vm = exec->vm(); |
| 245 | auto scope = DECLARE_THROW_SCOPE(vm); |
ggaren@apple.com | fea29f1 | 2010-05-29 06:33:05 +0000 | [diff] [blame] | 246 | unsigned argsCount = exec->argumentCount(); |
barraclough@apple.com | f1fa579 | 2011-06-11 02:03:00 +0000 | [diff] [blame] | 247 | double result = +std::numeric_limits<double>::infinity(); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 248 | for (unsigned k = 0; k < argsCount; ++k) { |
darin@apple.com | d9b2213 | 2013-09-22 04:02:59 +0000 | [diff] [blame] | 249 | double val = exec->uncheckedArgument(k).toNumber(exec); |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 250 | RETURN_IF_EXCEPTION(scope, encodedJSValue()); |
zandobersek@gmail.com | 9182d47 | 2013-02-13 23:01:21 +0000 | [diff] [blame] | 251 | if (std::isnan(val)) { |
fpizlo@apple.com | beef452 | 2014-04-16 22:44:00 +0000 | [diff] [blame] | 252 | result = PNaN; |
commit-queue@webkit.org | b471d14 | 2014-02-27 19:39:42 +0000 | [diff] [blame] | 253 | } else if (val < result || (!val && !result && std::signbit(val))) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 254 | result = val; |
| 255 | } |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 256 | return JSValue::encode(jsNumber(result)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 257 | } |
| 258 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 259 | EncodedJSValue JSC_HOST_CALL mathProtoFuncPow(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 260 | { |
| 261 | // ECMA 15.8.2.1.13 |
| 262 | |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 263 | VM& vm = exec->vm(); |
| 264 | auto scope = DECLARE_THROW_SCOPE(vm); |
| 265 | |
ggaren@apple.com | fea29f1 | 2010-05-29 06:33:05 +0000 | [diff] [blame] | 266 | double arg = exec->argument(0).toNumber(exec); |
jfbastien@apple.com | 8dd8e5c | 2017-12-02 05:44:04 +0000 | [diff] [blame] | 267 | RETURN_IF_EXCEPTION(scope, encodedJSValue()); |
jfbastien@apple.com | 762a370 | 2017-12-05 07:51:33 +0000 | [diff] [blame] | 268 | scope.release(); |
ggaren@apple.com | fea29f1 | 2010-05-29 06:33:05 +0000 | [diff] [blame] | 269 | double arg2 = exec->argument(1).toNumber(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 270 | |
benjamin@webkit.org | 903025b | 2015-02-14 04:20:21 +0000 | [diff] [blame] | 271 | return JSValue::encode(JSValue(operationMathPow(arg, arg2))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 272 | } |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 273 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 274 | EncodedJSValue JSC_HOST_CALL mathProtoFuncRandom(ExecState* exec) |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 275 | { |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 276 | return JSValue::encode(jsDoubleNumber(exec->lexicalGlobalObject()->weakRandomNumber())); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 277 | } |
| 278 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 279 | EncodedJSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 280 | { |
benjamin@webkit.org | cb58408 | 2015-05-08 00:23:32 +0000 | [diff] [blame] | 281 | return JSValue::encode(jsNumber(jsRound(exec->argument(0).toNumber(exec)))); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 282 | } |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 283 | |
commit-queue@webkit.org | 8cc4523 | 2014-07-20 16:16:57 +0000 | [diff] [blame] | 284 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSign(ExecState* exec) |
| 285 | { |
| 286 | double arg = exec->argument(0).toNumber(exec); |
| 287 | if (std::isnan(arg)) |
| 288 | return JSValue::encode(jsNaN()); |
| 289 | if (!arg) |
| 290 | return JSValue::encode(std::signbit(arg) ? jsNumber(-0.0) : jsNumber(0)); |
| 291 | return JSValue::encode(jsNumber(std::signbit(arg) ? -1 : 1)); |
| 292 | } |
| 293 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 294 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 295 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 296 | return JSValue::encode(jsDoubleNumber(Math::sin(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 297 | } |
| 298 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 299 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSqrt(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 300 | { |
oliver@apple.com | 5b67d9e | 2010-10-25 22:40:53 +0000 | [diff] [blame] | 301 | return JSValue::encode(jsDoubleNumber(sqrt(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 302 | } |
| 303 | |
barraclough@apple.com | 99ff343 | 2010-06-03 20:00:18 +0000 | [diff] [blame] | 304 | EncodedJSValue JSC_HOST_CALL mathProtoFuncTan(ExecState* exec) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 305 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 306 | return JSValue::encode(jsDoubleNumber(Math::tan(exec->argument(0).toNumber(exec)))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 307 | } |
| 308 | |
oliver@apple.com | 6436732 | 2013-04-26 00:41:38 +0000 | [diff] [blame] | 309 | EncodedJSValue JSC_HOST_CALL mathProtoFuncIMul(ExecState* exec) |
| 310 | { |
mark.lam@apple.com | 451de99 | 2016-09-07 22:10:50 +0000 | [diff] [blame] | 311 | VM& vm = exec->vm(); |
| 312 | auto scope = DECLARE_THROW_SCOPE(vm); |
oliver@apple.com | 6436732 | 2013-04-26 00:41:38 +0000 | [diff] [blame] | 313 | int32_t left = exec->argument(0).toInt32(exec); |
mark.lam@apple.com | e1ab17c | 2016-09-26 19:11:17 +0000 | [diff] [blame] | 314 | RETURN_IF_EXCEPTION(scope, encodedJSValue()); |
mark.lam@apple.com | 223e1f8 | 2016-11-28 22:21:29 +0000 | [diff] [blame] | 315 | scope.release(); |
oliver@apple.com | 6436732 | 2013-04-26 00:41:38 +0000 | [diff] [blame] | 316 | int32_t right = exec->argument(1).toInt32(exec); |
| 317 | return JSValue::encode(jsNumber(left * right)); |
| 318 | } |
| 319 | |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 320 | EncodedJSValue JSC_HOST_CALL mathProtoFuncACosh(ExecState* exec) |
| 321 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 322 | return JSValue::encode(jsDoubleNumber(Math::acosh(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | EncodedJSValue JSC_HOST_CALL mathProtoFuncASinh(ExecState* exec) |
| 326 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 327 | return JSValue::encode(jsDoubleNumber(Math::asinh(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | EncodedJSValue JSC_HOST_CALL mathProtoFuncATanh(ExecState* exec) |
| 331 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 332 | return JSValue::encode(jsDoubleNumber(Math::atanh(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCbrt(ExecState* exec) |
| 336 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 337 | return JSValue::encode(jsDoubleNumber(Math::cbrt(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | EncodedJSValue JSC_HOST_CALL mathProtoFuncCosh(ExecState* exec) |
| 341 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 342 | return JSValue::encode(jsDoubleNumber(Math::cosh(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | EncodedJSValue JSC_HOST_CALL mathProtoFuncExpm1(ExecState* exec) |
| 346 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 347 | return JSValue::encode(jsDoubleNumber(Math::expm1(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | EncodedJSValue JSC_HOST_CALL mathProtoFuncFround(ExecState* exec) |
| 351 | { |
| 352 | return JSValue::encode(jsDoubleNumber(static_cast<float>(exec->argument(0).toNumber(exec)))); |
| 353 | } |
| 354 | |
| 355 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog1p(ExecState* exec) |
| 356 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 357 | return JSValue::encode(jsDoubleNumber(Math::log1p(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog10(ExecState* exec) |
| 361 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 362 | return JSValue::encode(jsDoubleNumber(Math::log10(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | EncodedJSValue JSC_HOST_CALL mathProtoFuncLog2(ExecState* exec) |
| 366 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 367 | return JSValue::encode(jsDoubleNumber(Math::log2(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | EncodedJSValue JSC_HOST_CALL mathProtoFuncSinh(ExecState* exec) |
| 371 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 372 | return JSValue::encode(jsDoubleNumber(Math::sinh(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | EncodedJSValue JSC_HOST_CALL mathProtoFuncTanh(ExecState* exec) |
| 376 | { |
utatane.tea@gmail.com | ccb7499 | 2017-05-04 11:40:46 +0000 | [diff] [blame] | 377 | return JSValue::encode(jsDoubleNumber(Math::tanh(exec->argument(0).toNumber(exec)))); |
oliver@apple.com | 975f214 | 2013-10-31 22:38:05 +0000 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | EncodedJSValue JSC_HOST_CALL mathProtoFuncTrunc(ExecState*exec) |
| 381 | { |
| 382 | return JSValue::encode(jsNumber(exec->argument(0).toIntegerPreserveNaN(exec))); |
| 383 | } |
| 384 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 385 | } // namespace JSC |