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

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

Issue 1639343005: [generators] Implement Generator.prototype.return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@yield-star
Patch Set: Another 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/mips64/full-codegen-mips64.cc ('k') | src/js/generator.js » ('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 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 case Yield::kSuspend: 1861 case Yield::kSuspend:
1862 // Pop value from top-of-stack slot; box result into result register. 1862 // Pop value from top-of-stack slot; box result into result register.
1863 EmitCreateIteratorResult(false); 1863 EmitCreateIteratorResult(false);
1864 __ Push(result_register()); 1864 __ Push(result_register());
1865 // Fall through. 1865 // Fall through.
1866 case Yield::kInitial: { 1866 case Yield::kInitial: {
1867 Label suspend, continuation, post_runtime, resume; 1867 Label suspend, continuation, post_runtime, resume;
1868 1868
1869 __ jmp(&suspend); 1869 __ jmp(&suspend);
1870 __ bind(&continuation); 1870 __ bind(&continuation);
1871 // When we arrive here, the stack top is the resume mode and
1872 // result_register() holds the input value (the argument given to the
1873 // respective resume operation).
1871 __ RecordGeneratorContinuation(); 1874 __ RecordGeneratorContinuation();
1872 __ jmp(&resume); 1875 __ Pop(rbx);
1876 __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::RETURN));
1877 __ j(not_equal, &resume);
1878 __ Push(result_register());
1879 EmitCreateIteratorResult(true);
1880 EmitUnwindBeforeReturn();
1881 EmitReturnSequence();
1873 1882
1874 __ bind(&suspend); 1883 __ bind(&suspend);
1875 VisitForAccumulatorValue(expr->generator_object()); 1884 VisitForAccumulatorValue(expr->generator_object());
1876 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); 1885 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos()));
1877 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset), 1886 __ Move(FieldOperand(rax, JSGeneratorObject::kContinuationOffset),
1878 Smi::FromInt(continuation.pos())); 1887 Smi::FromInt(continuation.pos()));
1879 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi); 1888 __ movp(FieldOperand(rax, JSGeneratorObject::kContextOffset), rsi);
1880 __ movp(rcx, rsi); 1889 __ movp(rcx, rsi);
1881 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx, 1890 __ RecordWriteField(rax, JSGeneratorObject::kContextOffset, rcx, rdx,
1882 kDontSaveFPRegs); 1891 kDontSaveFPRegs);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 __ Move(LoadDescriptor::SlotRegister(), 2019 __ Move(LoadDescriptor::SlotRegister(),
2011 SmiFromSlot(expr->ValueFeedbackSlot())); 2020 SmiFromSlot(expr->ValueFeedbackSlot()));
2012 CallLoadIC(NOT_INSIDE_TYPEOF); // result.value in rax 2021 CallLoadIC(NOT_INSIDE_TYPEOF); // result.value in rax
2013 context()->DropAndPlug(2, rax); // drop iter and g 2022 context()->DropAndPlug(2, rax); // drop iter and g
2014 break; 2023 break;
2015 } 2024 }
2016 } 2025 }
2017 } 2026 }
2018 2027
2019 2028
2020 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 2029 void FullCodeGenerator::EmitGeneratorResume(
2021 Expression *value, 2030 Expression* generator, Expression* value,
2022 JSGeneratorObject::ResumeMode resume_mode) { 2031 JSGeneratorObject::ResumeMode resume_mode) {
2023 // The value stays in rax, and is ultimately read by the resumed generator, as 2032 // The value stays in rax, and is ultimately read by the resumed generator, as
2024 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it 2033 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
2025 // is read to throw the value when the resumed generator is already closed. 2034 // is read to throw the value when the resumed generator is already closed.
2026 // rbx will hold the generator object until the activation has been resumed. 2035 // rbx will hold the generator object until the activation has been resumed.
2027 VisitForStackValue(generator); 2036 VisitForStackValue(generator);
2028 VisitForAccumulatorValue(value); 2037 VisitForAccumulatorValue(value);
2029 __ Pop(rbx); 2038 __ Pop(rbx);
2030 2039
2031 // Store input value into generator object. 2040 // Store input value into generator object.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 if (resume_mode == JSGeneratorObject::NEXT) { 2085 if (resume_mode == JSGeneratorObject::NEXT) {
2077 Label slow_resume; 2086 Label slow_resume;
2078 __ cmpp(rdx, Immediate(0)); 2087 __ cmpp(rdx, Immediate(0));
2079 __ j(not_zero, &slow_resume); 2088 __ j(not_zero, &slow_resume);
2080 __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 2089 __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2081 __ SmiToInteger64(rcx, 2090 __ SmiToInteger64(rcx,
2082 FieldOperand(rbx, JSGeneratorObject::kContinuationOffset)); 2091 FieldOperand(rbx, JSGeneratorObject::kContinuationOffset));
2083 __ addp(rdx, rcx); 2092 __ addp(rdx, rcx);
2084 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset), 2093 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset),
2085 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); 2094 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
2095 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
2086 __ jmp(rdx); 2096 __ jmp(rdx);
2087 __ bind(&slow_resume); 2097 __ bind(&slow_resume);
2088 } 2098 }
2089 2099
2090 // Otherwise, we push holes for the operand stack and call the runtime to fix 2100 // Otherwise, we push holes for the operand stack and call the runtime to fix
2091 // up the stack and the handlers. 2101 // up the stack and the handlers.
2092 Label push_operand_holes, call_resume; 2102 Label push_operand_holes, call_resume;
2093 __ bind(&push_operand_holes); 2103 __ bind(&push_operand_holes);
2094 __ subp(rdx, Immediate(1)); 2104 __ subp(rdx, Immediate(1));
2095 __ j(carry, &call_resume); 2105 __ j(carry, &call_resume);
2096 __ Push(rcx); 2106 __ Push(rcx);
2097 __ jmp(&push_operand_holes); 2107 __ jmp(&push_operand_holes);
2098 __ bind(&call_resume); 2108 __ bind(&call_resume);
2109 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
2099 __ Push(rbx); 2110 __ Push(rbx);
2100 __ Push(result_register()); 2111 __ Push(result_register());
2101 __ Push(Smi::FromInt(resume_mode)); 2112 __ Push(Smi::FromInt(resume_mode));
2102 __ CallRuntime(Runtime::kResumeJSGeneratorObject); 2113 __ CallRuntime(Runtime::kResumeJSGeneratorObject);
2103 // Not reached: the runtime call returns elsewhere. 2114 // Not reached: the runtime call returns elsewhere.
2104 __ Abort(kGeneratorFailedToResume); 2115 __ Abort(kGeneratorFailedToResume);
2105 2116
2106 __ bind(&done); 2117 __ bind(&done);
2107 context()->Plug(result_register()); 2118 context()->Plug(result_register());
2108 } 2119 }
(...skipping 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after
4710 Assembler::target_address_at(call_target_address, 4721 Assembler::target_address_at(call_target_address,
4711 unoptimized_code)); 4722 unoptimized_code));
4712 return OSR_AFTER_STACK_CHECK; 4723 return OSR_AFTER_STACK_CHECK;
4713 } 4724 }
4714 4725
4715 4726
4716 } // namespace internal 4727 } // namespace internal
4717 } // namespace v8 4728 } // namespace v8
4718 4729
4719 #endif // V8_TARGET_ARCH_X64 4730 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/mips64/full-codegen-mips64.cc ('k') | src/js/generator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698