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 "bootstrapper.h" | 5 #include "bootstrapper.h" |
6 | 6 |
7 #include "accessors.h" | 7 #include "accessors.h" |
8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
9 #include "natives.h" | 9 #include "natives.h" |
10 #include "snapshot.h" | 10 #include "snapshot.h" |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1297 { // -- M a p | 1297 { // -- M a p |
1298 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, | 1298 InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize, |
1299 isolate()->initial_object_prototype(), | 1299 isolate()->initial_object_prototype(), |
1300 Builtins::kIllegal, true, true); | 1300 Builtins::kIllegal, true, true); |
1301 } | 1301 } |
1302 { // -- S e t | 1302 { // -- S e t |
1303 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, | 1303 InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize, |
1304 isolate()->initial_object_prototype(), | 1304 isolate()->initial_object_prototype(), |
1305 Builtins::kIllegal, true, true); | 1305 Builtins::kIllegal, true, true); |
1306 } | 1306 } |
| 1307 { // -- S e t I t e r a t o r |
| 1308 Handle<Map> map = isolate()->factory()->NewMap( |
| 1309 JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); |
| 1310 native_context()->set_set_iterator_map(*map); |
| 1311 } |
| 1312 { // -- M a p I t e r a t o r |
| 1313 Handle<Map> map = isolate()->factory()->NewMap( |
| 1314 JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize); |
| 1315 native_context()->set_map_iterator_map(*map); |
| 1316 } |
1307 } | 1317 } |
1308 | 1318 |
1309 if (FLAG_harmony_weak_collections) { | 1319 if (FLAG_harmony_weak_collections) { |
1310 { // -- W e a k M a p | 1320 { // -- W e a k M a p |
1311 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, | 1321 InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize, |
1312 isolate()->initial_object_prototype(), | 1322 isolate()->initial_object_prototype(), |
1313 Builtins::kIllegal, true, true); | 1323 Builtins::kIllegal, true, true); |
1314 } | 1324 } |
1315 { // -- W e a k S e t | 1325 { // -- W e a k S e t |
1316 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, | 1326 InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 native_context()->set_strict_generator_function_map( | 1361 native_context()->set_strict_generator_function_map( |
1352 *strict_mode_generator_function_map); | 1362 *strict_mode_generator_function_map); |
1353 | 1363 |
1354 Handle<JSFunction> object_function(native_context()->object_function()); | 1364 Handle<JSFunction> object_function(native_context()->object_function()); |
1355 Handle<Map> generator_object_prototype_map = Map::Create( | 1365 Handle<Map> generator_object_prototype_map = Map::Create( |
1356 object_function, 0); | 1366 object_function, 0); |
1357 generator_object_prototype_map->set_prototype( | 1367 generator_object_prototype_map->set_prototype( |
1358 *generator_object_prototype); | 1368 *generator_object_prototype); |
1359 native_context()->set_generator_object_prototype_map( | 1369 native_context()->set_generator_object_prototype_map( |
1360 *generator_object_prototype_map); | 1370 *generator_object_prototype_map); |
| 1371 } |
1361 | 1372 |
1362 // Create a map for generator result objects. | 1373 if (FLAG_harmony_collections || FLAG_harmony_generators) { |
| 1374 // Collection forEach uses an iterator result object. |
| 1375 // Generators return iteraror result objects. |
| 1376 |
| 1377 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); |
| 1378 Handle<JSFunction> object_function(native_context()->object_function()); |
1363 ASSERT(object_function->initial_map()->inobject_properties() == 0); | 1379 ASSERT(object_function->initial_map()->inobject_properties() == 0); |
1364 STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); | 1380 Handle<Map> iterator_result_map = Map::Create( |
1365 Handle<Map> generator_result_map = Map::Create( | |
1366 object_function, JSGeneratorObject::kResultPropertyCount); | 1381 object_function, JSGeneratorObject::kResultPropertyCount); |
1367 ASSERT(generator_result_map->inobject_properties() == | 1382 ASSERT(iterator_result_map->inobject_properties() == |
1368 JSGeneratorObject::kResultPropertyCount); | 1383 JSGeneratorObject::kResultPropertyCount); |
1369 Map::EnsureDescriptorSlack( | 1384 Map::EnsureDescriptorSlack( |
1370 generator_result_map, JSGeneratorObject::kResultPropertyCount); | 1385 iterator_result_map, JSGeneratorObject::kResultPropertyCount); |
1371 | 1386 |
1372 Handle<String> value_string = factory()->InternalizeOneByteString( | 1387 FieldDescriptor value_descr(isolate()->factory()->value_string(), |
1373 STATIC_ASCII_VECTOR("value")); | |
1374 FieldDescriptor value_descr(value_string, | |
1375 JSGeneratorObject::kResultValuePropertyIndex, | 1388 JSGeneratorObject::kResultValuePropertyIndex, |
1376 NONE, | 1389 NONE, |
1377 Representation::Tagged()); | 1390 Representation::Tagged()); |
1378 generator_result_map->AppendDescriptor(&value_descr); | 1391 iterator_result_map->AppendDescriptor(&value_descr); |
1379 | 1392 |
1380 Handle<String> done_string = factory()->InternalizeOneByteString( | 1393 FieldDescriptor done_descr(isolate()->factory()->done_string(), |
1381 STATIC_ASCII_VECTOR("done")); | |
1382 FieldDescriptor done_descr(done_string, | |
1383 JSGeneratorObject::kResultDonePropertyIndex, | 1394 JSGeneratorObject::kResultDonePropertyIndex, |
1384 NONE, | 1395 NONE, |
1385 Representation::Tagged()); | 1396 Representation::Tagged()); |
1386 generator_result_map->AppendDescriptor(&done_descr); | 1397 iterator_result_map->AppendDescriptor(&done_descr); |
1387 | 1398 |
1388 generator_result_map->set_unused_property_fields(0); | 1399 iterator_result_map->set_unused_property_fields(0); |
1389 ASSERT_EQ(JSGeneratorObject::kResultSize, | 1400 ASSERT_EQ(JSGeneratorObject::kResultSize, |
1390 generator_result_map->instance_size()); | 1401 iterator_result_map->instance_size()); |
1391 native_context()->set_generator_result_map(*generator_result_map); | 1402 native_context()->set_iterator_result_map(*iterator_result_map); |
1392 } | 1403 } |
1393 } | 1404 } |
1394 | 1405 |
1395 | 1406 |
1396 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { | 1407 bool Genesis::CompileBuiltin(Isolate* isolate, int index) { |
1397 Vector<const char> name = Natives::GetScriptName(index); | 1408 Vector<const char> name = Natives::GetScriptName(index); |
1398 Handle<String> source_code = | 1409 Handle<String> source_code = |
1399 isolate->bootstrapper()->NativesSourceLookup(index); | 1410 isolate->bootstrapper()->NativesSourceLookup(index); |
1400 return CompileNative(isolate, name, source_code); | 1411 return CompileNative(isolate, name, source_code); |
1401 } | 1412 } |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2680 return from + sizeof(NestingCounterType); | 2691 return from + sizeof(NestingCounterType); |
2681 } | 2692 } |
2682 | 2693 |
2683 | 2694 |
2684 // Called when the top-level V8 mutex is destroyed. | 2695 // Called when the top-level V8 mutex is destroyed. |
2685 void Bootstrapper::FreeThreadResources() { | 2696 void Bootstrapper::FreeThreadResources() { |
2686 ASSERT(!IsActive()); | 2697 ASSERT(!IsActive()); |
2687 } | 2698 } |
2688 | 2699 |
2689 } } // namespace v8::internal | 2700 } } // namespace v8::internal |
OLD | NEW |