Chromium Code Reviews| Index: src/ia32/full-codegen-ia32.cc |
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
| index 54e9eaf1d60969a65cd0ac17dd852e1a3bcf411e..21b2a3add69f2d28fdaeeb4f6fdf07f01a967194 100644 |
| --- a/src/ia32/full-codegen-ia32.cc |
| +++ b/src/ia32/full-codegen-ia32.cc |
| @@ -1953,14 +1953,30 @@ 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())); |
| + __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), |
| + Immediate(Smi::FromInt(continuation.pos()))); |
|
Michael Starzinger
2013/06/20 12:08:32
It's too bad that we cannot reliably predict the b
|
| + __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); |
| + __ mov(ecx, esi); |
| + __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, |
| + kDontSaveFPRegs); |
| + __ lea(ebx, Operand(ebp, StandardFrameConstants::kExpressionsOffset)); |
| + __ cmp(esp, ebx); |
| + __ j(equal, &post_runtime); |
| + __ push(eax); // generator object |
| __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| __ mov(context_register(), |
| Operand(ebp, StandardFrameConstants::kContextOffset)); |
| - |
| - Label resume; |
| - __ CompareRoot(result_register(), Heap::kTheHoleValueRootIndex); |
| - __ j(not_equal, &resume); |
| + __ bind(&post_runtime); |
| __ pop(result_register()); |
| EmitReturnSequence(); |
| @@ -1988,7 +2004,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. |
| __ mov(eax, isolate()->factory()->undefined_value()); |
| __ jmp(&l_next); |
| @@ -2010,12 +2027,22 @@ void FullCodeGenerator::VisitYield(Yield* expr) { |
| __ PushTryHandler(StackHandler::CATCH, expr->index()); |
| const int handler_size = StackHandlerConstants::kSize; |
| __ push(eax); // result |
| - __ push(Operand(esp, (0 + 1) * kPointerSize + handler_size)); // g |
| + __ jmp(&l_suspend); |
| + __ bind(&l_continuation); |
| + __ jmp(&l_resume); |
| + __ bind(&l_suspend); |
| + __ mov(eax, Operand(esp, (0 + 1) * kPointerSize + handler_size)); // g |
|
Michael Starzinger
2013/06/20 12:08:32
nit: The trailing '// g' comment is somewhat dupli
|
| + __ push(eax); // g |
| + ASSERT(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
| + __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), |
| + Immediate(Smi::FromInt(l_continuation.pos()))); |
| + __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); |
| + __ mov(ecx, esi); |
| + __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, |
| + kDontSaveFPRegs); |
| __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| __ mov(context_register(), |
| Operand(ebp, StandardFrameConstants::kContextOffset)); |
| - __ CompareRoot(eax, Heap::kTheHoleValueRootIndex); |
| - __ j(not_equal, &l_resume); |
| __ pop(eax); // result |
| EmitReturnSequence(); |
| __ bind(&l_resume); // received in eax |