Index: src/full-codegen/s390/full-codegen-s390.cc |
diff --git a/src/full-codegen/s390/full-codegen-s390.cc b/src/full-codegen/s390/full-codegen-s390.cc |
index 29a7f761b292c340e571835fb45d95d8ce79e9a2..8e92d89d2aae61ef0b584be3344f805ba1546cdd 100644 |
--- a/src/full-codegen/s390/full-codegen-s390.cc |
+++ b/src/full-codegen/s390/full-codegen-s390.cc |
@@ -1754,7 +1754,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; |
__ b(&suspend); |
__ bind(&continuation); |
@@ -1763,12 +1763,18 @@ void FullCodeGenerator::VisitYield(Yield* expr) { |
// respective resume operation). |
__ RecordGeneratorContinuation(); |
__ pop(r3); |
- __ CmpSmiLiteral(r3, Smi::FromInt(JSGeneratorObject::RETURN), r0); |
- __ bne(&resume); |
- __ push(result_register()); |
+ STATIC_ASSERT(JSGeneratorObject::kNext < JSGeneratorObject::kReturn); |
+ STATIC_ASSERT(JSGeneratorObject::kThrow > JSGeneratorObject::kReturn); |
+ __ CmpSmiLiteral(r3, Smi::FromInt(JSGeneratorObject::kReturn), r0); |
+ __ blt(&resume); |
+ __ Push(result_register()); |
+ __ bgt(&exception); |
EmitCreateIteratorResult(true); |
EmitUnwindAndReturn(); |
+ __ bind(&exception); |
+ __ CallRuntime(Runtime::kThrow); |
+ |
__ bind(&suspend); |
OperandStackDepthIncrement(1); // Not popped on this path. |
VisitForAccumulatorValue(expr->generator_object()); |
@@ -1794,113 +1800,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 r2, 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. |
- // r3 will hold the generator object until the activation has been resumed. |
- VisitForStackValue(generator); |
- VisitForAccumulatorValue(value); |
- PopOperand(r3); |
- |
- // Store input value into generator object. |
- __ StoreP(result_register(), |
- FieldMemOperand(r3, JSGeneratorObject::kInputOffset), r0); |
- __ LoadRR(r4, result_register()); |
- __ RecordWriteField(r3, JSGeneratorObject::kInputOffset, r4, r5, |
- kLRHasBeenSaved, kDontSaveFPRegs); |
- |
- // Load suspended function and context. |
- __ LoadP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset)); |
- __ LoadP(r6, FieldMemOperand(r3, JSGeneratorObject::kFunctionOffset)); |
- |
- // Load receiver and store as the first argument. |
- __ LoadP(r4, FieldMemOperand(r3, JSGeneratorObject::kReceiverOffset)); |
- __ push(r4); |
- |
- // 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. |
- __ LoadP(r5, FieldMemOperand(r6, JSFunction::kSharedFunctionInfoOffset)); |
- __ LoadW( |
- r5, FieldMemOperand(r5, SharedFunctionInfo::kFormalParameterCountOffset)); |
- __ LoadRoot(r4, Heap::kTheHoleValueRootIndex); |
- Label argument_loop, push_frame; |
-#if V8_TARGET_ARCH_S390X |
- __ CmpP(r5, Operand::Zero()); |
- __ beq(&push_frame, Label::kNear); |
-#else |
- __ SmiUntag(r5); |
- __ beq(&push_frame, Label::kNear); |
-#endif |
- __ LoadRR(r0, r5); |
- __ bind(&argument_loop); |
- __ push(r4); |
- __ SubP(r0, Operand(1)); |
- __ bne(&argument_loop); |
- |
- // Enter a new JavaScript frame, and initialize its slots as they were when |
- // the generator was suspended. |
- Label resume_frame, done; |
- __ bind(&push_frame); |
- __ b(r14, &resume_frame); // brasl |
- __ b(&done); |
- __ bind(&resume_frame); |
- // lr = return address. |
- // fp = caller's frame pointer. |
- // cp = callee's context, |
- // r6 = callee's JS function. |
- __ PushStandardFrame(r6); |
- |
- // Load the operand stack size. |
- __ LoadP(r5, FieldMemOperand(r3, JSGeneratorObject::kOperandStackOffset)); |
- __ LoadP(r5, FieldMemOperand(r5, FixedArray::kLengthOffset)); |
- __ SmiUntag(r5); |
- |
- // If we are sending a value and there is no operand stack, we can jump back |
- // in directly. |
- Label call_resume; |
- if (resume_mode == JSGeneratorObject::NEXT) { |
- Label slow_resume; |
- __ bne(&slow_resume, Label::kNear); |
- __ LoadP(ip, FieldMemOperand(r6, JSFunction::kCodeEntryOffset)); |
- __ LoadP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset)); |
- __ SmiUntag(r4); |
- __ AddP(ip, ip, r4); |
- __ LoadSmiLiteral(r4, Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); |
- __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset)); |
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
- __ Jump(ip); |
- __ bind(&slow_resume); |
- } else { |
- __ beq(&call_resume); |
- } |
- |
- // Otherwise, we push holes for the operand stack and call the runtime to fix |
- // up the stack and the handlers. |
- Label operand_loop; |
- __ LoadRR(r0, r5); |
- __ bind(&operand_loop); |
- __ push(r4); |
- __ SubP(r0, Operand(1)); |
- __ bne(&operand_loop); |
- |
- __ bind(&call_resume); |
- __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
- DCHECK(!result_register().is(r3)); |
- __ Push(r3, 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); |