Commit c10ab101 authored by Chunyang Dai's avatar Chunyang Dai Committed by Weiliang Lin

X87: Leaving a generator via an exception causes it to close

port 24a7ee877e1fe2ba0a52d69061946aeda7c26c10 (r25297)

original commit message:

  Leaving a generator via an exception causes it to close

BUG=
R=weiliang.lin@intel.com

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

Patch from Chunyang Dai <chunyang.dai@intel.com>.

Cr-Commit-Position: refs/heads/master@{#25316}
parent b96309b7
...@@ -2112,15 +2112,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2112,15 +2112,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
VisitForAccumulatorValue(value); VisitForAccumulatorValue(value);
__ pop(ebx); __ pop(ebx);
// Check generator state.
Label wrong_state, closed_state, done;
STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
__ cmp(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
Immediate(Smi::FromInt(0)));
__ j(equal, &closed_state);
__ j(less, &wrong_state);
// Load suspended function and context. // Load suspended function and context.
__ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset)); __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset));
__ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset)); __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
...@@ -2142,7 +2133,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2142,7 +2133,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);
...@@ -2189,25 +2180,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, ...@@ -2189,25 +2180,6 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Not reached: the runtime call returns elsewhere. // Not reached: the runtime call returns elsewhere.
__ Abort(kGeneratorFailedToResume); __ Abort(kGeneratorFailedToResume);
// Reach here when generator is closed.
__ bind(&closed_state);
if (resume_mode == JSGeneratorObject::NEXT) {
// Return completed iterator result when generator is closed.
__ push(Immediate(isolate()->factory()->undefined_value()));
// Pop value from top-of-stack slot; box result into result register.
EmitCreateIteratorResult(true);
} else {
// Throw the provided value.
__ push(eax);
__ CallRuntime(Runtime::kThrow, 1);
}
__ jmp(&done);
// Throw error if we attempt to operate on a running generator.
__ bind(&wrong_state);
__ push(ebx);
__ 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