OLD | NEW |
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 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 | 2022 |
2023 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | 2023 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
2024 __ bind(&l_catch); | 2024 __ bind(&l_catch); |
2025 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); | 2025 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); |
2026 __ LoadRoot(rcx, Heap::kthrow_stringRootIndex); // "throw" | 2026 __ LoadRoot(rcx, Heap::kthrow_stringRootIndex); // "throw" |
2027 __ push(rcx); | 2027 __ push(rcx); |
2028 __ push(Operand(rsp, 2 * kPointerSize)); // iter | 2028 __ push(Operand(rsp, 2 * kPointerSize)); // iter |
2029 __ push(rax); // exception | 2029 __ push(rax); // exception |
2030 __ jmp(&l_call); | 2030 __ jmp(&l_call); |
2031 | 2031 |
2032 // try { received = yield result.value } | 2032 // try { received = %yield result } |
| 2033 // Shuffle the received result above a try handler and yield it without |
| 2034 // re-boxing. |
2033 __ bind(&l_try); | 2035 __ bind(&l_try); |
2034 EmitCreateIteratorResult(false); // pop and box to rax | 2036 __ pop(rax); // result |
2035 __ PushTryHandler(StackHandler::CATCH, expr->index()); | 2037 __ PushTryHandler(StackHandler::CATCH, expr->index()); |
2036 const int handler_size = StackHandlerConstants::kSize; | 2038 const int handler_size = StackHandlerConstants::kSize; |
2037 __ push(rax); // result | 2039 __ push(rax); // result |
2038 __ push(Operand(rsp, (0 + 1) * kPointerSize + handler_size)); // g | 2040 __ push(Operand(rsp, (0 + 1) * kPointerSize + handler_size)); // g |
2039 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2041 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
2040 __ movq(context_register(), | 2042 __ movq(context_register(), |
2041 Operand(rbp, StandardFrameConstants::kContextOffset)); | 2043 Operand(rbp, StandardFrameConstants::kContextOffset)); |
2042 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); | 2044 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); |
2043 __ j(not_equal, &l_resume); | 2045 __ j(not_equal, &l_resume); |
2044 __ pop(rax); // result | 2046 __ pop(rax); // result |
2045 EmitReturnSequence(); | 2047 EmitReturnSequence(); |
2046 __ bind(&l_resume); // received in rax | 2048 __ bind(&l_resume); // received in rax |
2047 __ PopTryHandler(); | 2049 __ PopTryHandler(); |
2048 | 2050 |
2049 // receiver = iter; f = 'next'; arg = received; | 2051 // receiver = iter; f = 'next'; arg = received; |
2050 __ bind(&l_next); | 2052 __ bind(&l_next); |
2051 __ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next" | 2053 __ LoadRoot(rcx, Heap::knext_stringRootIndex); // "next" |
2052 __ push(rcx); | 2054 __ push(rcx); |
2053 __ push(Operand(rsp, 2 * kPointerSize)); // iter | 2055 __ push(Operand(rsp, 2 * kPointerSize)); // iter |
2054 __ push(rax); // received | 2056 __ push(rax); // received |
2055 | 2057 |
2056 // result = receiver[f](arg); | 2058 // result = receiver[f](arg); |
2057 __ bind(&l_call); | 2059 __ bind(&l_call); |
2058 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); | 2060 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); |
2059 CallIC(ic); | 2061 CallIC(ic); |
2060 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2062 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2061 __ Drop(1); // The key is still on the stack; drop it. | 2063 __ Drop(1); // The key is still on the stack; drop it. |
2062 | 2064 |
2063 // val = result.value; if (!result.done) goto l_try; | 2065 // if (!result.done) goto l_try; |
2064 __ bind(&l_loop); | 2066 __ bind(&l_loop); |
2065 // result.value | |
2066 __ push(rax); // save result | 2067 __ push(rax); // save result |
2067 __ LoadRoot(rcx, Heap::kvalue_stringRootIndex); // "value" | |
2068 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); | |
2069 CallIC(value_ic); // result.value in rax | |
2070 __ pop(rbx); // result | |
2071 __ push(rax); // result.value | |
2072 __ movq(rax, rbx); // result | |
2073 __ LoadRoot(rcx, Heap::kdone_stringRootIndex); // "done" | 2068 __ LoadRoot(rcx, Heap::kdone_stringRootIndex); // "done" |
2074 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); | 2069 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); |
2075 CallIC(done_ic); // result.done in rax | 2070 CallIC(done_ic); // result.done in rax |
2076 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2071 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2077 CallIC(bool_ic); | 2072 CallIC(bool_ic); |
2078 __ testq(result_register(), result_register()); | 2073 __ testq(result_register(), result_register()); |
2079 __ j(zero, &l_try); | 2074 __ j(zero, &l_try); |
2080 | 2075 |
2081 // result.value | 2076 // result.value |
2082 __ pop(rax); // result.value | 2077 __ pop(rax); // result |
| 2078 __ LoadRoot(rcx, Heap::kvalue_stringRootIndex); // "value" |
| 2079 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2080 CallIC(value_ic); // result.value in rax |
2083 context()->DropAndPlug(2, rax); // drop iter and g | 2081 context()->DropAndPlug(2, rax); // drop iter and g |
2084 break; | 2082 break; |
2085 } | 2083 } |
2086 } | 2084 } |
2087 } | 2085 } |
2088 | 2086 |
2089 | 2087 |
2090 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2088 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2091 Expression *value, | 2089 Expression *value, |
2092 JSGeneratorObject::ResumeMode resume_mode) { | 2090 JSGeneratorObject::ResumeMode resume_mode) { |
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4888 *context_length = 0; | 4886 *context_length = 0; |
4889 return previous_; | 4887 return previous_; |
4890 } | 4888 } |
4891 | 4889 |
4892 | 4890 |
4893 #undef __ | 4891 #undef __ |
4894 | 4892 |
4895 } } // namespace v8::internal | 4893 } } // namespace v8::internal |
4896 | 4894 |
4897 #endif // V8_TARGET_ARCH_X64 | 4895 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |