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/x87/full-codegen-x87.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_X87 5 #if V8_TARGET_ARCH_X87
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 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 } 1860 }
1861 1861
1862 case Yield::kFinal: { 1862 case Yield::kFinal: {
1863 // Pop value from top-of-stack slot, box result into result register. 1863 // Pop value from top-of-stack slot, box result into result register.
1864 EmitCreateIteratorResult(true); 1864 EmitCreateIteratorResult(true);
1865 EmitUnwindBeforeReturn(); 1865 EmitUnwindBeforeReturn();
1866 EmitReturnSequence(); 1866 EmitReturnSequence();
1867 break; 1867 break;
1868 } 1868 }
1869 1869
1870 case Yield::kDelegating: { 1870 case Yield::kDelegating:
1871 VisitForStackValue(expr->generator_object()); 1871 UNREACHABLE();
1872
1873 // Initial stack layout is as follows:
1874 // [sp + 1 * kPointerSize] iter
1875 // [sp + 0 * kPointerSize] g
1876
1877 Label l_catch, l_try, l_suspend, l_continuation, l_resume;
1878 Label l_next, l_call, l_loop;
1879 Register load_receiver = LoadDescriptor::ReceiverRegister();
1880 Register load_name = LoadDescriptor::NameRegister();
1881
1882 // Initial send value is undefined.
1883 __ mov(eax, isolate()->factory()->undefined_value());
1884 __ jmp(&l_next);
1885
1886 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; }
1887 __ bind(&l_catch);
1888 __ mov(load_name, isolate()->factory()->throw_string()); // "throw"
1889 __ push(load_name); // "throw"
1890 __ push(Operand(esp, 2 * kPointerSize)); // iter
1891 __ push(eax); // exception
1892 __ jmp(&l_call);
1893
1894 // try { received = %yield result }
1895 // Shuffle the received result above a try handler and yield it without
1896 // re-boxing.
1897 __ bind(&l_try);
1898 __ pop(eax); // result
1899 int handler_index = NewHandlerTableEntry();
1900 EnterTryBlock(handler_index, &l_catch);
1901 const int try_block_size = TryCatch::kElementCount * kPointerSize;
1902 __ push(eax); // result
1903
1904 __ jmp(&l_suspend);
1905 __ bind(&l_continuation);
1906 __ RecordGeneratorContinuation();
1907 __ jmp(&l_resume);
1908
1909 __ bind(&l_suspend);
1910 const int generator_object_depth = kPointerSize + try_block_size;
1911 __ mov(eax, Operand(esp, generator_object_depth));
1912 __ push(eax); // g
1913 __ push(Immediate(Smi::FromInt(handler_index))); // handler-index
1914 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos()));
1915 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset),
1916 Immediate(Smi::FromInt(l_continuation.pos())));
1917 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi);
1918 __ mov(ecx, esi);
1919 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx,
1920 kDontSaveFPRegs);
1921 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2);
1922 __ mov(context_register(),
1923 Operand(ebp, StandardFrameConstants::kContextOffset));
1924 __ pop(eax); // result
1925 EmitReturnSequence();
1926 __ bind(&l_resume); // received in eax
1927 ExitTryBlock(handler_index);
1928
1929 // receiver = iter; f = iter.next; arg = received;
1930 __ bind(&l_next);
1931
1932 __ mov(load_name, isolate()->factory()->next_string());
1933 __ push(load_name); // "next"
1934 __ push(Operand(esp, 2 * kPointerSize)); // iter
1935 __ push(eax); // received
1936
1937 // result = receiver[f](arg);
1938 __ bind(&l_call);
1939 __ mov(load_receiver, Operand(esp, kPointerSize));
1940 __ mov(LoadDescriptor::SlotRegister(),
1941 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot())));
1942 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code();
1943 CallIC(ic, TypeFeedbackId::None());
1944 __ mov(edi, eax);
1945 __ mov(Operand(esp, 2 * kPointerSize), edi);
1946 SetCallPosition(expr);
1947 __ Set(eax, 1);
1948 __ Call(
1949 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined),
1950 RelocInfo::CODE_TARGET);
1951
1952 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
1953 __ Drop(1); // The function is still on the stack; drop it.
1954
1955 // if (!result.done) goto l_try;
1956 __ bind(&l_loop);
1957 __ push(eax); // save result
1958 __ Move(load_receiver, eax); // result
1959 __ mov(load_name,
1960 isolate()->factory()->done_string()); // "done"
1961 __ mov(LoadDescriptor::SlotRegister(),
1962 Immediate(SmiFromSlot(expr->DoneFeedbackSlot())));
1963 CallLoadIC(NOT_INSIDE_TYPEOF); // result.done in eax
1964 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate());
1965 CallIC(bool_ic);
1966 __ CompareRoot(result_register(), Heap::kTrueValueRootIndex);
1967 __ j(not_equal, &l_try);
1968
1969 // result.value
1970 __ pop(load_receiver); // result
1971 __ mov(load_name,
1972 isolate()->factory()->value_string()); // "value"
1973 __ mov(LoadDescriptor::SlotRegister(),
1974 Immediate(SmiFromSlot(expr->ValueFeedbackSlot())));
1975 CallLoadIC(NOT_INSIDE_TYPEOF); // result.value in eax
1976 context()->DropAndPlug(2, eax); // drop iter and g
1977 break;
1978 }
1979 } 1872 }
1980 } 1873 }
1981 1874
1982 1875
1983 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 1876 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
1984 Expression *value, 1877 Expression *value,
1985 JSGeneratorObject::ResumeMode resume_mode) { 1878 JSGeneratorObject::ResumeMode resume_mode) {
1986 // The value stays in eax, and is ultimately read by the resumed generator, as 1879 // The value stays in eax, and is ultimately read by the resumed generator, as
1987 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 1880 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
1988 // is read to throw the value when the resumed generator is already closed. 1881 // is read to throw the value when the resumed generator is already closed.
(...skipping 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after
4714 Assembler::target_address_at(call_target_address, 4607 Assembler::target_address_at(call_target_address,
4715 unoptimized_code)); 4608 unoptimized_code));
4716 return OSR_AFTER_STACK_CHECK; 4609 return OSR_AFTER_STACK_CHECK;
4717 } 4610 }
4718 4611
4719 4612
4720 } // namespace internal 4613 } // namespace internal
4721 } // namespace v8 4614 } // namespace v8
4722 4615
4723 #endif // V8_TARGET_ARCH_X87 4616 #endif // V8_TARGET_ARCH_X87
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698