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 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 } | 1964 } |
1965 | 1965 |
1966 case Yield::kFinal: { | 1966 case Yield::kFinal: { |
1967 // 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. |
1968 EmitCreateIteratorResult(true); | 1968 EmitCreateIteratorResult(true); |
1969 EmitUnwindBeforeReturn(); | 1969 EmitUnwindBeforeReturn(); |
1970 EmitReturnSequence(); | 1970 EmitReturnSequence(); |
1971 break; | 1971 break; |
1972 } | 1972 } |
1973 | 1973 |
1974 case Yield::kDelegating: { | 1974 case Yield::kDelegating: |
1975 VisitForStackValue(expr->generator_object()); | 1975 UNREACHABLE(); |
1976 | |
1977 // Initial stack layout is as follows: | |
1978 // [sp + 1 * kPointerSize] iter | |
1979 // [sp + 0 * kPointerSize] g | |
1980 | |
1981 Label l_catch, l_try, l_suspend, l_continuation, l_resume; | |
1982 Label l_next, l_call; | |
1983 Register load_receiver = LoadDescriptor::ReceiverRegister(); | |
1984 Register load_name = LoadDescriptor::NameRegister(); | |
1985 | |
1986 // Initial send value is undefined. | |
1987 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); | |
1988 __ Branch(&l_next); | |
1989 | |
1990 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | |
1991 __ bind(&l_catch); | |
1992 __ mov(a0, v0); | |
1993 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw" | |
1994 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter | |
1995 __ Push(load_name, a3, a0); // "throw", iter, except | |
1996 __ jmp(&l_call); | |
1997 | |
1998 // try { received = %yield result } | |
1999 // Shuffle the received result above a try handler and yield it without | |
2000 // re-boxing. | |
2001 __ bind(&l_try); | |
2002 __ pop(a0); // result | |
2003 int handler_index = NewHandlerTableEntry(); | |
2004 EnterTryBlock(handler_index, &l_catch); | |
2005 const int try_block_size = TryCatch::kElementCount * kPointerSize; | |
2006 __ push(a0); // result | |
2007 | |
2008 __ jmp(&l_suspend); | |
2009 __ bind(&l_continuation); | |
2010 __ RecordGeneratorContinuation(); | |
2011 __ mov(a0, v0); | |
2012 __ jmp(&l_resume); | |
2013 | |
2014 __ bind(&l_suspend); | |
2015 const int generator_object_depth = kPointerSize + try_block_size; | |
2016 __ lw(a0, MemOperand(sp, generator_object_depth)); | |
2017 __ push(a0); // g | |
2018 __ Push(Smi::FromInt(handler_index)); // handler-index | |
2019 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | |
2020 __ li(a1, Operand(Smi::FromInt(l_continuation.pos()))); | |
2021 __ sw(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset)); | |
2022 __ sw(cp, FieldMemOperand(a0, JSGeneratorObject::kContextOffset)); | |
2023 __ mov(a1, cp); | |
2024 __ RecordWriteField(a0, JSGeneratorObject::kContextOffset, a1, a2, | |
2025 kRAHasBeenSaved, kDontSaveFPRegs); | |
2026 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); | |
2027 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2028 __ pop(v0); // result | |
2029 EmitReturnSequence(); | |
2030 __ mov(a0, v0); | |
2031 __ bind(&l_resume); // received in a0 | |
2032 ExitTryBlock(handler_index); | |
2033 | |
2034 // receiver = iter; f = 'next'; arg = received; | |
2035 __ bind(&l_next); | |
2036 | |
2037 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | |
2038 __ lw(a3, MemOperand(sp, 1 * kPointerSize)); // iter | |
2039 __ Push(load_name, a3, a0); // "next", iter, received | |
2040 | |
2041 // result = receiver[f](arg); | |
2042 __ bind(&l_call); | |
2043 __ lw(load_receiver, MemOperand(sp, kPointerSize)); | |
2044 __ lw(load_name, MemOperand(sp, 2 * kPointerSize)); | |
2045 __ li(LoadDescriptor::SlotRegister(), | |
2046 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | |
2047 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | |
2048 CallIC(ic, TypeFeedbackId::None()); | |
2049 __ mov(a0, v0); | |
2050 __ mov(a1, a0); | |
2051 __ sw(a1, MemOperand(sp, 2 * kPointerSize)); | |
2052 SetCallPosition(expr); | |
2053 __ li(a0, Operand(1)); | |
2054 __ Call( | |
2055 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined), | |
2056 RelocInfo::CODE_TARGET); | |
2057 | |
2058 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
2059 __ Drop(1); // The function is still on the stack; drop it. | |
2060 | |
2061 // if (!result.done) goto l_try; | |
2062 __ Move(load_receiver, v0); | |
2063 | |
2064 __ push(load_receiver); // save result | |
2065 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | |
2066 __ li(LoadDescriptor::SlotRegister(), | |
2067 Operand(SmiFromSlot(expr->DoneFeedbackSlot()))); | |
2068 CallLoadIC(NOT_INSIDE_TYPEOF); // v0=result.done | |
2069 __ mov(a0, v0); | |
2070 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | |
2071 CallIC(bool_ic); | |
2072 __ LoadRoot(at, Heap::kTrueValueRootIndex); | |
2073 __ Branch(&l_try, ne, result_register(), Operand(at)); | |
2074 | |
2075 // result.value | |
2076 __ pop(load_receiver); // result | |
2077 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | |
2078 __ li(LoadDescriptor::SlotRegister(), | |
2079 Operand(SmiFromSlot(expr->ValueFeedbackSlot()))); | |
2080 CallLoadIC(NOT_INSIDE_TYPEOF); // v0=result.value | |
2081 context()->DropAndPlug(2, v0); // drop iter and g | |
2082 break; | |
2083 } | |
2084 } | 1976 } |
2085 } | 1977 } |
2086 | 1978 |
2087 | 1979 |
2088 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 1980 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2089 Expression *value, | 1981 Expression *value, |
2090 JSGeneratorObject::ResumeMode resume_mode) { | 1982 JSGeneratorObject::ResumeMode resume_mode) { |
2091 // The value stays in a0, and is ultimately read by the resumed generator, as | 1983 // The value stays in a0, and is ultimately read by the resumed generator, as |
2092 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it | 1984 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
2093 // is read to throw the value when the resumed generator is already closed. | 1985 // is read to throw the value when the resumed generator is already closed. |
(...skipping 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4819 reinterpret_cast<uint32_t>( | 4711 reinterpret_cast<uint32_t>( |
4820 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4712 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4821 return OSR_AFTER_STACK_CHECK; | 4713 return OSR_AFTER_STACK_CHECK; |
4822 } | 4714 } |
4823 | 4715 |
4824 | 4716 |
4825 } // namespace internal | 4717 } // namespace internal |
4826 } // namespace v8 | 4718 } // namespace v8 |
4827 | 4719 |
4828 #endif // V8_TARGET_ARCH_MIPS | 4720 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |