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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 case Yield::kSuspend: | 1920 case Yield::kSuspend: |
1921 // Pop value from top-of-stack slot; box result into result register. | 1921 // Pop value from top-of-stack slot; box result into result register. |
1922 EmitCreateIteratorResult(false); | 1922 EmitCreateIteratorResult(false); |
1923 __ push(result_register()); | 1923 __ push(result_register()); |
1924 // Fall through. | 1924 // Fall through. |
1925 case Yield::kInitial: { | 1925 case Yield::kInitial: { |
1926 Label suspend, continuation, post_runtime, resume; | 1926 Label suspend, continuation, post_runtime, resume; |
1927 | 1927 |
1928 __ jmp(&suspend); | 1928 __ jmp(&suspend); |
1929 __ bind(&continuation); | 1929 __ bind(&continuation); |
| 1930 // When we arrive here, the stack top is the resume mode and |
| 1931 // result_register() holds the input value (the argument given to the |
| 1932 // respective resume operation). |
1930 __ RecordGeneratorContinuation(); | 1933 __ RecordGeneratorContinuation(); |
1931 __ jmp(&resume); | 1934 __ pop(a1); |
| 1935 __ Branch(&resume, ne, a1, |
| 1936 Operand(Smi::FromInt(JSGeneratorObject::RETURN))); |
| 1937 __ push(result_register()); |
| 1938 EmitCreateIteratorResult(true); |
| 1939 EmitUnwindBeforeReturn(); |
| 1940 EmitReturnSequence(); |
1932 | 1941 |
1933 __ bind(&suspend); | 1942 __ bind(&suspend); |
1934 VisitForAccumulatorValue(expr->generator_object()); | 1943 VisitForAccumulatorValue(expr->generator_object()); |
1935 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1944 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
1936 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); | 1945 __ li(a1, Operand(Smi::FromInt(continuation.pos()))); |
1937 __ sd(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); | 1946 __ sd(a1, FieldMemOperand(v0, JSGeneratorObject::kContinuationOffset)); |
1938 __ sd(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); | 1947 __ sd(cp, FieldMemOperand(v0, JSGeneratorObject::kContextOffset)); |
1939 __ mov(a1, cp); | 1948 __ mov(a1, cp); |
1940 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, | 1949 __ RecordWriteField(v0, JSGeneratorObject::kContextOffset, a1, a2, |
1941 kRAHasBeenSaved, kDontSaveFPRegs); | 1950 kRAHasBeenSaved, kDontSaveFPRegs); |
1942 __ Daddu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 1951 __ Daddu(a1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
1943 __ Branch(&post_runtime, eq, sp, Operand(a1)); | 1952 __ Branch(&post_runtime, eq, sp, Operand(a1)); |
1944 __ push(v0); // generator object | 1953 __ push(v0); // generator object |
1945 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1954 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1946 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1955 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
1947 __ bind(&post_runtime); | 1956 __ bind(&post_runtime); |
1948 __ pop(result_register()); | 1957 __ pop(result_register()); |
1949 EmitReturnSequence(); | 1958 EmitReturnSequence(); |
1950 | 1959 |
1951 __ bind(&resume); | 1960 __ bind(&resume); |
1952 context()->Plug(result_register()); | 1961 context()->Plug(result_register()); |
1953 break; | 1962 break; |
1954 } | 1963 } |
1955 | 1964 |
1956 case Yield::kFinal: { | 1965 case Yield::kFinal: { |
1957 VisitForAccumulatorValue(expr->generator_object()); | 1966 VisitForAccumulatorValue(expr->generator_object()); |
1958 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | |
1959 __ sd(a1, FieldMemOperand(result_register(), | |
1960 JSGeneratorObject::kContinuationOffset)); | |
1961 // Pop value from top-of-stack slot, box result into result register. | 1967 // Pop value from top-of-stack slot, box result into result register. |
1962 EmitCreateIteratorResult(true); | 1968 EmitCreateIteratorResult(true); |
1963 EmitUnwindBeforeReturn(); | 1969 EmitUnwindBeforeReturn(); |
1964 EmitReturnSequence(); | 1970 EmitReturnSequence(); |
1965 break; | 1971 break; |
1966 } | 1972 } |
1967 | 1973 |
1968 case Yield::kDelegating: { | 1974 case Yield::kDelegating: { |
1969 VisitForStackValue(expr->generator_object()); | 1975 VisitForStackValue(expr->generator_object()); |
1970 | 1976 |
(...skipping 24 matching lines...) Expand all Loading... |
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(); |
2004 __ mov(a0, v0); | 2010 __ mov(a0, v0); |
| 2011 __ pop(a1); |
| 2012 // TODO(neis): Ignoring the resume mode here is clearly wrong. Currently, |
| 2013 // return is not supported for yield*. The planned desugaring of yield* |
| 2014 // using do-expressions will naturally solve this. |
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 __ ld(a0, MemOperand(sp, generator_object_depth)); | 2019 __ ld(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()))); |
2014 __ sd(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset)); | 2024 __ sd(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset)); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 // in directly. | 2144 // in directly. |
2135 if (resume_mode == JSGeneratorObject::NEXT) { | 2145 if (resume_mode == JSGeneratorObject::NEXT) { |
2136 Label slow_resume; | 2146 Label slow_resume; |
2137 __ Branch(&slow_resume, ne, a3, Operand(zero_reg)); | 2147 __ Branch(&slow_resume, ne, a3, Operand(zero_reg)); |
2138 __ ld(a3, FieldMemOperand(a4, JSFunction::kCodeEntryOffset)); | 2148 __ ld(a3, FieldMemOperand(a4, JSFunction::kCodeEntryOffset)); |
2139 __ ld(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | 2149 __ ld(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
2140 __ SmiUntag(a2); | 2150 __ SmiUntag(a2); |
2141 __ Daddu(a3, a3, Operand(a2)); | 2151 __ Daddu(a3, a3, Operand(a2)); |
2142 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 2152 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
2143 __ sd(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | 2153 __ sd(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); |
| 2154 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2144 __ Jump(a3); | 2155 __ Jump(a3); |
2145 __ bind(&slow_resume); | 2156 __ bind(&slow_resume); |
2146 } | 2157 } |
2147 | 2158 |
2148 // Otherwise, we push holes for the operand stack and call the runtime to fix | 2159 // Otherwise, we push holes for the operand stack and call the runtime to fix |
2149 // up the stack and the handlers. | 2160 // up the stack and the handlers. |
2150 Label push_operand_holes, call_resume; | 2161 Label push_operand_holes, call_resume; |
2151 __ bind(&push_operand_holes); | 2162 __ bind(&push_operand_holes); |
2152 __ Dsubu(a3, a3, Operand(1)); | 2163 __ Dsubu(a3, a3, Operand(1)); |
2153 __ Branch(&call_resume, lt, a3, Operand(zero_reg)); | 2164 __ Branch(&call_resume, lt, a3, Operand(zero_reg)); |
2154 __ push(a2); | 2165 __ push(a2); |
2155 __ Branch(&push_operand_holes); | 2166 __ Branch(&push_operand_holes); |
2156 __ bind(&call_resume); | 2167 __ bind(&call_resume); |
| 2168 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2157 DCHECK(!result_register().is(a1)); | 2169 DCHECK(!result_register().is(a1)); |
2158 __ Push(a1, result_register()); | 2170 __ Push(a1, result_register()); |
2159 __ Push(Smi::FromInt(resume_mode)); | 2171 __ Push(Smi::FromInt(resume_mode)); |
2160 __ CallRuntime(Runtime::kResumeJSGeneratorObject); | 2172 __ CallRuntime(Runtime::kResumeJSGeneratorObject); |
2161 // Not reached: the runtime call returns elsewhere. | 2173 // Not reached: the runtime call returns elsewhere. |
2162 __ stop("not-reached"); | 2174 __ stop("not-reached"); |
2163 | 2175 |
2164 __ bind(&done); | 2176 __ bind(&done); |
2165 context()->Plug(result_register()); | 2177 context()->Plug(result_register()); |
2166 } | 2178 } |
(...skipping 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4816 reinterpret_cast<uint64_t>( | 4828 reinterpret_cast<uint64_t>( |
4817 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4829 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4818 return OSR_AFTER_STACK_CHECK; | 4830 return OSR_AFTER_STACK_CHECK; |
4819 } | 4831 } |
4820 | 4832 |
4821 | 4833 |
4822 } // namespace internal | 4834 } // namespace internal |
4823 } // namespace v8 | 4835 } // namespace v8 |
4824 | 4836 |
4825 #endif // V8_TARGET_ARCH_MIPS64 | 4837 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |