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 3478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3489 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 3489 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
3490 | 3490 |
3491 Handle<JSFunction> fun; | 3491 Handle<JSFunction> fun; |
3492 for (const FunctionInfo& info : infos) { | 3492 for (const FunctionInfo& info : infos) { |
3493 SimpleInstallFunction(proto, info.name, info.id, 0, true, attrs); | 3493 SimpleInstallFunction(proto, info.name, info.id, 0, true, attrs); |
3494 } | 3494 } |
3495 | 3495 |
3496 Accessors::FunctionSetPrototype(callsite_fun, proto).Assert(); | 3496 Accessors::FunctionSetPrototype(callsite_fun, proto).Assert(); |
3497 } | 3497 } |
3498 } | 3498 } |
3499 isolate->native_context()->set_exports_container(*container); | |
Yang
2017/02/15 12:40:15
Please clear this context field where we clear uti
Dan Ehrenberg
2017/02/15 16:43:26
Done.
| |
3499 } | 3500 } |
3500 | 3501 |
3501 | 3502 |
3502 void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate, | |
3503 Handle<JSObject> container) { | |
3504 HandleScope scope(isolate); | |
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 } | |
3518 | |
3519 | |
3520 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ | 3503 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ |
3521 void Genesis::InitializeGlobal_##id() {} | 3504 void Genesis::InitializeGlobal_##id() {} |
3522 | 3505 |
3523 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) | 3506 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) |
3524 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) | 3507 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) |
3525 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) | 3508 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) |
3526 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) | 3509 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) |
3527 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent) | 3510 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent) |
3528 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls) | 3511 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls) |
3529 #ifdef V8_I18N_SUPPORT | |
3530 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(datetime_format_to_parts) | |
3531 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(icu_case_mapping) | |
3532 #endif | |
3533 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators) | 3512 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators) |
3534 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_trailing_commas) | 3513 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_trailing_commas) |
3535 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_class_fields) | 3514 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_class_fields) |
3536 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_rest_spread) | 3515 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_rest_spread) |
3537 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_dynamic_import) | 3516 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_dynamic_import) |
3538 | 3517 |
3539 void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, | 3518 void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, |
3540 const char* name, Handle<Symbol> value) { | 3519 const char* name, Handle<Symbol> value) { |
3541 Handle<JSGlobalObject> global( | 3520 Handle<JSGlobalObject> global( |
3542 JSGlobalObject::cast(native_context->global_object())); | 3521 JSGlobalObject::cast(native_context->global_object())); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3653 NONE); | 3632 NONE); |
3654 } | 3633 } |
3655 | 3634 |
3656 void Genesis::InitializeGlobal_harmony_async_iteration() { | 3635 void Genesis::InitializeGlobal_harmony_async_iteration() { |
3657 if (!FLAG_harmony_async_iteration) return; | 3636 if (!FLAG_harmony_async_iteration) return; |
3658 Handle<JSFunction> symbol_fun(native_context()->symbol_function()); | 3637 Handle<JSFunction> symbol_fun(native_context()->symbol_function()); |
3659 InstallConstant(isolate(), symbol_fun, "asyncIterator", | 3638 InstallConstant(isolate(), symbol_fun, "asyncIterator", |
3660 factory()->async_iterator_symbol()); | 3639 factory()->async_iterator_symbol()); |
3661 } | 3640 } |
3662 | 3641 |
3642 #ifdef V8_I18N_SUPPORT | |
3643 void Genesis::InitializeGlobal_datetime_format_to_parts() { | |
3644 if (!FLAG_datetime_format_to_parts) return; | |
3645 Handle<JSObject> exports_container(native_context()->exports_container()); | |
3646 Handle<JSObject> date_time_format_prototype(JSObject::cast( | |
3647 native_context()->intl_date_time_format_function()->prototype())); | |
3648 Handle<JSFunction> format_date_to_parts = Handle<JSFunction>::cast( | |
3649 JSReceiver::GetProperty( | |
3650 exports_container, | |
3651 factory()->InternalizeUtf8String("FormatDateToParts")) | |
3652 .ToHandleChecked()); | |
3653 InstallFunction(date_time_format_prototype, format_date_to_parts, | |
3654 factory()->InternalizeUtf8String("formatToParts")); | |
3655 } | |
3656 | |
3657 namespace { | |
3658 | |
3659 void SetFunction(Handle<JSObject> target, Handle<JSFunction> function, | |
3660 Handle<Name> name, PropertyAttributes attributes = DONT_ENUM) { | |
3661 JSObject::SetOwnPropertyIgnoreAttributes(target, name, function, attributes) | |
3662 .ToHandleChecked(); | |
3663 } | |
3664 | |
3665 } // namespace | |
3666 | |
3667 void Genesis::InitializeGlobal_icu_case_mapping() { | |
3668 if (!FLAG_icu_case_mapping) return; | |
3669 | |
3670 Handle<JSObject> exports_container(native_context()->exports_container()); | |
3671 | |
3672 Handle<JSObject> string_prototype( | |
3673 JSObject::cast(native_context()->string_function()->prototype())); | |
3674 | |
3675 Handle<JSFunction> to_lower_case = Handle<JSFunction>::cast( | |
3676 JSReceiver::GetProperty( | |
3677 exports_container, | |
3678 factory()->InternalizeUtf8String("ToLowerCaseI18N")) | |
Yang
2017/02/15 12:40:15
We could also implement these functions as builtin
Dan Ehrenberg
2017/02/15 16:43:27
Yes, I plan to do that in a follow-on patch, but w
| |
3679 .ToHandleChecked()); | |
3680 SetFunction(string_prototype, to_lower_case, | |
3681 factory()->InternalizeUtf8String("toLowerCase")); | |
3682 | |
3683 Handle<JSFunction> to_upper_case = Handle<JSFunction>::cast( | |
3684 JSReceiver::GetProperty( | |
3685 exports_container, | |
3686 factory()->InternalizeUtf8String("ToUpperCaseI18N")) | |
3687 .ToHandleChecked()); | |
3688 SetFunction(string_prototype, to_upper_case, | |
3689 factory()->InternalizeUtf8String("toUpperCase")); | |
3690 | |
3691 Handle<JSFunction> to_locale_lower_case = Handle<JSFunction>::cast( | |
3692 JSReceiver::GetProperty( | |
3693 exports_container, | |
3694 factory()->InternalizeUtf8String("ToLocaleLowerCaseI18N")) | |
3695 .ToHandleChecked()); | |
3696 SetFunction(string_prototype, to_locale_lower_case, | |
3697 factory()->InternalizeUtf8String("toLocaleLowerCase")); | |
3698 | |
3699 Handle<JSFunction> to_locale_upper_case = Handle<JSFunction>::cast( | |
3700 JSReceiver::GetProperty( | |
3701 exports_container, | |
3702 factory()->InternalizeUtf8String("ToLocaleUpperCaseI18N")) | |
3703 .ToHandleChecked()); | |
3704 SetFunction(string_prototype, to_locale_upper_case, | |
3705 factory()->InternalizeUtf8String("toLocaleUpperCase")); | |
3706 } | |
3707 #endif | |
3708 | |
3663 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, | 3709 Handle<JSFunction> Genesis::InstallArrayBuffer(Handle<JSObject> target, |
3664 const char* name, | 3710 const char* name, |
3665 Builtins::Name call, | 3711 Builtins::Name call, |
3666 BuiltinFunctionId id) { | 3712 BuiltinFunctionId id) { |
3667 // Create the %ArrayBufferPrototype% | 3713 // Create the %ArrayBufferPrototype% |
3668 // Setup the {prototype} with the given {name} for @@toStringTag. | 3714 // Setup the {prototype} with the given {name} for @@toStringTag. |
3669 Handle<JSObject> prototype = | 3715 Handle<JSObject> prototype = |
3670 factory()->NewJSObject(isolate()->object_function(), TENURED); | 3716 factory()->NewJSObject(isolate()->object_function(), TENURED); |
3671 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), | 3717 JSObject::AddProperty(prototype, factory()->to_string_tag_symbol(), |
3672 factory()->NewStringFromAsciiChecked(name), | 3718 factory()->NewStringFromAsciiChecked(name), |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4109 "native harmony-atomics.js", NULL}; | 4155 "native harmony-atomics.js", NULL}; |
4110 static const char* harmony_simd_natives[] = {"native harmony-simd.js", | 4156 static const char* harmony_simd_natives[] = {"native harmony-simd.js", |
4111 nullptr}; | 4157 nullptr}; |
4112 static const char* harmony_do_expressions_natives[] = {nullptr}; | 4158 static const char* harmony_do_expressions_natives[] = {nullptr}; |
4113 static const char* harmony_regexp_lookbehind_natives[] = {nullptr}; | 4159 static const char* harmony_regexp_lookbehind_natives[] = {nullptr}; |
4114 static const char* harmony_regexp_named_captures_natives[] = {nullptr}; | 4160 static const char* harmony_regexp_named_captures_natives[] = {nullptr}; |
4115 static const char* harmony_regexp_property_natives[] = {nullptr}; | 4161 static const char* harmony_regexp_property_natives[] = {nullptr}; |
4116 static const char* harmony_function_sent_natives[] = {nullptr}; | 4162 static const char* harmony_function_sent_natives[] = {nullptr}; |
4117 static const char* harmony_array_prototype_values_natives[] = {nullptr}; | 4163 static const char* harmony_array_prototype_values_natives[] = {nullptr}; |
4118 #ifdef V8_I18N_SUPPORT | 4164 #ifdef V8_I18N_SUPPORT |
4119 static const char* icu_case_mapping_natives[] = {"native icu-case-mapping.js", | 4165 static const char* icu_case_mapping_natives[] = {nullptr}; |
4120 nullptr}; | 4166 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 | 4167 #endif |
4124 static const char* harmony_restrictive_generators_natives[] = {nullptr}; | 4168 static const char* harmony_restrictive_generators_natives[] = {nullptr}; |
4125 static const char* harmony_trailing_commas_natives[] = {nullptr}; | 4169 static const char* harmony_trailing_commas_natives[] = {nullptr}; |
4126 static const char* harmony_class_fields_natives[] = {nullptr}; | 4170 static const char* harmony_class_fields_natives[] = {nullptr}; |
4127 static const char* harmony_object_rest_spread_natives[] = {nullptr}; | 4171 static const char* harmony_object_rest_spread_natives[] = {nullptr}; |
4128 static const char* harmony_async_iteration_natives[] = {nullptr}; | 4172 static const char* harmony_async_iteration_natives[] = {nullptr}; |
4129 static const char* harmony_dynamic_import_natives[] = {nullptr}; | 4173 static const char* harmony_dynamic_import_natives[] = {nullptr}; |
4130 | 4174 |
4131 for (int i = ExperimentalNatives::GetDebuggerCount(); | 4175 for (int i = ExperimentalNatives::GetDebuggerCount(); |
4132 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 4176 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
4133 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ | 4177 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ |
4134 if (FLAG_##id) { \ | 4178 if (FLAG_##id) { \ |
4135 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 4179 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
4136 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 4180 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
4137 if (strncmp(script_name.start(), id##_natives[j], \ | 4181 if (strncmp(script_name.start(), id##_natives[j], \ |
4138 script_name.length()) == 0) { \ | 4182 script_name.length()) == 0) { \ |
4139 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \ | 4183 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \ |
4140 return false; \ | 4184 return false; \ |
4141 } \ | 4185 } \ |
4142 } \ | 4186 } \ |
4143 } \ | 4187 } \ |
4144 } | 4188 } |
4145 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); | 4189 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); |
4146 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); | 4190 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); |
4147 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); | 4191 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); |
Yang
2017/02/15 12:40:15
Can we remove HARMONY_SHIPPING from here, so that
Dan Ehrenberg
2017/02/15 16:43:27
IMO we should be developing patches behind a flag
| |
4148 #undef INSTALL_EXPERIMENTAL_NATIVES | 4192 #undef INSTALL_EXPERIMENTAL_NATIVES |
4149 } | 4193 } |
4150 | 4194 |
4151 if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false; | 4195 if (!CallUtilsFunction(isolate(), "PostExperimentals")) return false; |
4152 | 4196 |
4153 InstallExperimentalBuiltinFunctionIds(); | 4197 InstallExperimentalBuiltinFunctionIds(); |
4154 return true; | 4198 return true; |
4155 } | 4199 } |
4156 | 4200 |
4157 | 4201 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4237 ATOMIC_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; | 4281 ATOMIC_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; |
4238 | 4282 |
4239 for (const BuiltinFunctionIds& builtin : atomic_builtins) { | 4283 for (const BuiltinFunctionIds& builtin : atomic_builtins) { |
4240 Handle<JSObject> holder = | 4284 Handle<JSObject> holder = |
4241 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); | 4285 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); |
4242 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); | 4286 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); |
4243 } | 4287 } |
4244 } | 4288 } |
4245 } | 4289 } |
4246 | 4290 |
4247 | |
4248 #undef INSTALL_BUILTIN_ID | 4291 #undef INSTALL_BUILTIN_ID |
4249 | 4292 |
4250 | 4293 |
4251 void Genesis::InitializeNormalizedMapCaches() { | 4294 void Genesis::InitializeNormalizedMapCaches() { |
4252 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate()); | 4295 Handle<NormalizedMapCache> cache = NormalizedMapCache::New(isolate()); |
4253 native_context()->set_normalized_map_cache(*cache); | 4296 native_context()->set_normalized_map_cache(*cache); |
4254 } | 4297 } |
4255 | 4298 |
4256 | 4299 |
4257 bool Bootstrapper::InstallExtensions(Handle<Context> native_context, | 4300 bool Bootstrapper::InstallExtensions(Handle<Context> native_context, |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4875 } | 4918 } |
4876 | 4919 |
4877 | 4920 |
4878 // Called when the top-level V8 mutex is destroyed. | 4921 // Called when the top-level V8 mutex is destroyed. |
4879 void Bootstrapper::FreeThreadResources() { | 4922 void Bootstrapper::FreeThreadResources() { |
4880 DCHECK(!IsActive()); | 4923 DCHECK(!IsActive()); |
4881 } | 4924 } |
4882 | 4925 |
4883 } // namespace internal | 4926 } // namespace internal |
4884 } // namespace v8 | 4927 } // namespace v8 |
OLD | NEW |