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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 context()->Plug(result_register()); | 1662 context()->Plug(result_register()); |
1663 break; | 1663 break; |
1664 case KEYED_PROPERTY: | 1664 case KEYED_PROPERTY: |
1665 EmitKeyedPropertyAssignment(expr); | 1665 EmitKeyedPropertyAssignment(expr); |
1666 break; | 1666 break; |
1667 } | 1667 } |
1668 } | 1668 } |
1669 | 1669 |
1670 | 1670 |
1671 void FullCodeGenerator::VisitYield(Yield* expr) { | 1671 void FullCodeGenerator::VisitYield(Yield* expr) { |
1672 Comment cmnt(masm_, "[ Yield"); | 1672 // Resumable functions are not supported. |
1673 SetExpressionPosition(expr); | 1673 UNREACHABLE(); |
1674 | |
1675 // Evaluate yielded value first; the initial iterator definition depends on | |
1676 // this. It stays on the stack while we update the iterator. | |
1677 VisitForStackValue(expr->expression()); | |
1678 | |
1679 Label suspend, continuation, post_runtime, resume, exception; | |
1680 | |
1681 __ jmp(&suspend); | |
1682 __ bind(&continuation); | |
1683 // When we arrive here, eax holds the generator object. | |
1684 __ RecordGeneratorContinuation(); | |
1685 __ mov(ebx, FieldOperand(eax, JSGeneratorObject::kResumeModeOffset)); | |
1686 __ mov(eax, FieldOperand(eax, JSGeneratorObject::kInputOrDebugPosOffset)); | |
1687 STATIC_ASSERT(JSGeneratorObject::kNext < JSGeneratorObject::kReturn); | |
1688 STATIC_ASSERT(JSGeneratorObject::kThrow > JSGeneratorObject::kReturn); | |
1689 __ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::kReturn))); | |
1690 __ j(less, &resume); | |
1691 __ Push(result_register()); | |
1692 __ j(greater, &exception); | |
1693 EmitCreateIteratorResult(true); | |
1694 EmitUnwindAndReturn(); | |
1695 | |
1696 __ bind(&exception); | |
1697 __ CallRuntime(expr->rethrow_on_exception() ? Runtime::kReThrow | |
1698 : Runtime::kThrow); | |
1699 | |
1700 __ bind(&suspend); | |
1701 OperandStackDepthIncrement(1); // Not popped on this path. | |
1702 VisitForAccumulatorValue(expr->generator_object()); | |
1703 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | |
1704 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), | |
1705 Immediate(Smi::FromInt(continuation.pos()))); | |
1706 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); | |
1707 __ mov(ecx, esi); | |
1708 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, | |
1709 kDontSaveFPRegs); | |
1710 __ lea(ebx, Operand(ebp, StandardFrameConstants::kExpressionsOffset)); | |
1711 __ cmp(esp, ebx); | |
1712 __ j(equal, &post_runtime); | |
1713 __ push(eax); // generator object | |
1714 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | |
1715 RestoreContext(); | |
1716 __ bind(&post_runtime); | |
1717 PopOperand(result_register()); | |
1718 EmitReturnSequence(); | |
1719 | |
1720 __ bind(&resume); | |
1721 context()->Plug(result_register()); | |
1722 } | 1674 } |
1723 | 1675 |
1724 void FullCodeGenerator::PushOperand(MemOperand operand) { | 1676 void FullCodeGenerator::PushOperand(MemOperand operand) { |
1725 OperandStackDepthIncrement(1); | 1677 OperandStackDepthIncrement(1); |
1726 __ Push(operand); | 1678 __ Push(operand); |
1727 } | 1679 } |
1728 | 1680 |
1729 void FullCodeGenerator::EmitOperandStackDepthCheck() { | 1681 void FullCodeGenerator::EmitOperandStackDepthCheck() { |
1730 if (FLAG_debug_code) { | 1682 if (FLAG_debug_code) { |
1731 int expected_diff = StandardFrameConstants::kFixedFrameSizeFromFp + | 1683 int expected_diff = StandardFrameConstants::kFixedFrameSizeFromFp + |
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3519 isolate->builtins()->OnStackReplacement()->entry(), | 3471 isolate->builtins()->OnStackReplacement()->entry(), |
3520 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3472 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3521 return ON_STACK_REPLACEMENT; | 3473 return ON_STACK_REPLACEMENT; |
3522 } | 3474 } |
3523 | 3475 |
3524 | 3476 |
3525 } // namespace internal | 3477 } // namespace internal |
3526 } // namespace v8 | 3478 } // namespace v8 |
3527 | 3479 |
3528 #endif // V8_TARGET_ARCH_X87 | 3480 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |