Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: src/bootstrapper.cc

Issue 2116753002: [builtins] Unify most of the remaining Math builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2102223005
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/base/ieee754.cc ('k') | src/builtins.h » ('j') | src/builtins.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index a6ec9d923e8f8be15ba6761f7855ba0f8e97ca15..a98ba927bbabc01af8c9a7e0e0a22e09359647c3 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1669,32 +1669,28 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSObject> math = factory->NewJSObject(cons, TENURED);
DCHECK(math->IsJSObject());
JSObject::AddProperty(global, name, math, DONT_ENUM);
- Handle<JSFunction> math_abs =
- SimpleInstallFunction(math, "abs", Builtins::kMathAbs, 1, true);
- native_context()->set_math_abs(*math_abs);
+ SimpleInstallFunction(math, "abs", Builtins::kMathAbs, 1, true);
SimpleInstallFunction(math, "acos", Builtins::kMathAcos, 1, true);
+ SimpleInstallFunction(math, "acosh", Builtins::kMathAcosh, 1, true);
SimpleInstallFunction(math, "asin", Builtins::kMathAsin, 1, true);
+ SimpleInstallFunction(math, "asinh", Builtins::kMathAsinh, 1, true);
SimpleInstallFunction(math, "atan", Builtins::kMathAtan, 1, true);
- SimpleInstallFunction(math, "atan2", Builtins::kMathAtan2, 2, true);
SimpleInstallFunction(math, "atanh", Builtins::kMathAtanh, 1, true);
+ SimpleInstallFunction(math, "atan2", Builtins::kMathAtan2, 2, true);
SimpleInstallFunction(math, "ceil", Builtins::kMathCeil, 1, true);
SimpleInstallFunction(math, "cbrt", Builtins::kMathCbrt, 1, true);
SimpleInstallFunction(math, "expm1", Builtins::kMathExpm1, 1, true);
SimpleInstallFunction(math, "clz32", Builtins::kMathClz32, 1, true);
SimpleInstallFunction(math, "cos", Builtins::kMathCos, 1, true);
SimpleInstallFunction(math, "cosh", Builtins::kMathCosh, 1, true);
- Handle<JSFunction> math_exp =
- SimpleInstallFunction(math, "exp", Builtins::kMathExp, 1, true);
- native_context()->set_math_exp(*math_exp);
+ SimpleInstallFunction(math, "exp", Builtins::kMathExp, 1, true);
Handle<JSFunction> math_floor =
SimpleInstallFunction(math, "floor", Builtins::kMathFloor, 1, true);
native_context()->set_math_floor(*math_floor);
SimpleInstallFunction(math, "fround", Builtins::kMathFround, 1, true);
SimpleInstallFunction(math, "hypot", Builtins::kMathHypot, 2, false);
SimpleInstallFunction(math, "imul", Builtins::kMathImul, 2, true);
- Handle<JSFunction> math_log =
- SimpleInstallFunction(math, "log", Builtins::kMathLog, 1, true);
- native_context()->set_math_log(*math_log);
+ SimpleInstallFunction(math, "log", Builtins::kMathLog, 1, true);
SimpleInstallFunction(math, "log1p", Builtins::kMathLog1p, 1, true);
SimpleInstallFunction(math, "log2", Builtins::kMathLog2, 1, true);
SimpleInstallFunction(math, "log10", Builtins::kMathLog10, 1, true);
@@ -1704,17 +1700,17 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
SimpleInstallFunction(math, "pow", Builtins::kMathPow, 2, true);
Franzi 2016/07/01 09:09:48 Where are we using %math_pow? I didn't find it.
Benedikt Meurer 2016/07/01 10:48:33 It's used to implement ** in the parser.
native_context()->set_math_pow(*math_pow);
SimpleInstallFunction(math, "round", Builtins::kMathRound, 1, true);
+ SimpleInstallFunction(math, "sign", Builtins::kMathSign, 1, true);
SimpleInstallFunction(math, "sin", Builtins::kMathSin, 1, true);
SimpleInstallFunction(math, "sinh", Builtins::kMathSinh, 1, true);
- Handle<JSFunction> math_sqrt =
- SimpleInstallFunction(math, "sqrt", Builtins::kMathSqrt, 1, true);
- native_context()->set_math_sqrt(*math_sqrt);
+ SimpleInstallFunction(math, "sqrt", Builtins::kMathSqrt, 1, true);
SimpleInstallFunction(math, "tan", Builtins::kMathTan, 1, true);
SimpleInstallFunction(math, "tanh", Builtins::kMathTanh, 1, true);
SimpleInstallFunction(math, "trunc", Builtins::kMathTrunc, 1, true);
// Install math constants.
double const kE = base::ieee754::exp(1.0);
+ double const kPI = 3.1415926535897932;
JSObject::AddProperty(
math, factory->NewStringFromAsciiChecked("E"), factory->NewNumber(kE),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
@@ -1734,6 +1730,17 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
math, factory->NewStringFromAsciiChecked("LOG2E"),
factory->NewNumber(base::ieee754::log2(kE)),
static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("PI"), factory->NewNumber(kPI),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("SQRT1_2"),
+ factory->NewNumber(std::sqrt(0.5)),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("SQRT2"),
+ factory->NewNumber(std::sqrt(2.0)),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
}
{ // -- A r r a y B u f f e r
« no previous file with comments | « src/base/ieee754.cc ('k') | src/builtins.h » ('j') | src/builtins.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698