Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/full-codegen/mips64/full-codegen-mips64.cc

Issue 1648773003: [generators] Remove full-codegen implementation of yield*. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@yield-star-with-return
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 } 1965 }
1966 1966
1967 case Yield::kFinal: { 1967 case Yield::kFinal: {
1968 // Pop value from top-of-stack slot, box result into result register. 1968 // Pop value from top-of-stack slot, box result into result register.
1969 EmitCreateIteratorResult(true); 1969 EmitCreateIteratorResult(true);
1970 EmitUnwindBeforeReturn(); 1970 EmitUnwindBeforeReturn();
1971 EmitReturnSequence(); 1971 EmitReturnSequence();
1972 break; 1972 break;
1973 } 1973 }
1974 1974
1975 case Yield::kDelegating: { 1975 case Yield::kDelegating:
1976 VisitForStackValue(expr->generator_object()); 1976 UNREACHABLE();
1977
1978 // Initial stack layout is as follows:
1979 // [sp + 1 * kPointerSize] iter
1980 // [sp + 0 * kPointerSize] g
1981
1982 Label l_catch, l_try, l_suspend, l_continuation, l_resume;
1983 Label l_next, l_call;
1984 Register load_receiver = LoadDescriptor::ReceiverRegister();
1985 Register load_name = LoadDescriptor::NameRegister();
1986
1987 // Initial send value is undefined.
1988 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex);
1989 __ Branch(&l_next);
1990
1991 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
1992 __ bind(&l_catch);
1993 __ mov(a0, v0);
1994 __ LoadRoot(a2, Heap::kthrow_stringRootIndex); // "throw"
1995 __ ld(a3, MemOperand(sp, 1 * kPointerSize)); // iter
1996 __ Push(a2, a3, a0); // "throw", iter, except
1997 __ jmp(&l_call);
1998
1999 // try { received = %yield result }
2000 // Shuffle the received result above a try handler and yield it without
2001 // re-boxing.
2002 __ bind(&l_try);
2003 __ pop(a0); // result
2004 int handler_index = NewHandlerTableEntry();
2005 EnterTryBlock(handler_index, &l_catch);
2006 const int try_block_size = TryCatch::kElementCount * kPointerSize;
2007 __ push(a0); // result
2008
2009 __ jmp(&l_suspend);
2010 __ bind(&l_continuation);
2011 __ RecordGeneratorContinuation();
2012 __ mov(a0, v0);
2013 __ jmp(&l_resume);
2014
2015 __ bind(&l_suspend);
2016 const int generator_object_depth = kPointerSize + try_block_size;
2017 __ ld(a0, MemOperand(sp, generator_object_depth));
2018 __ push(a0); // g
2019 __ Push(Smi::FromInt(handler_index)); // handler-index
2020 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos()));
2021 __ li(a1, Operand(Smi::FromInt(l_continuation.pos())));
2022 __ sd(a1, FieldMemOperand(a0, JSGeneratorObject::kContinuationOffset));
2023 __ sd(cp, FieldMemOperand(a0, JSGeneratorObject::kContextOffset));
2024 __ mov(a1, cp);
2025 __ RecordWriteField(a0, JSGeneratorObject::kContextOffset, a1, a2,
2026 kRAHasBeenSaved, kDontSaveFPRegs);
2027 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2);
2028 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2029 __ pop(v0); // result
2030 EmitReturnSequence();
2031 __ mov(a0, v0);
2032 __ bind(&l_resume); // received in a0
2033 ExitTryBlock(handler_index);
2034
2035 // receiver = iter; f = 'next'; arg = received;
2036 __ bind(&l_next);
2037 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next"
2038 __ ld(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 __ ld(load_receiver, MemOperand(sp, kPointerSize));
2044 __ ld(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 __ sd(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 __ ld(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 } 1977 }
2085 } 1978 }
2086 1979
2087 1980
2088 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 1981 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
2089 Expression *value, 1982 Expression *value,
2090 JSGeneratorObject::ResumeMode resume_mode) { 1983 JSGeneratorObject::ResumeMode resume_mode) {
2091 // The value stays in a0, and is ultimately read by the resumed generator, as 1984 // The value stays in a0, and is ultimately read by the resumed generator, as
2092 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 1985 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2093 // is read to throw the value when the resumed generator is already closed. 1986 // is read to throw the value when the resumed generator is already closed.
(...skipping 2741 matching lines...) Expand 10 before | Expand all | Expand 10 after
4835 reinterpret_cast<uint64_t>( 4728 reinterpret_cast<uint64_t>(
4836 isolate->builtins()->OsrAfterStackCheck()->entry())); 4729 isolate->builtins()->OsrAfterStackCheck()->entry()));
4837 return OSR_AFTER_STACK_CHECK; 4730 return OSR_AFTER_STACK_CHECK;
4838 } 4731 }
4839 4732
4840 4733
4841 } // namespace internal 4734 } // namespace internal
4842 } // namespace v8 4735 } // namespace v8
4843 4736
4844 #endif // V8_TARGET_ARCH_MIPS64 4737 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698