Chromium Code Reviews| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 bool InstallNatives(GlobalContextType context_type); | 228 bool InstallNatives(GlobalContextType context_type); |
| 229 | 229 |
| 230 void InstallTypedArray(const char* name, ElementsKind elements_kind, | 230 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 231 Handle<JSFunction>* fun); | 231 Handle<JSFunction>* fun); |
| 232 bool InstallExperimentalNatives(); | 232 bool InstallExperimentalNatives(); |
| 233 bool InstallExtraNatives(); | 233 bool InstallExtraNatives(); |
| 234 bool InstallExperimentalExtraNatives(); | 234 bool InstallExperimentalExtraNatives(); |
| 235 bool InstallDebuggerNatives(); | 235 bool InstallDebuggerNatives(); |
| 236 void InstallBuiltinFunctionIds(); | 236 void InstallBuiltinFunctionIds(); |
| 237 void InstallExperimentalBuiltinFunctionIds(); | 237 void InstallExperimentalBuiltinFunctionIds(); |
| 238 void InstallExperimentalExports(); | |
| 238 void InitializeNormalizedMapCaches(); | 239 void InitializeNormalizedMapCaches(); |
| 239 | 240 |
| 240 enum ExtensionTraversalState { | 241 enum ExtensionTraversalState { |
| 241 UNVISITED, VISITED, INSTALLED | 242 UNVISITED, VISITED, INSTALLED |
| 242 }; | 243 }; |
| 243 | 244 |
| 244 class ExtensionStates { | 245 class ExtensionStates { |
| 245 public: | 246 public: |
| 246 ExtensionStates(); | 247 ExtensionStates(); |
| 247 ExtensionTraversalState get_state(RegisteredExtension* extension); | 248 ExtensionTraversalState get_state(RegisteredExtension* extension); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 | 527 |
| 527 void InstallSpeciesGetter(Handle<JSFunction> constructor) { | 528 void InstallSpeciesGetter(Handle<JSFunction> constructor) { |
| 528 Factory* factory = constructor->GetIsolate()->factory(); | 529 Factory* factory = constructor->GetIsolate()->factory(); |
| 529 // TODO(adamk): We should be able to share a SharedFunctionInfo | 530 // TODO(adamk): We should be able to share a SharedFunctionInfo |
| 530 // between all these JSFunctins. | 531 // between all these JSFunctins. |
| 531 SimpleInstallGetter(constructor, factory->symbol_species_string(), | 532 SimpleInstallGetter(constructor, factory->symbol_species_string(), |
| 532 factory->species_symbol(), Builtins::kReturnReceiver, | 533 factory->species_symbol(), Builtins::kReturnReceiver, |
| 533 true); | 534 true); |
| 534 } | 535 } |
| 535 | 536 |
| 537 void SetFunction(Handle<JSObject> target, Handle<JSFunction> function, | |
| 538 Handle<Name> name, PropertyAttributes attributes = DONT_ENUM) { | |
| 539 JSObject::SetOwnPropertyIgnoreAttributes(target, name, function, attributes) | |
| 540 .ToHandleChecked(); | |
| 541 } | |
| 542 | |
| 536 } // namespace | 543 } // namespace |
| 537 | 544 |
| 538 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { | 545 Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) { |
| 539 // Allocate the map for function instances. Maps are allocated first and their | 546 // Allocate the map for function instances. Maps are allocated first and their |
| 540 // prototypes patched later, once empty function is created. | 547 // prototypes patched later, once empty function is created. |
| 541 | 548 |
| 542 // Functions with this map will not have a 'prototype' property, and | 549 // Functions with this map will not have a 'prototype' property, and |
| 543 // can not be used as constructors. | 550 // can not be used as constructors. |
| 544 Handle<Map> function_without_prototype_map = | 551 Handle<Map> function_without_prototype_map = |
| 545 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); | 552 factory()->CreateSloppyFunctionMap(FUNCTION_WITHOUT_PROTOTYPE); |
| (...skipping 2948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3494 } | 3501 } |
| 3495 | 3502 |
| 3496 Accessors::FunctionSetPrototype(callsite_fun, proto).Assert(); | 3503 Accessors::FunctionSetPrototype(callsite_fun, proto).Assert(); |
| 3497 } | 3504 } |
| 3498 } | 3505 } |
| 3499 } | 3506 } |
| 3500 | 3507 |
| 3501 | 3508 |
| 3502 void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate, | 3509 void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate, |
| 3503 Handle<JSObject> container) { | 3510 Handle<JSObject> container) { |
| 3504 HandleScope scope(isolate); | 3511 isolate->native_context()->set_experimental_container(*container); |
| 3505 | |
| 3506 #ifdef V8_I18N_SUPPORT | |
| 3507 #define INITIALIZE_FLAG(FLAG) \ | |
| 3508 { \ | |
| 3509 Handle<String> name = \ | |
| 3510 isolate->factory()->NewStringFromAsciiChecked(#FLAG); \ | |
| 3511 JSObject::AddProperty(container, name, \ | |
| 3512 isolate->factory()->ToBoolean(FLAG), NONE); \ | |
| 3513 } | |
| 3514 | |
| 3515 #undef INITIALIZE_FLAG | |
| 3516 #endif | |
| 3517 } | 3512 } |
| 3518 | 3513 |
| 3519 | 3514 |
| 3520 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ | 3515 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ |
| 3521 void Genesis::InitializeGlobal_##id() {} | 3516 void Genesis::InitializeGlobal_##id() {} |
| 3522 | 3517 |
| 3523 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) | 3518 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) |
| 3524 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) | 3519 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) |
| 3525 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) | 3520 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) |
| 3526 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) | 3521 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3625 Handle<JSFunction> type##_function = InstallFunction( \ | 3620 Handle<JSFunction> type##_function = InstallFunction( \ |
| 3626 simd_object, #Type, JS_VALUE_TYPE, JSValue::kSize, \ | 3621 simd_object, #Type, JS_VALUE_TYPE, JSValue::kSize, \ |
| 3627 isolate->initial_object_prototype(), Builtins::kIllegal); \ | 3622 isolate->initial_object_prototype(), Builtins::kIllegal); \ |
| 3628 native_context()->set_##type##_function(*type##_function); \ | 3623 native_context()->set_##type##_function(*type##_function); \ |
| 3629 type##_function->shared()->set_instance_class_name(*factory->Type##_string()); | 3624 type##_function->shared()->set_instance_class_name(*factory->Type##_string()); |
| 3630 SIMD128_TYPES(SIMD128_INSTALL_FUNCTION) | 3625 SIMD128_TYPES(SIMD128_INSTALL_FUNCTION) |
| 3631 #undef SIMD128_INSTALL_FUNCTION | 3626 #undef SIMD128_INSTALL_FUNCTION |
| 3632 } | 3627 } |
| 3633 | 3628 |
| 3634 | 3629 |
| 3635 void Genesis::InitializeGlobal_harmony_array_prototype_values() { | 3630 void Genesis::InitializeGlobal_harmony_array_prototype_values() { |
|
Yang
2017/02/13 14:51:16
could we install the experimental functions like t
Dan Ehrenberg
2017/02/13 20:05:42
Done.
| |
| 3636 if (!FLAG_harmony_array_prototype_values) return; | 3631 if (!FLAG_harmony_array_prototype_values) return; |
| 3637 Handle<JSFunction> array_constructor(native_context()->array_function()); | 3632 Handle<JSFunction> array_constructor(native_context()->array_function()); |
| 3638 Handle<JSObject> array_prototype( | 3633 Handle<JSObject> array_prototype( |
| 3639 JSObject::cast(array_constructor->instance_prototype())); | 3634 JSObject::cast(array_constructor->instance_prototype())); |
| 3640 Handle<Object> values_iterator = | 3635 Handle<Object> values_iterator = |
| 3641 JSObject::GetProperty(array_prototype, factory()->iterator_symbol()) | 3636 JSObject::GetProperty(array_prototype, factory()->iterator_symbol()) |
| 3642 .ToHandleChecked(); | 3637 .ToHandleChecked(); |
| 3643 DCHECK(values_iterator->IsJSFunction()); | 3638 DCHECK(values_iterator->IsJSFunction()); |
| 3644 JSObject::AddProperty(array_prototype, factory()->values_string(), | 3639 JSObject::AddProperty(array_prototype, factory()->values_string(), |
| 3645 values_iterator, DONT_ENUM); | 3640 values_iterator, DONT_ENUM); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4109 "native harmony-atomics.js", NULL}; | 4104 "native harmony-atomics.js", NULL}; |
| 4110 static const char* harmony_simd_natives[] = {"native harmony-simd.js", | 4105 static const char* harmony_simd_natives[] = {"native harmony-simd.js", |
| 4111 nullptr}; | 4106 nullptr}; |
| 4112 static const char* harmony_do_expressions_natives[] = {nullptr}; | 4107 static const char* harmony_do_expressions_natives[] = {nullptr}; |
| 4113 static const char* harmony_regexp_lookbehind_natives[] = {nullptr}; | 4108 static const char* harmony_regexp_lookbehind_natives[] = {nullptr}; |
| 4114 static const char* harmony_regexp_named_captures_natives[] = {nullptr}; | 4109 static const char* harmony_regexp_named_captures_natives[] = {nullptr}; |
| 4115 static const char* harmony_regexp_property_natives[] = {nullptr}; | 4110 static const char* harmony_regexp_property_natives[] = {nullptr}; |
| 4116 static const char* harmony_function_sent_natives[] = {nullptr}; | 4111 static const char* harmony_function_sent_natives[] = {nullptr}; |
| 4117 static const char* harmony_array_prototype_values_natives[] = {nullptr}; | 4112 static const char* harmony_array_prototype_values_natives[] = {nullptr}; |
| 4118 #ifdef V8_I18N_SUPPORT | 4113 #ifdef V8_I18N_SUPPORT |
| 4119 static const char* icu_case_mapping_natives[] = {"native icu-case-mapping.js", | 4114 static const char* icu_case_mapping_natives[] = {nullptr}; |
| 4120 nullptr}; | 4115 static const char* datetime_format_to_parts_natives[] = {nullptr}; |
| 4121 static const char* datetime_format_to_parts_natives[] = { | |
| 4122 "native datetime-format-to-parts.js", nullptr}; | |
| 4123 #endif | 4116 #endif |
| 4124 static const char* harmony_restrictive_generators_natives[] = {nullptr}; | 4117 static const char* harmony_restrictive_generators_natives[] = {nullptr}; |
| 4125 static const char* harmony_trailing_commas_natives[] = {nullptr}; | 4118 static const char* harmony_trailing_commas_natives[] = {nullptr}; |
| 4126 static const char* harmony_class_fields_natives[] = {nullptr}; | 4119 static const char* harmony_class_fields_natives[] = {nullptr}; |
| 4127 static const char* harmony_object_rest_spread_natives[] = {nullptr}; | 4120 static const char* harmony_object_rest_spread_natives[] = {nullptr}; |
| 4128 static const char* harmony_async_iteration_natives[] = {nullptr}; | 4121 static const char* harmony_async_iteration_natives[] = {nullptr}; |
| 4129 static const char* harmony_dynamic_import_natives[] = {nullptr}; | 4122 static const char* harmony_dynamic_import_natives[] = {nullptr}; |
| 4130 | 4123 |
| 4131 for (int i = ExperimentalNatives::GetDebuggerCount(); | 4124 for (int i = ExperimentalNatives::GetDebuggerCount(); |
| 4132 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 4125 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 4144 } | 4137 } |
| 4145 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); | 4138 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); |
| 4146 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); | 4139 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); |
| 4147 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); | 4140 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); |
| 4148 #undef INSTALL_EXPERIMENTAL_NATIVES | 4141 #undef INSTALL_EXPERIMENTAL_NATIVES |
| 4149 } | 4142 } |
| 4150 | 4143 |
| 4151 if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false; | 4144 if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false; |
| 4152 | 4145 |
| 4153 InstallExperimentalBuiltinFunctionIds(); | 4146 InstallExperimentalBuiltinFunctionIds(); |
| 4147 InstallExperimentalExports(); | |
| 4154 return true; | 4148 return true; |
| 4155 } | 4149 } |
| 4156 | 4150 |
| 4157 | 4151 |
| 4158 bool Genesis::InstallExtraNatives() { | 4152 bool Genesis::InstallExtraNatives() { |
| 4159 HandleScope scope(isolate()); | 4153 HandleScope scope(isolate()); |
| 4160 | 4154 |
| 4161 Handle<JSObject> extras_binding = | 4155 Handle<JSObject> extras_binding = |
| 4162 factory()->NewJSObject(isolate()->object_function()); | 4156 factory()->NewJSObject(isolate()->object_function()); |
| 4163 native_context()->set_extras_binding_object(*extras_binding); | 4157 native_context()->set_extras_binding_object(*extras_binding); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4237 ATOMIC_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; | 4231 ATOMIC_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; |
| 4238 | 4232 |
| 4239 for (const BuiltinFunctionIds& builtin : atomic_builtins) { | 4233 for (const BuiltinFunctionIds& builtin : atomic_builtins) { |
| 4240 Handle<JSObject> holder = | 4234 Handle<JSObject> holder = |
| 4241 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); | 4235 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); |
| 4242 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); | 4236 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); |
| 4243 } | 4237 } |
| 4244 } | 4238 } |
| 4245 } | 4239 } |
| 4246 | 4240 |
| 4241 void Genesis::InstallExperimentalExports() { | |
| 4242 HandleScope scope(isolate()); | |
| 4243 | |
| 4244 Handle<JSObject> experimental_container( | |
| 4245 native_context()->experimental_container()); | |
| 4246 | |
| 4247 #if V8_I18N_SUPPORT | |
| 4248 if (FLAG_icu_case_mapping) { | |
| 4249 Handle<JSObject> string_prototype( | |
| 4250 JSObject::cast(native_context()->string_function()->prototype())); | |
| 4251 | |
| 4252 Handle<JSFunction> to_lower_case = Handle<JSFunction>::cast( | |
| 4253 JSReceiver::GetProperty( | |
| 4254 experimental_container, | |
| 4255 factory()->InternalizeUtf8String("ToLowerCaseI18N")) | |
| 4256 .ToHandleChecked()); | |
| 4257 SetFunction(string_prototype, to_lower_case, | |
| 4258 factory()->InternalizeUtf8String("toLowerCase")); | |
| 4259 | |
| 4260 Handle<JSFunction> to_upper_case = Handle<JSFunction>::cast( | |
| 4261 JSReceiver::GetProperty( | |
| 4262 experimental_container, | |
| 4263 factory()->InternalizeUtf8String("ToUpperCaseI18N")) | |
| 4264 .ToHandleChecked()); | |
| 4265 SetFunction(string_prototype, to_upper_case, | |
| 4266 factory()->InternalizeUtf8String("toUpperCase")); | |
| 4267 | |
| 4268 Handle<JSFunction> to_locale_lower_case = Handle<JSFunction>::cast( | |
| 4269 JSReceiver::GetProperty( | |
| 4270 experimental_container, | |
| 4271 factory()->InternalizeUtf8String("ToLocaleLowerCaseI18N")) | |
| 4272 .ToHandleChecked()); | |
| 4273 SetFunction(string_prototype, to_locale_lower_case, | |
| 4274 factory()->InternalizeUtf8String("toLocaleLowerCase")); | |
| 4275 | |
| 4276 Handle<JSFunction> to_locale_upper_case = Handle<JSFunction>::cast( | |
| 4277 JSReceiver::GetProperty( | |
| 4278 experimental_container, | |
| 4279 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) | |
| 4280 .ToHandleChecked()); | |
| 4281 SetFunction(string_prototype, to_locale_upper_case, | |
| 4282 factory()->InternalizeUtf8String("toLocaleUpperCase")); | |
| 4283 } | |
| 4284 | |
| 4285 if (FLAG_datetime_format_to_parts) { | |
| 4286 Handle<JSObject> date_time_format_prototype(JSObject::cast( | |
| 4287 native_context()->intl_date_time_format_function()->prototype())); | |
| 4288 Handle<JSFunction> format_date_to_parts = Handle<JSFunction>::cast( | |
| 4289 JSReceiver::GetProperty( | |
| 4290 experimental_container, | |
| 4291 factory()->InternalizeUtf8String("FormatDateToParts")) | |
| 4292 .ToHandleChecked()); | |
| 4293 InstallFunction(date_time_format_prototype, format_date_to_parts, | |
| 4294 factory()->InternalizeUtf8String("formatToParts")); | |
| 4295 } | |
| 4296 #endif // V8_I18N_SUPPORT | |
| 4297 } | |
| 4247 | 4298 |
| 4248 #undef INSTALL_BUILTIN_ID | 4299 #undef INSTALL_BUILTIN_ID |
| 4249 | 4300 |
| 4250 | 4301 |
| 4251 void Genesis::InitializeNormalizedMapCaches() { | 4302 void Genesis::InitializeNormalizedMapCaches() { |
| 4252 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate()); | 4303 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate()); |
| 4253 native_context()->set_normalized_map_cache(*cache); | 4304 native_context()->set_normalized_map_cache(*cache); |
| 4254 } | 4305 } |
| 4255 | 4306 |
| 4256 | 4307 |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4875 } | 4926 } |
| 4876 | 4927 |
| 4877 | 4928 |
| 4878 // Called when the top-level V8 mutex is destroyed. | 4929 // Called when the top-level V8 mutex is destroyed. |
| 4879 void Bootstrapper::FreeThreadResources() { | 4930 void Bootstrapper::FreeThreadResources() { |
| 4880 DCHECK(!IsActive()); | 4931 DCHECK(!IsActive()); |
| 4881 } | 4932 } |
| 4882 | 4933 |
| 4883 } // namespace internal | 4934 } // namespace internal |
| 4884 } // namespace v8 | 4935 } // namespace v8 |
| OLD | NEW |