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

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

Issue 16695006: Delegating yield does not re-box result objects (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase; make test pretty. 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/ia32/full-codegen-ia32.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 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 2019
2020 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } 2020 // catch (e) { receiver = iter; f = '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 __ LoadRoot(rcx, Heap::kthrow_stringRootIndex); // "throw" 2023 __ LoadRoot(rcx, Heap::kthrow_stringRootIndex); // "throw"
2024 __ push(rcx); 2024 __ push(rcx);
2025 __ push(Operand(rsp, 2 * kPointerSize)); // iter 2025 __ push(Operand(rsp, 2 * kPointerSize)); // iter
2026 __ push(rax); // exception 2026 __ push(rax); // exception
2027 __ jmp(&l_call); 2027 __ jmp(&l_call);
2028 2028
2029 // try { received = yield result.value } 2029 // try { received = %yield result }
2030 // Shuffle the received result above a try handler and yield it without
2031 // re-boxing.
2030 __ bind(&l_try); 2032 __ bind(&l_try);
2031 EmitCreateIteratorResult(false); // pop and box to rax 2033 __ pop(rax); // result
2032 __ PushTryHandler(StackHandler::CATCH, expr->index()); 2034 __ PushTryHandler(StackHandler::CATCH, expr->index());
2033 const int handler_size = StackHandlerConstants::kSize; 2035 const int handler_size = StackHandlerConstants::kSize;
2034 __ push(rax); // result 2036 __ push(rax); // result
2035 __ push(Operand(rsp, (0 + 1) * kPointerSize + handler_size)); // g 2037 __ push(Operand(rsp, (0 + 1) * kPointerSize + handler_size)); // g
2036 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); 2038 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1);
2037 __ movq(context_register(), 2039 __ movq(context_register(),
2038 Operand(rbp, StandardFrameConstants::kContextOffset)); 2040 Operand(rbp, StandardFrameConstants::kContextOffset));
2039 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 2041 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
2040 __ j(not_equal, &l_resume); 2042 __ j(not_equal, &l_resume);
2041 __ pop(rax); // result 2043 __ pop(rax); // result
2042 EmitReturnSequence(); 2044 EmitReturnSequence();
2043 __ bind(&l_resume); // received in rax 2045 __ bind(&l_resume); // received in rax
2044 __ PopTryHandler(); 2046 __ PopTryHandler();
2045 2047
2046 // receiver = iter; f = 'next'; arg = received; 2048 // receiver = iter; f = 'next'; arg = received;
2047 __ bind(&l_next); 2049 __ bind(&l_next);
2048 __ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next" 2050 __ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next"
2049 __ push(rcx); 2051 __ push(rcx);
2050 __ push(Operand(rsp, 2 * kPointerSize)); // iter 2052 __ push(Operand(rsp, 2 * kPointerSize)); // iter
2051 __ push(rax); // received 2053 __ push(rax); // received
2052 2054
2053 // result = receiver[f](arg); 2055 // result = receiver[f](arg);
2054 __ bind(&l_call); 2056 __ bind(&l_call);
2055 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); 2057 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1);
2056 CallIC(ic); 2058 CallIC(ic);
2057 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); 2059 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2058 __ Drop(1); // The key is still on the stack; drop it. 2060 __ Drop(1); // The key is still on the stack; drop it.
2059 2061
2060 // val = result.value; if (!result.done) goto l_try; 2062 // if (!result.done) goto l_try;
2061 __ bind(&l_loop); 2063 __ bind(&l_loop);
2062 // result.value
2063 __ push(rax); // save result 2064 __ push(rax); // save result
2064 __ LoadRoot(rcx, Heap::kvalue_stringRootIndex); // "value"
2065 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
2066 CallIC(value_ic); // result.value in rax
2067 __ pop(rbx); // result
2068 __ push(rax); // result.value
2069 __ movq(rax, rbx); // result
2070 __ LoadRoot(rcx, Heap::kdone_stringRootIndex); // "done" 2065 __ LoadRoot(rcx, Heap::kdone_stringRootIndex); // "done"
2071 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); 2066 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize();
2072 CallIC(done_ic); // result.done in rax 2067 CallIC(done_ic); // result.done in rax
2073 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); 2068 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate());
2074 CallIC(bool_ic); 2069 CallIC(bool_ic);
2075 __ testq(result_register(), result_register()); 2070 __ testq(result_register(), result_register());
2076 __ j(zero, &l_try); 2071 __ j(zero, &l_try);
2077 2072
2078 // result.value 2073 // result.value
2079 __ pop(rax); // result.value 2074 __ pop(rax); // result
2075 __ LoadRoot(rcx, Heap::kvalue_stringRootIndex); // "value"
2076 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize();
2077 CallIC(value_ic); // result.value in rax
2080 context()->DropAndPlug(2, rax); // drop iter and g 2078 context()->DropAndPlug(2, rax); // drop iter and g
2081 break; 2079 break;
2082 } 2080 }
2083 } 2081 }
2084 } 2082 }
2085 2083
2086 2084
2087 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, 2085 void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
2088 Expression *value, 2086 Expression *value,
2089 JSGeneratorObject::ResumeMode resume_mode) { 2087 JSGeneratorObject::ResumeMode resume_mode) {
(...skipping 2793 matching lines...) Expand 10 before | Expand all | Expand 10 after
4883 *context_length = 0; 4881 *context_length = 0;
4884 return previous_; 4882 return previous_;
4885 } 4883 }
4886 4884
4887 4885
4888 #undef __ 4886 #undef __
4889 4887
4890 } } // namespace v8::internal 4888 } } // namespace v8::internal
4891 4889
4892 #endif // V8_TARGET_ARCH_X64 4890 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | test/mjsunit/harmony/generators-iteration.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698