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