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

Side by Side Diff: src/ia32/full-codegen-ia32.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/hydrogen.cc ('k') | src/objects.h » ('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 1970 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 break; 1981 break;
1982 } 1982 }
1983 1983
1984 case Yield::DELEGATING: { 1984 case Yield::DELEGATING: {
1985 VisitForStackValue(expr->generator_object()); 1985 VisitForStackValue(expr->generator_object());
1986 1986
1987 // Initial stack layout is as follows: 1987 // Initial stack layout is as follows:
1988 // [sp + 1 * kPointerSize] iter 1988 // [sp + 1 * kPointerSize] iter
1989 // [sp + 0 * kPointerSize] g 1989 // [sp + 0 * kPointerSize] g
1990 1990
1991 Label l_catch, l_try, l_resume, l_send, l_call, l_loop; 1991 Label l_catch, l_try, l_resume, l_next, l_call, l_loop;
1992 // Initial send value is undefined. 1992 // Initial send value is undefined.
1993 __ mov(eax, isolate()->factory()->undefined_value()); 1993 __ mov(eax, isolate()->factory()->undefined_value());
1994 __ jmp(&l_send); 1994 __ jmp(&l_next);
1995 1995
1996 // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; } 1996 // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; }
1997 __ bind(&l_catch); 1997 __ bind(&l_catch);
1998 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); 1998 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos()));
1999 __ mov(edx, Operand(esp, 1 * kPointerSize)); // iter 1999 __ mov(edx, Operand(esp, 1 * kPointerSize)); // iter
2000 __ push(edx); // iter 2000 __ push(edx); // iter
2001 __ push(eax); // exception 2001 __ push(eax); // exception
2002 __ mov(ecx, isolate()->factory()->throw_string()); // "throw" 2002 __ mov(ecx, isolate()->factory()->throw_string()); // "throw"
2003 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize(); 2003 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize();
2004 CallIC(throw_ic); // iter.throw in eax 2004 CallIC(throw_ic); // iter.throw in eax
2005 __ jmp(&l_call); 2005 __ jmp(&l_call);
2006 2006
2007 // try { received = yield result.value } 2007 // try { received = yield result.value }
2008 __ bind(&l_try); 2008 __ bind(&l_try);
2009 __ pop(eax); // result.value 2009 __ pop(eax); // result.value
2010 __ PushTryHandler(StackHandler::CATCH, expr->index()); 2010 __ PushTryHandler(StackHandler::CATCH, expr->index());
2011 const int handler_size = StackHandlerConstants::kSize; 2011 const int handler_size = StackHandlerConstants::kSize;
2012 __ push(eax); // result.value 2012 __ push(eax); // result.value
2013 __ push(Operand(esp, (0 + 1) * kPointerSize + handler_size)); // g 2013 __ push(Operand(esp, (0 + 1) * kPointerSize + handler_size)); // g
2014 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 2014 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
2015 __ mov(context_register(), 2015 __ mov(context_register(),
2016 Operand(ebp, StandardFrameConstants::kContextOffset)); 2016 Operand(ebp, StandardFrameConstants::kContextOffset));
2017 __ CompareRoot(eax, Heap::kTheHoleValueRootIndex); 2017 __ CompareRoot(eax, Heap::kTheHoleValueRootIndex);
2018 __ j(not_equal, &l_resume); 2018 __ j(not_equal, &l_resume);
2019 EmitReturnIteratorResult(false); 2019 EmitReturnIteratorResult(false);
2020 __ bind(&l_resume); // received in eax 2020 __ bind(&l_resume); // received in eax
2021 __ PopTryHandler(); 2021 __ PopTryHandler();
2022 2022
2023 // receiver = iter; f = iter.send; arg = received; 2023 // receiver = iter; f = iter.next; arg = received;
2024 __ bind(&l_send); 2024 __ bind(&l_next);
2025 __ mov(edx, Operand(esp, 1 * kPointerSize)); // iter 2025 __ mov(edx, Operand(esp, 1 * kPointerSize)); // iter
2026 __ push(edx); // iter 2026 __ push(edx); // iter
2027 __ push(eax); // received 2027 __ push(eax); // received
2028 __ mov(ecx, isolate()->factory()->send_string()); // "send" 2028 __ mov(ecx, isolate()->factory()->next_string()); // "next"
2029 Handle<Code> send_ic = isolate()->builtins()->LoadIC_Initialize(); 2029 Handle<Code> next_ic = isolate()->builtins()->LoadIC_Initialize();
2030 CallIC(send_ic); // iter.send in eax 2030 CallIC(next_ic); // iter.next in eax
2031 2031
2032 // result = f.call(receiver, arg); 2032 // result = f.call(receiver, arg);
2033 __ bind(&l_call); 2033 __ bind(&l_call);
2034 Label l_call_runtime; 2034 Label l_call_runtime;
2035 __ JumpIfSmi(eax, &l_call_runtime); 2035 __ JumpIfSmi(eax, &l_call_runtime);
2036 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx); 2036 __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx);
2037 __ j(not_equal, &l_call_runtime); 2037 __ j(not_equal, &l_call_runtime);
2038 __ mov(edi, eax); 2038 __ mov(edi, eax);
2039 ParameterCount count(1); 2039 ParameterCount count(1);
2040 __ InvokeFunction(edi, count, CALL_FUNCTION, 2040 __ InvokeFunction(edi, count, CALL_FUNCTION,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2122 __ push(esi); // Callee's context. 2122 __ push(esi); // Callee's context.
2123 __ push(edi); // Callee's JS Function. 2123 __ push(edi); // Callee's JS Function.
2124 2124
2125 // Load the operand stack size. 2125 // Load the operand stack size.
2126 __ mov(edx, FieldOperand(ebx, JSGeneratorObject::kOperandStackOffset)); 2126 __ mov(edx, FieldOperand(ebx, JSGeneratorObject::kOperandStackOffset));
2127 __ mov(edx, FieldOperand(edx, FixedArray::kLengthOffset)); 2127 __ mov(edx, FieldOperand(edx, FixedArray::kLengthOffset));
2128 __ SmiUntag(edx); 2128 __ SmiUntag(edx);
2129 2129
2130 // If we are sending a value and there is no operand stack, we can jump back 2130 // If we are sending a value and there is no operand stack, we can jump back
2131 // in directly. 2131 // in directly.
2132 if (resume_mode == JSGeneratorObject::SEND) { 2132 if (resume_mode == JSGeneratorObject::NEXT) {
2133 Label slow_resume; 2133 Label slow_resume;
2134 __ cmp(edx, Immediate(0)); 2134 __ cmp(edx, Immediate(0));
2135 __ j(not_zero, &slow_resume); 2135 __ j(not_zero, &slow_resume);
2136 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); 2136 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset));
2137 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset)); 2137 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset));
2138 __ SmiUntag(ecx); 2138 __ SmiUntag(ecx);
2139 __ add(edx, ecx); 2139 __ add(edx, ecx);
2140 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), 2140 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
2141 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); 2141 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
2142 __ jmp(edx); 2142 __ jmp(edx);
(...skipping 2783 matching lines...) Expand 10 before | Expand all | Expand 10 after
4926 *stack_depth = 0; 4926 *stack_depth = 0;
4927 *context_length = 0; 4927 *context_length = 0;
4928 return previous_; 4928 return previous_;
4929 } 4929 }
4930 4930
4931 #undef __ 4931 #undef __
4932 4932
4933 } } // namespace v8::internal 4933 } } // namespace v8::internal
4934 4934
4935 #endif // V8_TARGET_ARCH_IA32 4935 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698