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

Side by Side Diff: src/bootstrapper.cc

Issue 2761783002: Always run our fast array builtins. (Closed)
Patch Set: REBASE. Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | src/js/array.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void HookUpGlobalProxy(Handle<JSGlobalProxy> global_proxy); 198 void HookUpGlobalProxy(Handle<JSGlobalProxy> global_proxy);
199 // The native context has a ScriptContextTable that store declarative bindings 199 // The native context has a ScriptContextTable that store declarative bindings
200 // made in script scopes. Add a "this" binding to that table pointing to the 200 // made in script scopes. Add a "this" binding to that table pointing to the
201 // global proxy. 201 // global proxy.
202 void InstallGlobalThisBinding(); 202 void InstallGlobalThisBinding();
203 // New context initialization. Used for creating a context from scratch. 203 // New context initialization. Used for creating a context from scratch.
204 void InitializeGlobal(Handle<JSGlobalObject> global_object, 204 void InitializeGlobal(Handle<JSGlobalObject> global_object,
205 Handle<JSFunction> empty_function, 205 Handle<JSFunction> empty_function,
206 GlobalContextType context_type); 206 GlobalContextType context_type);
207 void InitializeExperimentalGlobal(); 207 void InitializeExperimentalGlobal();
208 void InstallFastArrayBuiltins();
208 // Depending on the situation, expose and/or get rid of the utils object. 209 // Depending on the situation, expose and/or get rid of the utils object.
209 void ConfigureUtilsObject(GlobalContextType context_type); 210 void ConfigureUtilsObject(GlobalContextType context_type);
210 211
211 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ 212 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \
212 void InitializeGlobal_##id(); 213 void InitializeGlobal_##id();
213 214
214 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) 215 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION)
215 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) 216 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION)
216 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) 217 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
217 #undef DECLARE_FEATURE_INITIALIZATION 218 #undef DECLARE_FEATURE_INITIALIZATION
218 219
219 void InitializeGlobal_enable_fast_array_builtins(); 220 void InstallOneBuiltinFunction(const char* object, const char* method,
221 Builtins::Name name);
222 void InitializeGlobal_experimental_fast_array_builtins();
220 223
221 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, 224 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target,
222 const char* name, Builtins::Name call, 225 const char* name, Builtins::Name call,
223 BuiltinFunctionId id, bool is_shared); 226 BuiltinFunctionId id, bool is_shared);
224 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, 227 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target,
225 const char* name, 228 const char* name,
226 ElementsKind elements_kind); 229 ElementsKind elements_kind);
227 bool InstallNatives(GlobalContextType context_type); 230 bool InstallNatives(GlobalContextType context_type);
228 231
229 void InstallTypedArray(const char* name, ElementsKind elements_kind, 232 void InstallTypedArray(const char* name, ElementsKind elements_kind,
(...skipping 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 3058
3056 3059
3057 void Genesis::InitializeExperimentalGlobal() { 3060 void Genesis::InitializeExperimentalGlobal() {
3058 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); 3061 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id();
3059 3062
3060 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) 3063 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL)
3061 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) 3064 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL)
3062 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) 3065 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL)
3063 #undef FEATURE_INITIALIZE_GLOBAL 3066 #undef FEATURE_INITIALIZE_GLOBAL
3064 3067
3065 InitializeGlobal_enable_fast_array_builtins(); 3068 InitializeGlobal_experimental_fast_array_builtins();
3066 } 3069 }
3067 3070
3071 void Genesis::InstallFastArrayBuiltins() {
3072 InstallOneBuiltinFunction("Array", "forEach", Builtins::kArrayForEach);
3073 InstallOneBuiltinFunction("Array", "every", Builtins::kArrayEvery);
3074 InstallOneBuiltinFunction("Array", "some", Builtins::kArraySome);
3075 }
3068 3076
3069 bool Bootstrapper::CompileBuiltin(Isolate* isolate, int index) { 3077 bool Bootstrapper::CompileBuiltin(Isolate* isolate, int index) {
3070 Vector<const char> name = Natives::GetScriptName(index); 3078 Vector<const char> name = Natives::GetScriptName(index);
3071 Handle<String> source_code = 3079 Handle<String> source_code =
3072 isolate->bootstrapper()->SourceLookup<Natives>(index); 3080 isolate->bootstrapper()->SourceLookup<Natives>(index);
3073 3081
3074 // We pass in extras_utils so that builtin code can set it up for later use 3082 // We pass in extras_utils so that builtin code can set it up for later use
3075 // by actual extras code, compiled with CompileExtraBuiltin. 3083 // by actual extras code, compiled with CompileExtraBuiltin.
3076 Handle<Object> global = isolate->global_object(); 3084 Handle<Object> global = isolate->global_object();
3077 Handle<Object> utils = isolate->natives_utils_object(); 3085 Handle<Object> utils = isolate->natives_utils_object();
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 JSGlobalObject::cast(native_context->global_object())); 3663 JSGlobalObject::cast(native_context->global_object()));
3656 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); 3664 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol");
3657 Handle<JSObject> symbol = Handle<JSObject>::cast( 3665 Handle<JSObject> symbol = Handle<JSObject>::cast(
3658 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); 3666 JSObject::GetProperty(global, symbol_string).ToHandleChecked());
3659 Handle<String> name_string = factory->InternalizeUtf8String(name); 3667 Handle<String> name_string = factory->InternalizeUtf8String(name);
3660 PropertyAttributes attributes = 3668 PropertyAttributes attributes =
3661 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); 3669 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
3662 JSObject::AddProperty(symbol, name_string, value, attributes); 3670 JSObject::AddProperty(symbol, name_string, value, attributes);
3663 } 3671 }
3664 3672
3665 void Genesis::InitializeGlobal_enable_fast_array_builtins() { 3673 void Genesis::InstallOneBuiltinFunction(const char* object_name,
3666 if (!FLAG_enable_fast_array_builtins) return; 3674 const char* method_name,
3667 3675 Builtins::Name builtin_name) {
3668 Handle<JSGlobalObject> global(native_context()->global_object()); 3676 Handle<JSGlobalObject> global(native_context()->global_object());
3669 Isolate* isolate = global->GetIsolate(); 3677 Isolate* isolate = global->GetIsolate();
3670 Factory* factory = isolate->factory(); 3678 Factory* factory = isolate->factory();
3671 3679
3672 LookupIterator it1(global, factory->NewStringFromAsciiChecked("Array"), 3680 LookupIterator it1(global, factory->NewStringFromAsciiChecked(object_name),
3673 LookupIterator::OWN_SKIP_INTERCEPTOR); 3681 LookupIterator::OWN_SKIP_INTERCEPTOR);
3674 Handle<Object> array_object = Object::GetProperty(&it1).ToHandleChecked(); 3682 Handle<Object> object = Object::GetProperty(&it1).ToHandleChecked();
3675 LookupIterator it2(array_object, 3683 LookupIterator it2(object, factory->NewStringFromAsciiChecked("prototype"),
3676 factory->NewStringFromAsciiChecked("prototype"),
3677 LookupIterator::OWN_SKIP_INTERCEPTOR); 3684 LookupIterator::OWN_SKIP_INTERCEPTOR);
3678 Handle<Object> array_prototype = Object::GetProperty(&it2).ToHandleChecked(); 3685 Handle<Object> prototype = Object::GetProperty(&it2).ToHandleChecked();
3679 LookupIterator it3(array_prototype, 3686
3680 factory->NewStringFromAsciiChecked("forEach"), 3687 LookupIterator it3(prototype, factory->NewStringFromAsciiChecked(method_name),
3681 LookupIterator::OWN_SKIP_INTERCEPTOR); 3688 LookupIterator::OWN_SKIP_INTERCEPTOR);
3682 Handle<Object> for_each_function = 3689 Handle<Object> function = Object::GetProperty(&it3).ToHandleChecked();
3683 Object::GetProperty(&it3).ToHandleChecked(); 3690 Handle<JSFunction>::cast(function)->set_code(
3684 Handle<JSFunction>::cast(for_each_function) 3691 isolate->builtins()->builtin(builtin_name));
3685 ->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach)); 3692 Handle<JSFunction>::cast(function)->shared()->set_code(
3686 Handle<JSFunction>::cast(for_each_function) 3693 isolate->builtins()->builtin(builtin_name));
3687 ->shared() 3694 }
3688 ->set_code(isolate->builtins()->builtin(Builtins::kArrayForEach));
3689 3695
3690 LookupIterator it4(array_prototype, 3696 void Genesis::InitializeGlobal_experimental_fast_array_builtins() {
3691 factory->NewStringFromAsciiChecked("every"), 3697 if (!FLAG_experimental_fast_array_builtins) return;
3692 LookupIterator::OWN_SKIP_INTERCEPTOR); 3698 // Insert experimental fast array builtins here.
3693 Handle<Object> every_function = Object::GetProperty(&it4).ToHandleChecked();
3694 Handle<JSFunction>::cast(every_function)
3695 ->set_code(isolate->builtins()->builtin(Builtins::kArrayEvery));
3696 Handle<JSFunction>::cast(every_function)
3697 ->shared()
3698 ->set_code(isolate->builtins()->builtin(Builtins::kArrayEvery));
3699
3700 LookupIterator it5(array_prototype,
3701 factory->NewStringFromAsciiChecked("some"),
3702 LookupIterator::OWN_SKIP_INTERCEPTOR);
3703 Handle<Object> some_function = Object::GetProperty(&it5).ToHandleChecked();
3704 Handle<JSFunction>::cast(some_function)
3705 ->set_code(isolate->builtins()->builtin(Builtins::kArraySome));
3706 Handle<JSFunction>::cast(some_function)
3707 ->shared()
3708 ->set_code(isolate->builtins()->builtin(Builtins::kArraySome));
3709 } 3699 }
3710 3700
3711 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { 3701 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
3712 if (!FLAG_harmony_sharedarraybuffer) return; 3702 if (!FLAG_harmony_sharedarraybuffer) return;
3713 3703
3714 Handle<JSGlobalObject> global(native_context()->global_object()); 3704 Handle<JSGlobalObject> global(native_context()->global_object());
3715 Isolate* isolate = global->GetIsolate(); 3705 Isolate* isolate = global->GetIsolate();
3716 Factory* factory = isolate->factory(); 3706 Factory* factory = isolate->factory();
3717 3707
3718 Handle<JSFunction> shared_array_buffer_fun = 3708 Handle<JSFunction> shared_array_buffer_fun =
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4935 if (!InstallNatives(context_type)) return; 4925 if (!InstallNatives(context_type)) return;
4936 4926
4937 MakeFunctionInstancePrototypeWritable(); 4927 MakeFunctionInstancePrototypeWritable();
4938 4928
4939 if (!InstallExtraNatives()) return; 4929 if (!InstallExtraNatives()) return;
4940 if (!ConfigureGlobalObjects(global_proxy_template)) return; 4930 if (!ConfigureGlobalObjects(global_proxy_template)) return;
4941 4931
4942 isolate->counters()->contexts_created_from_scratch()->Increment(); 4932 isolate->counters()->contexts_created_from_scratch()->Increment();
4943 } 4933 }
4944 4934
4935 InstallFastArrayBuiltins();
Yang 2017/03/20 15:00:24 This seems wrong. We would install these builtins
mvstanton 2017/03/21 21:15:47 Done.
4936
4945 // Install experimental natives. Do not include them into the 4937 // Install experimental natives. Do not include them into the
4946 // snapshot as we should be able to turn them off at runtime. Re-installing 4938 // snapshot as we should be able to turn them off at runtime. Re-installing
4947 // them after they have already been deserialized would also fail. 4939 // them after they have already been deserialized would also fail.
4948 if (context_type == FULL_CONTEXT) { 4940 if (context_type == FULL_CONTEXT) {
4949 if (!isolate->serializer_enabled()) { 4941 if (!isolate->serializer_enabled()) {
4950 InitializeExperimentalGlobal(); 4942 InitializeExperimentalGlobal();
4951 4943
4952 if (FLAG_experimental_extras) { 4944 if (FLAG_experimental_extras) {
4953 if (!InstallExperimentalExtraNatives()) return; 4945 if (!InstallExperimentalExtraNatives()) return;
4954 } 4946 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5063 } 5055 }
5064 5056
5065 5057
5066 // Called when the top-level V8 mutex is destroyed. 5058 // Called when the top-level V8 mutex is destroyed.
5067 void Bootstrapper::FreeThreadResources() { 5059 void Bootstrapper::FreeThreadResources() {
5068 DCHECK(!IsActive()); 5060 DCHECK(!IsActive());
5069 } 5061 }
5070 5062
5071 } // namespace internal 5063 } // namespace internal
5072 } // namespace v8 5064 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | src/js/array.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698