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

Side by Side Diff: src/full-codegen/ppc/full-codegen-ppc.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: Rebase 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_PPC 5 #if V8_TARGET_ARCH_PPC
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 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 } 1931 }
1932 1932
1933 case Yield::kFinal: { 1933 case Yield::kFinal: {
1934 // Pop value from top-of-stack slot, box result into result register. 1934 // Pop value from top-of-stack slot, box result into result register.
1935 EmitCreateIteratorResult(true); 1935 EmitCreateIteratorResult(true);
1936 EmitUnwindBeforeReturn(); 1936 EmitUnwindBeforeReturn();
1937 EmitReturnSequence(); 1937 EmitReturnSequence();
1938 break; 1938 break;
1939 } 1939 }
1940 1940
1941 case Yield::kDelegating: { 1941 case Yield::kDelegating:
1942 VisitForStackValue(expr->generator_object()); 1942 UNREACHABLE();
1943
1944 // Initial stack layout is as follows:
1945 // [sp + 1 * kPointerSize] iter
1946 // [sp + 0 * kPointerSize] g
1947
1948 Label l_catch, l_try, l_suspend, l_continuation, l_resume;
1949 Label l_next, l_call;
1950 Register load_receiver = LoadDescriptor::ReceiverRegister();
1951 Register load_name = LoadDescriptor::NameRegister();
1952
1953 // Initial send value is undefined.
1954 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
1955 __ b(&l_next);
1956
1957 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
1958 __ bind(&l_catch);
1959 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw"
1960 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter
1961 __ Push(load_name, r6, r3); // "throw", iter, except
1962 __ b(&l_call);
1963
1964 // try { received = %yield result }
1965 // Shuffle the received result above a try handler and yield it without
1966 // re-boxing.
1967 __ bind(&l_try);
1968 __ pop(r3); // result
1969 int handler_index = NewHandlerTableEntry();
1970 EnterTryBlock(handler_index, &l_catch);
1971 const int try_block_size = TryCatch::kElementCount * kPointerSize;
1972 __ push(r3); // result
1973
1974 __ b(&l_suspend);
1975 __ bind(&l_continuation);
1976 __ RecordGeneratorContinuation();
1977 __ b(&l_resume);
1978
1979 __ bind(&l_suspend);
1980 const int generator_object_depth = kPointerSize + try_block_size;
1981 __ LoadP(r3, MemOperand(sp, generator_object_depth));
1982 __ push(r3); // g
1983 __ Push(Smi::FromInt(handler_index)); // handler-index
1984 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos()));
1985 __ LoadSmiLiteral(r4, Smi::FromInt(l_continuation.pos()));
1986 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset),
1987 r0);
1988 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0);
1989 __ mr(r4, cp);
1990 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5,
1991 kLRHasBeenSaved, kDontSaveFPRegs);
1992 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2);
1993 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
1994 __ pop(r3); // result
1995 EmitReturnSequence();
1996 __ bind(&l_resume); // received in r3
1997 ExitTryBlock(handler_index);
1998
1999 // receiver = iter; f = 'next'; arg = received;
2000 __ bind(&l_next);
2001
2002 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next"
2003 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter
2004 __ Push(load_name, r6, r3); // "next", iter, received
2005
2006 // result = receiver[f](arg);
2007 __ bind(&l_call);
2008 __ LoadP(load_receiver, MemOperand(sp, kPointerSize));
2009 __ LoadP(load_name, MemOperand(sp, 2 * kPointerSize));
2010 __ mov(LoadDescriptor::SlotRegister(),
2011 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot())));
2012 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code();
2013 CallIC(ic, TypeFeedbackId::None());
2014 __ mr(r4, r3);
2015 __ StoreP(r4, MemOperand(sp, 2 * kPointerSize));
2016 SetCallPosition(expr);
2017 __ li(r3, Operand(1));
2018 __ Call(
2019 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined),
2020 RelocInfo::CODE_TARGET);
2021
2022 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2023 __ Drop(1); // The function is still on the stack; drop it.
2024
2025 // if (!result.done) goto l_try;
2026 __ Move(load_receiver, r3);
2027
2028 __ push(load_receiver); // save result
2029 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done"
2030 __ mov(LoadDescriptor::SlotRegister(),
2031 Operand(SmiFromSlot(expr->DoneFeedbackSlot())));
2032 CallLoadIC(NOT_INSIDE_TYPEOF); // r0=result.done
2033 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate());
2034 CallIC(bool_ic);
2035 __ CompareRoot(result_register(), Heap::kTrueValueRootIndex);
2036 __ bne(&l_try);
2037
2038 // result.value
2039 __ pop(load_receiver); // result
2040 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value"
2041 __ mov(LoadDescriptor::SlotRegister(),
2042 Operand(SmiFromSlot(expr->ValueFeedbackSlot())));
2043 CallLoadIC(NOT_INSIDE_TYPEOF); // r3=result.value
2044 context()->DropAndPlug(2, r3); // drop iter and g
2045 break;
2046 }
2047 } 1943 }
2048 } 1944 }
2049 1945
2050 1946
2051 void FullCodeGenerator::EmitGeneratorResume( 1947 void FullCodeGenerator::EmitGeneratorResume(
2052 Expression* generator, Expression* value, 1948 Expression* generator, Expression* value,
2053 JSGeneratorObject::ResumeMode resume_mode) { 1949 JSGeneratorObject::ResumeMode resume_mode) {
2054 // The value stays in r3, and is ultimately read by the resumed generator, as 1950 // The value stays in r3, and is ultimately read by the resumed generator, as
2055 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 1951 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2056 // is read to throw the value when the resumed generator is already closed. 1952 // is read to throw the value when the resumed generator is already closed.
(...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after
4776 return ON_STACK_REPLACEMENT; 4672 return ON_STACK_REPLACEMENT;
4777 } 4673 }
4778 4674
4779 DCHECK(interrupt_address == 4675 DCHECK(interrupt_address ==
4780 isolate->builtins()->OsrAfterStackCheck()->entry()); 4676 isolate->builtins()->OsrAfterStackCheck()->entry());
4781 return OSR_AFTER_STACK_CHECK; 4677 return OSR_AFTER_STACK_CHECK;
4782 } 4678 }
4783 } // namespace internal 4679 } // namespace internal
4784 } // namespace v8 4680 } // namespace v8
4785 #endif // V8_TARGET_ARCH_PPC 4681 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/full-codegen/mips64/full-codegen-mips64.cc ('k') | src/full-codegen/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698