| 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/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/extensions/externalize-string-extension.h" | 9 #include "src/extensions/externalize-string-extension.h" |
| 10 #include "src/extensions/free-buffer-extension.h" | 10 #include "src/extensions/free-buffer-extension.h" |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, | 223 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, |
| 224 const char* name, | 224 const char* name, |
| 225 ElementsKind elements_kind); | 225 ElementsKind elements_kind); |
| 226 bool InstallNatives(); | 226 bool InstallNatives(); |
| 227 | 227 |
| 228 void InstallTypedArray( | 228 void InstallTypedArray( |
| 229 const char* name, | 229 const char* name, |
| 230 ElementsKind elements_kind, | 230 ElementsKind elements_kind, |
| 231 Handle<JSFunction>* fun, | 231 Handle<JSFunction>* fun, |
| 232 Handle<Map>* external_map); | 232 Handle<Map>* external_map); |
| 233 bool InstallExperimentalNatives(); | 233 bool InstallExperimentalNatives(bool include_shipping); |
| 234 void InstallBuiltinFunctionIds(); | 234 void InstallBuiltinFunctionIds(); |
| 235 void InstallJSFunctionResultCaches(); | 235 void InstallJSFunctionResultCaches(); |
| 236 void InitializeNormalizedMapCaches(); | 236 void InitializeNormalizedMapCaches(); |
| 237 | 237 |
| 238 enum ExtensionTraversalState { | 238 enum ExtensionTraversalState { |
| 239 UNVISITED, VISITED, INSTALLED | 239 UNVISITED, VISITED, INSTALLED |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 class ExtensionStates { | 242 class ExtensionStates { |
| 243 public: | 243 public: |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 // Set up the call-as-constructor delegate. | 1338 // Set up the call-as-constructor delegate. |
| 1339 Handle<Code> code = | 1339 Handle<Code> code = |
| 1340 Handle<Code>(isolate->builtins()->builtin( | 1340 Handle<Code>(isolate->builtins()->builtin( |
| 1341 Builtins::kHandleApiCallAsConstructor)); | 1341 Builtins::kHandleApiCallAsConstructor)); |
| 1342 Handle<JSFunction> delegate = factory->NewFunction( | 1342 Handle<JSFunction> delegate = factory->NewFunction( |
| 1343 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1343 factory->empty_string(), code, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 1344 native_context()->set_call_as_constructor_delegate(*delegate); | 1344 native_context()->set_call_as_constructor_delegate(*delegate); |
| 1345 delegate->shared()->DontAdaptArguments(); | 1345 delegate->shared()->DontAdaptArguments(); |
| 1346 } | 1346 } |
| 1347 | 1347 |
| 1348 #ifdef V8_ON_DEMAND_SNAPSHOT |
| 1349 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); |
| 1350 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) |
| 1351 #undef FEATURE_INITIALIZE_GLOBAL |
| 1352 #endif |
| 1353 |
| 1354 |
| 1348 // Initialize the embedder data slot. | 1355 // Initialize the embedder data slot. |
| 1349 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); | 1356 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); |
| 1350 native_context()->set_embedder_data(*embedder_data); | 1357 native_context()->set_embedder_data(*embedder_data); |
| 1351 } | 1358 } |
| 1352 | 1359 |
| 1353 | 1360 |
| 1354 void Genesis::InstallTypedArray( | 1361 void Genesis::InstallTypedArray( |
| 1355 const char* name, | 1362 const char* name, |
| 1356 ElementsKind elements_kind, | 1363 ElementsKind elements_kind, |
| 1357 Handle<JSFunction>* fun, | 1364 Handle<JSFunction>* fun, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1372 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); | 1379 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); |
| 1373 *external_map = Map::AsElementsKind(initial_map, external_kind); | 1380 *external_map = Map::AsElementsKind(initial_map, external_kind); |
| 1374 } | 1381 } |
| 1375 | 1382 |
| 1376 | 1383 |
| 1377 void Genesis::InitializeExperimentalGlobal() { | 1384 void Genesis::InitializeExperimentalGlobal() { |
| 1378 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); | 1385 #define FEATURE_INITIALIZE_GLOBAL(id, descr) InitializeGlobal_##id(); |
| 1379 | 1386 |
| 1380 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) | 1387 HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL) |
| 1381 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) | 1388 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) |
| 1389 #ifndef V8_ON_DEMAND_SNAPSHOT |
| 1382 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) | 1390 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) |
| 1391 #endif |
| 1383 #undef FEATURE_INITIALIZE_GLOBAL | 1392 #undef FEATURE_INITIALIZE_GLOBAL |
| 1384 } | 1393 } |
| 1385 | 1394 |
| 1386 | 1395 |
| 1387 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1396 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
| 1388 Vector<const char> name = Natives::GetScriptName(index); | 1397 Vector<const char> name = Natives::GetScriptName(index); |
| 1398 printf("CompileBuiltin:%*s\n", name.length(), name.start()); |
| 1389 Handle<String> source_code = | 1399 Handle<String> source_code = |
| 1390 isolate->bootstrapper()->NativesSourceLookup(index); | 1400 isolate->bootstrapper()->NativesSourceLookup(index); |
| 1391 return CompileNative(isolate, name, source_code); | 1401 return CompileNative(isolate, name, source_code); |
| 1392 } | 1402 } |
| 1393 | 1403 |
| 1394 | 1404 |
| 1395 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { | 1405 bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) { |
| 1396 Vector<const char> name = ExperimentalNatives::GetScriptName(index); | 1406 Vector<const char> name = ExperimentalNatives::GetScriptName(index); |
| 1407 printf("CompileExperimentalBuiltin:%*s\n", name.length(), name.start()); |
| 1397 Factory* factory = isolate->factory(); | 1408 Factory* factory = isolate->factory(); |
| 1398 Handle<String> source_code; | 1409 Handle<String> source_code; |
| 1399 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 1410 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 1400 isolate, source_code, | 1411 isolate, source_code, |
| 1401 factory->NewStringFromAscii(ExperimentalNatives::GetScriptSource(index)), | 1412 factory->NewStringFromAscii(ExperimentalNatives::GetScriptSource(index)), |
| 1402 false); | 1413 false); |
| 1403 return CompileNative(isolate, name, source_code); | 1414 return CompileNative(isolate, name, source_code); |
| 1404 } | 1415 } |
| 1405 | 1416 |
| 1406 | 1417 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 observers_begin_perform_splice); | 1564 observers_begin_perform_splice); |
| 1554 INSTALL_NATIVE(JSFunction, "EndPerformSplice", | 1565 INSTALL_NATIVE(JSFunction, "EndPerformSplice", |
| 1555 observers_end_perform_splice); | 1566 observers_end_perform_splice); |
| 1556 INSTALL_NATIVE(JSFunction, "NativeObjectObserve", | 1567 INSTALL_NATIVE(JSFunction, "NativeObjectObserve", |
| 1557 native_object_observe); | 1568 native_object_observe); |
| 1558 INSTALL_NATIVE(JSFunction, "NativeObjectGetNotifier", | 1569 INSTALL_NATIVE(JSFunction, "NativeObjectGetNotifier", |
| 1559 native_object_get_notifier); | 1570 native_object_get_notifier); |
| 1560 INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange", | 1571 INSTALL_NATIVE(JSFunction, "NativeObjectNotifierPerformChange", |
| 1561 native_object_notifier_perform_change); | 1572 native_object_notifier_perform_change); |
| 1562 INSTALL_NATIVE(JSFunction, "ArrayValues", array_values_iterator); | 1573 INSTALL_NATIVE(JSFunction, "ArrayValues", array_values_iterator); |
| 1574 |
| 1575 |
| 1576 #ifdef V8_ON_DEMAND_SNAPSHOT |
| 1577 #define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) InstallNativeFunctions_##id(); |
| 1578 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR) |
| 1579 #undef INSTALL_NATIVE_FUNCTIONS_FOR |
| 1580 #endif // V8_ON_DEMAND_SNAPSHOT |
| 1563 } | 1581 } |
| 1564 | 1582 |
| 1565 | 1583 |
| 1566 void Genesis::InstallExperimentalNativeFunctions() { | 1584 void Genesis::InstallExperimentalNativeFunctions() { |
| 1567 if (FLAG_harmony_proxies) { | 1585 if (FLAG_harmony_proxies) { |
| 1568 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); | 1586 INSTALL_NATIVE(JSFunction, "DerivedHasTrap", derived_has_trap); |
| 1569 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); | 1587 INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap); |
| 1570 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); | 1588 INSTALL_NATIVE(JSFunction, "DerivedSetTrap", derived_set_trap); |
| 1571 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); | 1589 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); |
| 1572 } | 1590 } |
| 1573 | 1591 |
| 1574 #define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) InstallNativeFunctions_##id(); | 1592 #define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) InstallNativeFunctions_##id(); |
| 1575 HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR) | 1593 HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR) |
| 1576 HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR) | 1594 HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR) |
| 1595 #ifndef V8_ON_DEMAND_SNAPSHOT |
| 1577 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR) | 1596 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR) |
| 1597 #endif |
| 1578 #undef INSTALL_NATIVE_FUNCTIONS_FOR | 1598 #undef INSTALL_NATIVE_FUNCTIONS_FOR |
| 1579 } | 1599 } |
| 1580 | 1600 |
| 1581 | 1601 |
| 1582 #define EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(id) \ | 1602 #define EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(id) \ |
| 1583 void Genesis::InstallNativeFunctions_##id() {} | 1603 void Genesis::InstallNativeFunctions_##id() {} |
| 1584 | 1604 |
| 1585 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_scoping) | 1605 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_scoping) |
| 1586 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_modules) | 1606 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_modules) |
| 1587 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_strings) | 1607 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_strings) |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 // Install natives. | 2022 // Install natives. |
| 2003 for (int i = Natives::GetDebuggerCount(); | 2023 for (int i = Natives::GetDebuggerCount(); |
| 2004 i < Natives::GetBuiltinsCount(); | 2024 i < Natives::GetBuiltinsCount(); |
| 2005 i++) { | 2025 i++) { |
| 2006 if (!CompileBuiltin(isolate(), i)) return false; | 2026 if (!CompileBuiltin(isolate(), i)) return false; |
| 2007 // TODO(ager): We really only need to install the JS builtin | 2027 // TODO(ager): We really only need to install the JS builtin |
| 2008 // functions on the builtins object after compiling and running | 2028 // functions on the builtins object after compiling and running |
| 2009 // runtime.js. | 2029 // runtime.js. |
| 2010 if (!InstallJSBuiltins(builtins)) return false; | 2030 if (!InstallJSBuiltins(builtins)) return false; |
| 2011 } | 2031 } |
| 2012 | 2032 #if V8_ON_DEMAND_SNAPSHOT |
| 2033 InstallExperimentalNatives(true); |
| 2034 #endif // V8_ON_DEMAND_SNAPSHOT |
| 2035 |
| 2013 InstallNativeFunctions(); | 2036 InstallNativeFunctions(); |
| 2014 | 2037 |
| 2015 // Store the map for the string prototype after the natives has been compiled | 2038 // Store the map for the string prototype after the natives has been compiled |
| 2016 // and the String function has been set up. | 2039 // and the String function has been set up. |
| 2017 Handle<JSFunction> string_function(native_context()->string_function()); | 2040 Handle<JSFunction> string_function(native_context()->string_function()); |
| 2018 DCHECK(JSObject::cast( | 2041 DCHECK(JSObject::cast( |
| 2019 string_function->initial_map()->prototype())->HasFastProperties()); | 2042 string_function->initial_map()->prototype())->HasFastProperties()); |
| 2020 native_context()->set_string_function_prototype_map( | 2043 native_context()->set_string_function_prototype_map( |
| 2021 HeapObject::cast(string_function->initial_map()->prototype())->map()); | 2044 HeapObject::cast(string_function->initial_map()->prototype())->map()); |
| 2022 | 2045 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 } | 2173 } |
| 2151 | 2174 |
| 2152 #ifdef VERIFY_HEAP | 2175 #ifdef VERIFY_HEAP |
| 2153 builtins->ObjectVerify(); | 2176 builtins->ObjectVerify(); |
| 2154 #endif | 2177 #endif |
| 2155 | 2178 |
| 2156 return true; | 2179 return true; |
| 2157 } | 2180 } |
| 2158 | 2181 |
| 2159 | 2182 |
| 2160 bool Genesis::InstallExperimentalNatives() { | 2183 bool Genesis::InstallExperimentalNatives(bool include_shipping) { |
| 2161 static const char* harmony_arrays_natives[] = { | 2184 static const char* harmony_arrays_natives[] = { |
| 2162 "native harmony-array.js", "native harmony-typedarray.js", NULL}; | 2185 "native harmony-array.js", "native harmony-typedarray.js", NULL}; |
| 2163 static const char* harmony_array_includes_natives[] = { | 2186 static const char* harmony_array_includes_natives[] = { |
| 2164 "native harmony-array-includes.js", NULL}; | 2187 "native harmony-array-includes.js", NULL}; |
| 2165 static const char* harmony_proxies_natives[] = {"native proxy.js", NULL}; | 2188 static const char* harmony_proxies_natives[] = {"native proxy.js", NULL}; |
| 2166 static const char* harmony_strings_natives[] = {"native harmony-string.js", | 2189 static const char* harmony_strings_natives[] = {"native harmony-string.js", |
| 2167 NULL}; | 2190 NULL}; |
| 2168 static const char* harmony_classes_natives[] = {"native harmony-classes.js", | 2191 static const char* harmony_classes_natives[] = {"native harmony-classes.js", |
| 2169 NULL}; | 2192 NULL}; |
| 2170 static const char* harmony_modules_natives[] = {NULL}; | 2193 static const char* harmony_modules_natives[] = {NULL}; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2188 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 2211 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
| 2189 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 2212 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
| 2190 if (strncmp(script_name.start(), id##_natives[j], \ | 2213 if (strncmp(script_name.start(), id##_natives[j], \ |
| 2191 script_name.length()) == 0) { \ | 2214 script_name.length()) == 0) { \ |
| 2192 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ | 2215 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ |
| 2193 } \ | 2216 } \ |
| 2194 } \ | 2217 } \ |
| 2195 } | 2218 } |
| 2196 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); | 2219 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); |
| 2197 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); | 2220 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); |
| 2221 #ifdef V8_ON_DEMAND_SNAPSHOT |
| 2222 if (include_shipping) { |
| 2223 #endif |
| 2198 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); | 2224 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); |
| 2225 |
| 2226 #ifdef V8_ON_DEMAND_SNAPSHOT |
| 2227 } |
| 2228 #endif |
| 2229 |
| 2199 #undef INSTALL_EXPERIMENTAL_NATIVES | 2230 #undef INSTALL_EXPERIMENTAL_NATIVES |
| 2200 } | 2231 } |
| 2201 | 2232 |
| 2202 InstallExperimentalNativeFunctions(); | 2233 InstallExperimentalNativeFunctions(); |
| 2203 return true; | 2234 return true; |
| 2204 } | 2235 } |
| 2205 | 2236 |
| 2206 | 2237 |
| 2207 static void InstallBuiltinFunctionId(Handle<JSObject> holder, | 2238 static void InstallBuiltinFunctionId(Handle<JSObject> holder, |
| 2208 const char* function_name, | 2239 const char* function_name, |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2753 InitializeNormalizedMapCaches(); | 2784 InitializeNormalizedMapCaches(); |
| 2754 if (!InstallNatives()) return; | 2785 if (!InstallNatives()) return; |
| 2755 | 2786 |
| 2756 MakeFunctionInstancePrototypeWritable(); | 2787 MakeFunctionInstancePrototypeWritable(); |
| 2757 | 2788 |
| 2758 if (!ConfigureGlobalObjects(global_proxy_template)) return; | 2789 if (!ConfigureGlobalObjects(global_proxy_template)) return; |
| 2759 isolate->counters()->contexts_created_from_scratch()->Increment(); | 2790 isolate->counters()->contexts_created_from_scratch()->Increment(); |
| 2760 } | 2791 } |
| 2761 | 2792 |
| 2762 // Install experimental natives. | 2793 // Install experimental natives. |
| 2763 if (!InstallExperimentalNatives()) return; | 2794 if (!InstallExperimentalNatives(false)) return; |
| 2764 InitializeExperimentalGlobal(); | 2795 InitializeExperimentalGlobal(); |
| 2765 | 2796 |
| 2766 // We can't (de-)serialize typed arrays currently, but we are lucky: The state | 2797 // We can't (de-)serialize typed arrays currently, but we are lucky: The state |
| 2767 // of the random number generator needs no initialization during snapshot | 2798 // of the random number generator needs no initialization during snapshot |
| 2768 // creation time and we don't need trigonometric functions then. | 2799 // creation time and we don't need trigonometric functions then. |
| 2769 if (!isolate->serializer_enabled()) { | 2800 if (!isolate->serializer_enabled()) { |
| 2770 // Initially seed the per-context random number generator using the | 2801 // Initially seed the per-context random number generator using the |
| 2771 // per-isolate random number generator. | 2802 // per-isolate random number generator. |
| 2772 const int num_elems = 2; | 2803 const int num_elems = 2; |
| 2773 const int num_bytes = num_elems * sizeof(uint32_t); | 2804 const int num_bytes = num_elems * sizeof(uint32_t); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2827 return from + sizeof(NestingCounterType); | 2858 return from + sizeof(NestingCounterType); |
| 2828 } | 2859 } |
| 2829 | 2860 |
| 2830 | 2861 |
| 2831 // Called when the top-level V8 mutex is destroyed. | 2862 // Called when the top-level V8 mutex is destroyed. |
| 2832 void Bootstrapper::FreeThreadResources() { | 2863 void Bootstrapper::FreeThreadResources() { |
| 2833 DCHECK(!IsActive()); | 2864 DCHECK(!IsActive()); |
| 2834 } | 2865 } |
| 2835 | 2866 |
| 2836 } } // namespace v8::internal | 2867 } } // namespace v8::internal |
| OLD | NEW |