OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
8 #include "src/ast/compile-time-value.h" | 8 #include "src/ast/compile-time-value.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 context()->Plug(result_register()); | 1670 context()->Plug(result_register()); |
1671 break; | 1671 break; |
1672 case KEYED_PROPERTY: | 1672 case KEYED_PROPERTY: |
1673 EmitKeyedPropertyAssignment(expr); | 1673 EmitKeyedPropertyAssignment(expr); |
1674 break; | 1674 break; |
1675 } | 1675 } |
1676 } | 1676 } |
1677 | 1677 |
1678 | 1678 |
1679 void FullCodeGenerator::VisitYield(Yield* expr) { | 1679 void FullCodeGenerator::VisitYield(Yield* expr) { |
1680 Comment cmnt(masm_, "[ Yield"); | 1680 // Resumable functions are not supported. |
1681 SetExpressionPosition(expr); | 1681 UNREACHABLE(); |
1682 | |
1683 // Evaluate yielded value first; the initial iterator definition depends on | |
1684 // this. It stays on the stack while we update the iterator. | |
1685 VisitForStackValue(expr->expression()); | |
1686 | |
1687 Label suspend, continuation, post_runtime, resume, exception; | |
1688 | |
1689 __ jmp(&suspend); | |
1690 __ bind(&continuation); | |
1691 // When we arrive here, eax holds the generator object. | |
1692 __ RecordGeneratorContinuation(); | |
1693 __ mov(ebx, FieldOperand(eax, JSGeneratorObject::kResumeModeOffset)); | |
1694 __ mov(eax, FieldOperand(eax, JSGeneratorObject::kInputOrDebugPosOffset)); | |
1695 STATIC_ASSERT(JSGeneratorObject::kNext < JSGeneratorObject::kReturn); | |
1696 STATIC_ASSERT(JSGeneratorObject::kThrow > JSGeneratorObject::kReturn); | |
1697 __ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::kReturn))); | |
1698 __ j(less, &resume); | |
1699 __ Push(result_register()); | |
1700 __ j(greater, &exception); | |
1701 EmitCreateIteratorResult(true); | |
1702 EmitUnwindAndReturn(); | |
1703 | |
1704 __ bind(&exception); | |
1705 __ CallRuntime(expr->rethrow_on_exception() ? Runtime::kReThrow | |
1706 : Runtime::kThrow); | |
1707 | |
1708 __ bind(&suspend); | |
1709 OperandStackDepthIncrement(1); // Not popped on this path. | |
1710 VisitForAccumulatorValue(expr->generator_object()); | |
1711 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | |
1712 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), | |
1713 Immediate(Smi::FromInt(continuation.pos()))); | |
1714 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); | |
1715 __ mov(ecx, esi); | |
1716 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, | |
1717 kDontSaveFPRegs); | |
1718 __ lea(ebx, Operand(ebp, StandardFrameConstants::kExpressionsOffset)); | |
1719 __ cmp(esp, ebx); | |
1720 __ j(equal, &post_runtime); | |
1721 __ push(eax); // generator object | |
1722 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | |
1723 RestoreContext(); | |
1724 __ bind(&post_runtime); | |
1725 PopOperand(result_register()); | |
1726 EmitReturnSequence(); | |
1727 | |
1728 __ bind(&resume); | |
1729 context()->Plug(result_register()); | |
1730 } | 1682 } |
1731 | 1683 |
1732 void FullCodeGenerator::PushOperand(MemOperand operand) { | 1684 void FullCodeGenerator::PushOperand(MemOperand operand) { |
1733 OperandStackDepthIncrement(1); | 1685 OperandStackDepthIncrement(1); |
1734 __ Push(operand); | 1686 __ Push(operand); |
1735 } | 1687 } |
1736 | 1688 |
1737 void FullCodeGenerator::EmitOperandStackDepthCheck() { | 1689 void FullCodeGenerator::EmitOperandStackDepthCheck() { |
1738 if (FLAG_debug_code) { | 1690 if (FLAG_debug_code) { |
1739 int expected_diff = StandardFrameConstants::kFixedFrameSizeFromFp + | 1691 int expected_diff = StandardFrameConstants::kFixedFrameSizeFromFp + |
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3527 isolate->builtins()->OnStackReplacement()->entry(), | 3479 isolate->builtins()->OnStackReplacement()->entry(), |
3528 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3480 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3529 return ON_STACK_REPLACEMENT; | 3481 return ON_STACK_REPLACEMENT; |
3530 } | 3482 } |
3531 | 3483 |
3532 | 3484 |
3533 } // namespace internal | 3485 } // namespace internal |
3534 } // namespace v8 | 3486 } // namespace v8 |
3535 | 3487 |
3536 #endif // V8_TARGET_ARCH_IA32 | 3488 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |