Chromium Code Reviews| Index: src/bootstrapper.cc |
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
| index 65208d7f3241b01d084c4f3ed6b8dc48c390da4c..11ac89799077dfab49b94824b91a6543103bbebf 100644 |
| --- a/src/bootstrapper.cc |
| +++ b/src/bootstrapper.cc |
| @@ -205,6 +205,7 @@ class Genesis BASE_EMBEDDED { |
| Handle<JSFunction> empty_function, |
| GlobalContextType context_type); |
| void InitializeExperimentalGlobal(); |
| + void InstallFastArrayBuiltins(); |
| // Depending on the situation, expose and/or get rid of the utils object. |
| void ConfigureUtilsObject(GlobalContextType context_type); |
| @@ -216,7 +217,9 @@ class Genesis BASE_EMBEDDED { |
| HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
| #undef DECLARE_FEATURE_INITIALIZATION |
| - void InitializeGlobal_enable_fast_array_builtins(); |
| + void InstallOneBuiltinFunction(const char* object, const char* method, |
| + Builtins::Name name); |
| + void InitializeGlobal_experimental_fast_array_builtins(); |
| Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
| const char* name, Builtins::Name call, |
| @@ -3062,9 +3065,14 @@ void Genesis::InitializeExperimentalGlobal() { |
| HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) |
| #undef FEATURE_INITIALIZE_GLOBAL |
| - InitializeGlobal_enable_fast_array_builtins(); |
| + InitializeGlobal_experimental_fast_array_builtins(); |
| } |
| +void Genesis::InstallFastArrayBuiltins() { |
| + InstallOneBuiltinFunction("Array", "forEach", Builtins::kArrayForEach); |
| + InstallOneBuiltinFunction("Array", "every", Builtins::kArrayEvery); |
| + InstallOneBuiltinFunction("Array", "some", Builtins::kArraySome); |
| +} |
| bool Bootstrapper::CompileBuiltin(Isolate* isolate, int index) { |
| Vector<const char> name = Natives::GetScriptName(index); |
| @@ -3662,50 +3670,32 @@ void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, |
| JSObject::AddProperty(symbol, name_string, value, attributes); |
| } |
| -void Genesis::InitializeGlobal_enable_fast_array_builtins() { |
| - if (!FLAG_enable_fast_array_builtins) return; |
| - |
| +void Genesis::InstallOneBuiltinFunction(const char* object_name, |
| + const char* method_name, |
| + Builtins::Name builtin_name) { |
| Handle<JSGlobalObject> global(native_context()->global_object()); |
| Isolate* isolate = global->GetIsolate(); |
| Factory* factory = isolate->factory(); |
| - LookupIterator it1(global, factory->NewStringFromAsciiChecked("Array"), |
| - LookupIterator::OWN_SKIP_INTERCEPTOR); |
| - Handle<Object> array_object = Object::GetProperty(&it1).ToHandleChecked(); |
| - LookupIterator it2(array_object, |
| - factory->NewStringFromAsciiChecked("prototype"), |
| - LookupIterator::OWN_SKIP_INTERCEPTOR); |
| - Handle<Object> array_prototype = Object::GetProperty(&it2).ToHandleChecked(); |
| - LookupIterator it3(array_prototype, |
| - factory->NewStringFromAsciiChecked("forEach"), |
| + LookupIterator it1(global, factory->NewStringFromAsciiChecked(object_name), |
| LookupIterator::OWN_SKIP_INTERCEPTOR); |
| - Handle<Object> for_each_function = |
| - Object::GetProperty(&it3).ToHandleChecked(); |
| - Handle<JSFunction>::cast(for_each_function) |
| - ->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach)); |
| - Handle<JSFunction>::cast(for_each_function) |
| - ->shared() |
| - ->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach)); |
| - |
| - LookupIterator it4(array_prototype, |
| - factory->NewStringFromAsciiChecked("every"), |
| + Handle<Object> object = Object::GetProperty(&it1).ToHandleChecked(); |
| + LookupIterator it2(object, factory->NewStringFromAsciiChecked("prototype"), |
| LookupIterator::OWN_SKIP_INTERCEPTOR); |
| - Handle<Object> every_function = Object::GetProperty(&it4).ToHandleChecked(); |
| - Handle<JSFunction>::cast(every_function) |
| - ->set_code(isolate->builtins()->builtin(Builtins::kArrayEvery)); |
| - Handle<JSFunction>::cast(every_function) |
| - ->shared() |
| - ->set_code(isolate->builtins()->builtin(Builtins::kArrayEvery)); |
| - |
| - LookupIterator it5(array_prototype, |
| - factory->NewStringFromAsciiChecked("some"), |
| + Handle<Object> prototype = Object::GetProperty(&it2).ToHandleChecked(); |
| + |
| + LookupIterator it3(prototype, factory->NewStringFromAsciiChecked(method_name), |
| LookupIterator::OWN_SKIP_INTERCEPTOR); |
| - Handle<Object> some_function = Object::GetProperty(&it5).ToHandleChecked(); |
| - Handle<JSFunction>::cast(some_function) |
| - ->set_code(isolate->builtins()->builtin(Builtins::kArraySome)); |
| - Handle<JSFunction>::cast(some_function) |
| - ->shared() |
| - ->set_code(isolate->builtins()->builtin(Builtins::kArraySome)); |
| + Handle<Object> function = Object::GetProperty(&it3).ToHandleChecked(); |
| + Handle<JSFunction>::cast(function)->set_code( |
| + isolate->builtins()->builtin(builtin_name)); |
| + Handle<JSFunction>::cast(function)->shared()->set_code( |
| + isolate->builtins()->builtin(builtin_name)); |
| +} |
| + |
| +void Genesis::InitializeGlobal_experimental_fast_array_builtins() { |
| + if (!FLAG_experimental_fast_array_builtins) return; |
| + // Insert experimental fast array builtins here. |
| } |
| void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
| @@ -4942,6 +4932,8 @@ Genesis::Genesis( |
| isolate->counters()->contexts_created_from_scratch()->Increment(); |
| } |
| + InstallFastArrayBuiltins(); |
|
Yang
2017/03/20 15:00:24
This seems wrong. We would install these builtins
mvstanton
2017/03/21 21:15:47
Done.
|
| + |
| // Install experimental natives. Do not include them into the |
| // snapshot as we should be able to turn them off at runtime. Re-installing |
| // them after they have already been deserialized would also fail. |