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

Side by Side Diff: src/bootstrapper.cc

Issue 1069883002: WIP SharedArrayBuffer implementation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update MakeTypeError calls 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
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) 182 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION)
183 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) 183 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION)
184 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) 184 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
185 #undef DECLARE_FEATURE_INITIALIZATION 185 #undef DECLARE_FEATURE_INITIALIZATION
186 186
187 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins, 187 Handle<JSFunction> InstallInternalArray(Handle<JSBuiltinsObject> builtins,
188 const char* name, 188 const char* name,
189 ElementsKind elements_kind); 189 ElementsKind elements_kind);
190 bool InstallNatives(); 190 bool InstallNatives();
191 191
192 void InstallTypedArray( 192 void InstallTypedArray(const char* name, ElementsKind elements_kind,
193 const char* name, 193 Handle<JSFunction>* fun, Handle<Map>* external_map,
194 ElementsKind elements_kind, 194 SharedFlag is_shared);
195 Handle<JSFunction>* fun,
196 Handle<Map>* external_map);
197 bool InstallExperimentalNatives(); 195 bool InstallExperimentalNatives();
198 void InstallBuiltinFunctionIds(); 196 void InstallBuiltinFunctionIds();
199 void InstallJSFunctionResultCaches(); 197 void InstallJSFunctionResultCaches();
200 void InitializeNormalizedMapCaches(); 198 void InitializeNormalizedMapCaches();
201 199
202 enum ExtensionTraversalState { 200 enum ExtensionTraversalState {
203 UNVISITED, VISITED, INSTALLED 201 UNVISITED, VISITED, INSTALLED
204 }; 202 };
205 203
206 class ExtensionStates { 204 class ExtensionStates {
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 Handle<JSFunction> array_buffer_fun = 1145 Handle<JSFunction> array_buffer_fun =
1148 InstallFunction( 1146 InstallFunction(
1149 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, 1147 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
1150 JSArrayBuffer::kSizeWithInternalFields, 1148 JSArrayBuffer::kSizeWithInternalFields,
1151 isolate->initial_object_prototype(), 1149 isolate->initial_object_prototype(),
1152 Builtins::kIllegal); 1150 Builtins::kIllegal);
1153 native_context()->set_array_buffer_fun(*array_buffer_fun); 1151 native_context()->set_array_buffer_fun(*array_buffer_fun);
1154 } 1152 }
1155 1153
1156 { // -- T y p e d A r r a y s 1154 { // -- T y p e d A r r a y s
1157 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ 1155 #define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
1158 { \ 1156 { \
1159 Handle<JSFunction> fun; \ 1157 Handle<JSFunction> fun; \
1160 Handle<Map> external_map; \ 1158 Handle<Map> external_map; \
1161 InstallTypedArray(#Type "Array", \ 1159 InstallTypedArray(#Type "Array", TYPE##_ELEMENTS, &fun, &external_map, \
1162 TYPE##_ELEMENTS, \ 1160 NOT_SHARED); \
1163 &fun, \ 1161 native_context()->set_##type##_array_fun(*fun); \
1164 &external_map); \ 1162 native_context()->set_##type##_array_external_map(*external_map); \
1165 native_context()->set_##type##_array_fun(*fun); \ 1163 }
1166 native_context()->set_##type##_array_external_map(*external_map); \
1167 }
1168 TYPED_ARRAYS(INSTALL_TYPED_ARRAY) 1164 TYPED_ARRAYS(INSTALL_TYPED_ARRAY)
1169 #undef INSTALL_TYPED_ARRAY 1165 #undef INSTALL_TYPED_ARRAY
1170 1166
1171 Handle<JSFunction> data_view_fun = 1167 Handle<JSFunction> data_view_fun =
1172 InstallFunction( 1168 InstallFunction(
1173 global, "DataView", JS_DATA_VIEW_TYPE, 1169 global, "DataView", JS_DATA_VIEW_TYPE,
1174 JSDataView::kSizeWithInternalFields, 1170 JSDataView::kSizeWithInternalFields,
1175 isolate->initial_object_prototype(), 1171 isolate->initial_object_prototype(),
1176 Builtins::kIllegal); 1172 Builtins::kIllegal);
1177 native_context()->set_data_view_fun(*data_view_fun); 1173 native_context()->set_data_view_fun(*data_view_fun);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 native_context()->set_call_as_constructor_delegate(*delegate); 1361 native_context()->set_call_as_constructor_delegate(*delegate);
1366 delegate->shared()->DontAdaptArguments(); 1362 delegate->shared()->DontAdaptArguments();
1367 } 1363 }
1368 1364
1369 // Initialize the embedder data slot. 1365 // Initialize the embedder data slot.
1370 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); 1366 Handle<FixedArray> embedder_data = factory->NewFixedArray(3);
1371 native_context()->set_embedder_data(*embedder_data); 1367 native_context()->set_embedder_data(*embedder_data);
1372 } 1368 }
1373 1369
1374 1370
1375 void Genesis::InstallTypedArray( 1371 void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind,
1376 const char* name, 1372 Handle<JSFunction>* fun,
1377 ElementsKind elements_kind, 1373 Handle<Map>* external_map,
1378 Handle<JSFunction>* fun, 1374 SharedFlag is_shared) {
1379 Handle<Map>* external_map) { 1375 DCHECK(!is_shared || FLAG_harmony_shared_typed_arrays);
1376 InstanceType type =
1377 is_shared ? JS_SHARED_TYPED_ARRAY_TYPE : JS_TYPED_ARRAY_TYPE;
Jarin 2015/04/29 04:46:00 change to (is_shared == SHARED) ? ...
binji 2015/04/30 16:39:43 Done.
1380 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object()); 1378 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1381 Handle<JSFunction> result = InstallFunction( 1379 Handle<JSFunction> result = InstallFunction(
1382 global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, 1380 global, name, type, JSTypedArray::kSize,
1383 isolate()->initial_object_prototype(), Builtins::kIllegal); 1381 isolate()->initial_object_prototype(), Builtins::kIllegal);
1384 1382
1385 Handle<Map> initial_map = isolate()->factory()->NewMap( 1383 Handle<Map> initial_map = isolate()->factory()->NewMap(
1386 JS_TYPED_ARRAY_TYPE, 1384 type, JSTypedArray::kSizeWithInternalFields, elements_kind);
1387 JSTypedArray::kSizeWithInternalFields,
1388 elements_kind);
1389 JSFunction::SetInitialMap(result, initial_map, 1385 JSFunction::SetInitialMap(result, initial_map,
1390 handle(initial_map->prototype(), isolate())); 1386 handle(initial_map->prototype(), isolate()));
1391 *fun = result; 1387 *fun = result;
1392 1388
1393 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); 1389 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind);
1394 *external_map = Map::AsElementsKind(initial_map, external_kind); 1390 *external_map = Map::AsElementsKind(initial_map, external_kind);
1395 } 1391 }
1396 1392
1397 1393
1398 void Genesis::InitializeExperimentalGlobal() { 1394 void Genesis::InitializeExperimentalGlobal() {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) 1659 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions)
1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) 1660 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring)
1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) 1661 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy)
1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode) 1662 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode)
1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) 1663 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps)
1668 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names) 1664 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_computed_property_names)
1669 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) 1665 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters)
1670 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) 1666 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect)
1671 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) 1667 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls)
1672 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) 1668 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring)
1669 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_shared_typed_arrays)
1673 1670
1674 1671
1675 void Genesis::InstallNativeFunctions_harmony_proxies() { 1672 void Genesis::InstallNativeFunctions_harmony_proxies() {
1676 if (FLAG_harmony_proxies) { 1673 if (FLAG_harmony_proxies) {
1677 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap); 1674 INSTALL_NATIVE(JSFunction, "$proxyDerivedHasTrap", derived_has_trap);
1678 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap); 1675 INSTALL_NATIVE(JSFunction, "$proxyDerivedGetTrap", derived_get_trap);
1679 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap); 1676 INSTALL_NATIVE(JSFunction, "$proxyDerivedSetTrap", derived_set_trap);
1680 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate); 1677 INSTALL_NATIVE(JSFunction, "$proxyEnumerate", proxy_enumerate);
1681 } 1678 }
1682 } 1679 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 Handle<JSObject> builtins(native_context()->builtins()); 1763 Handle<JSObject> builtins(native_context()->builtins());
1767 1764
1768 Handle<HeapObject> flag(FLAG_harmony_tostring ? heap()->true_value() 1765 Handle<HeapObject> flag(FLAG_harmony_tostring ? heap()->true_value()
1769 : heap()->false_value()); 1766 : heap()->false_value());
1770 Runtime::SetObjectProperty(isolate(), builtins, 1767 Runtime::SetObjectProperty(isolate(), builtins,
1771 factory()->harmony_tostring_string(), flag, 1768 factory()->harmony_tostring_string(), flag,
1772 STRICT).Assert(); 1769 STRICT).Assert();
1773 } 1770 }
1774 1771
1775 1772
1773 void Genesis::InitializeGlobal_harmony_shared_typed_arrays() {
1774 if (!FLAG_harmony_shared_typed_arrays) return;
1775
1776 Handle<JSGlobalObject> global(
1777 JSGlobalObject::cast(native_context()->global_object()));
1778
1779 Handle<JSFunction> shared_array_buffer_fun = InstallFunction(
1780 global, "SharedArrayBuffer", JS_SHARED_ARRAY_BUFFER_TYPE,
1781 JSArrayBuffer::kSizeWithInternalFields,
1782 isolate()->initial_object_prototype(), Builtins::kIllegal);
1783 native_context()->set_shared_array_buffer_fun(*shared_array_buffer_fun);
1784
1785 #define INSTALL_SHARED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
1786 { \
1787 Handle<JSFunction> fun; \
1788 Handle<Map> external_map; \
1789 InstallTypedArray("Shared" #Type "Array", TYPE##_ELEMENTS, &fun, \
1790 &external_map, SHARED); \
1791 native_context()->set_shared_##type##_array_fun(*fun); \
1792 native_context()->set_shared_##type##_array_external_map(*external_map); \
1793 }
1794 TYPED_ARRAYS(INSTALL_SHARED_TYPED_ARRAY)
1795 #undef INSTALL_SHARED_TYPED_ARRAY
1796 }
1797
1798
1776 Handle<JSFunction> Genesis::InstallInternalArray( 1799 Handle<JSFunction> Genesis::InstallInternalArray(
1777 Handle<JSBuiltinsObject> builtins, 1800 Handle<JSBuiltinsObject> builtins,
1778 const char* name, 1801 const char* name,
1779 ElementsKind elements_kind) { 1802 ElementsKind elements_kind) {
1780 // --- I n t e r n a l A r r a y --- 1803 // --- I n t e r n a l A r r a y ---
1781 // An array constructor on the builtins object that works like 1804 // An array constructor on the builtins object that works like
1782 // the public Array constructor, except that its prototype 1805 // the public Array constructor, except that its prototype
1783 // doesn't inherit from Object.prototype. 1806 // doesn't inherit from Object.prototype.
1784 // To be used only for internal work by builtins. Instances 1807 // To be used only for internal work by builtins. Instances
1785 // must not be leaked to user code. 1808 // must not be leaked to user code.
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 static const char* harmony_sloppy_natives[] = {nullptr}; 2341 static const char* harmony_sloppy_natives[] = {nullptr};
2319 static const char* harmony_unicode_natives[] = {nullptr}; 2342 static const char* harmony_unicode_natives[] = {nullptr};
2320 static const char* harmony_unicode_regexps_natives[] = {nullptr}; 2343 static const char* harmony_unicode_regexps_natives[] = {nullptr};
2321 static const char* harmony_computed_property_names_natives[] = {nullptr}; 2344 static const char* harmony_computed_property_names_natives[] = {nullptr};
2322 static const char* harmony_rest_parameters_natives[] = {nullptr}; 2345 static const char* harmony_rest_parameters_natives[] = {nullptr};
2323 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js", 2346 static const char* harmony_reflect_natives[] = {"native harmony-reflect.js",
2324 nullptr}; 2347 nullptr};
2325 static const char* harmony_spreadcalls_natives[] = { 2348 static const char* harmony_spreadcalls_natives[] = {
2326 "native harmony-spread.js", nullptr}; 2349 "native harmony-spread.js", nullptr};
2327 static const char* harmony_destructuring_natives[] = {nullptr}; 2350 static const char* harmony_destructuring_natives[] = {nullptr};
2351 static const char* harmony_shared_typed_arrays_natives[] = {
2352 "native harmony-sharedarraybuffer.js",
2353 "native harmony-sharedtypedarray.js", NULL};
2328 2354
2329 for (int i = ExperimentalNatives::GetDebuggerCount(); 2355 for (int i = ExperimentalNatives::GetDebuggerCount();
2330 i < ExperimentalNatives::GetBuiltinsCount(); i++) { 2356 i < ExperimentalNatives::GetBuiltinsCount(); i++) {
2331 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \ 2357 #define INSTALL_EXPERIMENTAL_NATIVES(id, desc) \
2332 if (FLAG_##id) { \ 2358 if (FLAG_##id) { \
2333 for (size_t j = 0; id##_natives[j] != NULL; j++) { \ 2359 for (size_t j = 0; id##_natives[j] != NULL; j++) { \
2334 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \ 2360 Vector<const char> script_name = ExperimentalNatives::GetScriptName(i); \
2335 if (strncmp(script_name.start(), id##_natives[j], \ 2361 if (strncmp(script_name.start(), id##_natives[j], \
2336 script_name.length()) == 0) { \ 2362 script_name.length()) == 0) { \
2337 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ 2363 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 return from + sizeof(NestingCounterType); 2986 return from + sizeof(NestingCounterType);
2961 } 2987 }
2962 2988
2963 2989
2964 // Called when the top-level V8 mutex is destroyed. 2990 // Called when the top-level V8 mutex is destroyed.
2965 void Bootstrapper::FreeThreadResources() { 2991 void Bootstrapper::FreeThreadResources() {
2966 DCHECK(!IsActive()); 2992 DCHECK(!IsActive());
2967 } 2993 }
2968 2994
2969 } } // namespace v8::internal 2995 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698