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: 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 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 } 1913 }
1914 1914
1915 case Yield::kFinal: { 1915 case Yield::kFinal: {
1916 // Pop value from top-of-stack slot, box result into result register. 1916 // Pop value from top-of-stack slot, box result into result register.
1917 EmitCreateIteratorResult(true); 1917 EmitCreateIteratorResult(true);
1918 EmitUnwindBeforeReturn(); 1918 EmitUnwindBeforeReturn();
1919 EmitReturnSequence(); 1919 EmitReturnSequence();
1920 break; 1920 break;
1921 } 1921 }
1922 1922
1923 case Yield::kDelegating: { 1923 case Yield::kDelegating:
1924 VisitForStackValue(expr->generator_object()); 1924 UNREACHABLE();
1925
1926 // Initial stack layout is as follows:
1927 // [sp + 1 * kPointerSize] iter
1928 // [sp + 0 * kPointerSize] g
1929
1930 Label l_catch, l_try, l_suspend, l_continuation, l_resume;
1931 Label l_next, l_call;
1932 Register load_receiver = LoadDescriptor::ReceiverRegister();
1933 Register load_name = LoadDescriptor::NameRegister();
1934
1935 // Initial send value is undefined.
1936 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex);
1937 __ b(&l_next);
1938
1939 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
1940 __ bind(&l_catch);
1941 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw"
1942 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter
1943 __ Push(load_name, r6, r3); // "throw", iter, except
1944 __ b(&l_call);
1945
1946 // try { received = %yield result }
1947 // Shuffle the received result above a try handler and yield it without
1948 // re-boxing.
1949 __ bind(&l_try);
1950 __ pop(r3); // result
1951 int handler_index = NewHandlerTableEntry();
1952 EnterTryBlock(handler_index, &l_catch);
1953 const int try_block_size = TryCatch::kElementCount * kPointerSize;
1954 __ push(r3); // result
1955
1956 __ b(&l_suspend);
1957 __ bind(&l_continuation);
1958 __ RecordGeneratorContinuation();
1959 __ b(&l_resume);
1960
1961 __ bind(&l_suspend);
1962 const int generator_object_depth = kPointerSize + try_block_size;
1963 __ LoadP(r3, MemOperand(sp, generator_object_depth));
1964 __ push(r3); // g
1965 __ Push(Smi::FromInt(handler_index)); // handler-index
1966 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos()));
1967 __ LoadSmiLiteral(r4, Smi::FromInt(l_continuation.pos()));
1968 __ StoreP(r4, FieldMemOperand(r3, JSGeneratorObject::kContinuationOffset),
1969 r0);
1970 __ StoreP(cp, FieldMemOperand(r3, JSGeneratorObject::kContextOffset), r0);
1971 __ mr(r4, cp);
1972 __ RecordWriteField(r3, JSGeneratorObject::kContextOffset, r4, r5,
1973 kLRHasBeenSaved, kDontSaveFPRegs);
1974 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2);
1975 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
1976 __ pop(r3); // result
1977 EmitReturnSequence();
1978 __ bind(&l_resume); // received in r3
1979 ExitTryBlock(handler_index);
1980
1981 // receiver = iter; f = 'next'; arg = received;
1982 __ bind(&l_next);
1983
1984 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next"
1985 __ LoadP(r6, MemOperand(sp, 1 * kPointerSize)); // iter
1986 __ Push(load_name, r6, r3); // "next", iter, received
1987
1988 // result = receiver[f](arg);
1989 __ bind(&l_call);
1990 __ LoadP(load_receiver, MemOperand(sp, kPointerSize));
1991 __ LoadP(load_name, MemOperand(sp, 2 * kPointerSize));
1992 __ mov(LoadDescriptor::SlotRegister(),
1993 Operand(SmiFromSlot(expr->KeyedLoadFeedbackSlot())));
1994 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code();
1995 CallIC(ic, TypeFeedbackId::None());
1996 __ mr(r4, r3);
1997 __ StoreP(r4, MemOperand(sp, 2 * kPointerSize));
1998 SetCallPosition(expr);
1999 __ li(r3, Operand(1));
2000 __ Call(
2001 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined),
2002 RelocInfo::CODE_TARGET);
2003
2004 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2005 __ Drop(1); // The function is still on the stack; drop it.
2006
2007 // if (!result.done) goto l_try;
2008 __ Move(load_receiver, r3);
2009
2010 __ push(load_receiver); // save result
2011 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done"
2012 __ mov(LoadDescriptor::SlotRegister(),
2013 Operand(SmiFromSlot(expr->DoneFeedbackSlot())));
2014 CallLoadIC(NOT_INSIDE_TYPEOF); // r0=result.done
2015 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate());
2016 CallIC(bool_ic);
2017 __ CompareRoot(result_register(), Heap::kTrueValueRootIndex);
2018 __ bne(&l_try);
2019
2020 // result.value
2021 __ pop(load_receiver); // result
2022 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value"
2023 __ mov(LoadDescriptor::SlotRegister(),
2024 Operand(SmiFromSlot(expr->ValueFeedbackSlot())));
2025 CallLoadIC(NOT_INSIDE_TYPEOF); // r3=result.value
2026 context()->DropAndPlug(2, r3); // drop iter and g
2027 break;
2028 }
2029 } 1925 }
2030 } 1926 }
2031 1927
2032 1928
2033 void FullCodeGenerator::EmitGeneratorResume( 1929 void FullCodeGenerator::EmitGeneratorResume(
2034 Expression* generator, Expression* value, 1930 Expression* generator, Expression* value,
2035 JSGeneratorObject::ResumeMode resume_mode) { 1931 JSGeneratorObject::ResumeMode resume_mode) {
2036 // The value stays in r3, and is ultimately read by the resumed generator, as 1932 // The value stays in r3, and is ultimately read by the resumed generator, as
2037 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 1933 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2038 // is read to throw the value when the resumed generator is already closed. 1934 // is read to throw the value when the resumed generator is already closed.
(...skipping 2754 matching lines...) Expand 10 before | Expand all | Expand 10 after
4793 return ON_STACK_REPLACEMENT; 4689 return ON_STACK_REPLACEMENT;
4794 } 4690 }
4795 4691
4796 DCHECK(interrupt_address == 4692 DCHECK(interrupt_address ==
4797 isolate->builtins()->OsrAfterStackCheck()->entry()); 4693 isolate->builtins()->OsrAfterStackCheck()->entry());
4798 return OSR_AFTER_STACK_CHECK; 4694 return OSR_AFTER_STACK_CHECK;
4799 } 4695 }
4800 } // namespace internal 4696 } // namespace internal
4801 } // namespace v8 4697 } // namespace v8
4802 #endif // V8_TARGET_ARCH_PPC 4698 #endif // V8_TARGET_ARCH_PPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698