Chromium Code Reviews| Index: src/bootstrapper.cc |
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc |
| index ba08aade83504d3848ad43347c08ccef94d8884e..707be5c2295aaebba8081edc9b34d0ea1f80a154 100644 |
| --- a/src/bootstrapper.cc |
| +++ b/src/bootstrapper.cc |
| @@ -1357,16 +1357,21 @@ void Genesis::InitializeExperimentalGlobal() { |
| *generator_object_prototype); |
| native_context()->set_generator_object_prototype_map( |
| *generator_object_prototype_map); |
| - |
| - // Create a map for generator result objects. |
| ASSERT(object_function->initial_map()->inobject_properties() == 0); |
| + } |
| + |
| + if (FLAG_harmony_collections || FLAG_harmony_generators) { |
| + // Collection forEach uses an iterator result object. |
| + // Generators return iteraror result objects. |
| + |
| STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2); |
| - Handle<Map> generator_result_map = Map::Create( |
| + Handle<JSFunction> object_function(native_context()->object_function()); |
| + Handle<Map> iterator_result_map = Map::Create( |
| object_function, JSGeneratorObject::kResultPropertyCount); |
| - ASSERT(generator_result_map->inobject_properties() == |
| + ASSERT(iterator_result_map->inobject_properties() == |
| JSGeneratorObject::kResultPropertyCount); |
| Map::EnsureDescriptorSlack( |
| - generator_result_map, JSGeneratorObject::kResultPropertyCount); |
| + iterator_result_map, JSGeneratorObject::kResultPropertyCount); |
| Handle<String> value_string = factory()->InternalizeOneByteString( |
| STATIC_ASCII_VECTOR("value")); |
| @@ -1374,7 +1379,7 @@ void Genesis::InitializeExperimentalGlobal() { |
| JSGeneratorObject::kResultValuePropertyIndex, |
| NONE, |
| Representation::Tagged()); |
| - generator_result_map->AppendDescriptor(&value_descr); |
| + iterator_result_map->AppendDescriptor(&value_descr); |
| Handle<String> done_string = factory()->InternalizeOneByteString( |
| STATIC_ASCII_VECTOR("done")); |
| @@ -1382,12 +1387,25 @@ void Genesis::InitializeExperimentalGlobal() { |
| JSGeneratorObject::kResultDonePropertyIndex, |
| NONE, |
| Representation::Tagged()); |
| - generator_result_map->AppendDescriptor(&done_descr); |
| + iterator_result_map->AppendDescriptor(&done_descr); |
| - generator_result_map->set_unused_property_fields(0); |
| + iterator_result_map->set_unused_property_fields(0); |
| ASSERT_EQ(JSGeneratorObject::kResultSize, |
| - generator_result_map->instance_size()); |
| - native_context()->set_generator_result_map(*generator_result_map); |
| + iterator_result_map->instance_size()); |
| + native_context()->set_iterator_result_map(*iterator_result_map); |
| + } |
| + |
| + if (FLAG_harmony_collections) { |
| + { // -- S e t I t e r a t o r |
| + Handle<Map> map = isolate()->factory()->NewMap( |
|
adamk
2014/04/14 22:46:38
Please move these up to their associated collectio
arv (Not doing code reviews)
2014/04/15 00:29:17
Done.
|
| + JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); |
| + native_context()->set_set_iterator_map(*map); |
| + } |
| + { // -- M a p I t e r a t o r |
| + Handle<Map> map = isolate()->factory()->NewMap( |
| + JS_MAP_ITERATOR_TYPE, JSMapIterator::kSize); |
| + native_context()->set_map_iterator_map(*map); |
| + } |
| } |
| } |