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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 context()->Plug(rax); | 1697 context()->Plug(rax); |
1698 break; | 1698 break; |
1699 case KEYED_PROPERTY: | 1699 case KEYED_PROPERTY: |
1700 EmitKeyedPropertyAssignment(expr); | 1700 EmitKeyedPropertyAssignment(expr); |
1701 break; | 1701 break; |
1702 } | 1702 } |
1703 } | 1703 } |
1704 | 1704 |
1705 | 1705 |
1706 void FullCodeGenerator::VisitYield(Yield* expr) { | 1706 void FullCodeGenerator::VisitYield(Yield* expr) { |
1707 Comment cmnt(masm_, "[ Yield"); | 1707 // Resumable functions are not supported. |
1708 SetExpressionPosition(expr); | 1708 UNREACHABLE(); |
1709 | |
1710 // Evaluate yielded value first; the initial iterator definition depends on | |
1711 // this. It stays on the stack while we update the iterator. | |
1712 VisitForStackValue(expr->expression()); | |
1713 | |
1714 Label suspend, continuation, post_runtime, resume, exception; | |
1715 | |
1716 __ jmp(&suspend); | |
1717 __ bind(&continuation); | |
1718 // When we arrive here, rax holds the generator object. | |
1719 __ RecordGeneratorContinuation(); | |
1720 __ movp(rbx, FieldOperand(rax, JSGeneratorObject::kResumeModeOffset)); | |
1721 __ movp(rax, FieldOperand(rax, JSGeneratorObject::kInputOrDebugPosOffset)); | |
1722 STATIC_ASSERT(JSGeneratorObject::kNext < JSGeneratorObject::kReturn); | |
1723 STATIC_ASSERT(JSGeneratorObject::kThrow > JSGeneratorObject::kReturn); | |
1724 __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::kReturn)); | |
1725 __ j(less, &resume); | |
1726 __ Push(result_register()); | |
1727 __ j(greater, &exception); | |
1728 EmitCreateIteratorResult(true); | |
1729 EmitUnwindAndReturn(); | |
1730 | |
1731 __ bind(&exception); | |
1732 __ CallRuntime(expr->rethrow_on_exception() ? Runtime::kReThrow | |
1733 : Runtime::kThrow); | |
1734 | |
1735 __ bind(&suspend); | |
1736 OperandStackDepthIncrement(1); // Not popped on this path. | |
1737 VisitForAccumulatorValue(expr->generator_object()); | |
1738 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | |
1739 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset), | |
1740 Smi::FromInt(continuation.pos())); | |
1741 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi); | |
1742 __ movp(rcx, rsi); | |
1743 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx, | |
1744 kDontSaveFPRegs); | |
1745 __ leap(rbx, Operand(rbp, StandardFrameConstants::kExpressionsOffset)); | |
1746 __ cmpp(rsp, rbx); | |
1747 __ j(equal, &post_runtime); | |
1748 __ Push(rax); // generator object | |
1749 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | |
1750 RestoreContext(); | |
1751 __ bind(&post_runtime); | |
1752 | |
1753 PopOperand(result_register()); | |
1754 EmitReturnSequence(); | |
1755 | |
1756 __ bind(&resume); | |
1757 context()->Plug(result_register()); | |
1758 } | 1709 } |
1759 | 1710 |
1760 void FullCodeGenerator::PushOperand(MemOperand operand) { | 1711 void FullCodeGenerator::PushOperand(MemOperand operand) { |
1761 OperandStackDepthIncrement(1); | 1712 OperandStackDepthIncrement(1); |
1762 __ Push(operand); | 1713 __ Push(operand); |
1763 } | 1714 } |
1764 | 1715 |
1765 void FullCodeGenerator::EmitOperandStackDepthCheck() { | 1716 void FullCodeGenerator::EmitOperandStackDepthCheck() { |
1766 if (FLAG_debug_code) { | 1717 if (FLAG_debug_code) { |
1767 int expected_diff = StandardFrameConstants::kFixedFrameSizeFromFp + | 1718 int expected_diff = StandardFrameConstants::kFixedFrameSizeFromFp + |
(...skipping 1747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3515 DCHECK_EQ( | 3466 DCHECK_EQ( |
3516 isolate->builtins()->OnStackReplacement()->entry(), | 3467 isolate->builtins()->OnStackReplacement()->entry(), |
3517 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3468 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3518 return ON_STACK_REPLACEMENT; | 3469 return ON_STACK_REPLACEMENT; |
3519 } | 3470 } |
3520 | 3471 |
3521 } // namespace internal | 3472 } // namespace internal |
3522 } // namespace v8 | 3473 } // namespace v8 |
3523 | 3474 |
3524 #endif // V8_TARGET_ARCH_X64 | 3475 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |