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

Side by Side Diff: src/full-codegen/x64/full-codegen-x64.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
« no previous file with comments | « src/full-codegen/ppc/full-codegen-ppc.cc ('k') | src/full-codegen/x87/full-codegen-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_X64 5 #if V8_TARGET_ARCH_X64
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 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 } 1908 }
1909 1909
1910 case Yield::kFinal: { 1910 case Yield::kFinal: {
1911 // Pop value from top-of-stack slot, box result into result register. 1911 // Pop value from top-of-stack slot, box result into result register.
1912 EmitCreateIteratorResult(true); 1912 EmitCreateIteratorResult(true);
1913 EmitUnwindBeforeReturn(); 1913 EmitUnwindBeforeReturn();
1914 EmitReturnSequence(); 1914 EmitReturnSequence();
1915 break; 1915 break;
1916 } 1916 }
1917 1917
1918 case Yield::kDelegating: { 1918 case Yield::kDelegating:
1919 VisitForStackValue(expr->generator_object()); 1919 UNREACHABLE();
1920
1921 // Initial stack layout is as follows:
1922 // [sp + 1 * kPointerSize] iter
1923 // [sp + 0 * kPointerSize] g
1924
1925 Label l_catch, l_try, l_suspend, l_continuation, l_resume;
1926 Label l_next, l_call, l_loop;
1927 Register load_receiver = LoadDescriptor::ReceiverRegister();
1928 Register load_name = LoadDescriptor::NameRegister();
1929
1930 // Initial send value is undefined.
1931 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
1932 __ jmp(&l_next);
1933
1934 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
1935 __ bind(&l_catch);
1936 __ LoadRoot(load_name, Heap::kthrow_stringRootIndex); // "throw"
1937 __ Push(load_name);
1938 __ Push(Operand(rsp, 2 * kPointerSize)); // iter
1939 __ Push(rax); // exception
1940 __ jmp(&l_call);
1941
1942 // try { received = %yield result }
1943 // Shuffle the received result above a try handler and yield it without
1944 // re-boxing.
1945 __ bind(&l_try);
1946 __ Pop(rax); // result
1947 int handler_index = NewHandlerTableEntry();
1948 EnterTryBlock(handler_index, &l_catch);
1949 const int try_block_size = TryCatch::kElementCount * kPointerSize;
1950 __ Push(rax); // result
1951
1952 __ jmp(&l_suspend);
1953 __ bind(&l_continuation);
1954 __ RecordGeneratorContinuation();
1955 __ jmp(&l_resume);
1956
1957 __ bind(&l_suspend);
1958 const int generator_object_depth = kPointerSize + try_block_size;
1959 __ movp(rax, Operand(rsp, generator_object_depth));
1960 __ Push(rax); // g
1961 __ Push(Smi::FromInt(handler_index)); // handler-index
1962 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos()));
1963 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset),
1964 Smi::FromInt(l_continuation.pos()));
1965 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi);
1966 __ movp(rcx, rsi);
1967 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx,
1968 kDontSaveFPRegs);
1969 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2);
1970 __ movp(context_register(),
1971 Operand(rbp, StandardFrameConstants::kContextOffset));
1972 __ Pop(rax); // result
1973 EmitReturnSequence();
1974 __ bind(&l_resume); // received in rax
1975 ExitTryBlock(handler_index);
1976
1977 // receiver = iter; f = 'next'; arg = received;
1978 __ bind(&l_next);
1979
1980 __ LoadRoot(load_name, Heap::knext_stringRootIndex);
1981 __ Push(load_name); // "next"
1982 __ Push(Operand(rsp, 2 * kPointerSize)); // iter
1983 __ Push(rax); // received
1984
1985 // result = receiver[f](arg);
1986 __ bind(&l_call);
1987 __ movp(load_receiver, Operand(rsp, kPointerSize));
1988 __ Move(LoadDescriptor::SlotRegister(),
1989 SmiFromSlot(expr->KeyedLoadFeedbackSlot()));
1990 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code();
1991 CallIC(ic, TypeFeedbackId::None());
1992 __ movp(rdi, rax);
1993 __ movp(Operand(rsp, 2 * kPointerSize), rdi);
1994
1995 SetCallPosition(expr);
1996 __ Set(rax, 1);
1997 __ Call(
1998 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined),
1999 RelocInfo::CODE_TARGET);
2000
2001 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2002 __ Drop(1); // The function is still on the stack; drop it.
2003
2004 // if (!result.done) goto l_try;
2005 __ bind(&l_loop);
2006 __ Move(load_receiver, rax);
2007 __ Push(load_receiver); // save result
2008 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done"
2009 __ Move(LoadDescriptor::SlotRegister(),
2010 SmiFromSlot(expr->DoneFeedbackSlot()));
2011 CallLoadIC(NOT_INSIDE_TYPEOF); // rax=result.done
2012 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate());
2013 CallIC(bool_ic);
2014 __ CompareRoot(result_register(), Heap::kTrueValueRootIndex);
2015 __ j(not_equal, &l_try);
2016
2017 // result.value
2018 __ Pop(load_receiver); // result
2019 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value"
2020 __ Move(LoadDescriptor::SlotRegister(),
2021 SmiFromSlot(expr->ValueFeedbackSlot()));
2022 CallLoadIC(NOT_INSIDE_TYPEOF); // result.value in rax
2023 context()->DropAndPlug(2, rax); // drop iter and g
2024 break;
2025 }
2026 } 1920 }
2027 } 1921 }
2028 1922
2029 1923
2030 void FullCodeGenerator::EmitGeneratorResume( 1924 void FullCodeGenerator::EmitGeneratorResume(
2031 Expression* generator, Expression* value, 1925 Expression* generator, Expression* value,
2032 JSGeneratorObject::ResumeMode resume_mode) { 1926 JSGeneratorObject::ResumeMode resume_mode) {
2033 // The value stays in rax, and is ultimately read by the resumed generator, as 1927 // The value stays in rax, and is ultimately read by the resumed generator, as
2034 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 1928 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2035 // is read to throw the value when the resumed generator is already closed. 1929 // is read to throw the value when the resumed generator is already closed.
(...skipping 2688 matching lines...) Expand 10 before | Expand all | Expand 10 after
4724 Assembler::target_address_at(call_target_address, 4618 Assembler::target_address_at(call_target_address,
4725 unoptimized_code)); 4619 unoptimized_code));
4726 return OSR_AFTER_STACK_CHECK; 4620 return OSR_AFTER_STACK_CHECK;
4727 } 4621 }
4728 4622
4729 4623
4730 } // namespace internal 4624 } // namespace internal
4731 } // namespace v8 4625 } // namespace v8
4732 4626
4733 #endif // V8_TARGET_ARCH_X64 4627 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/ppc/full-codegen-ppc.cc ('k') | src/full-codegen/x87/full-codegen-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698