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

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

Powered by Google App Engine
This is Rietveld 408576698