Index: src/heap.cc |
diff --git a/src/heap.cc b/src/heap.cc |
index 76f0a3c9a86e052add7782f4600217d317fc5a44..90e39f2a1a9f2e5ed72cac384977cd15f4c35f7a 100644 |
--- a/src/heap.cc |
+++ b/src/heap.cc |
@@ -4089,9 +4089,8 @@ MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) { |
int instance_size; |
int in_object_properties; |
if (fun->shared()->is_generator()) { |
- // TODO(wingo): Replace with JS_GENERATOR_OBJECT_TYPE. |
- instance_type = JS_OBJECT_TYPE; |
- instance_size = JSObject::kHeaderSize; |
+ instance_type = JS_GENERATOR_OBJECT_TYPE; |
+ instance_size = JSGeneratorObject::kSize; |
in_object_properties = 0; |
} else { |
instance_type = JS_OBJECT_TYPE; |
@@ -4340,6 +4339,29 @@ MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor, |
} |
+MaybeObject* Heap::AllocateJSGeneratorObject(JSFunction *function) { |
+ ASSERT(function->shared()->is_generator()); |
+ // Allocate the initial map if absent. |
+ if (!function->has_initial_map()) { |
+ Object* initial_map; |
+ MaybeObject* maybe_initial_map = AllocateInitialMap(function); |
+ if (!maybe_initial_map->ToObject(&initial_map)) return maybe_initial_map; |
Michael Starzinger
2013/04/11 19:17:39
Just use "maybe_initial_map->To()" here and make t
wingo
2013/04/12 10:50:17
Done.
|
+ function->set_initial_map(Map::cast(initial_map)); |
+ } |
+ Map *map = function->initial_map(); |
+ ASSERT(map->IsMap()); |
Michael Starzinger
2013/04/11 19:17:39
This assert is obsolete, the accessor should alrea
wingo
2013/04/12 10:50:17
Done.
|
+ ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE); |
+ JSGeneratorObject *generator; |
+ MaybeObject* maybe_generator = AllocateJSObjectFromMap(map, NOT_TENURED); |
Michael Starzinger
2013/04/11 19:17:39
The NOT_TENURED flag should be the default argumen
wingo
2013/04/12 10:50:17
Done.
|
+ if (!maybe_generator->To(&generator)) return maybe_generator; |
+ generator->set_function(function); |
+ generator->set_context(Smi::FromInt(0)); |
+ generator->set_continuation(0); |
+ generator->set_operand_stack(Smi::FromInt(0)); |
+ return generator; |
+} |
+ |
+ |
MaybeObject* Heap::AllocateJSModule(Context* context, ScopeInfo* scope_info) { |
// Allocate a fresh map. Modules do not have a prototype. |
Map* map; |