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/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) | 1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) |
1662 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) | 1662 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) |
1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_numeric_literals) | 1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_numeric_literals) |
1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) | 1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) |
1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates) | 1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_templates) |
1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) | 1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) |
1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) | 1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) |
1668 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) | 1668 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) |
1669 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) | 1669 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) |
1670 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) | 1670 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) |
| 1671 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) |
1671 | 1672 |
1672 | 1673 |
1673 void Genesis::InstallNativeFunctions_harmony_proxies() { | 1674 void Genesis::InstallNativeFunctions_harmony_proxies() { |
1674 if (FLAG_harmony_proxies) { | 1675 if (FLAG_harmony_proxies) { |
1675 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); | 1676 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); |
1676 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); | 1677 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); |
1677 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); | 1678 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); |
1678 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); | 1679 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); |
1679 } | 1680 } |
1680 } | 1681 } |
(...skipping 12 matching lines...) Expand all Loading... |
1693 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) | 1694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) |
1694 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) | 1695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) |
1695 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_numeric_literals) | 1696 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_numeric_literals) |
1696 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) | 1697 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tostring) |
1697 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) | 1698 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) |
1698 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates) | 1699 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_templates) |
1699 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) | 1700 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) |
1700 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) | 1701 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) |
1701 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) | 1702 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) |
1702 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) | 1703 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) |
| 1704 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_reflect) |
1703 | 1705 |
1704 void Genesis::InitializeGlobal_harmony_regexps() { | 1706 void Genesis::InitializeGlobal_harmony_regexps() { |
1705 Handle<JSObject> builtins(native_context()->builtins()); | 1707 Handle<JSObject> builtins(native_context()->builtins()); |
1706 | 1708 |
1707 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() | 1709 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() |
1708 : heap()->false_value()); | 1710 : heap()->false_value()); |
1709 PropertyAttributes attributes = | 1711 PropertyAttributes attributes = |
1710 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); | 1712 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); |
1711 Runtime::DefineObjectProperty(builtins, factory()->harmony_regexps_string(), | 1713 Runtime::DefineObjectProperty(builtins, factory()->harmony_regexps_string(), |
1712 flag, attributes).Assert(); | 1714 flag, attributes).Assert(); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2083 native_context()->set_strong_generator_function_map( | 2085 native_context()->set_strong_generator_function_map( |
2084 *strong_generator_function_map); | 2086 *strong_generator_function_map); |
2085 | 2087 |
2086 Handle<JSFunction> object_function(native_context()->object_function()); | 2088 Handle<JSFunction> object_function(native_context()->object_function()); |
2087 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); | 2089 Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0); |
2088 generator_object_prototype_map->SetPrototype(generator_object_prototype); | 2090 generator_object_prototype_map->SetPrototype(generator_object_prototype); |
2089 native_context()->set_generator_object_prototype_map( | 2091 native_context()->set_generator_object_prototype_map( |
2090 *generator_object_prototype_map); | 2092 *generator_object_prototype_map); |
2091 } | 2093 } |
2092 | 2094 |
| 2095 // Install references to functions of the Reflect object |
| 2096 { |
| 2097 Handle<JSFunction> apply = |
| 2098 InstallFunction(builtins, "ReflectApply", JS_OBJECT_TYPE, |
| 2099 JSObject::kHeaderSize, MaybeHandle<JSObject>(), |
| 2100 Builtins::kReflectApply); |
| 2101 Handle<JSFunction> construct = |
| 2102 InstallFunction(builtins, "ReflectConstruct", JS_OBJECT_TYPE, |
| 2103 JSObject::kHeaderSize, MaybeHandle<JSObject>(), |
| 2104 Builtins::kReflectConstruct); |
| 2105 if (FLAG_vector_ics) { |
| 2106 // Apply embeds an IC, so we need a type vector of size 1 in the shared |
| 2107 // function info. |
| 2108 FeedbackVectorSpec spec(0, 1); |
| 2109 spec.SetKind(0, Code::CALL_IC); |
| 2110 Handle<TypeFeedbackVector> feedback_vector = |
| 2111 factory()->NewTypeFeedbackVector(spec); |
| 2112 apply->shared()->set_feedback_vector(*feedback_vector); |
| 2113 |
| 2114 feedback_vector = factory()->NewTypeFeedbackVector(spec); |
| 2115 construct->shared()->set_feedback_vector(*feedback_vector); |
| 2116 } |
| 2117 |
| 2118 apply->shared()->set_internal_formal_parameter_count(3); |
| 2119 apply->shared()->set_length(3); |
| 2120 |
| 2121 construct->shared()->set_internal_formal_parameter_count(3); |
| 2122 construct->shared()->set_length(2); |
| 2123 } |
| 2124 |
2093 if (FLAG_disable_native_files) { | 2125 if (FLAG_disable_native_files) { |
2094 PrintF("Warning: Running without installed natives!\n"); | 2126 PrintF("Warning: Running without installed natives!\n"); |
2095 return true; | 2127 return true; |
2096 } | 2128 } |
2097 | 2129 |
2098 // Install public symbols. | 2130 // Install public symbols. |
2099 { | 2131 { |
2100 static const PropertyAttributes attributes = | 2132 static const PropertyAttributes attributes = |
2101 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 2133 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
2102 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ | 2134 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2283 static const char* harmony_numeric_literals_natives[] = {NULL}; | 2315 static const char* harmony_numeric_literals_natives[] = {NULL}; |
2284 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", | 2316 static const char* harmony_tostring_natives[] = {"native harmony-tostring.js", |
2285 NULL}; | 2317 NULL}; |
2286 static const char* harmony_templates_natives[] = { | 2318 static const char* harmony_templates_natives[] = { |
2287 "native harmony-templates.js", NULL}; | 2319 "native harmony-templates.js", NULL}; |
2288 static const char* harmony_sloppy_natives[] = {NULL}; | 2320 static const char* harmony_sloppy_natives[] = {NULL}; |
2289 static const char* harmony_unicode_natives[] = {NULL}; | 2321 static const char* harmony_unicode_natives[] = {NULL}; |
2290 static const char* harmony_unicode_regexps_natives[] = {NULL}; | 2322 static const char* harmony_unicode_regexps_natives[] = {NULL}; |
2291 static const char* harmony_computed_property_names_natives[] = {NULL}; | 2323 static const char* harmony_computed_property_names_natives[] = {NULL}; |
2292 static const char* harmony_rest_parameters_natives[] = {NULL}; | 2324 static const char* harmony_rest_parameters_natives[] = {NULL}; |
| 2325 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", |
| 2326 NULL}; |
2293 | 2327 |
2294 for (int i = ExperimentalNatives::GetDebuggerCount(); | 2328 for (int i = ExperimentalNatives::GetDebuggerCount(); |
2295 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 2329 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
2296 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ | 2330 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ |
2297 if (FLAG_##id) { \ | 2331 if (FLAG_##id) { \ |
2298 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 2332 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
2299 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 2333 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
2300 if (strncmp(script_name.start(), id##_natives[j], \ | 2334 if (strncmp(script_name.start(), id##_natives[j], \ |
2301 script_name.length()) == 0) { \ | 2335 script_name.length()) == 0) { \ |
2302 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ | 2336 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2880 InstallJSFunctionResultCaches(); | 2914 InstallJSFunctionResultCaches(); |
2881 InitializeNormalizedMapCaches(); | 2915 InitializeNormalizedMapCaches(); |
2882 if (!InstallNatives()) return; | 2916 if (!InstallNatives()) return; |
2883 | 2917 |
2884 MakeFunctionInstancePrototypeWritable(); | 2918 MakeFunctionInstancePrototypeWritable(); |
2885 | 2919 |
2886 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 2920 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
2887 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2921 isolate->counters()->contexts_created_from_scratch()->Increment(); |
2888 } | 2922 } |
2889 | 2923 |
| 2924 if (FLAG_harmony_reflect) { |
| 2925 // TODO(caitp): this should not be here, there's got to be a better way. |
| 2926 // Shouldn't InitializeExperimentalGlobal() happen before |
| 2927 // InitializeExperimentalNatives()? |
| 2928 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
| 2929 native_context()->global_object())); |
| 2930 Handle<String> reflect_string = |
| 2931 factory()->NewStringFromStaticChars("Reflect"); |
| 2932 Handle<Object> reflect = |
| 2933 factory()->NewJSObject(isolate->object_function(), TENURED); |
| 2934 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM); |
| 2935 } |
| 2936 |
2890 // Install experimental natives. Do not include them into the snapshot as we | 2937 // Install experimental natives. Do not include them into the snapshot as we |
2891 // should be able to turn them off at runtime. Re-installing them after | 2938 // should be able to turn them off at runtime. Re-installing them after |
2892 // they have already been deserialized would also fail. | 2939 // they have already been deserialized would also fail. |
2893 if (!isolate->serializer_enabled() && !InstallExperimentalNatives()) return; | 2940 if (!isolate->serializer_enabled() && !InstallExperimentalNatives()) return; |
2894 | 2941 |
2895 InitializeExperimentalGlobal(); | 2942 InitializeExperimentalGlobal(); |
2896 | 2943 |
2897 // The serializer cannot serialize typed arrays. Reset those typed arrays | 2944 // The serializer cannot serialize typed arrays. Reset those typed arrays |
2898 // for each new context. | 2945 // for each new context. |
2899 InitializeBuiltinTypedArrays(); | 2946 InitializeBuiltinTypedArrays(); |
(...skipping 24 matching lines...) Expand all Loading... |
2924 return from + sizeof(NestingCounterType); | 2971 return from + sizeof(NestingCounterType); |
2925 } | 2972 } |
2926 | 2973 |
2927 | 2974 |
2928 // Called when the top-level V8 mutex is destroyed. | 2975 // Called when the top-level V8 mutex is destroyed. |
2929 void Bootstrapper::FreeThreadResources() { | 2976 void Bootstrapper::FreeThreadResources() { |
2930 DCHECK(!IsActive()); | 2977 DCHECK(!IsActive()); |
2931 } | 2978 } |
2932 | 2979 |
2933 } } // namespace v8::internal | 2980 } } // namespace v8::internal |
OLD | NEW |