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/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2150 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) | 2150 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) |
2151 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) | 2151 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) |
2152 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) | 2152 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) |
2153 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) | 2153 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) |
2154 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function) | 2154 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function) |
2155 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let) | 2155 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let) |
2156 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) | 2156 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) |
2157 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_default_parameters) | 2157 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_default_parameters) |
2158 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring) | 2158 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring) |
2159 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_observe) | 2159 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_observe) |
2160 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_concat_spreadable) | |
2161 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexps) | 2160 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexps) |
2162 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps) | 2161 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps) |
2163 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) | |
2164 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_completion) | 2162 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_completion) |
2165 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tolength) | 2163 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tolength) |
2166 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) | 2164 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) |
2167 | 2165 |
2168 | 2166 |
2169 static void SimpleInstallFunction(Handle<JSObject>& base, const char* name, | 2167 static void SimpleInstallFunction(Handle<JSObject>& base, const char* name, |
2170 Builtins::Name call, int len, bool adapt) { | 2168 Builtins::Name call, int len, bool adapt) { |
2171 Handle<JSFunction> fun = | 2169 Handle<JSFunction> fun = |
2172 InstallFunction(base, name, JS_OBJECT_TYPE, JSObject::kHeaderSize, | 2170 InstallFunction(base, name, JS_OBJECT_TYPE, JSObject::kHeaderSize, |
2173 MaybeHandle<JSObject>(), call); | 2171 MaybeHandle<JSObject>(), call); |
2174 if (adapt) { | 2172 if (adapt) { |
2175 fun->shared()->set_internal_formal_parameter_count(len); | 2173 fun->shared()->set_internal_formal_parameter_count(len); |
2176 } else { | 2174 } else { |
2177 fun->shared()->DontAdaptArguments(); | 2175 fun->shared()->DontAdaptArguments(); |
2178 } | 2176 } |
2179 fun->shared()->set_length(len); | 2177 fun->shared()->set_length(len); |
2180 } | 2178 } |
2181 | 2179 |
2182 | 2180 |
| 2181 void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, |
| 2182 const char* name, Handle<Symbol> value) { |
| 2183 Handle<JSGlobalObject> global( |
| 2184 JSGlobalObject::cast(native_context->global_object())); |
| 2185 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); |
| 2186 Handle<JSObject> symbol = Handle<JSObject>::cast( |
| 2187 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); |
| 2188 Handle<String> name_string = factory->InternalizeUtf8String(name); |
| 2189 PropertyAttributes attributes = |
| 2190 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 2191 JSObject::AddProperty(symbol, name_string, value, attributes); |
| 2192 } |
| 2193 |
| 2194 |
| 2195 void Genesis::InitializeGlobal_harmony_tostring() { |
| 2196 if (!FLAG_harmony_tostring) return; |
| 2197 InstallPublicSymbol(factory(), native_context(), "toStringTag", |
| 2198 factory()->to_string_tag_symbol()); |
| 2199 } |
| 2200 |
| 2201 |
| 2202 void Genesis::InitializeGlobal_harmony_concat_spreadable() { |
| 2203 if (!FLAG_harmony_concat_spreadable) return; |
| 2204 InstallPublicSymbol(factory(), native_context(), "isConcatSpreadable", |
| 2205 factory()->is_concat_spreadable_symbol()); |
| 2206 } |
| 2207 |
| 2208 |
| 2209 void Genesis::InitializeGlobal_harmony_regexp_subclass() { |
| 2210 if (!FLAG_harmony_regexp_subclass) return; |
| 2211 InstallPublicSymbol(factory(), native_context(), "match", |
| 2212 factory()->match_symbol()); |
| 2213 InstallPublicSymbol(factory(), native_context(), "replace", |
| 2214 factory()->replace_symbol()); |
| 2215 InstallPublicSymbol(factory(), native_context(), "search", |
| 2216 factory()->search_symbol()); |
| 2217 InstallPublicSymbol(factory(), native_context(), "split", |
| 2218 factory()->split_symbol()); |
| 2219 } |
| 2220 |
| 2221 |
2183 void Genesis::InitializeGlobal_harmony_reflect() { | 2222 void Genesis::InitializeGlobal_harmony_reflect() { |
2184 if (!FLAG_harmony_reflect) return; | 2223 if (!FLAG_harmony_reflect) return; |
2185 | 2224 |
2186 Handle<JSGlobalObject> global(JSGlobalObject::cast( | 2225 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
2187 native_context()->global_object())); | 2226 native_context()->global_object())); |
2188 Handle<String> reflect_string = | 2227 Handle<String> reflect_string = |
2189 factory()->NewStringFromStaticChars("Reflect"); | 2228 factory()->NewStringFromStaticChars("Reflect"); |
2190 Handle<JSObject> reflect = | 2229 Handle<JSObject> reflect = |
2191 factory()->NewJSObject(isolate()->object_function(), TENURED); | 2230 factory()->NewJSObject(isolate()->object_function(), TENURED); |
2192 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM); | 2231 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2609 } | 2648 } |
2610 | 2649 |
2611 | 2650 |
2612 bool Genesis::InstallExperimentalNatives() { | 2651 bool Genesis::InstallExperimentalNatives() { |
2613 static const char* harmony_array_includes_natives[] = { | 2652 static const char* harmony_array_includes_natives[] = { |
2614 "native harmony-array-includes.js", nullptr}; | 2653 "native harmony-array-includes.js", nullptr}; |
2615 static const char* harmony_proxies_natives[] = {"native proxy.js", nullptr}; | 2654 static const char* harmony_proxies_natives[] = {"native proxy.js", nullptr}; |
2616 static const char* harmony_modules_natives[] = {nullptr}; | 2655 static const char* harmony_modules_natives[] = {nullptr}; |
2617 static const char* harmony_regexps_natives[] = {"native harmony-regexp.js", | 2656 static const char* harmony_regexps_natives[] = {"native harmony-regexp.js", |
2618 nullptr}; | 2657 nullptr}; |
2619 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", | 2658 static const char* harmony_tostring_natives[] = {nullptr}; |
2620 nullptr}; | |
2621 static const char* harmony_sloppy_natives[] = {nullptr}; | 2659 static const char* harmony_sloppy_natives[] = {nullptr}; |
2622 static const char* harmony_sloppy_function_natives[] = {nullptr}; | 2660 static const char* harmony_sloppy_function_natives[] = {nullptr}; |
2623 static const char* harmony_sloppy_let_natives[] = {nullptr}; | 2661 static const char* harmony_sloppy_let_natives[] = {nullptr}; |
2624 static const char* harmony_unicode_regexps_natives[] = {nullptr}; | 2662 static const char* harmony_unicode_regexps_natives[] = {nullptr}; |
2625 static const char* harmony_rest_parameters_natives[] = {nullptr}; | 2663 static const char* harmony_rest_parameters_natives[] = {nullptr}; |
2626 static const char* harmony_default_parameters_natives[] = {nullptr}; | 2664 static const char* harmony_default_parameters_natives[] = {nullptr}; |
2627 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", | 2665 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", |
2628 nullptr}; | 2666 nullptr}; |
2629 static const char* harmony_destructuring_natives[] = {nullptr}; | 2667 static const char* harmony_destructuring_natives[] = {nullptr}; |
2630 static const char* harmony_object_observe_natives[] = { | 2668 static const char* harmony_object_observe_natives[] = { |
2631 "native harmony-object-observe.js", nullptr}; | 2669 "native harmony-object-observe.js", nullptr}; |
2632 static const char* harmony_sharedarraybuffer_natives[] = { | 2670 static const char* harmony_sharedarraybuffer_natives[] = { |
2633 "native harmony-sharedarraybuffer.js", "native harmony-atomics.js", NULL}; | 2671 "native harmony-sharedarraybuffer.js", "native harmony-atomics.js", NULL}; |
2634 static const char* harmony_concat_spreadable_natives[] = { | 2672 static const char* harmony_concat_spreadable_natives[] = {nullptr}; |
2635 "native harmony-concat-spreadable.js", nullptr}; | |
2636 static const char* harmony_simd_natives[] = {"native harmony-simd.js", | 2673 static const char* harmony_simd_natives[] = {"native harmony-simd.js", |
2637 nullptr}; | 2674 nullptr}; |
2638 static const char* harmony_tolength_natives[] = {nullptr}; | 2675 static const char* harmony_tolength_natives[] = {nullptr}; |
2639 static const char* harmony_completion_natives[] = {nullptr}; | 2676 static const char* harmony_completion_natives[] = {nullptr}; |
2640 static const char* harmony_do_expressions_natives[] = {nullptr}; | 2677 static const char* harmony_do_expressions_natives[] = {nullptr}; |
| 2678 static const char* harmony_regexp_subclass_natives[] = {nullptr}; |
2641 | 2679 |
2642 for (int i = ExperimentalNatives::GetDebuggerCount(); | 2680 for (int i = ExperimentalNatives::GetDebuggerCount(); |
2643 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 2681 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
2644 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ | 2682 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ |
2645 if (FLAG_##id) { \ | 2683 if (FLAG_##id) { \ |
2646 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 2684 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
2647 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 2685 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
2648 if (strncmp(script_name.start(), id##_natives[j], \ | 2686 if (strncmp(script_name.start(), id##_natives[j], \ |
2649 script_name.length()) == 0) { \ | 2687 script_name.length()) == 0) { \ |
2650 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \ | 2688 if (!Bootstrapper::CompileExperimentalBuiltin(isolate(), i)) { \ |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3320 } | 3358 } |
3321 | 3359 |
3322 | 3360 |
3323 // Called when the top-level V8 mutex is destroyed. | 3361 // Called when the top-level V8 mutex is destroyed. |
3324 void Bootstrapper::FreeThreadResources() { | 3362 void Bootstrapper::FreeThreadResources() { |
3325 DCHECK(!IsActive()); | 3363 DCHECK(!IsActive()); |
3326 } | 3364 } |
3327 | 3365 |
3328 } // namespace internal | 3366 } // namespace internal |
3329 } // namespace v8 | 3367 } // namespace v8 |
OLD | NEW |