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 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 } | 1960 } |
1961 | 1961 |
1962 | 1962 |
1963 void FullCodeGenerator::VisitYield(Yield* expr) { | 1963 void FullCodeGenerator::VisitYield(Yield* expr) { |
1964 Comment cmnt(masm_, "[ Yield"); | 1964 Comment cmnt(masm_, "[ Yield"); |
1965 // Evaluate yielded value first; the initial iterator definition depends on | 1965 // Evaluate yielded value first; the initial iterator definition depends on |
1966 // this. It stays on the stack while we update the iterator. | 1966 // this. It stays on the stack while we update the iterator. |
1967 VisitForStackValue(expr->expression()); | 1967 VisitForStackValue(expr->expression()); |
1968 | 1968 |
1969 switch (expr->yield_kind()) { | 1969 switch (expr->yield_kind()) { |
1970 case Yield::kSuspend: | 1970 case Yield::SUSPEND: |
1971 // Pop value from top-of-stack slot; box result into result register. | 1971 // Pop value from top-of-stack slot; box result into result register. |
1972 EmitCreateIteratorResult(false); | 1972 EmitCreateIteratorResult(false); |
1973 __ push(result_register()); | 1973 __ push(result_register()); |
1974 // Fall through. | 1974 // Fall through. |
1975 case Yield::kInitial: { | 1975 case Yield::INITIAL: { |
1976 Label suspend, continuation, post_runtime, resume; | 1976 Label suspend, continuation, post_runtime, resume; |
1977 | 1977 |
1978 __ jmp(&suspend); | 1978 __ jmp(&suspend); |
1979 | 1979 |
1980 __ bind(&continuation); | 1980 __ bind(&continuation); |
1981 __ jmp(&resume); | 1981 __ jmp(&resume); |
1982 | 1982 |
1983 __ bind(&suspend); | 1983 __ bind(&suspend); |
1984 VisitForAccumulatorValue(expr->generator_object()); | 1984 VisitForAccumulatorValue(expr->generator_object()); |
1985 ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); | 1985 ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
(...skipping 13 matching lines...) Expand all Loading... |
1999 __ bind(&post_runtime); | 1999 __ bind(&post_runtime); |
2000 | 2000 |
2001 __ pop(result_register()); | 2001 __ pop(result_register()); |
2002 EmitReturnSequence(); | 2002 EmitReturnSequence(); |
2003 | 2003 |
2004 __ bind(&resume); | 2004 __ bind(&resume); |
2005 context()->Plug(result_register()); | 2005 context()->Plug(result_register()); |
2006 break; | 2006 break; |
2007 } | 2007 } |
2008 | 2008 |
2009 case Yield::kFinal: { | 2009 case Yield::FINAL: { |
2010 VisitForAccumulatorValue(expr->generator_object()); | 2010 VisitForAccumulatorValue(expr->generator_object()); |
2011 __ Move(FieldOperand(result_register(), | 2011 __ Move(FieldOperand(result_register(), |
2012 JSGeneratorObject::kContinuationOffset), | 2012 JSGeneratorObject::kContinuationOffset), |
2013 Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); | 2013 Smi::FromInt(JSGeneratorObject::kGeneratorClosed)); |
2014 // Pop value from top-of-stack slot, box result into result register. | 2014 // Pop value from top-of-stack slot, box result into result register. |
2015 EmitCreateIteratorResult(true); | 2015 EmitCreateIteratorResult(true); |
2016 EmitUnwindBeforeReturn(); | 2016 EmitUnwindBeforeReturn(); |
2017 EmitReturnSequence(); | 2017 EmitReturnSequence(); |
2018 break; | 2018 break; |
2019 } | 2019 } |
2020 | 2020 |
2021 case Yield::kDelegating: { | 2021 case Yield::DELEGATING: { |
2022 VisitForStackValue(expr->generator_object()); | 2022 VisitForStackValue(expr->generator_object()); |
2023 | 2023 |
2024 // Initial stack layout is as follows: | 2024 // Initial stack layout is as follows: |
2025 // [sp + 1 * kPointerSize] iter | 2025 // [sp + 1 * kPointerSize] iter |
2026 // [sp + 0 * kPointerSize] g | 2026 // [sp + 0 * kPointerSize] g |
2027 | 2027 |
2028 Label l_catch, l_try, l_suspend, l_continuation, l_resume; | 2028 Label l_catch, l_try, l_suspend, l_continuation, l_resume; |
2029 Label l_next, l_call, l_loop; | 2029 Label l_next, l_call, l_loop; |
2030 // Initial send value is undefined. | 2030 // Initial send value is undefined. |
2031 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 2031 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
(...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4882 *context_length = 0; | 4882 *context_length = 0; |
4883 return previous_; | 4883 return previous_; |
4884 } | 4884 } |
4885 | 4885 |
4886 | 4886 |
4887 #undef __ | 4887 #undef __ |
4888 | 4888 |
4889 } } // namespace v8::internal | 4889 } } // namespace v8::internal |
4890 | 4890 |
4891 #endif // V8_TARGET_ARCH_X64 | 4891 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |