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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 case Yield::kSuspend: | 1921 case Yield::kSuspend: |
1922 // Pop value from top-of-stack slot; box result into result register. | 1922 // Pop value from top-of-stack slot; box result into result register. |
1923 EmitCreateIteratorResult(false); | 1923 EmitCreateIteratorResult(false); |
1924 __ push(result_register()); | 1924 __ push(result_register()); |
1925 // Fall through. | 1925 // Fall through. |
1926 case Yield::kInitial: { | 1926 case Yield::kInitial: { |
1927 Label suspend, continuation, post_runtime, resume; | 1927 Label suspend, continuation, post_runtime, resume; |
1928 | 1928 |
1929 __ jmp(&suspend); | 1929 __ jmp(&suspend); |
1930 __ bind(&continuation); | 1930 __ bind(&continuation); |
| 1931 // When we arrive here, the stack top is the resume mode and |
| 1932 // result_register() holds the input value (the argument given to the |
| 1933 // respective resume operation). |
1931 __ RecordGeneratorContinuation(); | 1934 __ RecordGeneratorContinuation(); |
1932 __ jmp(&resume); | 1935 __ pop(r1); |
| 1936 __ cmp(r1, Operand(Smi::FromInt(JSGeneratorObject::RETURN))); |
| 1937 __ b(ne, &resume); |
| 1938 __ push(result_register()); |
| 1939 EmitCreateIteratorResult(true); |
| 1940 EmitUnwindBeforeReturn(); |
| 1941 EmitReturnSequence(); |
1933 | 1942 |
1934 __ bind(&suspend); | 1943 __ bind(&suspend); |
1935 VisitForAccumulatorValue(expr->generator_object()); | 1944 VisitForAccumulatorValue(expr->generator_object()); |
1936 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1945 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
1937 __ mov(r1, Operand(Smi::FromInt(continuation.pos()))); | 1946 __ mov(r1, Operand(Smi::FromInt(continuation.pos()))); |
1938 __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); | 1947 __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); |
1939 __ str(cp, FieldMemOperand(r0, JSGeneratorObject::kContextOffset)); | 1948 __ str(cp, FieldMemOperand(r0, JSGeneratorObject::kContextOffset)); |
1940 __ mov(r1, cp); | 1949 __ mov(r1, cp); |
1941 __ RecordWriteField(r0, JSGeneratorObject::kContextOffset, r1, r2, | 1950 __ RecordWriteField(r0, JSGeneratorObject::kContextOffset, r1, r2, |
1942 kLRHasBeenSaved, kDontSaveFPRegs); | 1951 kLRHasBeenSaved, kDontSaveFPRegs); |
1943 __ add(r1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); | 1952 __ add(r1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
1944 __ cmp(sp, r1); | 1953 __ cmp(sp, r1); |
1945 __ b(eq, &post_runtime); | 1954 __ b(eq, &post_runtime); |
1946 __ push(r0); // generator object | 1955 __ push(r0); // generator object |
1947 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1956 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
1948 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 1957 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
1949 __ bind(&post_runtime); | 1958 __ bind(&post_runtime); |
1950 __ pop(result_register()); | 1959 __ pop(result_register()); |
1951 EmitReturnSequence(); | 1960 EmitReturnSequence(); |
1952 | 1961 |
1953 __ bind(&resume); | 1962 __ bind(&resume); |
1954 context()->Plug(result_register()); | 1963 context()->Plug(result_register()); |
1955 break; | 1964 break; |
1956 } | 1965 } |
1957 | 1966 |
1958 case Yield::kFinal: { | 1967 case Yield::kFinal: { |
1959 VisitForAccumulatorValue(expr->generator_object()); | 1968 VisitForAccumulatorValue(expr->generator_object()); |
1960 __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | |
1961 __ str(r1, FieldMemOperand(result_register(), | |
1962 JSGeneratorObject::kContinuationOffset)); | |
1963 // Pop value from top-of-stack slot, box result into result register. | 1969 // Pop value from top-of-stack slot, box result into result register. |
1964 EmitCreateIteratorResult(true); | 1970 EmitCreateIteratorResult(true); |
1965 EmitUnwindBeforeReturn(); | 1971 EmitUnwindBeforeReturn(); |
1966 EmitReturnSequence(); | 1972 EmitReturnSequence(); |
1967 break; | 1973 break; |
1968 } | 1974 } |
1969 | 1975 |
1970 case Yield::kDelegating: { | 1976 case Yield::kDelegating: { |
1971 VisitForStackValue(expr->generator_object()); | 1977 VisitForStackValue(expr->generator_object()); |
1972 | 1978 |
(...skipping 23 matching lines...) Expand all Loading... |
1996 __ bind(&l_try); | 2002 __ bind(&l_try); |
1997 __ pop(r0); // result | 2003 __ pop(r0); // result |
1998 int handler_index = NewHandlerTableEntry(); | 2004 int handler_index = NewHandlerTableEntry(); |
1999 EnterTryBlock(handler_index, &l_catch); | 2005 EnterTryBlock(handler_index, &l_catch); |
2000 const int try_block_size = TryCatch::kElementCount * kPointerSize; | 2006 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
2001 __ push(r0); // result | 2007 __ push(r0); // result |
2002 | 2008 |
2003 __ jmp(&l_suspend); | 2009 __ jmp(&l_suspend); |
2004 __ bind(&l_continuation); | 2010 __ bind(&l_continuation); |
2005 __ RecordGeneratorContinuation(); | 2011 __ RecordGeneratorContinuation(); |
| 2012 __ pop(r1); |
| 2013 // TODO(neis): Ignoring the resume mode here is clearly wrong. Currently, |
| 2014 // return is not supported for yield*. The planned desugaring of yield* |
| 2015 // using do-expressions will naturally solve this. |
2006 __ jmp(&l_resume); | 2016 __ jmp(&l_resume); |
2007 | 2017 |
2008 __ bind(&l_suspend); | 2018 __ bind(&l_suspend); |
2009 const int generator_object_depth = kPointerSize + try_block_size; | 2019 const int generator_object_depth = kPointerSize + try_block_size; |
2010 __ ldr(r0, MemOperand(sp, generator_object_depth)); | 2020 __ ldr(r0, MemOperand(sp, generator_object_depth)); |
2011 __ push(r0); // g | 2021 __ push(r0); // g |
2012 __ Push(Smi::FromInt(handler_index)); // handler-index | 2022 __ Push(Smi::FromInt(handler_index)); // handler-index |
2013 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 2023 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
2014 __ mov(r1, Operand(Smi::FromInt(l_continuation.pos()))); | 2024 __ mov(r1, Operand(Smi::FromInt(l_continuation.pos()))); |
2015 __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); | 2025 __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2141 if (FLAG_enable_embedded_constant_pool) { | 2151 if (FLAG_enable_embedded_constant_pool) { |
2142 // Load the new code object's constant pool pointer. | 2152 // Load the new code object's constant pool pointer. |
2143 __ LoadConstantPoolPointerRegisterFromCodeTargetAddress(r3); | 2153 __ LoadConstantPoolPointerRegisterFromCodeTargetAddress(r3); |
2144 } | 2154 } |
2145 | 2155 |
2146 __ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); | 2156 __ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); |
2147 __ SmiUntag(r2); | 2157 __ SmiUntag(r2); |
2148 __ add(r3, r3, r2); | 2158 __ add(r3, r3, r2); |
2149 __ mov(r2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 2159 __ mov(r2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
2150 __ str(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); | 2160 __ str(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); |
| 2161 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2151 __ Jump(r3); | 2162 __ Jump(r3); |
2152 } | 2163 } |
2153 __ bind(&slow_resume); | 2164 __ bind(&slow_resume); |
2154 } | 2165 } |
2155 | 2166 |
2156 // Otherwise, we push holes for the operand stack and call the runtime to fix | 2167 // Otherwise, we push holes for the operand stack and call the runtime to fix |
2157 // up the stack and the handlers. | 2168 // up the stack and the handlers. |
2158 Label push_operand_holes, call_resume; | 2169 Label push_operand_holes, call_resume; |
2159 __ bind(&push_operand_holes); | 2170 __ bind(&push_operand_holes); |
2160 __ sub(r3, r3, Operand(1), SetCC); | 2171 __ sub(r3, r3, Operand(1), SetCC); |
2161 __ b(mi, &call_resume); | 2172 __ b(mi, &call_resume); |
2162 __ push(r2); | 2173 __ push(r2); |
2163 __ b(&push_operand_holes); | 2174 __ b(&push_operand_holes); |
2164 __ bind(&call_resume); | 2175 __ bind(&call_resume); |
| 2176 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2165 DCHECK(!result_register().is(r1)); | 2177 DCHECK(!result_register().is(r1)); |
2166 __ Push(r1, result_register()); | 2178 __ Push(r1, result_register()); |
2167 __ Push(Smi::FromInt(resume_mode)); | 2179 __ Push(Smi::FromInt(resume_mode)); |
2168 __ CallRuntime(Runtime::kResumeJSGeneratorObject); | 2180 __ CallRuntime(Runtime::kResumeJSGeneratorObject); |
2169 // Not reached: the runtime call returns elsewhere. | 2181 // Not reached: the runtime call returns elsewhere. |
2170 __ stop("not-reached"); | 2182 __ stop("not-reached"); |
2171 | 2183 |
2172 __ bind(&done); | 2184 __ bind(&done); |
2173 context()->Plug(result_register()); | 2185 context()->Plug(result_register()); |
2174 } | 2186 } |
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4851 DCHECK(interrupt_address == | 4863 DCHECK(interrupt_address == |
4852 isolate->builtins()->OsrAfterStackCheck()->entry()); | 4864 isolate->builtins()->OsrAfterStackCheck()->entry()); |
4853 return OSR_AFTER_STACK_CHECK; | 4865 return OSR_AFTER_STACK_CHECK; |
4854 } | 4866 } |
4855 | 4867 |
4856 | 4868 |
4857 } // namespace internal | 4869 } // namespace internal |
4858 } // namespace v8 | 4870 } // namespace v8 |
4859 | 4871 |
4860 #endif // V8_TARGET_ARCH_ARM | 4872 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |