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 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 } | 1972 } |
1973 | 1973 |
1974 case Yield::kFinal: { | 1974 case Yield::kFinal: { |
1975 // Pop value from top-of-stack slot, box result into result register. | 1975 // Pop value from top-of-stack slot, box result into result register. |
1976 EmitCreateIteratorResult(true); | 1976 EmitCreateIteratorResult(true); |
1977 EmitUnwindBeforeReturn(); | 1977 EmitUnwindBeforeReturn(); |
1978 EmitReturnSequence(); | 1978 EmitReturnSequence(); |
1979 break; | 1979 break; |
1980 } | 1980 } |
1981 | 1981 |
1982 case Yield::kDelegating: { | 1982 case Yield::kDelegating: |
1983 VisitForStackValue(expr->generator_object()); | 1983 UNREACHABLE(); |
1984 | |
1985 // Initial stack layout is as follows: | |
1986 // [sp + 1 * kPointerSize] iter | |
1987 // [sp + 0 * kPointerSize] g | |
1988 | |
1989 Label l_catch, l_try, l_suspend, l_continuation, l_resume; | |
1990 Label l_next, l_call, l_loop; | |
1991 Register load_receiver = LoadDescriptor::ReceiverRegister(); | |
1992 Register load_name = LoadDescriptor::NameRegister(); | |
1993 | |
1994 // Initial send value is undefined. | |
1995 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | |
1996 __ b(&l_next); | |
1997 | |
1998 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | |
1999 __ bind(&l_catch); | |
2000 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" | |
2001 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter | |
2002 __ Push(load_name, r3, r0); // "throw", iter, except | |
2003 __ jmp(&l_call); | |
2004 | |
2005 // try { received = %yield result } | |
2006 // Shuffle the received result above a try handler and yield it without | |
2007 // re-boxing. | |
2008 __ bind(&l_try); | |
2009 __ pop(r0); // result | |
2010 int handler_index = NewHandlerTableEntry(); | |
2011 EnterTryBlock(handler_index, &l_catch); | |
2012 const int try_block_size = TryCatch::kElementCount * kPointerSize; | |
2013 __ push(r0); // result | |
2014 | |
2015 __ jmp(&l_suspend); | |
2016 __ bind(&l_continuation); | |
2017 __ RecordGeneratorContinuation(); | |
2018 __ jmp(&l_resume); | |
2019 | |
2020 __ bind(&l_suspend); | |
2021 const int generator_object_depth = kPointerSize + try_block_size; | |
2022 __ ldr(r0, MemOperand(sp, generator_object_depth)); | |
2023 __ push(r0); // g | |
2024 __ Push(Smi::FromInt(handler_index)); // handler-index | |
2025 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | |
2026 __ mov(r1, Operand(Smi::FromInt(l_continuation.pos()))); | |
2027 __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); | |
2028 __ str(cp, FieldMemOperand(r0, JSGeneratorObject::kContextOffset)); | |
2029 __ mov(r1, cp); | |
2030 __ RecordWriteField(r0, JSGeneratorObject::kContextOffset, r1, r2, | |
2031 kLRHasBeenSaved, kDontSaveFPRegs); | |
2032 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); | |
2033 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2034 __ pop(r0); // result | |
2035 EmitReturnSequence(); | |
2036 __ bind(&l_resume); // received in r0 | |
2037 ExitTryBlock(handler_index); | |
2038 | |
2039 // receiver = iter; f = 'next'; arg = received; | |
2040 __ bind(&l_next); | |
2041 | |
2042 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | |
2043 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter | |
2044 __ Push(load_name, r3, r0); // "next", iter, received | |
2045 | |
2046 // result = receiver[f](arg); | |
2047 __ bind(&l_call); | |
2048 __ ldr(load_receiver, MemOperand(sp, kPointerSize)); | |
2049 __ ldr(load_name, MemOperand(sp, 2 * kPointerSize)); | |
2050 __ mov(LoadDescriptor::SlotRegister(), | |
2051 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | |
2052 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | |
2053 CallIC(ic, TypeFeedbackId::None()); | |
2054 __ mov(r1, r0); | |
2055 __ str(r1, MemOperand(sp, 2 * kPointerSize)); | |
2056 SetCallPosition(expr); | |
2057 __ mov(r0, Operand(1)); | |
2058 __ Call( | |
2059 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined), | |
2060 RelocInfo::CODE_TARGET); | |
2061 | |
2062 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2063 __ Drop(1); // The function is still on the stack; drop it. | |
2064 | |
2065 // if (!result.done) goto l_try; | |
2066 __ bind(&l_loop); | |
2067 __ Move(load_receiver, r0); | |
2068 | |
2069 __ push(load_receiver); // save result | |
2070 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | |
2071 __ mov(LoadDescriptor::SlotRegister(), | |
2072 Operand(SmiFromSlot(expr->DoneFeedbackSlot()))); | |
2073 CallLoadIC(NOT_INSIDE_TYPEOF); // r0=result.done | |
2074 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | |
2075 CallIC(bool_ic); | |
2076 __ CompareRoot(result_register(), Heap::kTrueValueRootIndex); | |
2077 __ b(ne, &l_try); | |
2078 | |
2079 // result.value | |
2080 __ pop(load_receiver); // result | |
2081 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | |
2082 __ mov(LoadDescriptor::SlotRegister(), | |
2083 Operand(SmiFromSlot(expr->ValueFeedbackSlot()))); | |
2084 CallLoadIC(NOT_INSIDE_TYPEOF); // r0=result.value | |
2085 context()->DropAndPlug(2, r0); // drop iter and g | |
2086 break; | |
2087 } | |
2088 } | 1984 } |
2089 } | 1985 } |
2090 | 1986 |
2091 | 1987 |
2092 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 1988 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2093 Expression *value, | 1989 Expression *value, |
2094 JSGeneratorObject::ResumeMode resume_mode) { | 1990 JSGeneratorObject::ResumeMode resume_mode) { |
2095 // The value stays in r0, and is ultimately read by the resumed generator, as | 1991 // The value stays in r0, and is ultimately read by the resumed generator, as |
2096 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it | 1992 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
2097 // is read to throw the value when the resumed generator is already closed. | 1993 // is read to throw the value when the resumed generator is already closed. |
(...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4852 DCHECK(interrupt_address == | 4748 DCHECK(interrupt_address == |
4853 isolate->builtins()->OsrAfterStackCheck()->entry()); | 4749 isolate->builtins()->OsrAfterStackCheck()->entry()); |
4854 return OSR_AFTER_STACK_CHECK; | 4750 return OSR_AFTER_STACK_CHECK; |
4855 } | 4751 } |
4856 | 4752 |
4857 | 4753 |
4858 } // namespace internal | 4754 } // namespace internal |
4859 } // namespace v8 | 4755 } // namespace v8 |
4860 | 4756 |
4861 #endif // V8_TARGET_ARCH_ARM | 4757 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |