OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 | 1805 |
1806 | 1806 |
1807 void FullCodeGenerator::VisitYield(Yield* expr) { | 1807 void FullCodeGenerator::VisitYield(Yield* expr) { |
1808 Comment cmnt(masm_, "[ Yield"); | 1808 Comment cmnt(masm_, "[ Yield"); |
1809 SetExpressionPosition(expr); | 1809 SetExpressionPosition(expr); |
1810 | 1810 |
1811 // Evaluate yielded value first; the initial iterator definition depends on | 1811 // Evaluate yielded value first; the initial iterator definition depends on |
1812 // this. It stays on the stack while we update the iterator. | 1812 // this. It stays on the stack while we update the iterator. |
1813 VisitForStackValue(expr->expression()); | 1813 VisitForStackValue(expr->expression()); |
1814 | 1814 |
1815 switch (expr->yield_kind()) { | 1815 Label suspend, continuation, post_runtime, resume; |
1816 case Yield::kSuspend: | |
1817 // Pop value from top-of-stack slot; box result into result register. | |
1818 EmitCreateIteratorResult(false); | |
1819 PushOperand(result_register()); | |
1820 // Fall through. | |
1821 case Yield::kInitial: { | |
1822 Label suspend, continuation, post_runtime, resume; | |
1823 | 1816 |
1824 __ b(&suspend); | 1817 __ b(&suspend); |
1825 __ bind(&continuation); | 1818 __ bind(&continuation); |
1826 // When we arrive here, the stack top is the resume mode and | 1819 // When we arrive here, the stack top is the resume mode and |
1827 // result_register() holds the input value (the argument given to the | 1820 // result_register() holds the input value (the argument given to the |
1828 // respective resume operation). | 1821 // respective resume operation). |
1829 __ RecordGeneratorContinuation(); | 1822 __ RecordGeneratorContinuation(); |
1830 __ pop(r4); | 1823 __ pop(r4); |
1831 __ CmpSmiLiteral(r4, Smi::FromInt(JSGeneratorObject::RETURN), r0); | 1824 __ CmpSmiLiteral(r4, Smi::FromInt(JSGeneratorObject::RETURN), r0); |
1832 __ bne(&resume); | 1825 __ bne(&resume); |
1833 __ push(result_register()); | 1826 __ push(result_register()); |
1834 EmitCreateIteratorResult(true); | 1827 EmitCreateIteratorResult(true); |
1835 EmitUnwindAndReturn(); | 1828 EmitUnwindAndReturn(); |
1836 | 1829 |
1837 __ bind(&suspend); | 1830 __ bind(&suspend); |
1838 OperandStackDepthIncrement(1); // Not popped on this path. | 1831 OperandStackDepthIncrement(1); // Not popped on this path. |
1839 VisitForAccumulatorValue(expr->generator_object()); | 1832 VisitForAccumulatorValue(expr->generator_object()); |
1840 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1833 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
1841 __ LoadSmiLiteral(r4, Smi::FromInt(continuation.pos())); | 1834 __ LoadSmiLiteral(r4, Smi::FromInt(continuation.pos())); |
1842 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset), | 1835 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset), |
1843 r0); | 1836 r0); |
1844 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0); | 1837 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0); |
1845 __ mr(r4, cp); | 1838 __ mr(r4, cp); |
1846 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5, | 1839 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5, |
1847 kLRHasBeenSaved, kDontSaveFPRegs); | 1840 kLRHasBeenSaved, kDontSaveFPRegs); |
1848 __ addi(r4, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 1841 __ addi(r4, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
1849 __ cmp(sp, r4); | 1842 __ cmp(sp, r4); |
1850 __ beq(&post_runtime); | 1843 __ beq(&post_runtime); |
1851 __ push(r3); // generator object | 1844 __ push(r3); // generator object |
1852 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1845 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1853 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1846 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
1854 __ bind(&post_runtime); | 1847 __ bind(&post_runtime); |
1855 PopOperand(result_register()); | 1848 PopOperand(result_register()); |
1856 EmitReturnSequence(); | 1849 EmitReturnSequence(); |
1857 | 1850 |
1858 __ bind(&resume); | 1851 __ bind(&resume); |
1859 context()->Plug(result_register()); | 1852 context()->Plug(result_register()); |
1860 break; | |
1861 } | |
1862 | |
1863 case Yield::kFinal: { | |
1864 // Pop value from top-of-stack slot, box result into result register. | |
1865 EmitCreateIteratorResult(true); | |
1866 EmitUnwindAndReturn(); | |
1867 break; | |
1868 } | |
1869 | |
1870 case Yield::kDelegating: | |
1871 UNREACHABLE(); | |
1872 } | |
1873 } | 1853 } |
1874 | 1854 |
1875 | 1855 |
1876 void FullCodeGenerator::EmitGeneratorResume( | 1856 void FullCodeGenerator::EmitGeneratorResume( |
1877 Expression* generator, Expression* value, | 1857 Expression* generator, Expression* value, |
1878 JSGeneratorObject::ResumeMode resume_mode) { | 1858 JSGeneratorObject::ResumeMode resume_mode) { |
1879 // The value stays in r3, and is ultimately read by the resumed generator, as | 1859 // The value stays in r3, and is ultimately read by the resumed generator, as |
1880 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it | 1860 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
1881 // is read to throw the value when the resumed generator is already closed. | 1861 // is read to throw the value when the resumed generator is already closed. |
1882 // r4 will hold the generator object until the activation has been resumed. | 1862 // r4 will hold the generator object until the activation has been resumed. |
(...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4177 return ON_STACK_REPLACEMENT; | 4157 return ON_STACK_REPLACEMENT; |
4178 } | 4158 } |
4179 | 4159 |
4180 DCHECK(interrupt_address == | 4160 DCHECK(interrupt_address == |
4181 isolate->builtins()->OsrAfterStackCheck()->entry()); | 4161 isolate->builtins()->OsrAfterStackCheck()->entry()); |
4182 return OSR_AFTER_STACK_CHECK; | 4162 return OSR_AFTER_STACK_CHECK; |
4183 } | 4163 } |
4184 } // namespace internal | 4164 } // namespace internal |
4185 } // namespace v8 | 4165 } // namespace v8 |
4186 #endif // V8_TARGET_ARCH_PPC | 4166 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |