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