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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ | 171 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ |
172 void InitializeGlobal_##id(); | 172 void InitializeGlobal_##id(); |
173 | 173 |
174 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) | 174 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) |
175 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) | 175 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) |
176 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) | 176 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
177 #undef DECLARE_FEATURE_INITIALIZATION | 177 #undef DECLARE_FEATURE_INITIALIZATION |
178 | 178 |
179 void InstallOneBuiltinFunction(Handle<Object> prototype, const char* method, | 179 void InstallOneBuiltinFunction(Handle<Object> prototype, const char* method, |
180 Builtins::Name name, | 180 Builtins::Name name); |
181 int internal_formal_parameter_count); | |
182 void InitializeGlobal_experimental_fast_array_builtins(); | 181 void InitializeGlobal_experimental_fast_array_builtins(); |
183 | 182 |
184 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, | 183 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
185 const char* name, | 184 const char* name, |
186 Builtins::Name call_byteLength, | 185 Builtins::Name call_byteLength, |
187 BuiltinFunctionId byteLength_id, | 186 BuiltinFunctionId byteLength_id, |
188 Builtins::Name call_slice); | 187 Builtins::Name call_slice); |
189 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 188 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
190 const char* name, | 189 const char* name, |
191 ElementsKind elements_kind); | 190 ElementsKind elements_kind); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 fun->shared()->set_internal_formal_parameter_count(len); | 389 fun->shared()->set_internal_formal_parameter_count(len); |
391 } else { | 390 } else { |
392 fun->shared()->DontAdaptArguments(); | 391 fun->shared()->DontAdaptArguments(); |
393 } | 392 } |
394 fun->shared()->set_length(len); | 393 fun->shared()->set_length(len); |
395 return fun; | 394 return fun; |
396 } | 395 } |
397 | 396 |
398 Handle<JSFunction> InstallArrayBuiltinFunction(Handle<JSObject> base, | 397 Handle<JSFunction> InstallArrayBuiltinFunction(Handle<JSObject> base, |
399 const char* name, | 398 const char* name, |
400 Builtins::Name call, | 399 Builtins::Name call) { |
401 int argument_count) { | |
402 Isolate* isolate = base->GetIsolate(); | 400 Isolate* isolate = base->GetIsolate(); |
403 Handle<String> str_name = isolate->factory()->InternalizeUtf8String(name); | 401 Handle<String> str_name = isolate->factory()->InternalizeUtf8String(name); |
404 Handle<JSFunction> fun = | 402 Handle<JSFunction> fun = |
405 CreateFunction(isolate, str_name, JS_OBJECT_TYPE, JSObject::kHeaderSize, | 403 CreateFunction(isolate, str_name, JS_OBJECT_TYPE, JSObject::kHeaderSize, |
406 MaybeHandle<JSObject>(), call, true); | 404 MaybeHandle<JSObject>(), call, true); |
407 fun->shared()->set_internal_formal_parameter_count(argument_count); | 405 fun->shared()->set_internal_formal_parameter_count( |
| 406 Builtins::GetBuiltinParameterCount(call)); |
408 | 407 |
409 // Set the length to 1 to satisfy ECMA-262. | 408 // Set the length to 1 to satisfy ECMA-262. |
410 fun->shared()->set_length(1); | 409 fun->shared()->set_length(1); |
411 fun->shared()->set_language_mode(STRICT); | 410 fun->shared()->set_language_mode(STRICT); |
412 InstallFunction(base, fun, str_name); | 411 InstallFunction(base, fun, str_name); |
413 return fun; | 412 return fun; |
414 } | 413 } |
415 | 414 |
416 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base, | 415 Handle<JSFunction> SimpleInstallFunction(Handle<JSObject> base, |
417 Handle<String> name, | 416 Handle<String> name, |
(...skipping 3446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3864 Handle<JSObject> symbol = Handle<JSObject>::cast( | 3863 Handle<JSObject> symbol = Handle<JSObject>::cast( |
3865 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); | 3864 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); |
3866 Handle<String> name_string = factory->InternalizeUtf8String(name); | 3865 Handle<String> name_string = factory->InternalizeUtf8String(name); |
3867 PropertyAttributes attributes = | 3866 PropertyAttributes attributes = |
3868 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 3867 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
3869 JSObject::AddProperty(symbol, name_string, value, attributes); | 3868 JSObject::AddProperty(symbol, name_string, value, attributes); |
3870 } | 3869 } |
3871 | 3870 |
3872 void Genesis::InstallOneBuiltinFunction(Handle<Object> prototype, | 3871 void Genesis::InstallOneBuiltinFunction(Handle<Object> prototype, |
3873 const char* method_name, | 3872 const char* method_name, |
3874 Builtins::Name builtin_name, | 3873 Builtins::Name builtin_name) { |
3875 int internal_formal_parameter_count) { | |
3876 LookupIterator it( | 3874 LookupIterator it( |
3877 prototype, isolate()->factory()->NewStringFromAsciiChecked(method_name), | 3875 prototype, isolate()->factory()->NewStringFromAsciiChecked(method_name), |
3878 LookupIterator::OWN_SKIP_INTERCEPTOR); | 3876 LookupIterator::OWN_SKIP_INTERCEPTOR); |
3879 Handle<Object> function = Object::GetProperty(&it).ToHandleChecked(); | 3877 Handle<Object> function = Object::GetProperty(&it).ToHandleChecked(); |
3880 Handle<JSFunction>::cast(function)->set_code( | 3878 Handle<JSFunction>::cast(function)->set_code( |
3881 isolate()->builtins()->builtin(builtin_name)); | 3879 isolate()->builtins()->builtin(builtin_name)); |
3882 SharedFunctionInfo* info = Handle<JSFunction>::cast(function)->shared(); | 3880 SharedFunctionInfo* info = Handle<JSFunction>::cast(function)->shared(); |
3883 info->set_code(isolate()->builtins()->builtin(builtin_name)); | 3881 info->set_code(isolate()->builtins()->builtin(builtin_name)); |
3884 info->set_internal_formal_parameter_count(internal_formal_parameter_count); | 3882 info->set_internal_formal_parameter_count( |
| 3883 Builtins::GetBuiltinParameterCount(builtin_name)); |
3885 } | 3884 } |
3886 | 3885 |
3887 void Genesis::InitializeGlobal_experimental_fast_array_builtins() { | 3886 void Genesis::InitializeGlobal_experimental_fast_array_builtins() { |
3888 if (!FLAG_experimental_fast_array_builtins) return; | 3887 if (!FLAG_experimental_fast_array_builtins) return; |
3889 { | 3888 { |
3890 Handle<Object> typed_array_prototype( | 3889 Handle<Object> typed_array_prototype( |
3891 native_context()->typed_array_prototype(), isolate()); | 3890 native_context()->typed_array_prototype(), isolate()); |
3892 // Insert experimental fast TypedArray builtins here. | 3891 // Insert experimental fast TypedArray builtins here. |
3893 InstallOneBuiltinFunction(typed_array_prototype, "every", | 3892 InstallOneBuiltinFunction(typed_array_prototype, "every", |
3894 Builtins::kTypedArrayPrototypeEvery, | 3893 Builtins::kTypedArrayPrototypeEvery); |
3895 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
3896 InstallOneBuiltinFunction(typed_array_prototype, "some", | 3894 InstallOneBuiltinFunction(typed_array_prototype, "some", |
3897 Builtins::kTypedArrayPrototypeSome, | 3895 Builtins::kTypedArrayPrototypeSome); |
3898 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
3899 InstallOneBuiltinFunction(typed_array_prototype, "reduce", | 3896 InstallOneBuiltinFunction(typed_array_prototype, "reduce", |
3900 Builtins::kTypedArrayPrototypeReduce, | 3897 Builtins::kTypedArrayPrototypeReduce); |
3901 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
3902 InstallOneBuiltinFunction(typed_array_prototype, "reduceRight", | 3898 InstallOneBuiltinFunction(typed_array_prototype, "reduceRight", |
3903 Builtins::kTypedArrayPrototypeReduceRight, | 3899 Builtins::kTypedArrayPrototypeReduceRight); |
3904 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
3905 } | 3900 } |
3906 } | 3901 } |
3907 | 3902 |
3908 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 3903 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
3909 if (!FLAG_harmony_sharedarraybuffer) return; | 3904 if (!FLAG_harmony_sharedarraybuffer) return; |
3910 | 3905 |
3911 Handle<JSGlobalObject> global(native_context()->global_object()); | 3906 Handle<JSGlobalObject> global(native_context()->global_object()); |
3912 Isolate* isolate = global->GetIsolate(); | 3907 Isolate* isolate = global->GetIsolate(); |
3913 Factory* factory = isolate->factory(); | 3908 Factory* factory = isolate->factory(); |
3914 | 3909 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4359 | 4354 |
4360 // Make sure that Array.prototype.concat appears to be compiled. | 4355 // Make sure that Array.prototype.concat appears to be compiled. |
4361 // The code will never be called, but inline caching for call will | 4356 // The code will never be called, but inline caching for call will |
4362 // only work if it appears to be compiled. | 4357 // only work if it appears to be compiled. |
4363 concat->shared()->DontAdaptArguments(); | 4358 concat->shared()->DontAdaptArguments(); |
4364 DCHECK(concat->is_compiled()); | 4359 DCHECK(concat->is_compiled()); |
4365 // Set the lengths for the functions to satisfy ECMA-262. | 4360 // Set the lengths for the functions to satisfy ECMA-262. |
4366 concat->shared()->set_length(1); | 4361 concat->shared()->set_length(1); |
4367 | 4362 |
4368 // Install Array.prototype.forEach | 4363 // Install Array.prototype.forEach |
4369 Handle<JSFunction> forEach = InstallArrayBuiltinFunction( | 4364 Handle<JSFunction> forEach = |
4370 proto, "forEach", Builtins::kArrayForEach, | 4365 InstallArrayBuiltinFunction(proto, "forEach", Builtins::kArrayForEach); |
4371 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
4372 // Add forEach to the context. | 4366 // Add forEach to the context. |
4373 native_context()->set_array_for_each_iterator(*forEach); | 4367 native_context()->set_array_for_each_iterator(*forEach); |
4374 | 4368 |
4375 // Install Array.prototype.filter | 4369 // Install Array.prototype.filter |
4376 InstallArrayBuiltinFunction( | 4370 InstallArrayBuiltinFunction(proto, "filter", Builtins::kArrayFilter); |
4377 proto, "filter", Builtins::kArrayFilter, | |
4378 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
4379 | 4371 |
4380 // Install Array.prototype.map | 4372 // Install Array.prototype.map |
4381 InstallArrayBuiltinFunction( | 4373 InstallArrayBuiltinFunction(proto, "map", Builtins::kArrayMap); |
4382 proto, "map", Builtins::kArrayMap, | |
4383 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
4384 | 4374 |
4385 // Install Array.prototype.every | 4375 // Install Array.prototype.every |
4386 InstallArrayBuiltinFunction( | 4376 InstallArrayBuiltinFunction(proto, "every", Builtins::kArrayEvery); |
4387 proto, "every", Builtins::kArrayEvery, | |
4388 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
4389 | 4377 |
4390 // Install Array.prototype.some | 4378 // Install Array.prototype.some |
4391 InstallArrayBuiltinFunction( | 4379 InstallArrayBuiltinFunction(proto, "some", Builtins::kArraySome); |
4392 proto, "some", Builtins::kArraySome, | |
4393 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
4394 | 4380 |
4395 // Install Array.prototype.reduce | 4381 // Install Array.prototype.reduce |
4396 InstallArrayBuiltinFunction( | 4382 InstallArrayBuiltinFunction(proto, "reduce", Builtins::kArrayReduce); |
4397 proto, "reduce", Builtins::kArrayReduce, | |
4398 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
4399 | 4383 |
4400 // Install Array.prototype.reduceRight | 4384 // Install Array.prototype.reduceRight |
4401 InstallArrayBuiltinFunction( | 4385 InstallArrayBuiltinFunction(proto, "reduceRight", |
4402 proto, "reduceRight", Builtins::kArrayReduceRight, | 4386 Builtins::kArrayReduceRight); |
4403 SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
4404 } | 4387 } |
4405 | 4388 |
4406 // Install InternalArray.prototype.concat | 4389 // Install InternalArray.prototype.concat |
4407 { | 4390 { |
4408 Handle<JSFunction> array_constructor( | 4391 Handle<JSFunction> array_constructor( |
4409 native_context()->internal_array_function()); | 4392 native_context()->internal_array_function()); |
4410 Handle<JSObject> proto(JSObject::cast(array_constructor->prototype())); | 4393 Handle<JSObject> proto(JSObject::cast(array_constructor->prototype())); |
4411 Handle<JSFunction> concat = | 4394 Handle<JSFunction> concat = |
4412 InstallFunction(proto, "concat", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 4395 InstallFunction(proto, "concat", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
4413 MaybeHandle<JSObject>(), Builtins::kArrayConcat); | 4396 MaybeHandle<JSObject>(), Builtins::kArrayConcat); |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5298 } | 5281 } |
5299 | 5282 |
5300 | 5283 |
5301 // Called when the top-level V8 mutex is destroyed. | 5284 // Called when the top-level V8 mutex is destroyed. |
5302 void Bootstrapper::FreeThreadResources() { | 5285 void Bootstrapper::FreeThreadResources() { |
5303 DCHECK(!IsActive()); | 5286 DCHECK(!IsActive()); |
5304 } | 5287 } |
5305 | 5288 |
5306 } // namespace internal | 5289 } // namespace internal |
5307 } // namespace v8 | 5290 } // namespace v8 |
OLD | NEW |