| 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 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 | 1996 |
| 1997 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | 1997 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
| 1998 __ bind(&l_catch); | 1998 __ bind(&l_catch); |
| 1999 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); | 1999 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); |
| 2000 __ mov(ecx, isolate()->factory()->throw_string()); // "throw" | 2000 __ mov(ecx, isolate()->factory()->throw_string()); // "throw" |
| 2001 __ push(ecx); // "throw" | 2001 __ push(ecx); // "throw" |
| 2002 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2002 __ push(Operand(esp, 2 * kPointerSize)); // iter |
| 2003 __ push(eax); // exception | 2003 __ push(eax); // exception |
| 2004 __ jmp(&l_call); | 2004 __ jmp(&l_call); |
| 2005 | 2005 |
| 2006 // try { received = yield result.value } | 2006 // try { received = %yield result } |
| 2007 // Shuffle the received result above a try handler and yield it without |
| 2008 // re-boxing. |
| 2007 __ bind(&l_try); | 2009 __ bind(&l_try); |
| 2008 EmitCreateIteratorResult(false); // pop and box to eax | 2010 __ pop(eax); // result |
| 2009 __ PushTryHandler(StackHandler::CATCH, expr->index()); | 2011 __ PushTryHandler(StackHandler::CATCH, expr->index()); |
| 2010 const int handler_size = StackHandlerConstants::kSize; | 2012 const int handler_size = StackHandlerConstants::kSize; |
| 2011 __ push(eax); // result | 2013 __ push(eax); // result |
| 2012 __ push(Operand(esp, (0 + 1) * kPointerSize + handler_size)); // g | 2014 __ push(Operand(esp, (0 + 1) * kPointerSize + handler_size)); // g |
| 2013 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 2015 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 2014 __ mov(context_register(), | 2016 __ mov(context_register(), |
| 2015 Operand(ebp, StandardFrameConstants::kContextOffset)); | 2017 Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2016 __ CompareRoot(eax, Heap::kTheHoleValueRootIndex); | 2018 __ CompareRoot(eax, Heap::kTheHoleValueRootIndex); |
| 2017 __ j(not_equal, &l_resume); | 2019 __ j(not_equal, &l_resume); |
| 2018 __ pop(eax); // result | 2020 __ pop(eax); // result |
| 2019 EmitReturnSequence(); | 2021 EmitReturnSequence(); |
| 2020 __ bind(&l_resume); // received in eax | 2022 __ bind(&l_resume); // received in eax |
| 2021 __ PopTryHandler(); | 2023 __ PopTryHandler(); |
| 2022 | 2024 |
| 2023 // receiver = iter; f = iter.next; arg = received; | 2025 // receiver = iter; f = iter.next; arg = received; |
| 2024 __ bind(&l_next); | 2026 __ bind(&l_next); |
| 2025 __ mov(ecx, isolate()->factory()->next_string()); // "next" | 2027 __ mov(ecx, isolate()->factory()->next_string()); // "next" |
| 2026 __ push(ecx); | 2028 __ push(ecx); |
| 2027 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2029 __ push(Operand(esp, 2 * kPointerSize)); // iter |
| 2028 __ push(eax); // received | 2030 __ push(eax); // received |
| 2029 | 2031 |
| 2030 // result = receiver[f](arg); | 2032 // result = receiver[f](arg); |
| 2031 __ bind(&l_call); | 2033 __ bind(&l_call); |
| 2032 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); | 2034 Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); |
| 2033 CallIC(ic); | 2035 CallIC(ic); |
| 2034 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2036 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2035 __ Drop(1); // The key is still on the stack; drop it. | 2037 __ Drop(1); // The key is still on the stack; drop it. |
| 2036 | 2038 |
| 2037 // val = result.value; if (!result.done) goto l_try; | 2039 // if (!result.done) goto l_try; |
| 2038 __ bind(&l_loop); | 2040 __ bind(&l_loop); |
| 2039 // result.value | |
| 2040 __ push(eax); // save result | 2041 __ push(eax); // save result |
| 2041 __ mov(edx, eax); // result | 2042 __ mov(edx, eax); // result |
| 2042 __ mov(ecx, isolate()->factory()->value_string()); // "value" | |
| 2043 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); | |
| 2044 CallIC(value_ic); // result.value in eax | |
| 2045 __ pop(ebx); // result | |
| 2046 __ push(eax); // result.value | |
| 2047 __ mov(edx, ebx); // result | |
| 2048 __ mov(ecx, isolate()->factory()->done_string()); // "done" | 2043 __ mov(ecx, isolate()->factory()->done_string()); // "done" |
| 2049 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); | 2044 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2050 CallIC(done_ic); // result.done in eax | 2045 CallIC(done_ic); // result.done in eax |
| 2051 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2046 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
| 2052 CallIC(bool_ic); | 2047 CallIC(bool_ic); |
| 2053 __ test(eax, eax); | 2048 __ test(eax, eax); |
| 2054 __ j(zero, &l_try); | 2049 __ j(zero, &l_try); |
| 2055 | 2050 |
| 2056 // result.value | 2051 // result.value |
| 2057 __ pop(eax); // result.value | 2052 __ pop(edx); // result |
| 2053 __ mov(ecx, isolate()->factory()->value_string()); // "value" |
| 2054 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2055 CallIC(value_ic); // result.value in eax |
| 2058 context()->DropAndPlug(2, eax); // drop iter and g | 2056 context()->DropAndPlug(2, eax); // drop iter and g |
| 2059 break; | 2057 break; |
| 2060 } | 2058 } |
| 2061 } | 2059 } |
| 2062 } | 2060 } |
| 2063 | 2061 |
| 2064 | 2062 |
| 2065 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2063 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
| 2066 Expression *value, | 2064 Expression *value, |
| 2067 JSGeneratorObject::ResumeMode resume_mode) { | 2065 JSGeneratorObject::ResumeMode resume_mode) { |
| (...skipping 2828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4896 *stack_depth = 0; | 4894 *stack_depth = 0; |
| 4897 *context_length = 0; | 4895 *context_length = 0; |
| 4898 return previous_; | 4896 return previous_; |
| 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_IA32 | 4903 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |