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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 // Note on Mips implementation: | 7 // Note on Mips implementation: |
8 // | 8 // |
9 // The result_register() for mips is the 'v0' register, which is defined | 9 // The result_register() for mips is the 'v0' register, which is defined |
10 // by the ABI to contain function return values. However, the first | 10 // by the ABI to contain function return values. However, the first |
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 | 1841 |
1842 | 1842 |
1843 void FullCodeGenerator::VisitYield(Yield* expr) { | 1843 void FullCodeGenerator::VisitYield(Yield* expr) { |
1844 Comment cmnt(masm_, "[ Yield"); | 1844 Comment cmnt(masm_, "[ Yield"); |
1845 SetExpressionPosition(expr); | 1845 SetExpressionPosition(expr); |
1846 | 1846 |
1847 // Evaluate yielded value first; the initial iterator definition depends on | 1847 // Evaluate yielded value first; the initial iterator definition depends on |
1848 // this. It stays on the stack while we update the iterator. | 1848 // this. It stays on the stack while we update the iterator. |
1849 VisitForStackValue(expr->expression()); | 1849 VisitForStackValue(expr->expression()); |
1850 | 1850 |
1851 switch (expr->yield_kind()) { | 1851 Label suspend, continuation, post_runtime, resume; |
1852 case Yield::kSuspend: | |
1853 // Pop value from top-of-stack slot; box result into result register. | |
1854 EmitCreateIteratorResult(false); | |
1855 PushOperand(result_register()); | |
1856 // Fall through. | |
1857 case Yield::kInitial: { | |
1858 Label suspend, continuation, post_runtime, resume; | |
1859 | 1852 |
1860 __ jmp(&suspend); | 1853 __ jmp(&suspend); |
1861 __ bind(&continuation); | 1854 __ bind(&continuation); |
1862 // When we arrive here, the stack top is the resume mode and | 1855 // When we arrive here, the stack top is the resume mode and |
1863 // result_register() holds the input value (the argument given to the | 1856 // result_register() holds the input value (the argument given to the |
1864 // respective resume operation). | 1857 // respective resume operation). |
1865 __ RecordGeneratorContinuation(); | 1858 __ RecordGeneratorContinuation(); |
1866 __ pop(a1); | 1859 __ pop(a1); |
1867 __ Branch(&resume, ne, a1, | 1860 __ Branch(&resume, ne, a1, Operand(Smi::FromInt(JSGeneratorObject::RETURN))); |
1868 Operand(Smi::FromInt(JSGeneratorObject::RETURN))); | 1861 __ push(result_register()); |
1869 __ push(result_register()); | 1862 EmitCreateIteratorResult(true); |
1870 EmitCreateIteratorResult(true); | 1863 EmitUnwindAndReturn(); |
1871 EmitUnwindAndReturn(); | |
1872 | 1864 |
1873 __ bind(&suspend); | 1865 __ bind(&suspend); |
1874 OperandStackDepthIncrement(1); // Not popped on this path. | 1866 OperandStackDepthIncrement(1); // Not popped on this path. |
1875 VisitForAccumulatorValue(expr->generator_object()); | 1867 VisitForAccumulatorValue(expr->generator_object()); |
1876 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1868 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
1877 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); | 1869 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); |
1878 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); | 1870 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); |
1879 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); | 1871 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); |
1880 __ mov(a1, cp); | 1872 __ mov(a1, cp); |
1881 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, | 1873 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, |
1882 kRAHasBeenSaved, kDontSaveFPRegs); | 1874 kRAHasBeenSaved, kDontSaveFPRegs); |
1883 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 1875 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
1884 __ Branch(&post_runtime, eq, sp, Operand(a1)); | 1876 __ Branch(&post_runtime, eq, sp, Operand(a1)); |
1885 __ push(v0); // generator object | 1877 __ push(v0); // generator object |
1886 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1878 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1887 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1879 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
1888 __ bind(&post_runtime); | 1880 __ bind(&post_runtime); |
1889 PopOperand(result_register()); | 1881 PopOperand(result_register()); |
1890 EmitReturnSequence(); | 1882 EmitReturnSequence(); |
1891 | 1883 |
1892 __ bind(&resume); | 1884 __ bind(&resume); |
1893 context()->Plug(result_register()); | 1885 context()->Plug(result_register()); |
1894 break; | |
1895 } | |
1896 | |
1897 case Yield::kFinal: { | |
1898 // Pop value from top-of-stack slot, box result into result register. | |
1899 EmitCreateIteratorResult(true); | |
1900 EmitUnwindAndReturn(); | |
1901 break; | |
1902 } | |
1903 | |
1904 case Yield::kDelegating: | |
1905 UNREACHABLE(); | |
1906 } | |
1907 } | 1886 } |
1908 | 1887 |
1909 | 1888 |
1910 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 1889 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
1911 Expression *value, | 1890 Expression *value, |
1912 JSGeneratorObject::ResumeMode resume_mode) { | 1891 JSGeneratorObject::ResumeMode resume_mode) { |
1913 // The value stays in a0, and is ultimately read by the resumed generator, as | 1892 // The value stays in a0, and is ultimately read by the resumed generator, as |
1914 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it | 1893 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
1915 // is read to throw the value when the resumed generator is already closed. | 1894 // is read to throw the value when the resumed generator is already closed. |
1916 // a1 will hold the generator object until the activation has been resumed. | 1895 // a1 will hold the generator object until the activation has been resumed. |
(...skipping 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4207 reinterpret_cast<uint32_t>( | 4186 reinterpret_cast<uint32_t>( |
4208 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4187 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4209 return OSR_AFTER_STACK_CHECK; | 4188 return OSR_AFTER_STACK_CHECK; |
4210 } | 4189 } |
4211 | 4190 |
4212 | 4191 |
4213 } // namespace internal | 4192 } // namespace internal |
4214 } // namespace v8 | 4193 } // namespace v8 |
4215 | 4194 |
4216 #endif // V8_TARGET_ARCH_MIPS | 4195 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |