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