Index: src/x64/full-codegen-x64.cc |
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc |
index 564c3def865d6b3535209e5bcf8fb32f19605a3c..e219b8cf1dc93c84feb12e6b1203de1a565d3415 100644 |
--- a/src/x64/full-codegen-x64.cc |
+++ b/src/x64/full-codegen-x64.cc |
@@ -1907,6 +1907,60 @@ void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
} |
+void FullCodeGenerator::VisitYield(Yield* expr) { |
+ Comment cmnt(masm_, "[ Yield"); |
+ // Evaluate yielded value first; the initial iterator definition depends on |
+ // this. It stays on the stack while we update the iterator. |
+ VisitForStackValue(expr->expression()); |
+ |
+ switch (expr->yield_kind()) { |
+ case Yield::INITIAL: |
+ case Yield::SUSPEND: { |
+ VisitForStackValue(expr->generator_object()); |
+ __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
+ __ movq(context_register(), |
+ Operand(rbp, StandardFrameConstants::kContextOffset)); |
+ |
+ Label resume; |
+ __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex); |
+ __ j(not_equal, &resume); |
+ __ pop(result_register()); |
+ if (expr->yield_kind() == Yield::SUSPEND) { |
+ // TODO(wingo): Box into { value: VALUE, done: false }. |
+ } |
+ EmitReturnSequence(); |
+ |
+ __ bind(&resume); |
+ context()->Plug(result_register()); |
+ break; |
+ } |
+ |
+ case Yield::FINAL: { |
+ VisitForAccumulatorValue(expr->generator_object()); |
+ __ Move(FieldOperand(result_register(), |
+ JSGeneratorObject::kContinuationOffset), |
+ Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); |
+ __ pop(result_register()); |
+ // TODO(wingo): Box into { value: VALUE, done: true }. |
+ |
+ // Exit all nested statements. |
+ NestedStatement* current = nesting_stack_; |
+ int stack_depth = 0; |
+ int context_length = 0; |
+ while (current != NULL) { |
+ current = current->Exit(&stack_depth, &context_length); |
+ } |
+ __ Drop(stack_depth); |
+ EmitReturnSequence(); |
+ break; |
+ } |
+ |
+ case Yield::DELEGATING: |
+ UNIMPLEMENTED(); |
+ } |
+} |
+ |
+ |
void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
SetSourcePosition(prop->position()); |
Literal* key = prop->key()->AsLiteral(); |