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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 bool InstallNatives(); | 223 bool InstallNatives(); |
224 | 224 |
225 void InstallTypedArray( | 225 void InstallTypedArray( |
226 const char* name, | 226 const char* name, |
227 ElementsKind elements_kind, | 227 ElementsKind elements_kind, |
228 Handle<JSFunction>* fun, | 228 Handle<JSFunction>* fun, |
229 Handle<Map>* external_map); | 229 Handle<Map>* external_map); |
230 bool InstallExperimentalNatives(); | 230 bool InstallExperimentalNatives(); |
231 bool InstallExtraNatives(); | 231 bool InstallExtraNatives(); |
232 void InstallBuiltinFunctionIds(); | 232 void InstallBuiltinFunctionIds(); |
| 233 void InstallExperimentalBuiltinFunctionIds(); |
233 void InstallJSFunctionResultCaches(); | 234 void InstallJSFunctionResultCaches(); |
234 void InitializeNormalizedMapCaches(); | 235 void InitializeNormalizedMapCaches(); |
235 | 236 |
236 enum ExtensionTraversalState { | 237 enum ExtensionTraversalState { |
237 UNVISITED, VISITED, INSTALLED | 238 UNVISITED, VISITED, INSTALLED |
238 }; | 239 }; |
239 | 240 |
240 class ExtensionStates { | 241 class ExtensionStates { |
241 public: | 242 public: |
242 ExtensionStates(); | 243 ExtensionStates(); |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) | 1760 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) |
1760 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) | 1761 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) |
1761 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) | 1762 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) |
1762 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) | 1763 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) |
1763 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) | 1764 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) |
1764 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) | 1765 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) |
1765 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) | 1766 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) |
1766 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object) | 1767 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object) |
1767 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays) | 1768 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays) |
1768 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer) | 1769 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer) |
| 1770 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics) |
1769 | 1771 |
1770 | 1772 |
1771 void Genesis::InstallNativeFunctions_harmony_proxies() { | 1773 void Genesis::InstallNativeFunctions_harmony_proxies() { |
1772 if (FLAG_harmony_proxies) { | 1774 if (FLAG_harmony_proxies) { |
1773 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap); | 1775 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap); |
1774 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap); | 1776 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap); |
1775 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap); | 1777 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap); |
1776 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate); | 1778 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate); |
1777 } | 1779 } |
1778 } | 1780 } |
1779 | 1781 |
| 1782 |
1780 #undef INSTALL_NATIVE | 1783 #undef INSTALL_NATIVE |
1781 | 1784 |
1782 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ | 1785 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ |
1783 void Genesis::InitializeGlobal_##id() {} | 1786 void Genesis::InitializeGlobal_##id() {} |
1784 | 1787 |
1785 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) | 1788 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) |
1786 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrays) | 1789 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrays) |
1787 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) | 1790 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) |
1788 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_classes) | 1791 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_classes) |
1789 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) | 1792 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) |
1790 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) | 1793 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) |
1791 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) | 1794 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) |
1792 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) | 1795 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) |
1793 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) | 1796 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) |
1794 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) | 1797 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) |
1795 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) | 1798 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) |
1796 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spreadcalls) | 1799 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spreadcalls) |
1797 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring) | 1800 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring) |
1798 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object) | 1801 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object) |
1799 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spread_arrays) | 1802 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spread_arrays) |
| 1803 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_atomics) |
1800 | 1804 |
1801 void Genesis::InitializeGlobal_harmony_regexps() { | 1805 void Genesis::InitializeGlobal_harmony_regexps() { |
1802 Handle<JSObject> builtins(native_context()->builtins()); | 1806 Handle<JSObject> builtins(native_context()->builtins()); |
1803 | 1807 |
1804 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() | 1808 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() |
1805 : heap()->false_value()); | 1809 : heap()->false_value()); |
1806 Runtime::SetObjectProperty(isolate(), builtins, | 1810 Runtime::SetObjectProperty(isolate(), builtins, |
1807 factory()->harmony_regexps_string(), flag, | 1811 factory()->harmony_regexps_string(), flag, |
1808 STRICT).Assert(); | 1812 STRICT).Assert(); |
1809 } | 1813 } |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2434 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", | 2438 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", |
2435 nullptr}; | 2439 nullptr}; |
2436 static const char* harmony_spreadcalls_natives[] = { | 2440 static const char* harmony_spreadcalls_natives[] = { |
2437 "native harmony-spread.js", nullptr}; | 2441 "native harmony-spread.js", nullptr}; |
2438 static const char* harmony_destructuring_natives[] = {nullptr}; | 2442 static const char* harmony_destructuring_natives[] = {nullptr}; |
2439 static const char* harmony_object_natives[] = {"native harmony-object.js", | 2443 static const char* harmony_object_natives[] = {"native harmony-object.js", |
2440 NULL}; | 2444 NULL}; |
2441 static const char* harmony_spread_arrays_natives[] = {nullptr}; | 2445 static const char* harmony_spread_arrays_natives[] = {nullptr}; |
2442 static const char* harmony_sharedarraybuffer_natives[] = { | 2446 static const char* harmony_sharedarraybuffer_natives[] = { |
2443 "native harmony-sharedarraybuffer.js", NULL}; | 2447 "native harmony-sharedarraybuffer.js", NULL}; |
| 2448 static const char* harmony_atomics_natives[] = {"native harmony-atomics.js", |
| 2449 nullptr}; |
2444 | 2450 |
2445 for (int i = ExperimentalNatives::GetDebuggerCount(); | 2451 for (int i = ExperimentalNatives::GetDebuggerCount(); |
2446 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 2452 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
2447 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ | 2453 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ |
2448 if (FLAG_##id) { \ | 2454 if (FLAG_##id) { \ |
2449 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 2455 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
2450 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 2456 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
2451 if (strncmp(script_name.start(), id##_natives[j], \ | 2457 if (strncmp(script_name.start(), id##_natives[j], \ |
2452 script_name.length()) == 0) { \ | 2458 script_name.length()) == 0) { \ |
2453 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ | 2459 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ |
2454 } \ | 2460 } \ |
2455 } \ | 2461 } \ |
2456 } | 2462 } |
2457 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); | 2463 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); |
2458 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); | 2464 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); |
2459 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); | 2465 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); |
2460 #undef INSTALL_EXPERIMENTAL_NATIVES | 2466 #undef INSTALL_EXPERIMENTAL_NATIVES |
2461 } | 2467 } |
2462 | 2468 |
2463 CallUtilsFunction(isolate(), "PostExperimentals"); | 2469 CallUtilsFunction(isolate(), "PostExperimentals"); |
2464 | 2470 |
2465 InstallExperimentalNativeFunctions(); | 2471 InstallExperimentalNativeFunctions(); |
| 2472 InstallExperimentalBuiltinFunctionIds(); |
2466 return true; | 2473 return true; |
2467 } | 2474 } |
2468 | 2475 |
2469 | 2476 |
2470 bool Genesis::InstallExtraNatives() { | 2477 bool Genesis::InstallExtraNatives() { |
2471 for (int i = ExtraNatives::GetDebuggerCount(); | 2478 for (int i = ExtraNatives::GetDebuggerCount(); |
2472 i < ExtraNatives::GetBuiltinsCount(); i++) { | 2479 i < ExtraNatives::GetBuiltinsCount(); i++) { |
2473 if (!CompileExtraBuiltin(isolate(), i)) return false; | 2480 if (!CompileExtraBuiltin(isolate(), i)) return false; |
2474 } | 2481 } |
2475 | 2482 |
2476 return true; | 2483 return true; |
2477 } | 2484 } |
2478 | 2485 |
2479 | 2486 |
2480 static void InstallBuiltinFunctionId(Handle<JSObject> holder, | 2487 static void InstallBuiltinFunctionId(Handle<JSObject> holder, |
2481 const char* function_name, | 2488 const char* function_name, |
2482 BuiltinFunctionId id) { | 2489 BuiltinFunctionId id) { |
2483 Isolate* isolate = holder->GetIsolate(); | 2490 Isolate* isolate = holder->GetIsolate(); |
2484 Handle<Object> function_object = | 2491 Handle<Object> function_object = |
2485 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); | 2492 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); |
2486 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 2493 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
2487 function->shared()->set_function_data(Smi::FromInt(id)); | 2494 function->shared()->set_function_data(Smi::FromInt(id)); |
2488 } | 2495 } |
2489 | 2496 |
2490 | 2497 |
| 2498 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ |
| 2499 { #holder_expr, #fun_name, k##name } \ |
| 2500 , |
| 2501 |
| 2502 |
2491 void Genesis::InstallBuiltinFunctionIds() { | 2503 void Genesis::InstallBuiltinFunctionIds() { |
2492 HandleScope scope(isolate()); | 2504 HandleScope scope(isolate()); |
2493 struct BuiltinFunctionIds { | 2505 struct BuiltinFunctionIds { |
2494 const char* holder_expr; | 2506 const char* holder_expr; |
2495 const char* fun_name; | 2507 const char* fun_name; |
2496 BuiltinFunctionId id; | 2508 BuiltinFunctionId id; |
2497 }; | 2509 }; |
2498 | 2510 |
2499 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \ | |
2500 { #holder_expr, #fun_name, k##name } \ | |
2501 , | |
2502 const BuiltinFunctionIds builtins[] = { | 2511 const BuiltinFunctionIds builtins[] = { |
2503 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; | 2512 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; |
2504 #undef INSTALL_BUILTIN_ID | |
2505 | 2513 |
2506 for (const BuiltinFunctionIds& builtin : builtins) { | 2514 for (const BuiltinFunctionIds& builtin : builtins) { |
2507 Handle<JSObject> holder = | 2515 Handle<JSObject> holder = |
2508 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); | 2516 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); |
2509 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); | 2517 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); |
2510 } | 2518 } |
2511 } | 2519 } |
2512 | 2520 |
2513 | 2521 |
| 2522 void Genesis::InstallExperimentalBuiltinFunctionIds() { |
| 2523 if (FLAG_harmony_atomics) { |
| 2524 struct BuiltinFunctionIds { |
| 2525 const char* holder_expr; |
| 2526 const char* fun_name; |
| 2527 BuiltinFunctionId id; |
| 2528 }; |
| 2529 |
| 2530 const BuiltinFunctionIds atomic_builtins[] = { |
| 2531 ATOMIC_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; |
| 2532 |
| 2533 for (const BuiltinFunctionIds& builtin : atomic_builtins) { |
| 2534 Handle<JSObject> holder = |
| 2535 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); |
| 2536 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); |
| 2537 } |
| 2538 } |
| 2539 } |
| 2540 |
| 2541 |
| 2542 #undef INSTALL_BUILTIN_ID |
| 2543 |
| 2544 |
2514 // Do not forget to update macros.py with named constant | 2545 // Do not forget to update macros.py with named constant |
2515 // of cache id. | 2546 // of cache id. |
2516 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ | 2547 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ |
2517 F(16, native_context()->regexp_function()) | 2548 F(16, native_context()->regexp_function()) |
2518 | 2549 |
2519 | 2550 |
2520 static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) { | 2551 static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) { |
2521 Factory* factory = factory_function->GetIsolate()->factory(); | 2552 Factory* factory = factory_function->GetIsolate()->factory(); |
2522 // Caches are supposed to live for a long time, allocate in old space. | 2553 // Caches are supposed to live for a long time, allocate in old space. |
2523 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size; | 2554 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size; |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 } | 3145 } |
3115 | 3146 |
3116 | 3147 |
3117 // Called when the top-level V8 mutex is destroyed. | 3148 // Called when the top-level V8 mutex is destroyed. |
3118 void Bootstrapper::FreeThreadResources() { | 3149 void Bootstrapper::FreeThreadResources() { |
3119 DCHECK(!IsActive()); | 3150 DCHECK(!IsActive()); |
3120 } | 3151 } |
3121 | 3152 |
3122 } // namespace internal | 3153 } // namespace internal |
3123 } // namespace v8 | 3154 } // namespace v8 |
OLD | NEW |