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