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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 } | 1877 } |
1878 | 1878 |
1879 case Yield::kFinal: { | 1879 case Yield::kFinal: { |
1880 // 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. |
1881 EmitCreateIteratorResult(true); | 1881 EmitCreateIteratorResult(true); |
1882 EmitUnwindBeforeReturn(); | 1882 EmitUnwindBeforeReturn(); |
1883 EmitReturnSequence(); | 1883 EmitReturnSequence(); |
1884 break; | 1884 break; |
1885 } | 1885 } |
1886 | 1886 |
1887 case Yield::kDelegating: { | 1887 case Yield::kDelegating: |
1888 VisitForStackValue(expr->generator_object()); | 1888 UNREACHABLE(); |
1889 | |
1890 // Initial stack layout is as follows: | |
1891 // [sp + 1 * kPointerSize] iter | |
1892 // [sp + 0 * kPointerSize] g | |
1893 | |
1894 Label l_catch, l_try, l_suspend, l_continuation, l_resume; | |
1895 Label l_next, l_call, l_loop; | |
1896 Register load_receiver = LoadDescriptor::ReceiverRegister(); | |
1897 Register load_name = LoadDescriptor::NameRegister(); | |
1898 | |
1899 // Initial send value is undefined. | |
1900 __ mov(eax, isolate()->factory()->undefined_value()); | |
1901 __ jmp(&l_next); | |
1902 | |
1903 // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } | |
1904 __ bind(&l_catch); | |
1905 __ mov(load_name, isolate()->factory()->throw_string()); // "throw" | |
1906 __ push(load_name); // "throw" | |
1907 __ push(Operand(esp, 2 * kPointerSize)); // iter | |
1908 __ push(eax); // exception | |
1909 __ jmp(&l_call); | |
1910 | |
1911 // try { received = %yield result } | |
1912 // Shuffle the received result above a try handler and yield it without | |
1913 // re-boxing. | |
1914 __ bind(&l_try); | |
1915 __ pop(eax); // result | |
1916 int handler_index = NewHandlerTableEntry(); | |
1917 EnterTryBlock(handler_index, &l_catch); | |
1918 const int try_block_size = TryCatch::kElementCount * kPointerSize; | |
1919 __ push(eax); // result | |
1920 | |
1921 __ jmp(&l_suspend); | |
1922 __ bind(&l_continuation); | |
1923 __ RecordGeneratorContinuation(); | |
1924 __ jmp(&l_resume); | |
1925 | |
1926 __ bind(&l_suspend); | |
1927 const int generator_object_depth = kPointerSize + try_block_size; | |
1928 __ mov(eax, Operand(esp, generator_object_depth)); | |
1929 __ push(eax); // g | |
1930 __ push(Immediate(Smi::FromInt(handler_index))); // handler-index | |
1931 DCHECK(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); | |
1932 __ mov(FieldOperand(eax, JSGeneratorObject::kContinuationOffset), | |
1933 Immediate(Smi::FromInt(l_continuation.pos()))); | |
1934 __ mov(FieldOperand(eax, JSGeneratorObject::kContextOffset), esi); | |
1935 __ mov(ecx, esi); | |
1936 __ RecordWriteField(eax, JSGeneratorObject::kContextOffset, ecx, edx, | |
1937 kDontSaveFPRegs); | |
1938 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 2); | |
1939 __ mov(context_register(), | |
1940 Operand(ebp, StandardFrameConstants::kContextOffset)); | |
1941 __ pop(eax); // result | |
1942 EmitReturnSequence(); | |
1943 __ bind(&l_resume); // received in eax | |
1944 ExitTryBlock(handler_index); | |
1945 | |
1946 // receiver = iter; f = iter.next; arg = received; | |
1947 __ bind(&l_next); | |
1948 | |
1949 __ mov(load_name, isolate()->factory()->next_string()); | |
1950 __ push(load_name); // "next" | |
1951 __ push(Operand(esp, 2 * kPointerSize)); // iter | |
1952 __ push(eax); // received | |
1953 | |
1954 // result = receiver[f](arg); | |
1955 __ bind(&l_call); | |
1956 __ mov(load_receiver, Operand(esp, kPointerSize)); | |
1957 __ mov(LoadDescriptor::SlotRegister(), | |
1958 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | |
1959 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate(), SLOPPY).code(); | |
1960 CallIC(ic, TypeFeedbackId::None()); | |
1961 __ mov(edi, eax); | |
1962 __ mov(Operand(esp, 2 * kPointerSize), edi); | |
1963 SetCallPosition(expr); | |
1964 __ Set(eax, 1); | |
1965 __ Call( | |
1966 isolate()->builtins()->Call(ConvertReceiverMode::kNotNullOrUndefined), | |
1967 RelocInfo::CODE_TARGET); | |
1968 | |
1969 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | |
1970 __ Drop(1); // The function is still on the stack; drop it. | |
1971 | |
1972 // if (!result.done) goto l_try; | |
1973 __ bind(&l_loop); | |
1974 __ push(eax); // save result | |
1975 __ Move(load_receiver, eax); // result | |
1976 __ mov(load_name, | |
1977 isolate()->factory()->done_string()); // "done" | |
1978 __ mov(LoadDescriptor::SlotRegister(), | |
1979 Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); | |
1980 CallLoadIC(NOT_INSIDE_TYPEOF); // result.done in eax | |
1981 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | |
1982 CallIC(bool_ic); | |
1983 __ CompareRoot(result_register(), Heap::kTrueValueRootIndex); | |
1984 __ j(not_equal, &l_try); | |
1985 | |
1986 // result.value | |
1987 __ pop(load_receiver); // result | |
1988 __ mov(load_name, | |
1989 isolate()->factory()->value_string()); // "value" | |
1990 __ mov(LoadDescriptor::SlotRegister(), | |
1991 Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); | |
1992 CallLoadIC(NOT_INSIDE_TYPEOF); // result.value in eax | |
1993 context()->DropAndPlug(2, eax); // drop iter and g | |
1994 break; | |
1995 } | |
1996 } | 1889 } |
1997 } | 1890 } |
1998 | 1891 |
1999 | 1892 |
2000 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 1893 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2001 Expression *value, | 1894 Expression *value, |
2002 JSGeneratorObject::ResumeMode resume_mode) { | 1895 JSGeneratorObject::ResumeMode resume_mode) { |
2003 // The value stays in eax, and is ultimately read by the resumed generator, as | 1896 // The value stays in eax, and is ultimately read by the resumed generator, as |
2004 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it | 1897 // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it |
2005 // is read to throw the value when the resumed generator is already closed. | 1898 // is read to throw the value when the resumed generator is already closed. |
(...skipping 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4713 Assembler::target_address_at(call_target_address, | 4606 Assembler::target_address_at(call_target_address, |
4714 unoptimized_code)); | 4607 unoptimized_code)); |
4715 return OSR_AFTER_STACK_CHECK; | 4608 return OSR_AFTER_STACK_CHECK; |
4716 } | 4609 } |
4717 | 4610 |
4718 | 4611 |
4719 } // namespace internal | 4612 } // namespace internal |
4720 } // namespace v8 | 4613 } // namespace v8 |
4721 | 4614 |
4722 #endif // V8_TARGET_ARCH_X87 | 4615 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |