OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/base/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1662 | 1662 |
1663 { // -- M a t h | 1663 { // -- M a t h |
1664 Handle<String> name = factory->InternalizeUtf8String("Math"); | 1664 Handle<String> name = factory->InternalizeUtf8String("Math"); |
1665 Handle<JSFunction> cons = factory->NewFunction(name); | 1665 Handle<JSFunction> cons = factory->NewFunction(name); |
1666 JSFunction::SetInstancePrototype( | 1666 JSFunction::SetInstancePrototype( |
1667 cons, | 1667 cons, |
1668 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 1668 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
1669 Handle<JSObject> math = factory->NewJSObject(cons, TENURED); | 1669 Handle<JSObject> math = factory->NewJSObject(cons, TENURED); |
1670 DCHECK(math->IsJSObject()); | 1670 DCHECK(math->IsJSObject()); |
1671 JSObject::AddProperty(global, name, math, DONT_ENUM); | 1671 JSObject::AddProperty(global, name, math, DONT_ENUM); |
1672 Handle<JSFunction> math_abs = | 1672 SimpleInstallFunction(math, "abs", Builtins::kMathAbs, 1, true); |
1673 SimpleInstallFunction(math, "abs", Builtins::kMathAbs, 1, true); | |
1674 native_context()->set_math_abs(*math_abs); | |
1675 SimpleInstallFunction(math, "acos", Builtins::kMathAcos, 1, true); | 1673 SimpleInstallFunction(math, "acos", Builtins::kMathAcos, 1, true); |
1674 SimpleInstallFunction(math, "acosh", Builtins::kMathAcosh, 1, true); | |
1676 SimpleInstallFunction(math, "asin", Builtins::kMathAsin, 1, true); | 1675 SimpleInstallFunction(math, "asin", Builtins::kMathAsin, 1, true); |
1676 SimpleInstallFunction(math, "asinh", Builtins::kMathAsinh, 1, true); | |
1677 SimpleInstallFunction(math, "atan", Builtins::kMathAtan, 1, true); | 1677 SimpleInstallFunction(math, "atan", Builtins::kMathAtan, 1, true); |
1678 SimpleInstallFunction(math, "atanh", Builtins::kMathAtanh, 1, true); | |
1678 SimpleInstallFunction(math, "atan2", Builtins::kMathAtan2, 2, true); | 1679 SimpleInstallFunction(math, "atan2", Builtins::kMathAtan2, 2, true); |
1679 SimpleInstallFunction(math, "atanh", Builtins::kMathAtanh, 1, true); | |
1680 SimpleInstallFunction(math, "ceil", Builtins::kMathCeil, 1, true); | 1680 SimpleInstallFunction(math, "ceil", Builtins::kMathCeil, 1, true); |
1681 SimpleInstallFunction(math, "cbrt", Builtins::kMathCbrt, 1, true); | 1681 SimpleInstallFunction(math, "cbrt", Builtins::kMathCbrt, 1, true); |
1682 SimpleInstallFunction(math, "expm1", Builtins::kMathExpm1, 1, true); | 1682 SimpleInstallFunction(math, "expm1", Builtins::kMathExpm1, 1, true); |
1683 SimpleInstallFunction(math, "clz32", Builtins::kMathClz32, 1, true); | 1683 SimpleInstallFunction(math, "clz32", Builtins::kMathClz32, 1, true); |
1684 SimpleInstallFunction(math, "cos", Builtins::kMathCos, 1, true); | 1684 SimpleInstallFunction(math, "cos", Builtins::kMathCos, 1, true); |
1685 SimpleInstallFunction(math, "cosh", Builtins::kMathCosh, 1, true); | 1685 SimpleInstallFunction(math, "cosh", Builtins::kMathCosh, 1, true); |
1686 Handle<JSFunction> math_exp = | 1686 SimpleInstallFunction(math, "exp", Builtins::kMathExp, 1, true); |
1687 SimpleInstallFunction(math, "exp", Builtins::kMathExp, 1, true); | |
1688 native_context()->set_math_exp(*math_exp); | |
1689 Handle<JSFunction> math_floor = | 1687 Handle<JSFunction> math_floor = |
1690 SimpleInstallFunction(math, "floor", Builtins::kMathFloor, 1, true); | 1688 SimpleInstallFunction(math, "floor", Builtins::kMathFloor, 1, true); |
1691 native_context()->set_math_floor(*math_floor); | 1689 native_context()->set_math_floor(*math_floor); |
1692 SimpleInstallFunction(math, "fround", Builtins::kMathFround, 1, true); | 1690 SimpleInstallFunction(math, "fround", Builtins::kMathFround, 1, true); |
1693 SimpleInstallFunction(math, "hypot", Builtins::kMathHypot, 2, false); | 1691 SimpleInstallFunction(math, "hypot", Builtins::kMathHypot, 2, false); |
1694 SimpleInstallFunction(math, "imul", Builtins::kMathImul, 2, true); | 1692 SimpleInstallFunction(math, "imul", Builtins::kMathImul, 2, true); |
1695 Handle<JSFunction> math_log = | 1693 SimpleInstallFunction(math, "log", Builtins::kMathLog, 1, true); |
1696 SimpleInstallFunction(math, "log", Builtins::kMathLog, 1, true); | |
1697 native_context()->set_math_log(*math_log); | |
1698 SimpleInstallFunction(math, "log1p", Builtins::kMathLog1p, 1, true); | 1694 SimpleInstallFunction(math, "log1p", Builtins::kMathLog1p, 1, true); |
1699 SimpleInstallFunction(math, "log2", Builtins::kMathLog2, 1, true); | 1695 SimpleInstallFunction(math, "log2", Builtins::kMathLog2, 1, true); |
1700 SimpleInstallFunction(math, "log10", Builtins::kMathLog10, 1, true); | 1696 SimpleInstallFunction(math, "log10", Builtins::kMathLog10, 1, true); |
1701 SimpleInstallFunction(math, "max", Builtins::kMathMax, 2, false); | 1697 SimpleInstallFunction(math, "max", Builtins::kMathMax, 2, false); |
1702 SimpleInstallFunction(math, "min", Builtins::kMathMin, 2, false); | 1698 SimpleInstallFunction(math, "min", Builtins::kMathMin, 2, false); |
1703 Handle<JSFunction> math_pow = | 1699 Handle<JSFunction> math_pow = |
1704 SimpleInstallFunction(math, "pow", Builtins::kMathPow, 2, true); | 1700 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.
| |
1705 native_context()->set_math_pow(*math_pow); | 1701 native_context()->set_math_pow(*math_pow); |
1706 SimpleInstallFunction(math, "round", Builtins::kMathRound, 1, true); | 1702 SimpleInstallFunction(math, "round", Builtins::kMathRound, 1, true); |
1703 SimpleInstallFunction(math, "sign", Builtins::kMathSign, 1, true); | |
1707 SimpleInstallFunction(math, "sin", Builtins::kMathSin, 1, true); | 1704 SimpleInstallFunction(math, "sin", Builtins::kMathSin, 1, true); |
1708 SimpleInstallFunction(math, "sinh", Builtins::kMathSinh, 1, true); | 1705 SimpleInstallFunction(math, "sinh", Builtins::kMathSinh, 1, true); |
1709 Handle<JSFunction> math_sqrt = | 1706 SimpleInstallFunction(math, "sqrt", Builtins::kMathSqrt, 1, true); |
1710 SimpleInstallFunction(math, "sqrt", Builtins::kMathSqrt, 1, true); | |
1711 native_context()->set_math_sqrt(*math_sqrt); | |
1712 SimpleInstallFunction(math, "tan", Builtins::kMathTan, 1, true); | 1707 SimpleInstallFunction(math, "tan", Builtins::kMathTan, 1, true); |
1713 SimpleInstallFunction(math, "tanh", Builtins::kMathTanh, 1, true); | 1708 SimpleInstallFunction(math, "tanh", Builtins::kMathTanh, 1, true); |
1714 SimpleInstallFunction(math, "trunc", Builtins::kMathTrunc, 1, true); | 1709 SimpleInstallFunction(math, "trunc", Builtins::kMathTrunc, 1, true); |
1715 | 1710 |
1716 // Install math constants. | 1711 // Install math constants. |
1717 double const kE = base::ieee754::exp(1.0); | 1712 double const kE = base::ieee754::exp(1.0); |
1713 double const kPI = 3.1415926535897932; | |
1718 JSObject::AddProperty( | 1714 JSObject::AddProperty( |
1719 math, factory->NewStringFromAsciiChecked("E"), factory->NewNumber(kE), | 1715 math, factory->NewStringFromAsciiChecked("E"), factory->NewNumber(kE), |
1720 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | 1716 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); |
1721 JSObject::AddProperty( | 1717 JSObject::AddProperty( |
1722 math, factory->NewStringFromAsciiChecked("LN10"), | 1718 math, factory->NewStringFromAsciiChecked("LN10"), |
1723 factory->NewNumber(base::ieee754::log(10.0)), | 1719 factory->NewNumber(base::ieee754::log(10.0)), |
1724 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | 1720 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); |
1725 JSObject::AddProperty( | 1721 JSObject::AddProperty( |
1726 math, factory->NewStringFromAsciiChecked("LN2"), | 1722 math, factory->NewStringFromAsciiChecked("LN2"), |
1727 factory->NewNumber(base::ieee754::log(2.0)), | 1723 factory->NewNumber(base::ieee754::log(2.0)), |
1728 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | 1724 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); |
1729 JSObject::AddProperty( | 1725 JSObject::AddProperty( |
1730 math, factory->NewStringFromAsciiChecked("LOG10E"), | 1726 math, factory->NewStringFromAsciiChecked("LOG10E"), |
1731 factory->NewNumber(base::ieee754::log10(kE)), | 1727 factory->NewNumber(base::ieee754::log10(kE)), |
1732 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | 1728 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); |
1733 JSObject::AddProperty( | 1729 JSObject::AddProperty( |
1734 math, factory->NewStringFromAsciiChecked("LOG2E"), | 1730 math, factory->NewStringFromAsciiChecked("LOG2E"), |
1735 factory->NewNumber(base::ieee754::log2(kE)), | 1731 factory->NewNumber(base::ieee754::log2(kE)), |
1736 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | 1732 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); |
1733 JSObject::AddProperty( | |
1734 math, factory->NewStringFromAsciiChecked("PI"), factory->NewNumber(kPI), | |
1735 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | |
1736 JSObject::AddProperty( | |
1737 math, factory->NewStringFromAsciiChecked("SQRT1_2"), | |
1738 factory->NewNumber(std::sqrt(0.5)), | |
1739 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | |
1740 JSObject::AddProperty( | |
1741 math, factory->NewStringFromAsciiChecked("SQRT2"), | |
1742 factory->NewNumber(std::sqrt(2.0)), | |
1743 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY)); | |
1737 } | 1744 } |
1738 | 1745 |
1739 { // -- A r r a y B u f f e r | 1746 { // -- A r r a y B u f f e r |
1740 Handle<JSFunction> array_buffer_fun = | 1747 Handle<JSFunction> array_buffer_fun = |
1741 InstallArrayBuffer(global, "ArrayBuffer"); | 1748 InstallArrayBuffer(global, "ArrayBuffer"); |
1742 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, | 1749 InstallWithIntrinsicDefaultProto(isolate, array_buffer_fun, |
1743 Context::ARRAY_BUFFER_FUN_INDEX); | 1750 Context::ARRAY_BUFFER_FUN_INDEX); |
1744 } | 1751 } |
1745 | 1752 |
1746 { // -- T y p e d A r r a y | 1753 { // -- T y p e d A r r a y |
(...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3948 } | 3955 } |
3949 | 3956 |
3950 | 3957 |
3951 // Called when the top-level V8 mutex is destroyed. | 3958 // Called when the top-level V8 mutex is destroyed. |
3952 void Bootstrapper::FreeThreadResources() { | 3959 void Bootstrapper::FreeThreadResources() { |
3953 DCHECK(!IsActive()); | 3960 DCHECK(!IsActive()); |
3954 } | 3961 } |
3955 | 3962 |
3956 } // namespace internal | 3963 } // namespace internal |
3957 } // namespace v8 | 3964 } // namespace v8 |
OLD | NEW |