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

Side by Side Diff: src/bootstrapper.cc

Issue 427723002: Enable ES6 Map and Set by default (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove old test, fix BUILD.gn Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « BUILD.gn ('k') | src/flag-definitions.h » ('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/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/extensions/externalize-string-extension.h" 9 #include "src/extensions/externalize-string-extension.h"
10 #include "src/extensions/free-buffer-extension.h" 10 #include "src/extensions/free-buffer-extension.h"
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 1120
1121 Handle<JSFunction> data_view_fun = 1121 Handle<JSFunction> data_view_fun =
1122 InstallFunction( 1122 InstallFunction(
1123 global, "DataView", JS_DATA_VIEW_TYPE, 1123 global, "DataView", JS_DATA_VIEW_TYPE,
1124 JSDataView::kSizeWithInternalFields, 1124 JSDataView::kSizeWithInternalFields,
1125 isolate->initial_object_prototype(), 1125 isolate->initial_object_prototype(),
1126 Builtins::kIllegal); 1126 Builtins::kIllegal);
1127 native_context()->set_data_view_fun(*data_view_fun); 1127 native_context()->set_data_view_fun(*data_view_fun);
1128 } 1128 }
1129 1129
1130 // -- M a p
1131 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize,
1132 isolate->initial_object_prototype(), Builtins::kIllegal);
1133
1134 // -- S e t
1135 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize,
1136 isolate->initial_object_prototype(), Builtins::kIllegal);
1137
1138 { // Set up the iterator result object
1139 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
1140 Handle<JSFunction> object_function(native_context()->object_function());
1141 DCHECK(object_function->initial_map()->inobject_properties() == 0);
1142 Handle<Map> iterator_result_map =
1143 Map::Create(object_function, JSGeneratorObject::kResultPropertyCount);
1144 DCHECK(iterator_result_map->inobject_properties() ==
1145 JSGeneratorObject::kResultPropertyCount);
1146 Map::EnsureDescriptorSlack(iterator_result_map,
1147 JSGeneratorObject::kResultPropertyCount);
1148
1149 FieldDescriptor value_descr(factory->value_string(),
1150 JSGeneratorObject::kResultValuePropertyIndex,
1151 NONE, Representation::Tagged());
1152 iterator_result_map->AppendDescriptor(&value_descr);
1153
1154 FieldDescriptor done_descr(factory->done_string(),
1155 JSGeneratorObject::kResultDonePropertyIndex,
1156 NONE, Representation::Tagged());
1157 iterator_result_map->AppendDescriptor(&done_descr);
1158
1159 iterator_result_map->set_unused_property_fields(0);
1160 DCHECK_EQ(JSGeneratorObject::kResultSize,
1161 iterator_result_map->instance_size());
1162 native_context()->set_iterator_result_map(*iterator_result_map);
1163 }
1164
1130 // -- W e a k M a p 1165 // -- W e a k M a p
1131 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, 1166 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
1132 isolate->initial_object_prototype(), Builtins::kIllegal); 1167 isolate->initial_object_prototype(), Builtins::kIllegal);
1133 // -- W e a k S e t 1168 // -- W e a k S e t
1134 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, 1169 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
1135 isolate->initial_object_prototype(), Builtins::kIllegal); 1170 isolate->initial_object_prototype(), Builtins::kIllegal);
1136 1171
1137 { 1172 {
1138 // --- S y m b o l --- 1173 // --- S y m b o l ---
1139 Handle<JSFunction> symbol_fun = InstallFunction( 1174 Handle<JSFunction> symbol_fun = InstallFunction(
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 result->set_initial_map(*initial_map); 1339 result->set_initial_map(*initial_map);
1305 initial_map->set_constructor(*result); 1340 initial_map->set_constructor(*result);
1306 *fun = result; 1341 *fun = result;
1307 1342
1308 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind); 1343 ElementsKind external_kind = GetNextTransitionElementsKind(elements_kind);
1309 *external_map = Map::AsElementsKind(initial_map, external_kind); 1344 *external_map = Map::AsElementsKind(initial_map, external_kind);
1310 } 1345 }
1311 1346
1312 1347
1313 void Genesis::InitializeExperimentalGlobal() { 1348 void Genesis::InitializeExperimentalGlobal() {
1314 Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
1315
1316 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no 1349 // TODO(mstarzinger): Move this into Genesis::InitializeGlobal once we no
1317 // longer need to live behind flags, so functions get added to the snapshot. 1350 // longer need to live behind flags, so functions get added to the snapshot.
1318 1351
1319 if (FLAG_harmony_collections) {
1320 // -- M a p
1321 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize,
1322 isolate()->initial_object_prototype(), Builtins::kIllegal);
1323 // -- S e t
1324 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize,
1325 isolate()->initial_object_prototype(), Builtins::kIllegal);
1326 { // -- S e t I t e r a t o r
1327 Handle<JSObject> builtins(native_context()->builtins());
1328 Handle<JSFunction> set_iterator_function =
1329 InstallFunction(builtins, "SetIterator", JS_SET_ITERATOR_TYPE,
1330 JSSetIterator::kSize,
1331 isolate()->initial_object_prototype(),
1332 Builtins::kIllegal);
1333 native_context()->set_set_iterator_map(
1334 set_iterator_function->initial_map());
1335 }
1336 { // -- M a p I t e r a t o r
1337 Handle<JSObject> builtins(native_context()->builtins());
1338 Handle<JSFunction> map_iterator_function =
1339 InstallFunction(builtins, "MapIterator", JS_MAP_ITERATOR_TYPE,
1340 JSMapIterator::kSize,
1341 isolate()->initial_object_prototype(),
1342 Builtins::kIllegal);
1343 native_context()->set_map_iterator_map(
1344 map_iterator_function->initial_map());
1345 }
1346 }
1347
1348 if (FLAG_harmony_generators) { 1352 if (FLAG_harmony_generators) {
1349 // Create generator meta-objects and install them on the builtins object. 1353 // Create generator meta-objects and install them on the builtins object.
1350 Handle<JSObject> builtins(native_context()->builtins()); 1354 Handle<JSObject> builtins(native_context()->builtins());
1351 Handle<JSObject> generator_object_prototype = 1355 Handle<JSObject> generator_object_prototype =
1352 factory()->NewJSObject(isolate()->object_function(), TENURED); 1356 factory()->NewJSObject(isolate()->object_function(), TENURED);
1353 Handle<JSFunction> generator_function_prototype = InstallFunction( 1357 Handle<JSFunction> generator_function_prototype = InstallFunction(
1354 builtins, "GeneratorFunctionPrototype", JS_FUNCTION_TYPE, 1358 builtins, "GeneratorFunctionPrototype", JS_FUNCTION_TYPE,
1355 JSFunction::kHeaderSize, generator_object_prototype, 1359 JSFunction::kHeaderSize, generator_object_prototype,
1356 Builtins::kIllegal); 1360 Builtins::kIllegal);
1357 InstallFunction(builtins, "GeneratorFunction", 1361 InstallFunction(builtins, "GeneratorFunction",
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 *strict_generator_function_map); 1403 *strict_generator_function_map);
1400 1404
1401 Handle<JSFunction> object_function(native_context()->object_function()); 1405 Handle<JSFunction> object_function(native_context()->object_function());
1402 Handle<Map> generator_object_prototype_map = Map::Create( 1406 Handle<Map> generator_object_prototype_map = Map::Create(
1403 object_function, 0); 1407 object_function, 0);
1404 generator_object_prototype_map->set_prototype( 1408 generator_object_prototype_map->set_prototype(
1405 *generator_object_prototype); 1409 *generator_object_prototype);
1406 native_context()->set_generator_object_prototype_map( 1410 native_context()->set_generator_object_prototype_map(
1407 *generator_object_prototype_map); 1411 *generator_object_prototype_map);
1408 } 1412 }
1409
1410 if (FLAG_harmony_collections || FLAG_harmony_generators) {
1411 // Collection forEach uses an iterator result object.
1412 // Generators return iteraror result objects.
1413
1414 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
1415 Handle<JSFunction> object_function(native_context()->object_function());
1416 DCHECK(object_function->initial_map()->inobject_properties() == 0);
1417 Handle<Map> iterator_result_map = Map::Create(
1418 object_function, JSGeneratorObject::kResultPropertyCount);
1419 DCHECK(iterator_result_map->inobject_properties() ==
1420 JSGeneratorObject::kResultPropertyCount);
1421 Map::EnsureDescriptorSlack(
1422 iterator_result_map, JSGeneratorObject::kResultPropertyCount);
1423
1424 FieldDescriptor value_descr(isolate()->factory()->value_string(),
1425 JSGeneratorObject::kResultValuePropertyIndex,
1426 NONE,
1427 Representation::Tagged());
1428 iterator_result_map->AppendDescriptor(&value_descr);
1429
1430 FieldDescriptor done_descr(isolate()->factory()->done_string(),
1431 JSGeneratorObject::kResultDonePropertyIndex,
1432 NONE,
1433 Representation::Tagged());
1434 iterator_result_map->AppendDescriptor(&done_descr);
1435
1436 iterator_result_map->set_unused_property_fields(0);
1437 DCHECK_EQ(JSGeneratorObject::kResultSize,
1438 iterator_result_map->instance_size());
1439 native_context()->set_iterator_result_map(*iterator_result_map);
1440 }
1441 } 1413 }
1442 1414
1443 1415
1444 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { 1416 bool Genesis::CompileBuiltin(Isolate* isolate, int index) {
1445 Vector<const char> name = Natives::GetScriptName(index); 1417 Vector<const char> name = Natives::GetScriptName(index);
1446 Handle<String> source_code = 1418 Handle<String> source_code =
1447 isolate->bootstrapper()->NativesSourceLookup(index); 1419 isolate->bootstrapper()->NativesSourceLookup(index);
1448 return CompileNative(isolate, name, source_code); 1420 return CompileNative(isolate, name, source_code);
1449 } 1421 }
1450 1422
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 { 1890 {
1919 Handle<JSFunction> array_function = 1891 Handle<JSFunction> array_function =
1920 InstallInternalArray(builtins, "InternalArray", FAST_HOLEY_ELEMENTS); 1892 InstallInternalArray(builtins, "InternalArray", FAST_HOLEY_ELEMENTS);
1921 native_context()->set_internal_array_function(*array_function); 1893 native_context()->set_internal_array_function(*array_function);
1922 } 1894 }
1923 1895
1924 { 1896 {
1925 InstallInternalArray(builtins, "InternalPackedArray", FAST_ELEMENTS); 1897 InstallInternalArray(builtins, "InternalPackedArray", FAST_ELEMENTS);
1926 } 1898 }
1927 1899
1900 { // -- S e t I t e r a t o r
1901 Handle<JSFunction> set_iterator_function = InstallFunction(
1902 builtins, "SetIterator", JS_SET_ITERATOR_TYPE, JSSetIterator::kSize,
1903 isolate()->initial_object_prototype(), Builtins::kIllegal);
1904 native_context()->set_set_iterator_map(
1905 set_iterator_function->initial_map());
1906 }
1907
1908 { // -- M a p I t e r a t o r
1909 Handle<JSFunction> map_iterator_function = InstallFunction(
1910 builtins, "MapIterator", JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize,
1911 isolate()->initial_object_prototype(), Builtins::kIllegal);
1912 native_context()->set_map_iterator_map(
1913 map_iterator_function->initial_map());
1914 }
1915
1928 if (FLAG_disable_native_files) { 1916 if (FLAG_disable_native_files) {
1929 PrintF("Warning: Running without installed natives!\n"); 1917 PrintF("Warning: Running without installed natives!\n");
1930 return true; 1918 return true;
1931 } 1919 }
1932 1920
1933 // Install natives. 1921 // Install natives.
1934 for (int i = Natives::GetDebuggerCount(); 1922 for (int i = Natives::GetDebuggerCount();
1935 i < Natives::GetBuiltinsCount(); 1923 i < Natives::GetBuiltinsCount();
1936 i++) { 1924 i++) {
1937 if (!CompileBuiltin(isolate(), i)) return false; 1925 if (!CompileBuiltin(isolate(), i)) return false;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2062 "native " file) == 0) { \ 2050 "native " file) == 0) { \
2063 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \ 2051 if (!CompileExperimentalBuiltin(isolate(), i)) return false; \
2064 } 2052 }
2065 2053
2066 2054
2067 bool Genesis::InstallExperimentalNatives() { 2055 bool Genesis::InstallExperimentalNatives() {
2068 for (int i = ExperimentalNatives::GetDebuggerCount(); 2056 for (int i = ExperimentalNatives::GetDebuggerCount();
2069 i < ExperimentalNatives::GetBuiltinsCount(); 2057 i < ExperimentalNatives::GetBuiltinsCount();
2070 i++) { 2058 i++) {
2071 INSTALL_EXPERIMENTAL_NATIVE(i, proxies, "proxy.js") 2059 INSTALL_EXPERIMENTAL_NATIVE(i, proxies, "proxy.js")
2072 INSTALL_EXPERIMENTAL_NATIVE(i, collections, "collection.js")
2073 INSTALL_EXPERIMENTAL_NATIVE(i, collections, "collection-iterator.js")
2074 INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js") 2060 INSTALL_EXPERIMENTAL_NATIVE(i, generators, "generator.js")
2075 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "array-iterator.js") 2061 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "array-iterator.js")
2076 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "string-iterator.js") 2062 INSTALL_EXPERIMENTAL_NATIVE(i, iteration, "string-iterator.js")
2077 INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js") 2063 INSTALL_EXPERIMENTAL_NATIVE(i, strings, "harmony-string.js")
2078 INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js") 2064 INSTALL_EXPERIMENTAL_NATIVE(i, arrays, "harmony-array.js")
2079 } 2065 }
2080 2066
2081 InstallExperimentalNativeFunctions(); 2067 InstallExperimentalNativeFunctions();
2082 return true; 2068 return true;
2083 } 2069 }
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 return from + sizeof(NestingCounterType); 2715 return from + sizeof(NestingCounterType);
2730 } 2716 }
2731 2717
2732 2718
2733 // Called when the top-level V8 mutex is destroyed. 2719 // Called when the top-level V8 mutex is destroyed.
2734 void Bootstrapper::FreeThreadResources() { 2720 void Bootstrapper::FreeThreadResources() {
2735 DCHECK(!IsActive()); 2721 DCHECK(!IsActive());
2736 } 2722 }
2737 2723
2738 } } // namespace v8::internal 2724 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698