| 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 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 case Yield::kSuspend: | 1831 case Yield::kSuspend: |
| 1832 // Pop value from top-of-stack slot; box result into result register. | 1832 // Pop value from top-of-stack slot; box result into result register. |
| 1833 EmitCreateIteratorResult(false); | 1833 EmitCreateIteratorResult(false); |
| 1834 __ push(result_register()); | 1834 __ push(result_register()); |
| 1835 // Fall through. | 1835 // Fall through. |
| 1836 case Yield::kInitial: { | 1836 case Yield::kInitial: { |
| 1837 Label suspend, continuation, post_runtime, resume; | 1837 Label suspend, continuation, post_runtime, resume; |
| 1838 | 1838 |
| 1839 __ jmp(&suspend); | 1839 __ jmp(&suspend); |
| 1840 __ bind(&continuation); | 1840 __ bind(&continuation); |
| 1841 // When we arrive here, the stack top is the resume mode and |
| 1842 // result_register() holds the input value (the argument given to the |
| 1843 // respective resume operation). |
| 1841 __ RecordGeneratorContinuation(); | 1844 __ RecordGeneratorContinuation(); |
| 1842 __ jmp(&resume); | 1845 __ pop(ebx); |
| 1846 __ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::RETURN))); |
| 1847 __ j(not_equal, &resume); |
| 1848 __ push(result_register()); |
| 1849 EmitCreateIteratorResult(true); |
| 1850 EmitUnwindBeforeReturn(); |
| 1851 EmitReturnSequence(); |
| 1843 | 1852 |
| 1844 __ bind(&suspend); | 1853 __ bind(&suspend); |
| 1845 VisitForAccumulatorValue(expr->generator_object()); | 1854 VisitForAccumulatorValue(expr->generator_object()); |
| 1846 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1855 DCHECK(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
| 1847 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), | 1856 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), |
| 1848 Immediate(Smi::FromInt(continuation.pos()))); | 1857 Immediate(Smi::FromInt(continuation.pos()))); |
| 1849 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); | 1858 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); |
| 1850 __ mov(ecx, esi); | 1859 __ mov(ecx, esi); |
| 1851 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, | 1860 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, |
| 1852 kDontSaveFPRegs); | 1861 kDontSaveFPRegs); |
| 1853 __ lea(ebx, Operand(ebp, StandardFrameConstants::kExpressionsOffset)); | 1862 __ lea(ebx, Operand(ebp, StandardFrameConstants::kExpressionsOffset)); |
| 1854 __ cmp(esp, ebx); | 1863 __ cmp(esp, ebx); |
| 1855 __ j(equal, &post_runtime); | 1864 __ j(equal, &post_runtime); |
| 1856 __ push(eax); // generator object | 1865 __ push(eax); // generator object |
| 1857 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 1866 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 1858 __ mov(context_register(), | 1867 __ mov(context_register(), |
| 1859 Operand(ebp, StandardFrameConstants::kContextOffset)); | 1868 Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 1860 __ bind(&post_runtime); | 1869 __ bind(&post_runtime); |
| 1861 __ pop(result_register()); | 1870 __ pop(result_register()); |
| 1862 EmitReturnSequence(); | 1871 EmitReturnSequence(); |
| 1863 | 1872 |
| 1864 __ bind(&resume); | 1873 __ bind(&resume); |
| 1865 context()->Plug(result_register()); | 1874 context()->Plug(result_register()); |
| 1866 break; | 1875 break; |
| 1867 } | 1876 } |
| 1868 | 1877 |
| 1869 case Yield::kFinal: { | 1878 case Yield::kFinal: { |
| 1870 VisitForAccumulatorValue(expr->generator_object()); | 1879 VisitForAccumulatorValue(expr->generator_object()); |
| 1871 __ mov(FieldOperand(result_register(), | |
| 1872 JSGeneratorObject::kContinuationOffset), | |
| 1873 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | |
| 1874 // Pop value from top-of-stack slot, box result into result register. | 1880 // Pop value from top-of-stack slot, box result into result register. |
| 1875 EmitCreateIteratorResult(true); | 1881 EmitCreateIteratorResult(true); |
| 1876 EmitUnwindBeforeReturn(); | 1882 EmitUnwindBeforeReturn(); |
| 1877 EmitReturnSequence(); | 1883 EmitReturnSequence(); |
| 1878 break; | 1884 break; |
| 1879 } | 1885 } |
| 1880 | 1886 |
| 1881 case Yield::kDelegating: { | 1887 case Yield::kDelegating: { |
| 1882 VisitForStackValue(expr->generator_object()); | 1888 VisitForStackValue(expr->generator_object()); |
| 1883 | 1889 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1908 __ bind(&l_try); | 1914 __ bind(&l_try); |
| 1909 __ pop(eax); // result | 1915 __ pop(eax); // result |
| 1910 int handler_index = NewHandlerTableEntry(); | 1916 int handler_index = NewHandlerTableEntry(); |
| 1911 EnterTryBlock(handler_index, &l_catch); | 1917 EnterTryBlock(handler_index, &l_catch); |
| 1912 const int try_block_size = TryCatch::kElementCount * kPointerSize; | 1918 const int try_block_size = TryCatch::kElementCount * kPointerSize; |
| 1913 __ push(eax); // result | 1919 __ push(eax); // result |
| 1914 | 1920 |
| 1915 __ jmp(&l_suspend); | 1921 __ jmp(&l_suspend); |
| 1916 __ bind(&l_continuation); | 1922 __ bind(&l_continuation); |
| 1917 __ RecordGeneratorContinuation(); | 1923 __ RecordGeneratorContinuation(); |
| 1924 __ pop(ebx); |
| 1925 // TODO(neis): Ignoring the resume mode here is clearly wrong. Currently, |
| 1926 // return is not supported for yield*. The planned desugaring of yield* |
| 1927 // using do-expressions will naturally solve this. |
| 1918 __ jmp(&l_resume); | 1928 __ jmp(&l_resume); |
| 1919 | 1929 |
| 1920 __ bind(&l_suspend); | 1930 __ bind(&l_suspend); |
| 1921 const int generator_object_depth = kPointerSize + try_block_size; | 1931 const int generator_object_depth = kPointerSize + try_block_size; |
| 1922 __ mov(eax, Operand(esp, generator_object_depth)); | 1932 __ mov(eax, Operand(esp, generator_object_depth)); |
| 1923 __ push(eax); // g | 1933 __ push(eax); // g |
| 1924 __ push(Immediate(Smi::FromInt(handler_index))); // handler-index | 1934 __ push(Immediate(Smi::FromInt(handler_index))); // handler-index |
| 1925 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | 1935 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
| 1926 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), | 1936 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), |
| 1927 Immediate(Smi::FromInt(l_continuation.pos()))); | 1937 Immediate(Smi::FromInt(l_continuation.pos()))); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 if (resume_mode == JSGeneratorObject::NEXT) { | 2053 if (resume_mode == JSGeneratorObject::NEXT) { |
| 2044 Label slow_resume; | 2054 Label slow_resume; |
| 2045 __ cmp(edx, Immediate(0)); | 2055 __ cmp(edx, Immediate(0)); |
| 2046 __ j(not_zero, &slow_resume); | 2056 __ j(not_zero, &slow_resume); |
| 2047 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 2057 __ mov(edx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
| 2048 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset)); | 2058 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset)); |
| 2049 __ SmiUntag(ecx); | 2059 __ SmiUntag(ecx); |
| 2050 __ add(edx, ecx); | 2060 __ add(edx, ecx); |
| 2051 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), | 2061 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), |
| 2052 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | 2062 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
| 2063 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
| 2053 __ jmp(edx); | 2064 __ jmp(edx); |
| 2054 __ bind(&slow_resume); | 2065 __ bind(&slow_resume); |
| 2055 } | 2066 } |
| 2056 | 2067 |
| 2057 // Otherwise, we push holes for the operand stack and call the runtime to fix | 2068 // Otherwise, we push holes for the operand stack and call the runtime to fix |
| 2058 // up the stack and the handlers. | 2069 // up the stack and the handlers. |
| 2059 Label push_operand_holes, call_resume; | 2070 Label push_operand_holes, call_resume; |
| 2060 __ bind(&push_operand_holes); | 2071 __ bind(&push_operand_holes); |
| 2061 __ sub(edx, Immediate(1)); | 2072 __ sub(edx, Immediate(1)); |
| 2062 __ j(carry, &call_resume); | 2073 __ j(carry, &call_resume); |
| 2063 __ push(ecx); | 2074 __ push(ecx); |
| 2064 __ jmp(&push_operand_holes); | 2075 __ jmp(&push_operand_holes); |
| 2065 __ bind(&call_resume); | 2076 __ bind(&call_resume); |
| 2077 __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation. |
| 2066 __ push(ebx); | 2078 __ push(ebx); |
| 2067 __ push(result_register()); | 2079 __ push(result_register()); |
| 2068 __ Push(Smi::FromInt(resume_mode)); | 2080 __ Push(Smi::FromInt(resume_mode)); |
| 2069 __ CallRuntime(Runtime::kResumeJSGeneratorObject); | 2081 __ CallRuntime(Runtime::kResumeJSGeneratorObject); |
| 2070 // Not reached: the runtime call returns elsewhere. | 2082 // Not reached: the runtime call returns elsewhere. |
| 2071 __ Abort(kGeneratorFailedToResume); | 2083 __ Abort(kGeneratorFailedToResume); |
| 2072 | 2084 |
| 2073 __ bind(&done); | 2085 __ bind(&done); |
| 2074 context()->Plug(result_register()); | 2086 context()->Plug(result_register()); |
| 2075 } | 2087 } |
| (...skipping 2641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4717 Assembler::target_address_at(call_target_address, | 4729 Assembler::target_address_at(call_target_address, |
| 4718 unoptimized_code)); | 4730 unoptimized_code)); |
| 4719 return OSR_AFTER_STACK_CHECK; | 4731 return OSR_AFTER_STACK_CHECK; |
| 4720 } | 4732 } |
| 4721 | 4733 |
| 4722 | 4734 |
| 4723 } // namespace internal | 4735 } // namespace internal |
| 4724 } // namespace v8 | 4736 } // namespace v8 |
| 4725 | 4737 |
| 4726 #endif // V8_TARGET_ARCH_IA32 | 4738 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |