Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: src/bootstrapper.cc

Issue 1124813005: WIP Atomics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix AtomicsLoad type in typer.cc Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const char* name, 221 const char* name,
222 ElementsKind elements_kind); 222 ElementsKind elements_kind);
223 bool InstallNatives(); 223 bool InstallNatives();
224 224
225 void InstallTypedArray(const char* name, ElementsKind elements_kind, 225 void InstallTypedArray(const char* name, ElementsKind elements_kind,
226 Handle<JSFunction>* fun, Handle<Map>* external_map, 226 Handle<JSFunction>* fun, Handle<Map>* external_map,
227 SharedFlag is_shared); 227 SharedFlag is_shared);
228 bool InstallExperimentalNatives(); 228 bool InstallExperimentalNatives();
229 bool InstallExtraNatives(); 229 bool InstallExtraNatives();
230 void InstallBuiltinFunctionIds(); 230 void InstallBuiltinFunctionIds();
231 void InstallExperimentalBuiltinFunctionIds();
231 void InstallJSFunctionResultCaches(); 232 void InstallJSFunctionResultCaches();
232 void InitializeNormalizedMapCaches(); 233 void InitializeNormalizedMapCaches();
233 234
234 enum ExtensionTraversalState { 235 enum ExtensionTraversalState {
235 UNVISITED, VISITED, INSTALLED 236 UNVISITED, VISITED, INSTALLED
236 }; 237 };
237 238
238 class ExtensionStates { 239 class ExtensionStates {
239 public: 240 public:
240 ExtensionStates(); 241 ExtensionStates();
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) 1721 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
1721 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) 1722 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode)
1722 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) 1723 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
1723 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) 1724 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names)
1724 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) 1725 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters)
1725 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) 1726 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect)
1726 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) 1727 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls)
1727 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) 1728 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring)
1728 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object) 1729 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object)
1729 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_shared_typed_arrays) 1730 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_shared_typed_arrays)
1731 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics)
1730 1732
1731 1733
1732 void Genesis::InstallNativeFunctions_harmony_proxies() { 1734 void Genesis::InstallNativeFunctions_harmony_proxies() {
1733 if (FLAG_harmony_proxies) { 1735 if (FLAG_harmony_proxies) {
1734 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap); 1736 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap);
1735 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap); 1737 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap);
1736 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap); 1738 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap);
1737 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate); 1739 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate);
1738 } 1740 }
1739 } 1741 }
1740 1742
1743
1741 #undef INSTALL_NATIVE 1744 #undef INSTALL_NATIVE
1742 1745
1743 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ 1746 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \
1744 void Genesis::InitializeGlobal_##id() {} 1747 void Genesis::InitializeGlobal_##id() {}
1745 1748
1746 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) 1749 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules)
1747 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrays) 1750 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrays)
1748 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) 1751 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes)
1749 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_classes) 1752 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_classes)
1750 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals) 1753 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_literals)
1751 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) 1754 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions)
1752 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) 1755 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies)
1753 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) 1756 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
1754 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode) 1757 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode)
1755 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names) 1758 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_computed_property_names)
1756 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters) 1759 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_rest_parameters)
1757 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spreadcalls) 1760 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_spreadcalls)
1758 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring) 1761 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring)
1759 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object) 1762 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object)
1763 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_atomics)
1760 1764
1761 void Genesis::InitializeGlobal_harmony_regexps() { 1765 void Genesis::InitializeGlobal_harmony_regexps() {
1762 Handle<JSObject> builtins(native_context()->builtins()); 1766 Handle<JSObject> builtins(native_context()->builtins());
1763 1767
1764 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value() 1768 Handle<HeapObject> flag(FLAG_harmony_regexps ? heap()->true_value()
1765 : heap()->false_value()); 1769 : heap()->false_value());
1766 Runtime::SetObjectProperty(isolate(), builtins, 1770 Runtime::SetObjectProperty(isolate(), builtins,
1767 factory()->harmony_regexps_string(), flag, 1771 factory()->harmony_regexps_string(), flag,
1768 STRICT).Assert(); 1772 STRICT).Assert();
1769 } 1773 }
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 static const char* harmony_rest_parameters_natives[] = {nullptr}; 2409 static const char* harmony_rest_parameters_natives[] = {nullptr};
2406 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", 2410 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js",
2407 nullptr}; 2411 nullptr};
2408 static const char* harmony_spreadcalls_natives[] = { 2412 static const char* harmony_spreadcalls_natives[] = {
2409 "native harmony-spread.js", nullptr}; 2413 "native harmony-spread.js", nullptr};
2410 static const char* harmony_destructuring_natives[] = {nullptr}; 2414 static const char* harmony_destructuring_natives[] = {nullptr};
2411 static const char* harmony_object_natives[] = {"native harmony-object.js", 2415 static const char* harmony_object_natives[] = {"native harmony-object.js",
2412 NULL}; 2416 NULL};
2413 static const char* harmony_shared_typed_arrays_natives[] = { 2417 static const char* harmony_shared_typed_arrays_natives[] = {
2414 "native harmony-sharedarraybuffer.js", 2418 "native harmony-sharedarraybuffer.js",
2415 "native harmony-sharedtypedarray.js", NULL}; 2419 "native harmony-sharedtypedarray.js", nullptr};
2420 static const char* harmony_atomics_natives[] = {"native harmony-atomics.js",
2421 nullptr};
2416 2422
2417 for (int i = ExperimentalNatives::GetDebuggerCount(); 2423 for (int i = ExperimentalNatives::GetDebuggerCount();
2418 i < ExperimentalNatives::GetBuiltinsCount(); i++) { 2424 i < ExperimentalNatives::GetBuiltinsCount(); i++) {
2419 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ 2425 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \
2420 if (FLAG_##id) { \ 2426 if (FLAG_##id) { \
2421 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ 2427 for (size_t j = 0; id##_natives[j] != NULL; j++) { \
2422 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ 2428 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \
2423 if (strncmp(script_name.start(), id##_natives[j], \ 2429 if (strncmp(script_name.start(), id##_natives[j], \
2424 script_name.length()) == 0) { \ 2430 script_name.length()) == 0) { \
2425 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ 2431 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
2426 } \ 2432 } \
2427 } \ 2433 } \
2428 } 2434 }
2429 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES); 2435 HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES);
2430 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES); 2436 HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES);
2431 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES); 2437 HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES);
2432 #undef INSTALL_EXPERIMENTAL_NATIVES 2438 #undef INSTALL_EXPERIMENTAL_NATIVES
2433 } 2439 }
2434 2440
2435 InstallExperimentalNativeFunctions(); 2441 InstallExperimentalNativeFunctions();
2442 InstallExperimentalBuiltinFunctionIds();
2436 return true; 2443 return true;
2437 } 2444 }
2438 2445
2439 2446
2440 bool Genesis::InstallExtraNatives() { 2447 bool Genesis::InstallExtraNatives() {
2441 for (int i = ExtraNatives::GetDebuggerCount(); 2448 for (int i = ExtraNatives::GetDebuggerCount();
2442 i < ExtraNatives::GetBuiltinsCount(); i++) { 2449 i < ExtraNatives::GetBuiltinsCount(); i++) {
2443 if (!CompileExtraBuiltin(isolate(), i)) return false; 2450 if (!CompileExtraBuiltin(isolate(), i)) return false;
2444 } 2451 }
2445 2452
2446 return true; 2453 return true;
2447 } 2454 }
2448 2455
2449 2456
2450 static void InstallBuiltinFunctionId(Handle<JSObject> holder, 2457 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
2451 const char* function_name, 2458 const char* function_name,
2452 BuiltinFunctionId id) { 2459 BuiltinFunctionId id) {
2453 Isolate* isolate = holder->GetIsolate(); 2460 Isolate* isolate = holder->GetIsolate();
2454 Handle<Object> function_object = 2461 Handle<Object> function_object =
2455 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); 2462 Object::GetProperty(isolate, holder, function_name).ToHandleChecked();
2456 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2463 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2457 function->shared()->set_function_data(Smi::FromInt(id)); 2464 function->shared()->set_function_data(Smi::FromInt(id));
2458 } 2465 }
2459 2466
2460 2467
2468 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
2469 { #holder_expr, #fun_name, k##name } \
2470 ,
2471
2472
2461 void Genesis::InstallBuiltinFunctionIds() { 2473 void Genesis::InstallBuiltinFunctionIds() {
2462 HandleScope scope(isolate()); 2474 HandleScope scope(isolate());
2463 struct BuiltinFunctionIds { 2475 struct BuiltinFunctionIds {
2464 const char* holder_expr; 2476 const char* holder_expr;
2465 const char* fun_name; 2477 const char* fun_name;
2466 BuiltinFunctionId id; 2478 BuiltinFunctionId id;
2467 }; 2479 };
2468 2480
2469 #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
2470 { #holder_expr, #fun_name, k##name } \
2471 ,
2472 const BuiltinFunctionIds builtins[] = { 2481 const BuiltinFunctionIds builtins[] = {
2473 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)}; 2482 FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)};
2474 #undef INSTALL_BUILTIN_ID
2475 2483
2476 for (const BuiltinFunctionIds& builtin : builtins) { 2484 for (const BuiltinFunctionIds& builtin : builtins) {
2477 Handle<JSObject> holder = 2485 Handle<JSObject> holder =
2478 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr); 2486 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr);
2479 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id); 2487 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id);
2480 } 2488 }
2481 } 2489 }
2482 2490
2483 2491
2492 void Genesis::InstallExperimentalBuiltinFunctionIds() {
2493 if (FLAG_harmony_atomics) {
2494 struct BuiltinFunctionIds {
2495 const char* holder_expr;
2496 const char* fun_name;
2497 BuiltinFunctionId id;
2498 };
2499
2500 const BuiltinFunctionIds atomic_builtins[] = {
2501 ATOMIC_FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)};
2502
2503 for (const BuiltinFunctionIds& builtin : atomic_builtins) {
2504 Handle<JSObject> holder =
2505 ResolveBuiltinIdHolder(native_context(), builtin.holder_expr);
2506 InstallBuiltinFunctionId(holder, builtin.fun_name, builtin.id);
2507 }
2508 }
2509 }
2510
2511
2512 #undef INSTALL_BUILTIN_ID
2513
2514
2484 // Do not forget to update macros.py with named constant 2515 // Do not forget to update macros.py with named constant
2485 // of cache id. 2516 // of cache id.
2486 #define JSFUNCTION_RESULT_CACHE_LIST(F) \ 2517 #define JSFUNCTION_RESULT_CACHE_LIST(F) \
2487 F(16, native_context()->regexp_function()) 2518 F(16, native_context()->regexp_function())
2488 2519
2489 2520
2490 static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) { 2521 static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) {
2491 Factory* factory = factory_function->GetIsolate()->factory(); 2522 Factory* factory = factory_function->GetIsolate()->factory();
2492 // Caches are supposed to live for a long time, allocate in old space. 2523 // Caches are supposed to live for a long time, allocate in old space.
2493 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size; 2524 int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size;
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 return from + sizeof(NestingCounterType); 3089 return from + sizeof(NestingCounterType);
3059 } 3090 }
3060 3091
3061 3092
3062 // Called when the top-level V8 mutex is destroyed. 3093 // Called when the top-level V8 mutex is destroyed.
3063 void Bootstrapper::FreeThreadResources() { 3094 void Bootstrapper::FreeThreadResources() {
3064 DCHECK(!IsActive()); 3095 DCHECK(!IsActive());
3065 } 3096 }
3066 3097
3067 } } // namespace v8::internal 3098 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698