Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index 7288f38171eb75f6c4e15106817249b4b0b950fe..843b8d701cbcb3cf2b09d3eedf80bc2cb65c1852 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -2292,6 +2292,31 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { |
} |
+RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSGeneratorObject) { |
+ NoHandleAllocation ha(isolate); |
+ ASSERT(args.length() == 0); |
+ JavaScriptFrameIterator it(isolate); |
+ JavaScriptFrame* frame = it.frame(); |
+ JSFunction* function = JSFunction::cast(frame->function()); |
+ RUNTIME_ASSERT(function->shared()->is_generator()); |
+ |
+ JSGeneratorObject* generator; |
+ if (frame->IsConstructor()) { |
+ generator = JSGeneratorObject::cast(frame->receiver()); |
+ } else { |
+ MaybeObject* maybe_generator = |
+ isolate->heap()->AllocateJSGeneratorObject(function); |
+ if (!maybe_generator->To(&generator)) return maybe_generator; |
+ } |
+ generator->set_function(function); |
+ generator->set_context(isolate->heap()->undefined_value()); |
+ generator->set_continuation(0); |
+ generator->set_operand_stack(isolate->heap()->empty_fixed_array()); |
+ |
+ return generator; |
+} |
+ |
+ |
MUST_USE_RESULT static MaybeObject* CharFromCode(Isolate* isolate, |
Object* char_code) { |
uint32_t code; |