OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 case Yield::kSuspend: | 1839 case Yield::kSuspend: |
1840 // Pop value from top-of-stack slot; box result into result register. | 1840 // Pop value from top-of-stack slot; box result into result register. |
1841 EmitCreateIteratorResult(false); | 1841 EmitCreateIteratorResult(false); |
1842 __ push(result_register()); | 1842 __ push(result_register()); |
1843 // Fall through. | 1843 // Fall through. |
1844 case Yield::kInitial: { | 1844 case Yield::kInitial: { |
1845 Label suspend, continuation, post_runtime, resume; | 1845 Label suspend, continuation, post_runtime, resume; |
1846 | 1846 |
1847 __ jmp(&suspend); | 1847 __ jmp(&suspend); |
1848 __ bind(&continuation); | 1848 __ bind(&continuation); |
| 1849 // When we arrive here, the stack top is the resume mode and |
| 1850 // result_register() holds the input value (the argument given to the |
| 1851 // respective resume operation). |
1849 __ RecordGeneratorContinuation(); | 1852 __ RecordGeneratorContinuation(); |
1850 __ jmp(&resume); | 1853 __ pop(ebx); |
| 1854 __ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::RETURN))); |
| 1855 __ j(not_equal, &resume); |
| 1856 __ push(result_register()); |
| 1857 EmitCreateIteratorResult(true); |
| 1858 EmitUnwindBeforeReturn(); |
| 1859 EmitReturnSequence(); |
1851 | 1860 |
1852 __ bind(&suspend); | 1861 __ bind(&suspend); |
1853 VisitForAccumulatorValue(expr->generator_object()); | 1862 VisitForAccumulatorValue(expr->generator_object()); |
1854 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1863 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
1855 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), | 1864 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), |
1856 Immediate(Smi::FromInt(continuation.pos()))); | 1865 Immediate(Smi::FromInt(continuation.pos()))); |
1857 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); | 1866 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); |
1858 __ mov(ecx, esi); | 1867 __ mov(ecx, esi); |
1859 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, | 1868 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, |
1860 kDontSaveFPRegs); | 1869 kDontSaveFPRegs); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 if (resume_mode == JSGeneratorObject::NEXT) { | 2062 if (resume_mode == JSGeneratorObject::NEXT) { |
2054 Label slow_resume; | 2063 Label slow_resume; |
2055 __ cmp(edx, Immediate(0)); | 2064 __ cmp(edx, Immediate(0)); |
2056 __ j(not_zero, &slow_resume); | 2065 __ j(not_zero, &slow_resume); |
2057 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 2066 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
2058 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset)); | 2067 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset)); |
2059 __ SmiUntag(ecx); | 2068 __ SmiUntag(ecx); |
2060 __ add(edx, ecx); | 2069 __ add(edx, ecx); |
2061 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), | 2070 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), |
2062 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 2071 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
| 2072 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2063 __ jmp(edx); | 2073 __ jmp(edx); |
2064 __ bind(&slow_resume); | 2074 __ bind(&slow_resume); |
2065 } | 2075 } |
2066 | 2076 |
2067 // Otherwise, we push holes for the operand stack and call the runtime to fix | 2077 // Otherwise, we push holes for the operand stack and call the runtime to fix |
2068 // up the stack and the handlers. | 2078 // up the stack and the handlers. |
2069 Label push_operand_holes, call_resume; | 2079 Label push_operand_holes, call_resume; |
2070 __ bind(&push_operand_holes); | 2080 __ bind(&push_operand_holes); |
2071 __ sub(edx, Immediate(1)); | 2081 __ sub(edx, Immediate(1)); |
2072 __ j(carry, &call_resume); | 2082 __ j(carry, &call_resume); |
2073 __ push(ecx); | 2083 __ push(ecx); |
2074 __ jmp(&push_operand_holes); | 2084 __ jmp(&push_operand_holes); |
2075 __ bind(&call_resume); | 2085 __ bind(&call_resume); |
| 2086 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
2076 __ push(ebx); | 2087 __ push(ebx); |
2077 __ push(result_register()); | 2088 __ push(result_register()); |
2078 __ Push(Smi::FromInt(resume_mode)); | 2089 __ Push(Smi::FromInt(resume_mode)); |
2079 __ CallRuntime(Runtime::kResumeJSGeneratorObject); | 2090 __ CallRuntime(Runtime::kResumeJSGeneratorObject); |
2080 // Not reached: the runtime call returns elsewhere. | 2091 // Not reached: the runtime call returns elsewhere. |
2081 __ Abort(kGeneratorFailedToResume); | 2092 __ Abort(kGeneratorFailedToResume); |
2082 | 2093 |
2083 __ bind(&done); | 2094 __ bind(&done); |
2084 context()->Plug(result_register()); | 2095 context()->Plug(result_register()); |
2085 } | 2096 } |
(...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4707 Assembler::target_address_at(call_target_address, | 4718 Assembler::target_address_at(call_target_address, |
4708 unoptimized_code)); | 4719 unoptimized_code)); |
4709 return OSR_AFTER_STACK_CHECK; | 4720 return OSR_AFTER_STACK_CHECK; |
4710 } | 4721 } |
4711 | 4722 |
4712 | 4723 |
4713 } // namespace internal | 4724 } // namespace internal |
4714 } // namespace v8 | 4725 } // namespace v8 |
4715 | 4726 |
4716 #endif // V8_TARGET_ARCH_IA32 | 4727 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |