MIPS: Leaving a generator via an exception causes it to close.

Port 757f4002
Port r25297

BUG=v8:3096
LOG=Y
R=paul.lind@imgtec.com

Review URL: https://codereview.chromium.org/716183004

Cr-Commit-Position: refs/heads/master@{#25304}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25304 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8970ade1
...@@ -2185,14 +2185,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2185,14 +2185,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
VisitForAccumulatorValue(value); VisitForAccumulatorValue(value);
__ pop(a1); __ pop(a1);
// Check generator state.
Label wrong_state, closed_state, done;
__ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
__ Branch(&closed_state, eq, a3, Operand(zero_reg));
__ Branch(&wrong_state, lt, a3, Operand(zero_reg));
// Load suspended function and context. // Load suspended function and context.
__ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
__ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
...@@ -2215,7 +2207,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2215,7 +2207,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Enter a new JavaScript frame, and initialize its slots as they were when // Enter a new JavaScript frame, and initialize its slots as they were when
// the generator was suspended. // the generator was suspended.
Label resume_frame; Label resume_frame, done;
__ bind(&push_frame); __ bind(&push_frame);
__ Call(&resume_frame); __ Call(&resume_frame);
__ jmp(&done); __ jmp(&done);
...@@ -2264,26 +2256,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2264,26 +2256,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Not reached: the runtime call returns elsewhere. // Not reached: the runtime call returns elsewhere.
__ stop("not-reached"); __ stop("not-reached");
// Reach here when generator is closed.
__ bind(&closed_state);
if (resume_mode == JSGeneratorObject::NEXT) {
// Return completed iterator result when generator is closed.
__ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
__ push(a2);
// Pop value from top-of-stack slot; box result into result register.
EmitCreateIteratorResult(true);
} else {
// Throw the provided value.
__ push(a0);
__ CallRuntime(Runtime::kThrow, 1);
}
__ jmp(&done);
// Throw error if we attempt to operate on a running generator.
__ bind(&wrong_state);
__ push(a1);
__ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
__ bind(&done); __ bind(&done);
context()->Plug(result_register()); context()->Plug(result_register());
} }
......
...@@ -2180,14 +2180,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2180,14 +2180,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
VisitForAccumulatorValue(value); VisitForAccumulatorValue(value);
__ pop(a1); __ pop(a1);
// Check generator state.
Label wrong_state, closed_state, done;
__ ld(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
__ Branch(&closed_state, eq, a3, Operand(zero_reg));
__ Branch(&wrong_state, lt, a3, Operand(zero_reg));
// Load suspended function and context. // Load suspended function and context.
__ ld(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset)); __ ld(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
__ ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); __ ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
...@@ -2212,7 +2204,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2212,7 +2204,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Enter a new JavaScript frame, and initialize its slots as they were when // Enter a new JavaScript frame, and initialize its slots as they were when
// the generator was suspended. // the generator was suspended.
Label resume_frame; Label resume_frame, done;
__ bind(&push_frame); __ bind(&push_frame);
__ Call(&resume_frame); __ Call(&resume_frame);
__ jmp(&done); __ jmp(&done);
...@@ -2261,26 +2253,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2261,26 +2253,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Not reached: the runtime call returns elsewhere. // Not reached: the runtime call returns elsewhere.
__ stop("not-reached"); __ stop("not-reached");
// Reach here when generator is closed.
__ bind(&closed_state);
if (resume_mode == JSGeneratorObject::NEXT) {
// Return completed iterator result when generator is closed.
__ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
__ push(a2);
// Pop value from top-of-stack slot; box result into result register.
EmitCreateIteratorResult(true);
} else {
// Throw the provided value.
__ push(a0);
__ CallRuntime(Runtime::kThrow, 1);
}
__ jmp(&done);
// Throw error if we attempt to operate on a running generator.
__ bind(&wrong_state);
__ push(a1);
__ CallRuntime(Runtime::kThrowGeneratorStateError, 1);
__ bind(&done); __ bind(&done);
context()->Plug(result_register()); context()->Plug(result_register());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment