| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) | 215 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) |
| 216 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) | 216 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) |
| 217 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) | 217 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
| 218 #undef DECLARE_FEATURE_INITIALIZATION | 218 #undef DECLARE_FEATURE_INITIALIZATION |
| 219 | 219 |
| 220 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 220 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
| 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( | 225 void InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 226 const char* name, | 226 Handle<JSFunction>* fun, Handle<Map>* external_map, |
| 227 ElementsKind elements_kind, | 227 SharedFlag is_shared); |
| 228 Handle<JSFunction>* fun, | |
| 229 Handle<Map>* external_map); | |
| 230 bool InstallExperimentalNatives(); | 228 bool InstallExperimentalNatives(); |
| 231 bool InstallExtraNatives(); | 229 bool InstallExtraNatives(); |
| 232 void InstallBuiltinFunctionIds(); | 230 void InstallBuiltinFunctionIds(); |
| 233 void InstallJSFunctionResultCaches(); | 231 void InstallJSFunctionResultCaches(); |
| 234 void InitializeNormalizedMapCaches(); | 232 void InitializeNormalizedMapCaches(); |
| 235 | 233 |
| 236 enum ExtensionTraversalState { | 234 enum ExtensionTraversalState { |
| 237 UNVISITED, VISITED, INSTALLED | 235 UNVISITED, VISITED, INSTALLED |
| 238 }; | 236 }; |
| 239 | 237 |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 InstallFunction( | 1177 InstallFunction( |
| 1180 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1178 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
| 1181 JSArrayBuffer::kSizeWithInternalFields, | 1179 JSArrayBuffer::kSizeWithInternalFields, |
| 1182 isolate->initial_object_prototype(), | 1180 isolate->initial_object_prototype(), |
| 1183 Builtins::kIllegal); | 1181 Builtins::kIllegal); |
| 1184 native_context()->set_array_buffer_fun(*array_buffer_fun); | 1182 native_context()->set_array_buffer_fun(*array_buffer_fun); |
| 1185 native_context()->set_array_buffer_map(array_buffer_fun->initial_map()); | 1183 native_context()->set_array_buffer_map(array_buffer_fun->initial_map()); |
| 1186 } | 1184 } |
| 1187 | 1185 |
| 1188 { // -- T y p e d A r r a y s | 1186 { // -- T y p e d A r r a y s |
| 1189 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 1187 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
| 1190 { \ | 1188 { \ |
| 1191 Handle<JSFunction> fun; \ | 1189 Handle<JSFunction> fun; \ |
| 1192 Handle<Map> external_map; \ | 1190 Handle<Map> external_map; \ |
| 1193 InstallTypedArray(#Type "Array", \ | 1191 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun, &external_map, \ |
| 1194 TYPE##_ELEMENTS, \ | 1192 NOT_SHARED); \ |
| 1195 &fun, \ | 1193 native_context()->set_##type##_array_fun(*fun); \ |
| 1196 &external_map); \ | 1194 native_context()->set_##type##_array_external_map(*external_map); \ |
| 1197 native_context()->set_##type##_array_fun(*fun); \ | 1195 } |
| 1198 native_context()->set_##type##_array_external_map(*external_map); \ | |
| 1199 } | |
| 1200 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) | 1196 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) |
| 1201 #undef INSTALL_TYPED_ARRAY | 1197 #undef INSTALL_TYPED_ARRAY |
| 1202 | 1198 |
| 1203 Handle<JSFunction> data_view_fun = | 1199 Handle<JSFunction> data_view_fun = |
| 1204 InstallFunction( | 1200 InstallFunction( |
| 1205 global, "DataView", JS_DATA_VIEW_TYPE, | 1201 global, "DataView", JS_DATA_VIEW_TYPE, |
| 1206 JSDataView::kSizeWithInternalFields, | 1202 JSDataView::kSizeWithInternalFields, |
| 1207 isolate->initial_object_prototype(), | 1203 isolate->initial_object_prototype(), |
| 1208 Builtins::kIllegal); | 1204 Builtins::kIllegal); |
| 1209 native_context()->set_data_view_fun(*data_view_fun); | 1205 native_context()->set_data_view_fun(*data_view_fun); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 native_context()->set_call_as_constructor_delegate(*delegate); | 1393 native_context()->set_call_as_constructor_delegate(*delegate); |
| 1398 delegate->shared()->DontAdaptArguments(); | 1394 delegate->shared()->DontAdaptArguments(); |
| 1399 } | 1395 } |
| 1400 | 1396 |
| 1401 // Initialize the embedder data slot. | 1397 // Initialize the embedder data slot. |
| 1402 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); | 1398 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); |
| 1403 native_context()->set_embedder_data(*embedder_data); | 1399 native_context()->set_embedder_data(*embedder_data); |
| 1404 } | 1400 } |
| 1405 | 1401 |
| 1406 | 1402 |
| 1407 void Genesis::InstallTypedArray( | 1403 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind, |
| 1408 const char* name, | 1404 Handle<JSFunction>* fun, |
| 1409 ElementsKind elements_kind, | 1405 Handle<Map>* external_map, |
| 1410 Handle<JSFunction>* fun, | 1406 SharedFlag is_shared) { |
| 1411 Handle<Map>* external_map) { | 1407 DCHECK(is_shared == NOT_SHARED || FLAG_harmony_shared_typed_arrays); |
| 1408 InstanceType type = |
| 1409 is_shared == SHARED ? JS_SHARED_TYPED_ARRAY_TYPE : JS_TYPED_ARRAY_TYPE; |
| 1412 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); | 1410 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); |
| 1413 Handle<JSFunction> result = InstallFunction( | 1411 Handle<JSFunction> result = InstallFunction( |
| 1414 global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, | 1412 global, name, type, JSTypedArray::kSize, |
| 1415 isolate()->initial_object_prototype(), Builtins::kIllegal); | 1413 isolate()->initial_object_prototype(), Builtins::kIllegal); |
| 1416 | 1414 |
| 1417 Handle<Map> initial_map = isolate()->factory()->NewMap( | 1415 Handle<Map> initial_map = isolate()->factory()->NewMap( |
| 1418 JS_TYPED_ARRAY_TYPE, | 1416 type, JSTypedArray::kSizeWithInternalFields, elements_kind); |
| 1419 JSTypedArray::kSizeWithInternalFields, | |
| 1420 elements_kind); | |
| 1421 JSFunction::SetInitialMap(result, initial_map, | 1417 JSFunction::SetInitialMap(result, initial_map, |
| 1422 handle(initial_map->prototype(), isolate())); | 1418 handle(initial_map->prototype(), isolate())); |
| 1423 *fun = result; | 1419 *fun = result; |
| 1424 | 1420 |
| 1425 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); | 1421 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); |
| 1426 *external_map = Map::AsElementsKind(initial_map, external_kind); | 1422 *external_map = Map::AsElementsKind(initial_map, external_kind); |
| 1427 } | 1423 } |
| 1428 | 1424 |
| 1429 | 1425 |
| 1430 void Genesis::InitializeExperimentalGlobal() { | 1426 void Genesis::InitializeExperimentalGlobal() { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) | 1717 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) |
| 1722 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) | 1718 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) |
| 1723 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) | 1719 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) |
| 1724 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) | 1720 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) |
| 1725 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) | 1721 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) |
| 1726 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) | 1722 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) |
| 1727 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) | 1723 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) |
| 1728 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) | 1724 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) |
| 1729 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) | 1725 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) |
| 1730 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object) | 1726 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object) |
| 1727 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_shared_typed_arrays) |
| 1731 | 1728 |
| 1732 | 1729 |
| 1733 void Genesis::InstallNativeFunctions_harmony_proxies() { | 1730 void Genesis::InstallNativeFunctions_harmony_proxies() { |
| 1734 if (FLAG_harmony_proxies) { | 1731 if (FLAG_harmony_proxies) { |
| 1735 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap); | 1732 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap); |
| 1736 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap); | 1733 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap); |
| 1737 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap); | 1734 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap); |
| 1738 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate); | 1735 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate); |
| 1739 } | 1736 } |
| 1740 } | 1737 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1813 Handle<JSObject> builtins(native_context()->builtins()); | 1810 Handle<JSObject> builtins(native_context()->builtins()); |
| 1814 | 1811 |
| 1815 Handle<HeapObject> flag(FLAG_harmony_tostring ? heap()->true_value() | 1812 Handle<HeapObject> flag(FLAG_harmony_tostring ? heap()->true_value() |
| 1816 : heap()->false_value()); | 1813 : heap()->false_value()); |
| 1817 Runtime::SetObjectProperty(isolate(), builtins, | 1814 Runtime::SetObjectProperty(isolate(), builtins, |
| 1818 factory()->harmony_tostring_string(), flag, | 1815 factory()->harmony_tostring_string(), flag, |
| 1819 STRICT).Assert(); | 1816 STRICT).Assert(); |
| 1820 } | 1817 } |
| 1821 | 1818 |
| 1822 | 1819 |
| 1820 void Genesis::InitializeGlobal_harmony_shared_typed_arrays() { |
| 1821 if (!FLAG_harmony_shared_typed_arrays) return; |
| 1822 |
| 1823 Handle<JSGlobalObject> global( |
| 1824 JSGlobalObject::cast(native_context()->global_object())); |
| 1825 |
| 1826 Handle<JSFunction> shared_array_buffer_fun = InstallFunction( |
| 1827 global, "SharedArrayBuffer", JS_SHARED_ARRAY_BUFFER_TYPE, |
| 1828 JSArrayBuffer::kSizeWithInternalFields, |
| 1829 isolate()->initial_object_prototype(), Builtins::kIllegal); |
| 1830 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun); |
| 1831 |
| 1832 #define INSTALL_SHARED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
| 1833 { \ |
| 1834 Handle<JSFunction> fun; \ |
| 1835 Handle<Map> external_map; \ |
| 1836 InstallTypedArray("Shared" #Type "Array", TYPE##_ELEMENTS, &fun, \ |
| 1837 &external_map, SHARED); \ |
| 1838 native_context()->set_shared_##type##_array_fun(*fun); \ |
| 1839 native_context()->set_shared_##type##_array_external_map(*external_map); \ |
| 1840 } |
| 1841 TYPED_ARRAYS(INSTALL_SHARED_TYPED_ARRAY) |
| 1842 #undef INSTALL_SHARED_TYPED_ARRAY |
| 1843 } |
| 1844 |
| 1845 |
| 1823 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, | 1846 Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target, |
| 1824 const char* name, | 1847 const char* name, |
| 1825 ElementsKind elements_kind) { | 1848 ElementsKind elements_kind) { |
| 1826 // --- I n t e r n a l A r r a y --- | 1849 // --- I n t e r n a l A r r a y --- |
| 1827 // An array constructor on the builtins object that works like | 1850 // An array constructor on the builtins object that works like |
| 1828 // the public Array constructor, except that its prototype | 1851 // the public Array constructor, except that its prototype |
| 1829 // doesn't inherit from Object.prototype. | 1852 // doesn't inherit from Object.prototype. |
| 1830 // To be used only for internal work by builtins. Instances | 1853 // To be used only for internal work by builtins. Instances |
| 1831 // must not be leaked to user code. | 1854 // must not be leaked to user code. |
| 1832 Handle<JSObject> prototype = | 1855 Handle<JSObject> prototype = |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2371 static const char* harmony_unicode_regexps_natives[] = {nullptr}; | 2394 static const char* harmony_unicode_regexps_natives[] = {nullptr}; |
| 2372 static const char* harmony_computed_property_names_natives[] = {nullptr}; | 2395 static const char* harmony_computed_property_names_natives[] = {nullptr}; |
| 2373 static const char* harmony_rest_parameters_natives[] = {nullptr}; | 2396 static const char* harmony_rest_parameters_natives[] = {nullptr}; |
| 2374 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", | 2397 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", |
| 2375 nullptr}; | 2398 nullptr}; |
| 2376 static const char* harmony_spreadcalls_natives[] = { | 2399 static const char* harmony_spreadcalls_natives[] = { |
| 2377 "native harmony-spread.js", nullptr}; | 2400 "native harmony-spread.js", nullptr}; |
| 2378 static const char* harmony_destructuring_natives[] = {nullptr}; | 2401 static const char* harmony_destructuring_natives[] = {nullptr}; |
| 2379 static const char* harmony_object_natives[] = {"native harmony-object.js", | 2402 static const char* harmony_object_natives[] = {"native harmony-object.js", |
| 2380 NULL}; | 2403 NULL}; |
| 2404 static const char* harmony_shared_typed_arrays_natives[] = { |
| 2405 "native harmony-sharedarraybuffer.js", |
| 2406 "native harmony-sharedtypedarray.js", NULL}; |
| 2381 | 2407 |
| 2382 for (int i = ExperimentalNatives::GetDebuggerCount(); | 2408 for (int i = ExperimentalNatives::GetDebuggerCount(); |
| 2383 i < ExperimentalNatives::GetBuiltinsCount(); i++) { | 2409 i < ExperimentalNatives::GetBuiltinsCount(); i++) { |
| 2384 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ | 2410 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ |
| 2385 if (FLAG_##id) { \ | 2411 if (FLAG_##id) { \ |
| 2386 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ | 2412 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ |
| 2387 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ | 2413 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ |
| 2388 if (strncmp(script_name.start(), id##_natives[j], \ | 2414 if (strncmp(script_name.start(), id##_natives[j], \ |
| 2389 script_name.length()) == 0) { \ | 2415 script_name.length()) == 0) { \ |
| 2390 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ | 2416 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3023 return from + sizeof(NestingCounterType); | 3049 return from + sizeof(NestingCounterType); |
| 3024 } | 3050 } |
| 3025 | 3051 |
| 3026 | 3052 |
| 3027 // Called when the top-level V8 mutex is destroyed. | 3053 // Called when the top-level V8 mutex is destroyed. |
| 3028 void Bootstrapper::FreeThreadResources() { | 3054 void Bootstrapper::FreeThreadResources() { |
| 3029 DCHECK(!IsActive()); | 3055 DCHECK(!IsActive()); |
| 3030 } | 3056 } |
| 3031 | 3057 |
| 3032 } } // namespace v8::internal | 3058 } } // namespace v8::internal |
| OLD | NEW |