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 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 | 2037 |
2038 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | 2038 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
2039 __ bind(&l_catch); | 2039 __ bind(&l_catch); |
2040 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); | 2040 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); |
2041 __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw" | 2041 __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw" |
2042 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter | 2042 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter |
2043 __ push(r3); // iter | 2043 __ push(r3); // iter |
2044 __ push(r0); // exception | 2044 __ push(r0); // exception |
2045 __ jmp(&l_call); | 2045 __ jmp(&l_call); |
2046 | 2046 |
2047 // try { received = yield result.value } | 2047 // try { received = %yield result } |
| 2048 // Shuffle the received result above a try handler and yield it without |
| 2049 // re-boxing. |
2048 __ bind(&l_try); | 2050 __ bind(&l_try); |
2049 EmitCreateIteratorResult(false); // pop and box to r0 | 2051 __ pop(r0); // result |
2050 __ PushTryHandler(StackHandler::CATCH, expr->index()); | 2052 __ PushTryHandler(StackHandler::CATCH, expr->index()); |
2051 const int handler_size = StackHandlerConstants::kSize; | 2053 const int handler_size = StackHandlerConstants::kSize; |
2052 __ push(r0); // result | 2054 __ push(r0); // result |
2053 __ ldr(r3, MemOperand(sp, (0 + 1) * kPointerSize + handler_size)); // g | 2055 __ ldr(r3, MemOperand(sp, (0 + 1) * kPointerSize + handler_size)); // g |
2054 __ push(r3); // g | 2056 __ push(r3); // g |
2055 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2057 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
2056 __ ldr(context_register(), | 2058 __ ldr(context_register(), |
2057 MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2059 MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2058 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 2060 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
2059 __ b(ne, &l_resume); | 2061 __ b(ne, &l_resume); |
2060 __ pop(r0); // result | 2062 __ pop(r0); // result |
2061 EmitReturnSequence(); | 2063 EmitReturnSequence(); |
2062 __ bind(&l_resume); // received in r0 | 2064 __ bind(&l_resume); // received in r0 |
2063 __ PopTryHandler(); | 2065 __ PopTryHandler(); |
2064 | 2066 |
2065 // receiver = iter; f = 'next'; arg = received; | 2067 // receiver = iter; f = 'next'; arg = received; |
2066 __ bind(&l_next); | 2068 __ bind(&l_next); |
2067 __ LoadRoot(r2, Heap::knext_stringRootIndex); // "next" | 2069 __ LoadRoot(r2, Heap::knext_stringRootIndex); // "next" |
2068 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter | 2070 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter |
2069 __ push(r3); // iter | 2071 __ push(r3); // iter |
2070 __ push(r0); // received | 2072 __ push(r0); // received |
2071 | 2073 |
2072 // result = receiver[f](arg); | 2074 // result = receiver[f](arg); |
2073 __ bind(&l_call); | 2075 __ bind(&l_call); |
2074 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); | 2076 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); |
2075 CallIC(ic); | 2077 CallIC(ic); |
2076 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2078 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2077 | 2079 |
2078 // val = result.value; if (!result.done) goto l_try; | 2080 // if (!result.done) goto l_try; |
2079 __ bind(&l_loop); | 2081 __ bind(&l_loop); |
2080 // result.value | |
2081 __ push(r0); // save result | 2082 __ push(r0); // save result |
2082 __ LoadRoot(r2, Heap::kvalue_stringRootIndex); // "value" | |
2083 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); | |
2084 CallIC(value_ic); // result.value in r0 | |
2085 __ pop(r1); // result | |
2086 __ push(r0); // result.value | |
2087 __ mov(r0, r1); // result | |
2088 __ LoadRoot(r2, Heap::kdone_stringRootIndex); // "done" | 2083 __ LoadRoot(r2, Heap::kdone_stringRootIndex); // "done" |
2089 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); | 2084 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); |
2090 CallIC(done_ic); // result.done in r0 | 2085 CallIC(done_ic); // result.done in r0 |
2091 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2086 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2092 CallIC(bool_ic); | 2087 CallIC(bool_ic); |
2093 __ cmp(r0, Operand(0)); | 2088 __ cmp(r0, Operand(0)); |
2094 __ b(eq, &l_try); | 2089 __ b(eq, &l_try); |
2095 | 2090 |
2096 // result.value | 2091 // result.value |
2097 __ pop(r0); // result.value | 2092 __ pop(r0); // result |
| 2093 __ LoadRoot(r2, Heap::kvalue_stringRootIndex); // "value" |
| 2094 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2095 CallIC(value_ic); // result.value in r0 |
2098 context()->DropAndPlug(2, r0); // drop iter and g | 2096 context()->DropAndPlug(2, r0); // drop iter and g |
2099 break; | 2097 break; |
2100 } | 2098 } |
2101 } | 2099 } |
2102 } | 2100 } |
2103 | 2101 |
2104 | 2102 |
2105 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2103 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2106 Expression *value, | 2104 Expression *value, |
2107 JSGeneratorObject::ResumeMode resume_mode) { | 2105 JSGeneratorObject::ResumeMode resume_mode) { |
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4896 *context_length = 0; | 4894 *context_length = 0; |
4897 return previous_; | 4895 return previous_; |
4898 } | 4896 } |
4899 | 4897 |
4900 | 4898 |
4901 #undef __ | 4899 #undef __ |
4902 | 4900 |
4903 } } // namespace v8::internal | 4901 } } // namespace v8::internal |
4904 | 4902 |
4905 #endif // V8_TARGET_ARCH_ARM | 4903 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |