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 2653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2664 HandleScope scope(isolate); | 2664 HandleScope scope(isolate); |
2665 | 2665 |
2666 #define INITIALIZE_FLAG(FLAG) \ | 2666 #define INITIALIZE_FLAG(FLAG) \ |
2667 { \ | 2667 { \ |
2668 Handle<String> name = \ | 2668 Handle<String> name = \ |
2669 isolate->factory()->NewStringFromAsciiChecked(#FLAG); \ | 2669 isolate->factory()->NewStringFromAsciiChecked(#FLAG); \ |
2670 JSObject::AddProperty(container, name, \ | 2670 JSObject::AddProperty(container, name, \ |
2671 isolate->factory()->ToBoolean(FLAG), NONE); \ | 2671 isolate->factory()->ToBoolean(FLAG), NONE); \ |
2672 } | 2672 } |
2673 | 2673 |
2674 INITIALIZE_FLAG(FLAG_harmony_species) | |
2675 INITIALIZE_FLAG(FLAG_intl_extra) | 2674 INITIALIZE_FLAG(FLAG_intl_extra) |
2676 | 2675 |
2677 #undef INITIALIZE_FLAG | 2676 #undef INITIALIZE_FLAG |
2678 } | 2677 } |
2679 | 2678 |
2680 | 2679 |
2681 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ | 2680 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ |
2682 void Genesis::InitializeGlobal_##id() {} | 2681 void Genesis::InitializeGlobal_##id() {} |
2683 | 2682 |
2684 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps) | |
2685 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) | 2683 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) |
2686 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_for_in) | 2684 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_for_in) |
2687 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_iterator_close) | |
2688 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_exec) | |
2689 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) | 2685 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) |
2690 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) | 2686 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures) |
2691 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) | 2687 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property) |
2692 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_name) | |
2693 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent) | 2688 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent) |
2694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(promise_extra) | 2689 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(promise_extra) |
2695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(intl_extra) | 2690 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(intl_extra) |
2696 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_explicit_tailcalls) | 2691 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_explicit_tailcalls) |
2697 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls) | 2692 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls) |
2698 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_instanceof) | |
2699 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_declarations) | 2693 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_declarations) |
2700 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_exponentiation_operator) | 2694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_exponentiation_operator) |
2701 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_string_padding) | 2695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_string_padding) |
2702 #ifdef V8_I18N_SUPPORT | 2696 #ifdef V8_I18N_SUPPORT |
2703 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(icu_case_mapping) | 2697 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(icu_case_mapping) |
2704 #endif | 2698 #endif |
2705 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_async_await) | 2699 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_async_await) |
2706 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators) | 2700 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators) |
2707 | 2701 |
2708 void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, | 2702 void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, |
2709 const char* name, Handle<Symbol> value) { | 2703 const char* name, Handle<Symbol> value) { |
2710 Handle<JSGlobalObject> global( | 2704 Handle<JSGlobalObject> global( |
2711 JSGlobalObject::cast(native_context->global_object())); | 2705 JSGlobalObject::cast(native_context->global_object())); |
2712 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); | 2706 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); |
2713 Handle<JSObject> symbol = Handle<JSObject>::cast( | 2707 Handle<JSObject> symbol = Handle<JSObject>::cast( |
2714 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); | 2708 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); |
2715 Handle<String> name_string = factory->InternalizeUtf8String(name); | 2709 Handle<String> name_string = factory->InternalizeUtf8String(name); |
2716 PropertyAttributes attributes = | 2710 PropertyAttributes attributes = |
2717 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 2711 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
2718 JSObject::AddProperty(symbol, name_string, value, attributes); | 2712 JSObject::AddProperty(symbol, name_string, value, attributes); |
2719 } | 2713 } |
2720 | 2714 |
2721 | 2715 |
2722 void Genesis::InitializeGlobal_harmony_regexp_subclass() { | |
2723 if (!FLAG_harmony_regexp_subclass) return; | |
2724 InstallPublicSymbol(factory(), native_context(), "match", | |
2725 factory()->match_symbol()); | |
2726 InstallPublicSymbol(factory(), native_context(), "replace", | |
2727 factory()->replace_symbol()); | |
2728 InstallPublicSymbol(factory(), native_context(), "search", | |
2729 factory()->search_symbol()); | |
2730 InstallPublicSymbol(factory(), native_context(), "split", | |
2731 factory()->split_symbol()); | |
2732 } | |
2733 | |
2734 | |
2735 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 2716 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
2736 if (!FLAG_harmony_sharedarraybuffer) return; | 2717 if (!FLAG_harmony_sharedarraybuffer) return; |
2737 | 2718 |
2738 Handle<JSGlobalObject> global(native_context()->global_object()); | 2719 Handle<JSGlobalObject> global(native_context()->global_object()); |
2739 Isolate* isolate = global->GetIsolate(); | 2720 Isolate* isolate = global->GetIsolate(); |
2740 Factory* factory = isolate->factory(); | 2721 Factory* factory = isolate->factory(); |
2741 | 2722 |
2742 Handle<JSFunction> shared_array_buffer_fun = | 2723 Handle<JSFunction> shared_array_buffer_fun = |
2743 InstallArrayBuffer(global, "SharedArrayBuffer"); | 2724 InstallArrayBuffer(global, "SharedArrayBuffer"); |
2744 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); | 2725 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2863 JSObject::AddProperty(prototype, factory()->constructor_string(), | 2844 JSObject::AddProperty(prototype, factory()->constructor_string(), |
2864 array_buffer_fun, DONT_ENUM); | 2845 array_buffer_fun, DONT_ENUM); |
2865 | 2846 |
2866 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), | 2847 SimpleInstallFunction(array_buffer_fun, factory()->isView_string(), |
2867 Builtins::kArrayBufferIsView, 1, true); | 2848 Builtins::kArrayBufferIsView, 1, true); |
2868 | 2849 |
2869 return array_buffer_fun; | 2850 return array_buffer_fun; |
2870 } | 2851 } |
2871 | 2852 |
2872 | 2853 |
2873 void Genesis::InitializeGlobal_harmony_species() { | |
2874 if (!FLAG_harmony_species) return; | |
2875 InstallPublicSymbol(factory(), native_context(), "species", | |
2876 factory()->species_symbol()); | |
2877 } | |
2878 | |
2879 | |
2880 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 2854 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
2881 const char* name, | 2855 const char* name, |
2882 ElementsKind elements_kind) { | 2856 ElementsKind elements_kind) { |
2883 // --- I n t e r n a l A r r a y --- | 2857 // --- I n t e r n a l A r r a y --- |
2884 // An array constructor on the builtins object that works like | 2858 // An array constructor on the builtins object that works like |
2885 // the public Array constructor, except that its prototype | 2859 // the public Array constructor, except that its prototype |
2886 // doesn't inherit from Object.prototype. | 2860 // doesn't inherit from Object.prototype. |
2887 // To be used only for internal work by builtins. Instances | 2861 // To be used only for internal work by builtins. Instances |
2888 // must not be leaked to user code. | 2862 // must not be leaked to user code. |
2889 Handle<JSObject> prototype = | 2863 Handle<JSObject> prototype = |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3268 Map::EnsureDescriptorSlack(map, 1); | 3242 Map::EnsureDescriptorSlack(map, 1); |
3269 map->AppendDescriptor(&d); | 3243 map->AppendDescriptor(&d); |
3270 } | 3244 } |
3271 } | 3245 } |
3272 | 3246 |
3273 return true; | 3247 return true; |
3274 } | 3248 } |
3275 | 3249 |
3276 | 3250 |
3277 bool Genesis::InstallExperimentalNatives() { | 3251 bool Genesis::InstallExperimentalNatives() { |
3278 static const char* harmony_iterator_close_natives[] = {nullptr}; | |
3279 static const char* harmony_species_natives[] = {"native harmony-species.js", | |
3280 nullptr}; | |
3281 static const char* harmony_explicit_tailcalls_natives[] = {nullptr}; | 3252 static const char* harmony_explicit_tailcalls_natives[] = {nullptr}; |
3282 static const char* harmony_tailcalls_natives[] = {nullptr}; | 3253 static const char* harmony_tailcalls_natives[] = {nullptr}; |
3283 static const char* harmony_unicode_regexps_natives[] = { | |
3284 "native harmony-unicode-regexps.js", nullptr}; | |
3285 static const char* harmony_sharedarraybuffer_natives[] = { | 3254 static const char* harmony_sharedarraybuffer_natives[] = { |
3286 "native harmony-sharedarraybuffer.js", "native harmony-atomics.js", NULL}; | 3255 "native harmony-sharedarraybuffer.js", "native harmony-atomics.js", NULL}; |
3287 static const char* harmony_simd_natives[] = {"native harmony-simd.js", | 3256 static const char* harmony_simd_natives[] = {"native harmony-simd.js", |
3288 nullptr}; | 3257 nullptr}; |
3289 static const char* harmony_do_expressions_natives[] = {nullptr}; | 3258 static const char* harmony_do_expressions_natives[] = {nullptr}; |
3290 static const char* harmony_for_in_natives[] = {nullptr}; | 3259 static const char* harmony_for_in_natives[] = {nullptr}; |
3291 static const char* harmony_regexp_exec_natives[] = { | |
3292 "native harmony-regexp-exec.js", nullptr}; | |
3293 static const char* harmony_regexp_subclass_natives[] = {nullptr}; | |
3294 static const char* harmony_regexp_lookbehind_natives[] = {nullptr}; | 3260 static const char* harmony_regexp_lookbehind_natives[] = {nullptr}; |
3295 static const char* harmony_instanceof_natives[] = {nullptr}; | |
3296 static const char* harmony_restrictive_declarations_natives[] = {nullptr}; | 3261 static const char* harmony_restrictive_declarations_natives[] = {nullptr}; |
3297 static const char* harmony_regexp_named_captures_natives[] = {nullptr}; | 3262 static const char* harmony_regexp_named_captures_natives[] = {nullptr}; |
3298 static const char* harmony_regexp_property_natives[] = {nullptr}; | 3263 static const char* harmony_regexp_property_natives[] = {nullptr}; |
3299 static const char* harmony_function_name_natives[] = {nullptr}; | |
3300 static const char* harmony_function_sent_natives[] = {nullptr}; | 3264 static const char* harmony_function_sent_natives[] = {nullptr}; |
3301 static const char* promise_extra_natives[] = {"native promise-extra.js", | 3265 static const char* promise_extra_natives[] = {"native promise-extra.js", |
3302 nullptr}; | 3266 nullptr}; |
3303 static const char* intl_extra_natives[] = {"native intl-extra.js", nullptr}; | 3267 static const char* intl_extra_natives[] = {"native intl-extra.js", nullptr}; |
3304 static const char* harmony_object_values_entries_natives[] = {nullptr}; | 3268 static const char* harmony_object_values_entries_natives[] = {nullptr}; |
3305 static const char* harmony_object_own_property_descriptors_natives[] = { | 3269 static const char* harmony_object_own_property_descriptors_natives[] = { |
3306 nullptr}; | 3270 nullptr}; |
3307 static const char* harmony_array_prototype_values_natives[] = {nullptr}; | 3271 static const char* harmony_array_prototype_values_natives[] = {nullptr}; |
3308 static const char* harmony_exponentiation_operator_natives[] = {nullptr}; | 3272 static const char* harmony_exponentiation_operator_natives[] = {nullptr}; |
3309 static const char* harmony_string_padding_natives[] = { | 3273 static const char* harmony_string_padding_natives[] = { |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3987 } | 3951 } |
3988 | 3952 |
3989 | 3953 |
3990 // Called when the top-level V8 mutex is destroyed. | 3954 // Called when the top-level V8 mutex is destroyed. |
3991 void Bootstrapper::FreeThreadResources() { | 3955 void Bootstrapper::FreeThreadResources() { |
3992 DCHECK(!IsActive()); | 3956 DCHECK(!IsActive()); |
3993 } | 3957 } |
3994 | 3958 |
3995 } // namespace internal | 3959 } // namespace internal |
3996 } // namespace v8 | 3960 } // namespace v8 |
OLD | NEW |