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

Side by Side Diff: src/full-codegen/x87/full-codegen-x87.cc

Issue 1671783002: X87: [generators] Implement Generator.prototype.return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
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
« no previous file with comments | « no previous file | no next file » | 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_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 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 case Yield::kSuspend: 1835 case Yield::kSuspend:
1836 // Pop value from top-of-stack slot; box result into result register. 1836 // Pop value from top-of-stack slot; box result into result register.
1837 EmitCreateIteratorResult(false); 1837 EmitCreateIteratorResult(false);
1838 __ push(result_register()); 1838 __ push(result_register());
1839 // Fall through. 1839 // Fall through.
1840 case Yield::kInitial: { 1840 case Yield::kInitial: {
1841 Label suspend, continuation, post_runtime, resume; 1841 Label suspend, continuation, post_runtime, resume;
1842 1842
1843 __ jmp(&suspend); 1843 __ jmp(&suspend);
1844 __ bind(&continuation); 1844 __ bind(&continuation);
1845 // When we arrive here, the stack top is the resume mode and
1846 // result_register() holds the input value (the argument given to the
1847 // respective resume operation).
1845 __ RecordGeneratorContinuation(); 1848 __ RecordGeneratorContinuation();
1846 __ jmp(&resume); 1849 __ pop(ebx);
1850 __ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::RETURN)));
1851 __ j(not_equal, &resume);
1852 __ push(result_register());
1853 EmitCreateIteratorResult(true);
1854 EmitUnwindBeforeReturn();
1855 EmitReturnSequence();
1847 1856
1848 __ bind(&suspend); 1857 __ bind(&suspend);
1849 VisitForAccumulatorValue(expr->generator_object()); 1858 VisitForAccumulatorValue(expr->generator_object());
1850 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); 1859 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos()));
1851 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), 1860 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset),
1852 Immediate(Smi::FromInt(continuation.pos()))); 1861 Immediate(Smi::FromInt(continuation.pos())));
1853 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); 1862 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi);
1854 __ mov(ecx, esi); 1863 __ mov(ecx, esi);
1855 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, 1864 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx,
1856 kDontSaveFPRegs); 1865 kDontSaveFPRegs);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 // The value stays in eax, and is ultimately read by the resumed generator, as 2006 // The value stays in eax, and is ultimately read by the resumed generator, as
1998 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 2007 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
1999 // is read to throw the value when the resumed generator is already closed. 2008 // is read to throw the value when the resumed generator is already closed.
2000 // ebx will hold the generator object until the activation has been resumed. 2009 // ebx will hold the generator object until the activation has been resumed.
2001 VisitForStackValue(generator); 2010 VisitForStackValue(generator);
2002 VisitForAccumulatorValue(value); 2011 VisitForAccumulatorValue(value);
2003 __ pop(ebx); 2012 __ pop(ebx);
2004 2013
2005 // Store input value into generator object. 2014 // Store input value into generator object.
2006 __ mov(FieldOperand(ebx, JSGeneratorObject::kInputOffset), result_register()); 2015 __ mov(FieldOperand(ebx, JSGeneratorObject::kInputOffset), result_register());
2007 __ mov(edx, result_register()); 2016 __ mov(ecx, result_register());
2008 __ RecordWriteField(ebx, JSGeneratorObject::kInputOffset, edx, ecx, 2017 __ RecordWriteField(ebx, JSGeneratorObject::kInputOffset, ecx, edx,
2009 kDontSaveFPRegs); 2018 kDontSaveFPRegs);
2010 2019
2011 // Load suspended function and context. 2020 // Load suspended function and context.
2012 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset)); 2021 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset));
2013 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset)); 2022 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
2014 2023
2015 // Push receiver. 2024 // Push receiver.
2016 __ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset)); 2025 __ push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset));
2017 2026
2018 // Push holes for arguments to generator function. 2027 // Push holes for arguments to generator function.
(...skipping 30 matching lines...) Expand all
2049 if (resume_mode == JSGeneratorObject::NEXT) { 2058 if (resume_mode == JSGeneratorObject::NEXT) {
2050 Label slow_resume; 2059 Label slow_resume;
2051 __ cmp(edx, Immediate(0)); 2060 __ cmp(edx, Immediate(0));
2052 __ j(not_zero, &slow_resume); 2061 __ j(not_zero, &slow_resume);
2053 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); 2062 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset));
2054 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset)); 2063 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset));
2055 __ SmiUntag(ecx); 2064 __ SmiUntag(ecx);
2056 __ add(edx, ecx); 2065 __ add(edx, ecx);
2057 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), 2066 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
2058 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); 2067 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
2068 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
2059 __ jmp(edx); 2069 __ jmp(edx);
2060 __ bind(&slow_resume); 2070 __ bind(&slow_resume);
2061 } 2071 }
2062 2072
2063 // Otherwise, we push holes for the operand stack and call the runtime to fix 2073 // Otherwise, we push holes for the operand stack and call the runtime to fix
2064 // up the stack and the handlers. 2074 // up the stack and the handlers.
2065 Label push_operand_holes, call_resume; 2075 Label push_operand_holes, call_resume;
2066 __ bind(&push_operand_holes); 2076 __ bind(&push_operand_holes);
2067 __ sub(edx, Immediate(1)); 2077 __ sub(edx, Immediate(1));
2068 __ j(carry, &call_resume); 2078 __ j(carry, &call_resume);
2069 __ push(ecx); 2079 __ push(ecx);
2070 __ jmp(&push_operand_holes); 2080 __ jmp(&push_operand_holes);
2071 __ bind(&call_resume); 2081 __ bind(&call_resume);
2082 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
2072 __ push(ebx); 2083 __ push(ebx);
2073 __ push(result_register()); 2084 __ push(result_register());
2074 __ Push(Smi::FromInt(resume_mode)); 2085 __ Push(Smi::FromInt(resume_mode));
2075 __ CallRuntime(Runtime::kResumeJSGeneratorObject); 2086 __ CallRuntime(Runtime::kResumeJSGeneratorObject);
2076 // Not reached: the runtime call returns elsewhere. 2087 // Not reached: the runtime call returns elsewhere.
2077 __ Abort(kGeneratorFailedToResume); 2088 __ Abort(kGeneratorFailedToResume);
2078 2089
2079 __ bind(&done); 2090 __ bind(&done);
2080 context()->Plug(result_register()); 2091 context()->Plug(result_register());
2081 } 2092 }
(...skipping 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
4705 Assembler::target_address_at(call_target_address, 4716 Assembler::target_address_at(call_target_address,
4706 unoptimized_code)); 4717 unoptimized_code));
4707 return OSR_AFTER_STACK_CHECK; 4718 return OSR_AFTER_STACK_CHECK;
4708 } 4719 }
4709 4720
4710 4721
4711 } // namespace internal 4722 } // namespace internal
4712 } // namespace v8 4723 } // namespace v8
4713 4724
4714 #endif // V8_TARGET_ARCH_X87 4725 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698