Index: src/full-codegen/mips64/full-codegen-mips64.cc |
diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc |
index c9075f5f5171a380d5790edd388221cfa96af8df..91f9b6cd5a31ed8fd34c393ed65d867aab9d76f8 100644 |
--- a/src/full-codegen/mips64/full-codegen-mips64.cc |
+++ b/src/full-codegen/mips64/full-codegen-mips64.cc |
@@ -1839,7 +1839,7 @@ void FullCodeGenerator::VisitYield(Yield* expr) { |
// this. It stays on the stack while we update the iterator. |
VisitForStackValue(expr->expression()); |
- Label suspend, continuation, post_runtime, resume; |
+ Label suspend, continuation, post_runtime, resume, exception; |
__ jmp(&suspend); |
__ bind(&continuation); |
@@ -1848,11 +1848,16 @@ void FullCodeGenerator::VisitYield(Yield* expr) { |
// respective resume operation). |
__ RecordGeneratorContinuation(); |
__ pop(a1); |
- __ Branch(&resume, ne, a1, Operand(Smi::FromInt(JSGeneratorObject::RETURN))); |
- __ push(result_register()); |
+ __ Branch(&resume, eq, a1, Operand(Smi::FromInt(JSGeneratorObject::kNext))); |
+ __ Push(result_register()); |
+ __ Branch(&exception, eq, a1, |
+ Operand(Smi::FromInt(JSGeneratorObject::kThrow))); |
EmitCreateIteratorResult(true); |
EmitUnwindAndReturn(); |
+ __ bind(&exception); |
+ __ CallRuntime(Runtime::kThrow); |
+ |
__ bind(&suspend); |
OperandStackDepthIncrement(1); // Not popped on this path. |
VisitForAccumulatorValue(expr->generator_object()); |
@@ -1876,105 +1881,6 @@ void FullCodeGenerator::VisitYield(Yield* expr) { |
context()->Plug(result_register()); |
} |
- |
-void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
- Expression *value, |
- JSGeneratorObject::ResumeMode resume_mode) { |
- // The value stays in a0, and is ultimately read by the resumed generator, as |
- // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
- // is read to throw the value when the resumed generator is already closed. |
- // a1 will hold the generator object until the activation has been resumed. |
- VisitForStackValue(generator); |
- VisitForAccumulatorValue(value); |
- PopOperand(a1); |
- |
- // Store input value into generator object. |
- __ sd(result_register(), |
- FieldMemOperand(a1, JSGeneratorObject::kInputOffset)); |
- __ mov(a2, result_register()); |
- __ RecordWriteField(a1, JSGeneratorObject::kInputOffset, a2, a3, |
- kRAHasBeenSaved, kDontSaveFPRegs); |
- |
- // Load suspended function and context. |
- __ ld(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); |
- __ ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); |
- |
- // Load receiver and store as the first argument. |
- __ ld(a2, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset)); |
- __ push(a2); |
- |
- // Push holes for arguments to generator function. Since the parser forced |
- // context allocation for any variables in generators, the actual argument |
- // values have already been copied into the context and these dummy values |
- // will never be used. |
- __ ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); |
- // The argument count is stored as int32_t on 64-bit platforms. |
- // TODO(plind): Smi on 32-bit platforms. |
- __ lw(a3, |
- FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); |
- __ LoadRoot(a2, Heap::kTheHoleValueRootIndex); |
- Label push_argument_holes, push_frame; |
- __ bind(&push_argument_holes); |
- __ Dsubu(a3, a3, Operand(1)); |
- __ Branch(&push_frame, lt, a3, Operand(zero_reg)); |
- __ push(a2); |
- __ jmp(&push_argument_holes); |
- |
- // Enter a new JavaScript frame, and initialize its slots as they were when |
- // the generator was suspended. |
- Label resume_frame, done; |
- __ bind(&push_frame); |
- __ Call(&resume_frame); |
- __ jmp(&done); |
- __ bind(&resume_frame); |
- // ra = return address. |
- // fp = caller's frame pointer. |
- // cp = callee's context, |
- // a4 = callee's JS function. |
- __ PushStandardFrame(a4); |
- |
- // Load the operand stack size. |
- __ ld(a3, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset)); |
- __ ld(a3, FieldMemOperand(a3, FixedArray::kLengthOffset)); |
- __ SmiUntag(a3); |
- |
- // If we are sending a value and there is no operand stack, we can jump back |
- // in directly. |
- if (resume_mode == JSGeneratorObject::NEXT) { |
- Label slow_resume; |
- __ Branch(&slow_resume, ne, a3, Operand(zero_reg)); |
- __ ld(a3, FieldMemOperand(a4, JSFunction::kCodeEntryOffset)); |
- __ ld(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
- __ SmiUntag(a2); |
- __ Daddu(a3, a3, Operand(a2)); |
- __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
- __ sd(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
- __ Jump(a3); |
- __ bind(&slow_resume); |
- } |
- |
- // Otherwise, we push holes for the operand stack and call the runtime to fix |
- // up the stack and the handlers. |
- Label push_operand_holes, call_resume; |
- __ bind(&push_operand_holes); |
- __ Dsubu(a3, a3, Operand(1)); |
- __ Branch(&call_resume, lt, a3, Operand(zero_reg)); |
- __ push(a2); |
- __ Branch(&push_operand_holes); |
- __ bind(&call_resume); |
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
- DCHECK(!result_register().is(a1)); |
- __ Push(a1, result_register()); |
- __ Push(Smi::FromInt(resume_mode)); |
- __ CallRuntime(Runtime::kResumeJSGeneratorObject); |
- // Not reached: the runtime call returns elsewhere. |
- __ stop("not-reached"); |
- |
- __ bind(&done); |
- context()->Plug(result_register()); |
-} |
- |
void FullCodeGenerator::PushOperands(Register reg1, Register reg2) { |
OperandStackDepthIncrement(2); |
__ Push(reg1, reg2); |