| Index: src/bootstrapper.cc
|
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
|
| index e58bf5abdb43b79699b32fea96f7fc6f340dfd08..4d5aec9602863828306f9f4c0442dee22c32c946 100644
|
| --- a/src/bootstrapper.cc
|
| +++ b/src/bootstrapper.cc
|
| @@ -1534,6 +1534,38 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
|
| }
|
|
|
|
|
| +static Handle<JSObject> ResolveBuiltinIdHolder(Handle<Context> native_context,
|
| + const char* holder_expr) {
|
| + Isolate* isolate = native_context->GetIsolate();
|
| + Factory* factory = isolate->factory();
|
| + Handle<GlobalObject> global(native_context->global_object());
|
| + const char* period_pos = strchr(holder_expr, '.');
|
| + if (period_pos == NULL) {
|
| + return Handle<JSObject>::cast(
|
| + Object::GetPropertyOrElement(
|
| + global, factory->InternalizeUtf8String(holder_expr))
|
| + .ToHandleChecked());
|
| + }
|
| + const char* inner = period_pos + 1;
|
| + ASSERT_EQ(NULL, strchr(inner, '.'));
|
| + Vector<const char> property(holder_expr,
|
| + static_cast<int>(period_pos - holder_expr));
|
| + Handle<String> property_string = factory->InternalizeUtf8String(property);
|
| + ASSERT(!property_string.is_null());
|
| + Handle<JSObject> object = Handle<JSObject>::cast(
|
| + Object::GetProperty(global, property_string).ToHandleChecked());
|
| + if (strcmp("prototype", inner) == 0) {
|
| + Handle<JSFunction> function = Handle<JSFunction>::cast(object);
|
| + return Handle<JSObject>(JSObject::cast(function->prototype()));
|
| + }
|
| + Handle<String> inner_string = factory->InternalizeUtf8String(inner);
|
| + ASSERT(!inner_string.is_null());
|
| + Handle<Object> value =
|
| + Object::GetProperty(object, inner_string).ToHandleChecked();
|
| + return Handle<JSObject>::cast(value);
|
| +}
|
| +
|
| +
|
| #define INSTALL_NATIVE(Type, name, var) \
|
| Handle<String> var##_name = \
|
| factory()->InternalizeOneByteString(STATIC_ASCII_VECTOR(name)); \
|
| @@ -1541,6 +1573,12 @@ bool Genesis::CompileScriptCached(Isolate* isolate,
|
| handle(native_context()->builtins()), var##_name).ToHandleChecked(); \
|
| native_context()->set_##var(Type::cast(*var##_native));
|
|
|
| +#define INSTALL_NATIVE_MATH(name) \
|
| + { \
|
| + Handle<Object> fun = \
|
| + ResolveBuiltinIdHolder(native_context(), "Math." #name); \
|
| + native_context()->set_math_##name##_fun(JSFunction::cast(*fun)); \
|
| + }
|
|
|
| void Genesis::InstallNativeFunctions() {
|
| HandleScope scope(isolate());
|
| @@ -1583,6 +1621,26 @@ void Genesis::InstallNativeFunctions() {
|
| native_object_get_notifier);
|
| INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange",
|
| native_object_notifier_perform_change);
|
| +
|
| + INSTALL_NATIVE_MATH(abs)
|
| + INSTALL_NATIVE_MATH(acos)
|
| + INSTALL_NATIVE_MATH(asin)
|
| + INSTALL_NATIVE_MATH(atan)
|
| + INSTALL_NATIVE_MATH(atan2)
|
| + INSTALL_NATIVE_MATH(ceil)
|
| + INSTALL_NATIVE_MATH(cos)
|
| + INSTALL_NATIVE_MATH(exp)
|
| + INSTALL_NATIVE_MATH(floor)
|
| + INSTALL_NATIVE_MATH(imul)
|
| + INSTALL_NATIVE_MATH(log)
|
| + INSTALL_NATIVE_MATH(max)
|
| + INSTALL_NATIVE_MATH(min)
|
| + INSTALL_NATIVE_MATH(pow)
|
| + INSTALL_NATIVE_MATH(random)
|
| + INSTALL_NATIVE_MATH(round)
|
| + INSTALL_NATIVE_MATH(sin)
|
| + INSTALL_NATIVE_MATH(sqrt)
|
| + INSTALL_NATIVE_MATH(tan)
|
| }
|
|
|
|
|
| @@ -2029,28 +2087,6 @@ bool Genesis::InstallExperimentalNatives() {
|
| }
|
|
|
|
|
| -static Handle<JSObject> ResolveBuiltinIdHolder(
|
| - Handle<Context> native_context,
|
| - const char* holder_expr) {
|
| - Isolate* isolate = native_context->GetIsolate();
|
| - Factory* factory = isolate->factory();
|
| - Handle<GlobalObject> global(native_context->global_object());
|
| - const char* period_pos = strchr(holder_expr, '.');
|
| - if (period_pos == NULL) {
|
| - return Handle<JSObject>::cast(Object::GetPropertyOrElement(
|
| - global, factory->InternalizeUtf8String(holder_expr)).ToHandleChecked());
|
| - }
|
| - ASSERT_EQ(".prototype", period_pos);
|
| - Vector<const char> property(holder_expr,
|
| - static_cast<int>(period_pos - holder_expr));
|
| - Handle<String> property_string = factory->InternalizeUtf8String(property);
|
| - ASSERT(!property_string.is_null());
|
| - Handle<JSFunction> function = Handle<JSFunction>::cast(
|
| - Object::GetProperty(global, property_string).ToHandleChecked());
|
| - return Handle<JSObject>(JSObject::cast(function->prototype()));
|
| -}
|
| -
|
| -
|
| static void InstallBuiltinFunctionId(Handle<JSObject> holder,
|
| const char* function_name,
|
| BuiltinFunctionId id) {
|
| @@ -2336,6 +2372,10 @@ bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
|
| isolate(), builtins, Builtins::GetName(id)).ToHandleChecked();
|
| Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
|
| builtins->set_javascript_builtin(id, *function);
|
| + // TODO(mstarzinger): This is just a temporary hack to make TurboFan work,
|
| + // the correct solution is to restore the context register after invoking
|
| + // builtins from full-codegen.
|
| + function->shared()->set_optimization_disabled(true);
|
| if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) {
|
| return false;
|
| }
|
|
|