Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: src/x64/full-codegen-x64.cc

Issue 15990004: Generators: Avoid calling into runtime if operand stack is empty (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add asserts to runtime.cc; clarify generated runtime call Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/full-codegen-x64.cc
diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
index e5d190ade934156e0e62fbde8150e853ed5956e4..f2d98eb052893a09b2e9eaea4f25af6c5a01bb1d 100644
--- a/src/x64/full-codegen-x64.cc
+++ b/src/x64/full-codegen-x64.cc
@@ -1976,14 +1976,31 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
__ push(result_register());
// Fall through.
case Yield::INITIAL: {
- VisitForStackValue(expr->generator_object());
+ Label suspend, continuation, post_runtime, resume;
+
+ __ jmp(&suspend);
+
+ __ bind(&continuation);
+ __ jmp(&resume);
+
+ __ bind(&suspend);
+ VisitForAccumulatorValue(expr->generator_object());
+ ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos()));
+ __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset),
+ Smi::FromInt(continuation.pos()));
+ __ movq(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi);
+ __ movq(rcx, rsi);
+ __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx,
+ kDontSaveFPRegs);
+ __ lea(rbx, Operand(rbp, StandardFrameConstants::kExpressionsOffset));
+ __ cmpq(rsp, rbx);
+ __ j(equal, &post_runtime);
+ __ push(rax); // generator object
__ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
__ movq(context_register(),
Operand(rbp, StandardFrameConstants::kContextOffset));
+ __ bind(&post_runtime);
- Label resume;
- __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex);
- __ j(not_equal, &resume);
__ pop(result_register());
EmitReturnSequence();
@@ -2011,7 +2028,8 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
// [sp + 1 * kPointerSize] iter
// [sp + 0 * kPointerSize] g
- Label l_catch, l_try, l_resume, l_next, l_call, l_loop;
+ Label l_catch, l_try, l_suspend, l_continuation, l_resume;
+ Label l_next, l_call, l_loop;
// Initial send value is undefined.
__ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
__ jmp(&l_next);
@@ -2033,12 +2051,23 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
__ PushTryHandler(StackHandler::CATCH, expr->index());
const int handler_size = StackHandlerConstants::kSize;
__ push(rax); // result
- __ push(Operand(rsp, (0 + 1) * kPointerSize + handler_size)); // g
+ __ jmp(&l_suspend);
+ __ bind(&l_continuation);
+ __ jmp(&l_resume);
+ __ bind(&l_suspend);
+ const int generator_object_depth = kPointerSize + handler_size;
+ __ movq(rax, Operand(rsp, generator_object_depth));
+ __ push(rax); // g
+ ASSERT(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos()));
+ __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset),
+ Smi::FromInt(l_continuation.pos()));
+ __ movq(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi);
+ __ movq(rcx, rsi);
+ __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx,
+ kDontSaveFPRegs);
__ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
__ movq(context_register(),
Operand(rbp, StandardFrameConstants::kContextOffset));
- __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
- __ j(not_equal, &l_resume);
__ pop(rax); // result
EmitReturnSequence();
__ bind(&l_resume); // received in rax
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698