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 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 | 1953 |
1954 case Yield::FINAL: { | 1954 case Yield::FINAL: { |
1955 VisitForAccumulatorValue(expr->generator_object()); | 1955 VisitForAccumulatorValue(expr->generator_object()); |
1956 __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | 1956 __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); |
1957 __ str(r1, FieldMemOperand(result_register(), | 1957 __ str(r1, FieldMemOperand(result_register(), |
1958 JSGeneratorObject::kContinuationOffset)); | 1958 JSGeneratorObject::kContinuationOffset)); |
1959 EmitReturnIteratorResult(true); | 1959 EmitReturnIteratorResult(true); |
1960 break; | 1960 break; |
1961 } | 1961 } |
1962 | 1962 |
1963 case Yield::DELEGATING: | 1963 case Yield::DELEGATING: { |
1964 UNIMPLEMENTED(); | 1964 VisitForStackValue(expr->generator_object()); |
| 1965 |
| 1966 // Initial stack layout is as follows: |
| 1967 // [sp + 1 * kPointerSize] iter |
| 1968 // [sp + 0 * kPointerSize] g |
| 1969 |
| 1970 Label l_catch, l_try, l_resume, l_send, l_call, l_loop; |
| 1971 // Initial send value is undefined. |
| 1972 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 1973 __ b(&l_send); |
| 1974 |
| 1975 // catch (e) { receiver = iter; f = iter.throw; arg = e; goto l_call; } |
| 1976 __ bind(&l_catch); |
| 1977 handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); |
| 1978 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter |
| 1979 __ push(r3); // iter |
| 1980 __ push(r0); // exception |
| 1981 __ mov(r0, r3); // iter |
| 1982 __ push(r0); // push LoadIC state |
| 1983 __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw" |
| 1984 Handle<Code> throw_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 1985 CallIC(throw_ic); // iter.throw in r0 |
| 1986 __ add(sp, sp, Operand(kPointerSize)); // drop LoadIC state |
| 1987 __ jmp(&l_call); |
| 1988 |
| 1989 // try { received = yield result.value } |
| 1990 __ bind(&l_try); |
| 1991 __ pop(r0); // result.value |
| 1992 __ PushTryHandler(StackHandler::CATCH, expr->index()); |
| 1993 const int handler_size = StackHandlerConstants::kSize; |
| 1994 __ push(r0); // result.value |
| 1995 __ ldr(r3, MemOperand(sp, (0 + 1) * kPointerSize + handler_size)); // g |
| 1996 __ push(r3); // g |
| 1997 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 1998 __ ldr(context_register(), |
| 1999 MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2000 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
| 2001 __ b(ne, &l_resume); |
| 2002 EmitReturnIteratorResult(false); |
| 2003 __ bind(&l_resume); // received in r0 |
| 2004 __ PopTryHandler(); |
| 2005 |
| 2006 // receiver = iter; f = iter.send; arg = received; |
| 2007 __ bind(&l_send); |
| 2008 __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter |
| 2009 __ push(r3); // iter |
| 2010 __ push(r0); // received |
| 2011 __ mov(r0, r3); // iter |
| 2012 __ push(r0); // push LoadIC state |
| 2013 __ LoadRoot(r2, Heap::ksend_stringRootIndex); // "send" |
| 2014 Handle<Code> send_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2015 CallIC(send_ic); // iter.send in r0 |
| 2016 __ add(sp, sp, Operand(kPointerSize)); // drop LoadIC state |
| 2017 |
| 2018 // result = f.call(receiver, arg); |
| 2019 __ bind(&l_call); |
| 2020 Label l_call_runtime; |
| 2021 __ JumpIfSmi(r0, &l_call_runtime); |
| 2022 __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); |
| 2023 __ b(ne, &l_call_runtime); |
| 2024 __ mov(r1, r0); |
| 2025 ParameterCount count(1); |
| 2026 __ InvokeFunction(r1, count, CALL_FUNCTION, |
| 2027 NullCallWrapper(), CALL_AS_METHOD); |
| 2028 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2029 __ jmp(&l_loop); |
| 2030 __ bind(&l_call_runtime); |
| 2031 __ push(r0); |
| 2032 __ CallRuntime(Runtime::kCall, 3); |
| 2033 |
| 2034 // val = result.value; if (!result.done) goto l_try; |
| 2035 __ bind(&l_loop); |
| 2036 // result.value |
| 2037 __ push(r0); // save result |
| 2038 __ LoadRoot(r2, Heap::kvalue_stringRootIndex); // "value" |
| 2039 Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2040 CallIC(value_ic); // result.value in r0 |
| 2041 __ pop(r1); // result |
| 2042 __ push(r0); // result.value |
| 2043 __ mov(r0, r1); // result |
| 2044 __ push(r0); // push LoadIC state |
| 2045 __ LoadRoot(r2, Heap::kdone_stringRootIndex); // "done" |
| 2046 Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2047 CallIC(done_ic); // result.done in r0 |
| 2048 __ add(sp, sp, Operand(kPointerSize)); // drop LoadIC state |
| 2049 ToBooleanStub stub(r0); |
| 2050 __ CallStub(&stub); |
| 2051 __ cmp(r0, Operand(0)); |
| 2052 __ b(eq, &l_try); |
| 2053 |
| 2054 // result.value |
| 2055 __ pop(r0); // result.value |
| 2056 context()->DropAndPlug(2, r0); // drop iter and g |
| 2057 break; |
| 2058 } |
1965 } | 2059 } |
1966 } | 2060 } |
1967 | 2061 |
1968 | 2062 |
1969 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2063 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
1970 Expression *value, | 2064 Expression *value, |
1971 JSGeneratorObject::ResumeMode resume_mode) { | 2065 JSGeneratorObject::ResumeMode resume_mode) { |
1972 // The value stays in r0, and is ultimately read by the resumed generator, as | 2066 // The value stays in r0, and is ultimately read by the resumed generator, as |
1973 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. r1 | 2067 // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. r1 |
1974 // will hold the generator object until the activation has been resumed. | 2068 // will hold the generator object until the activation has been resumed. |
(...skipping 2774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4749 *context_length = 0; | 4843 *context_length = 0; |
4750 return previous_; | 4844 return previous_; |
4751 } | 4845 } |
4752 | 4846 |
4753 | 4847 |
4754 #undef __ | 4848 #undef __ |
4755 | 4849 |
4756 } } // namespace v8::internal | 4850 } } // namespace v8::internal |
4757 | 4851 |
4758 #endif // V8_TARGET_ARCH_ARM | 4852 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |