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 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 } | 1986 } |
1987 | 1987 |
1988 | 1988 |
1989 void FullCodeGenerator::VisitYield(Yield* expr) { | 1989 void FullCodeGenerator::VisitYield(Yield* expr) { |
1990 Comment cmnt(masm_, "[ Yield"); | 1990 Comment cmnt(masm_, "[ Yield"); |
1991 // Evaluate yielded value first; the initial iterator definition depends on | 1991 // Evaluate yielded value first; the initial iterator definition depends on |
1992 // this. It stays on the stack while we update the iterator. | 1992 // this. It stays on the stack while we update the iterator. |
1993 VisitForStackValue(expr->expression()); | 1993 VisitForStackValue(expr->expression()); |
1994 | 1994 |
1995 switch (expr->yield_kind()) { | 1995 switch (expr->yield_kind()) { |
1996 case Yield::kSuspend: | 1996 case Yield::SUSPEND: |
1997 // Pop value from top-of-stack slot; box result into result register. | 1997 // Pop value from top-of-stack slot; box result into result register. |
1998 EmitCreateIteratorResult(false); | 1998 EmitCreateIteratorResult(false); |
1999 __ push(result_register()); | 1999 __ push(result_register()); |
2000 // Fall through. | 2000 // Fall through. |
2001 case Yield::kInitial: { | 2001 case Yield::INITIAL: { |
2002 Label suspend, continuation, post_runtime, resume; | 2002 Label suspend, continuation, post_runtime, resume; |
2003 | 2003 |
2004 __ jmp(&suspend); | 2004 __ jmp(&suspend); |
2005 | 2005 |
2006 __ bind(&continuation); | 2006 __ bind(&continuation); |
2007 __ jmp(&resume); | 2007 __ jmp(&resume); |
2008 | 2008 |
2009 __ bind(&suspend); | 2009 __ bind(&suspend); |
2010 VisitForAccumulatorValue(expr->generator_object()); | 2010 VisitForAccumulatorValue(expr->generator_object()); |
2011 ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 2011 ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
(...skipping 10 matching lines...) Expand all Loading... |
2022 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2022 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2023 __ bind(&post_runtime); | 2023 __ bind(&post_runtime); |
2024 __ pop(result_register()); | 2024 __ pop(result_register()); |
2025 EmitReturnSequence(); | 2025 EmitReturnSequence(); |
2026 | 2026 |
2027 __ bind(&resume); | 2027 __ bind(&resume); |
2028 context()->Plug(result_register()); | 2028 context()->Plug(result_register()); |
2029 break; | 2029 break; |
2030 } | 2030 } |
2031 | 2031 |
2032 case Yield::kFinal: { | 2032 case Yield::FINAL: { |
2033 VisitForAccumulatorValue(expr->generator_object()); | 2033 VisitForAccumulatorValue(expr->generator_object()); |
2034 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); | 2034 __ li(a1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); |
2035 __ sw(a1, FieldMemOperand(result_register(), | 2035 __ sw(a1, FieldMemOperand(result_register(), |
2036 JSGeneratorObject::kContinuationOffset)); | 2036 JSGeneratorObject::kContinuationOffset)); |
2037 // Pop value from top-of-stack slot, box result into result register. | 2037 // Pop value from top-of-stack slot, box result into result register. |
2038 EmitCreateIteratorResult(true); | 2038 EmitCreateIteratorResult(true); |
2039 EmitUnwindBeforeReturn(); | 2039 EmitUnwindBeforeReturn(); |
2040 EmitReturnSequence(); | 2040 EmitReturnSequence(); |
2041 break; | 2041 break; |
2042 } | 2042 } |
2043 | 2043 |
2044 case Yield::kDelegating: { | 2044 case Yield::DELEGATING: { |
2045 VisitForStackValue(expr->generator_object()); | 2045 VisitForStackValue(expr->generator_object()); |
2046 | 2046 |
2047 // Initial stack layout is as follows: | 2047 // Initial stack layout is as follows: |
2048 // [sp + 1 * kPointerSize] iter | 2048 // [sp + 1 * kPointerSize] iter |
2049 // [sp + 0 * kPointerSize] g | 2049 // [sp + 0 * kPointerSize] g |
2050 | 2050 |
2051 Label l_catch, l_try, l_suspend, l_continuation, l_resume; | 2051 Label l_catch, l_try, l_suspend, l_continuation, l_resume; |
2052 Label l_next, l_call, l_loop; | 2052 Label l_next, l_call, l_loop; |
2053 // Initial send value is undefined. | 2053 // Initial send value is undefined. |
2054 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); | 2054 __ LoadRoot(a0, Heap::kUndefinedValueRootIndex); |
(...skipping 2869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4924 *context_length = 0; | 4924 *context_length = 0; |
4925 return previous_; | 4925 return previous_; |
4926 } | 4926 } |
4927 | 4927 |
4928 | 4928 |
4929 #undef __ | 4929 #undef __ |
4930 | 4930 |
4931 } } // namespace v8::internal | 4931 } } // namespace v8::internal |
4932 | 4932 |
4933 #endif // V8_TARGET_ARCH_MIPS | 4933 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |