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 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 case Yield::kSuspend: | 1919 case Yield::kSuspend: |
1920 // Pop value from top-of-stack slot; box result into result register. | 1920 // Pop value from top-of-stack slot; box result into result register. |
1921 EmitCreateIteratorResult(false); | 1921 EmitCreateIteratorResult(false); |
1922 __ push(result_register()); | 1922 __ push(result_register()); |
1923 // Fall through. | 1923 // Fall through. |
1924 case Yield::kInitial: { | 1924 case Yield::kInitial: { |
1925 Label suspend, continuation, post_runtime, resume; | 1925 Label suspend, continuation, post_runtime, resume; |
1926 | 1926 |
1927 __ jmp(&suspend); | 1927 __ jmp(&suspend); |
1928 __ bind(&continuation); | 1928 __ bind(&continuation); |
| 1929 // When we arrive here, the stack top is the resume mode and |
| 1930 // result_register() holds the input value (the argument given to the |
| 1931 // respective resume operation). |
1929 __ RecordGeneratorContinuation(); | 1932 __ RecordGeneratorContinuation(); |
1930 __ jmp(&resume); | 1933 __ pop(a1); |
| 1934 __ Branch(&resume, ne, a1, |
| 1935 Operand(Smi::FromInt(JSGeneratorObject::RETURN))); |
| 1936 __ push(result_register()); |
| 1937 EmitCreateIteratorResult(true); |
| 1938 EmitUnwindBeforeReturn(); |
| 1939 EmitReturnSequence(); |
1931 | 1940 |
1932 __ bind(&suspend); | 1941 __ bind(&suspend); |
1933 VisitForAccumulatorValue(expr->generator_object()); | 1942 VisitForAccumulatorValue(expr->generator_object()); |
1934 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1943 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
1935 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); | 1944 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); |
1936 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); | 1945 __ sw(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); |
1937 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); | 1946 __ sw(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); |
1938 __ mov(a1, cp); | 1947 __ mov(a1, cp); |
1939 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, | 1948 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, |
1940 kRAHasBeenSaved, kDontSaveFPRegs); | 1949 kRAHasBeenSaved, kDontSaveFPRegs); |
1941 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 1950 __ Addu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
1942 __ Branch(&post_runtime, eq, sp, Operand(a1)); | 1951 __ Branch(&post_runtime, eq, sp, Operand(a1)); |
1943 __ push(v0); // generator object | 1952 __ push(v0); // generator object |
1944 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1953 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1945 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1954 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
1946 __ bind(&post_runtime); | 1955 __ bind(&post_runtime); |
1947 __ pop(result_register()); | 1956 __ pop(result_register()); |
1948 EmitReturnSequence(); | 1957 EmitReturnSequence(); |
1949 | 1958 |
1950 __ bind(&resume); | 1959 __ bind(&resume); |
1951 context()->Plug(result_register()); | 1960 context()->Plug(result_register()); |
1952 break; | 1961 break; |
1953 } | 1962 } |
1954 | 1963 |
1955 case Yield::kFinal: { | 1964 case Yield::kFinal: { |
1956 VisitForAccumulatorValue(expr->generator_object()); | 1965 VisitForAccumulatorValue(expr->generator_object()); |
1957 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | |
1958 __ sw(a1, FieldMemOperand(result_register(), | |
1959 JSGeneratorObject::kContinuationOffset)); | |
1960 // Pop value from top-of-stack slot, box result into result register. | 1966 // Pop value from top-of-stack slot, box result into result register. |
1961 EmitCreateIteratorResult(true); | 1967 EmitCreateIteratorResult(true); |
1962 EmitUnwindBeforeReturn(); | 1968 EmitUnwindBeforeReturn(); |
1963 EmitReturnSequence(); | 1969 EmitReturnSequence(); |
1964 break; | 1970 break; |
1965 } | 1971 } |
1966 | 1972 |
1967 case Yield::kDelegating: { | 1973 case Yield::kDelegating: { |
1968 VisitForStackValue(expr->generator_object()); | 1974 VisitForStackValue(expr->generator_object()); |
1969 | 1975 |
(...skipping 24 matching lines...) Expand all Loading... |
1994 __ bind(&l_try); | 2000 __ bind(&l_try); |
1995 __ pop(a0); // result | 2001 __ pop(a0); // result |
1996 int handler_index = NewHandlerTableEntry(); | 2002 int handler_index = NewHandlerTableEntry(); |
1997 EnterTryBlock(handler_index, &l_catch); | 2003 EnterTryBlock(handler_index, &l_catch); |
1998 const int try_block_size = TryCatch::kElementCount * kPointerSize; | 2004 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
1999 __ push(a0); // result | 2005 __ push(a0); // result |
2000 | 2006 |
2001 __ jmp(&l_suspend); | 2007 __ jmp(&l_suspend); |
2002 __ bind(&l_continuation); | 2008 __ bind(&l_continuation); |
2003 __ RecordGeneratorContinuation(); | 2009 __ RecordGeneratorContinuation(); |
| 2010 __ pop(a1); |
| 2011 // TODO(neis): Ignoring the resume mode here is clearly wrong. Currently, |
| 2012 // return is not supported for yield*. The planned desugaring of yield* |
| 2013 // using do-expressions will naturally solve this. |
2004 __ mov(a0, v0); | 2014 __ mov(a0, v0); |
2005 __ jmp(&l_resume); | 2015 __ jmp(&l_resume); |
2006 | 2016 |
2007 __ bind(&l_suspend); | 2017 __ bind(&l_suspend); |
2008 const int generator_object_depth = kPointerSize + try_block_size; | 2018 const int generator_object_depth = kPointerSize + try_block_size; |
2009 __ lw(a0, MemOperand(sp, generator_object_depth)); | 2019 __ lw(a0, MemOperand(sp, generator_object_depth)); |
2010 __ push(a0); // g | 2020 __ push(a0); // g |
2011 __ Push(Smi::FromInt(handler_index)); // handler-index | 2021 __ Push(Smi::FromInt(handler_index)); // handler-index |
2012 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2022 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
2013 __ li(a1, Operand(Smi::FromInt(l_continuation.pos()))); | 2023 __ li(a1, Operand(Smi::FromInt(l_continuation.pos()))); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 // in directly. | 2143 // in directly. |
2134 if (resume_mode == JSGeneratorObject::NEXT) { | 2144 if (resume_mode == JSGeneratorObject::NEXT) { |
2135 Label slow_resume; | 2145 Label slow_resume; |
2136 __ Branch(&slow_resume, ne, a3, Operand(zero_reg)); | 2146 __ Branch(&slow_resume, ne, a3, Operand(zero_reg)); |
2137 __ lw(a3, FieldMemOperand(t0, JSFunction::kCodeEntryOffset)); | 2147 __ lw(a3, FieldMemOperand(t0, JSFunction::kCodeEntryOffset)); |
2138 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | 2148 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
2139 __ SmiUntag(a2); | 2149 __ SmiUntag(a2); |
2140 __ Addu(a3, a3, Operand(a2)); | 2150 __ Addu(a3, a3, Operand(a2)); |
2141 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 2151 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
2142 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | 2152 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
| 2153 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2143 __ Jump(a3); | 2154 __ Jump(a3); |
2144 __ bind(&slow_resume); | 2155 __ bind(&slow_resume); |
2145 } | 2156 } |
2146 | 2157 |
2147 // Otherwise, we push holes for the operand stack and call the runtime to fix | 2158 // Otherwise, we push holes for the operand stack and call the runtime to fix |
2148 // up the stack and the handlers. | 2159 // up the stack and the handlers. |
2149 Label push_operand_holes, call_resume; | 2160 Label push_operand_holes, call_resume; |
2150 __ bind(&push_operand_holes); | 2161 __ bind(&push_operand_holes); |
2151 __ Subu(a3, a3, Operand(1)); | 2162 __ Subu(a3, a3, Operand(1)); |
2152 __ Branch(&call_resume, lt, a3, Operand(zero_reg)); | 2163 __ Branch(&call_resume, lt, a3, Operand(zero_reg)); |
2153 __ push(a2); | 2164 __ push(a2); |
2154 __ Branch(&push_operand_holes); | 2165 __ Branch(&push_operand_holes); |
2155 __ bind(&call_resume); | 2166 __ bind(&call_resume); |
| 2167 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2156 DCHECK(!result_register().is(a1)); | 2168 DCHECK(!result_register().is(a1)); |
2157 __ Push(a1, result_register()); | 2169 __ Push(a1, result_register()); |
2158 __ Push(Smi::FromInt(resume_mode)); | 2170 __ Push(Smi::FromInt(resume_mode)); |
2159 __ CallRuntime(Runtime::kResumeJSGeneratorObject); | 2171 __ CallRuntime(Runtime::kResumeJSGeneratorObject); |
2160 // Not reached: the runtime call returns elsewhere. | 2172 // Not reached: the runtime call returns elsewhere. |
2161 __ stop("not-reached"); | 2173 __ stop("not-reached"); |
2162 | 2174 |
2163 __ bind(&done); | 2175 __ bind(&done); |
2164 context()->Plug(result_register()); | 2176 context()->Plug(result_register()); |
2165 } | 2177 } |
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4801 reinterpret_cast<uint32_t>( | 4813 reinterpret_cast<uint32_t>( |
4802 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4814 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4803 return OSR_AFTER_STACK_CHECK; | 4815 return OSR_AFTER_STACK_CHECK; |
4804 } | 4816 } |
4805 | 4817 |
4806 | 4818 |
4807 } // namespace internal | 4819 } // namespace internal |
4808 } // namespace v8 | 4820 } // namespace v8 |
4809 | 4821 |
4810 #endif // V8_TARGET_ARCH_MIPS | 4822 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |