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

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

Issue 16136011: Generator object "next" method takes optional send value (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased onto master Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/harmony/generators-iteration.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 break; 2005 break;
2006 } 2006 }
2007 2007
2008 case Yield::DELEGATING: { 2008 case Yield::DELEGATING: {
2009 VisitForStackValue(expr->generator_object()); 2009 VisitForStackValue(expr->generator_object());
2010 2010
2011 // Initial stack layout is as follows: 2011 // Initial stack layout is as follows:
2012 // [sp + 1 * kPointerSize] iter 2012 // [sp + 1 * kPointerSize] iter
2013 // [sp + 0 * kPointerSize] g 2013 // [sp + 0 * kPointerSize] g
2014 2014
2015 Label l_catch, l_try, l_resume, l_send, l_call, l_loop; 2015 Label l_catch, l_try, l_resume, l_next, l_call, l_loop;
2016 // Initial send value is undefined. 2016 // Initial send value is undefined.
2017 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); 2017 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex);
2018 __ jmp(&l_send); 2018 __ jmp(&l_next);
2019 2019
2020 // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; } 2020 // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; }
2021 __ bind(&l_catch); 2021 __ bind(&l_catch);
2022 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); 2022 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
2023 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); // iter 2023 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); // iter
2024 __ push(rcx); // iter 2024 __ push(rcx); // iter
2025 __ push(rax); // exception 2025 __ push(rax); // exception
2026 __ movq(rax, rcx); // iter 2026 __ movq(rax, rcx); // iter
2027 __ LoadRoot(rcx, Heap::kthrow_stringRootIndex); // "throw" 2027 __ LoadRoot(rcx, Heap::kthrow_stringRootIndex); // "throw"
2028 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize(); 2028 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize();
2029 CallIC(throw_ic); // iter.throw in rax 2029 CallIC(throw_ic); // iter.throw in rax
2030 __ jmp(&l_call); 2030 __ jmp(&l_call);
2031 2031
2032 // try { received = yield result.value } 2032 // try { received = yield result.value }
2033 __ bind(&l_try); 2033 __ bind(&l_try);
2034 __ pop(rax); // result.value 2034 __ pop(rax); // result.value
2035 __ PushTryHandler(StackHandler::CATCH, expr->index()); 2035 __ PushTryHandler(StackHandler::CATCH, expr->index());
2036 const int handler_size = StackHandlerConstants::kSize; 2036 const int handler_size = StackHandlerConstants::kSize;
2037 __ push(rax); // result.value 2037 __ push(rax); // result.value
2038 __ push(Operand(rsp, (0 + 1) * kPointerSize + handler_size)); // g 2038 __ push(Operand(rsp, (0 + 1) * kPointerSize + handler_size)); // g
2039 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 2039 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
2040 __ movq(context_register(), 2040 __ movq(context_register(),
2041 Operand(rbp, StandardFrameConstants::kContextOffset)); 2041 Operand(rbp, StandardFrameConstants::kContextOffset));
2042 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 2042 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2043 __ j(not_equal, &l_resume); 2043 __ j(not_equal, &l_resume);
2044 EmitReturnIteratorResult(false); 2044 EmitReturnIteratorResult(false);
2045 __ bind(&l_resume); // received in rax 2045 __ bind(&l_resume); // received in rax
2046 __ PopTryHandler(); 2046 __ PopTryHandler();
2047 2047
2048 // receiver = iter; f = iter.send; arg = received; 2048 // receiver = iter; f = iter.next; arg = received;
2049 __ bind(&l_send); 2049 __ bind(&l_next);
2050 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); // iter 2050 __ movq(rcx, Operand(rsp, 1 * kPointerSize)); // iter
2051 __ push(rcx); // iter 2051 __ push(rcx); // iter
2052 __ push(rax); // received 2052 __ push(rax); // received
2053 __ movq(rax, rcx); // iter 2053 __ movq(rax, rcx); // iter
2054 __ LoadRoot(rcx, Heap::ksend_stringRootIndex); // "send" 2054 __ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next"
2055 Handle<Code> send_ic = isolate()->builtins()->LoadIC_Initialize(); 2055 Handle<Code> next_ic = isolate()->builtins()->LoadIC_Initialize();
2056 CallIC(send_ic); // iter.send in rax 2056 CallIC(next_ic); // iter.next in rax
2057 2057
2058 // result = f.call(receiver, arg); 2058 // result = f.call(receiver, arg);
2059 __ bind(&l_call); 2059 __ bind(&l_call);
2060 Label l_call_runtime; 2060 Label l_call_runtime;
2061 __ JumpIfSmi(rax, &l_call_runtime); 2061 __ JumpIfSmi(rax, &l_call_runtime);
2062 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx); 2062 __ CmpObjectType(rax, JS_FUNCTION_TYPE, rbx);
2063 __ j(not_equal, &l_call_runtime); 2063 __ j(not_equal, &l_call_runtime);
2064 __ movq(rdi, rax); 2064 __ movq(rdi, rax);
2065 ParameterCount count(1); 2065 ParameterCount count(1);
2066 __ InvokeFunction(rdi, count, CALL_FUNCTION, 2066 __ InvokeFunction(rdi, count, CALL_FUNCTION,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2148 __ push(rsi); // Callee's context. 2148 __ push(rsi); // Callee's context.
2149 __ push(rdi); // Callee's JS Function. 2149 __ push(rdi); // Callee's JS Function.
2150 2150
2151 // Load the operand stack size. 2151 // Load the operand stack size.
2152 __ movq(rdx, FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset)); 2152 __ movq(rdx, FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset));
2153 __ movq(rdx, FieldOperand(rdx, FixedArray::kLengthOffset)); 2153 __ movq(rdx, FieldOperand(rdx, FixedArray::kLengthOffset));
2154 __ SmiToInteger32(rdx, rdx); 2154 __ SmiToInteger32(rdx, rdx);
2155 2155
2156 // If we are sending a value and there is no operand stack, we can jump back 2156 // If we are sending a value and there is no operand stack, we can jump back
2157 // in directly. 2157 // in directly.
2158 if (resume_mode == JSGeneratorObject::SEND) { 2158 if (resume_mode == JSGeneratorObject::NEXT) {
2159 Label slow_resume; 2159 Label slow_resume;
2160 __ cmpq(rdx, Immediate(0)); 2160 __ cmpq(rdx, Immediate(0));
2161 __ j(not_zero, &slow_resume); 2161 __ j(not_zero, &slow_resume);
2162 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 2162 __ movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2163 __ SmiToInteger64(rcx, 2163 __ SmiToInteger64(rcx,
2164 FieldOperand(rbx, JSGeneratorObject::kContinuationOffset)); 2164 FieldOperand(rbx, JSGeneratorObject::kContinuationOffset));
2165 __ addq(rdx, rcx); 2165 __ addq(rdx, rcx);
2166 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset), 2166 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset),
2167 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); 2167 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
2168 __ jmp(rdx); 2168 __ jmp(rdx);
(...skipping 2747 matching lines...) Expand 10 before | Expand all | Expand 10 after
4916 *context_length = 0; 4916 *context_length = 0;
4917 return previous_; 4917 return previous_;
4918 } 4918 }
4919 4919
4920 4920
4921 #undef __ 4921 #undef __
4922 4922
4923 } } // namespace v8::internal 4923 } } // namespace v8::internal
4924 4924
4925 #endif // V8_TARGET_ARCH_X64 4925 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/mjsunit/harmony/generators-iteration.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698