| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 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 3804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3815 SetExpressionPosition(expr); | 3815 SetExpressionPosition(expr); |
| 3816 | 3816 |
| 3817 // Evaluate yielded value first; the initial iterator definition depends on | 3817 // Evaluate yielded value first; the initial iterator definition depends on |
| 3818 // this. It stays on the stack while we update the iterator. | 3818 // this. It stays on the stack while we update the iterator. |
| 3819 VisitForStackValue(expr->expression()); | 3819 VisitForStackValue(expr->expression()); |
| 3820 | 3820 |
| 3821 // TODO(jbramley): Tidy this up once the merge is done, using named registers | 3821 // TODO(jbramley): Tidy this up once the merge is done, using named registers |
| 3822 // and suchlike. The implementation changes a little by bleeding_edge so I | 3822 // and suchlike. The implementation changes a little by bleeding_edge so I |
| 3823 // don't want to spend too much time on it now. | 3823 // don't want to spend too much time on it now. |
| 3824 | 3824 |
| 3825 switch (expr->yield_kind()) { | 3825 Label suspend, continuation, post_runtime, resume; |
| 3826 case Yield::kSuspend: | |
| 3827 // Pop value from top-of-stack slot; box result into result register. | |
| 3828 EmitCreateIteratorResult(false); | |
| 3829 PushOperand(result_register()); | |
| 3830 // Fall through. | |
| 3831 case Yield::kInitial: { | |
| 3832 Label suspend, continuation, post_runtime, resume; | |
| 3833 | 3826 |
| 3834 __ B(&suspend); | 3827 __ B(&suspend); |
| 3835 // TODO(jbramley): This label is bound here because the following code | 3828 // TODO(jbramley): This label is bound here because the following code |
| 3836 // looks at its pos(). Is it possible to do something more efficient here, | 3829 // looks at its pos(). Is it possible to do something more efficient here, |
| 3837 // perhaps using Adr? | 3830 // perhaps using Adr? |
| 3838 __ Bind(&continuation); | 3831 __ Bind(&continuation); |
| 3839 // When we arrive here, the stack top is the resume mode and | 3832 // When we arrive here, the stack top is the resume mode and |
| 3840 // result_register() holds the input value (the argument given to the | 3833 // result_register() holds the input value (the argument given to the |
| 3841 // respective resume operation). | 3834 // respective resume operation). |
| 3842 __ RecordGeneratorContinuation(); | 3835 __ RecordGeneratorContinuation(); |
| 3843 __ Pop(x1); | 3836 __ Pop(x1); |
| 3844 __ Cmp(x1, Smi::FromInt(JSGeneratorObject::RETURN)); | 3837 __ Cmp(x1, Smi::FromInt(JSGeneratorObject::RETURN)); |
| 3845 __ B(ne, &resume); | 3838 __ B(ne, &resume); |
| 3846 __ Push(result_register()); | 3839 __ Push(result_register()); |
| 3847 EmitCreateIteratorResult(true); | 3840 EmitCreateIteratorResult(true); |
| 3848 EmitUnwindAndReturn(); | 3841 EmitUnwindAndReturn(); |
| 3849 | 3842 |
| 3850 __ Bind(&suspend); | 3843 __ Bind(&suspend); |
| 3851 OperandStackDepthIncrement(1); // Not popped on this path. | 3844 OperandStackDepthIncrement(1); // Not popped on this path. |
| 3852 VisitForAccumulatorValue(expr->generator_object()); | 3845 VisitForAccumulatorValue(expr->generator_object()); |
| 3853 DCHECK((continuation.pos() > 0) && Smi::IsValid(continuation.pos())); | 3846 DCHECK((continuation.pos() > 0) && Smi::IsValid(continuation.pos())); |
| 3854 __ Mov(x1, Smi::FromInt(continuation.pos())); | 3847 __ Mov(x1, Smi::FromInt(continuation.pos())); |
| 3855 __ Str(x1, FieldMemOperand(x0, JSGeneratorObject::kContinuationOffset)); | 3848 __ Str(x1, FieldMemOperand(x0, JSGeneratorObject::kContinuationOffset)); |
| 3856 __ Str(cp, FieldMemOperand(x0, JSGeneratorObject::kContextOffset)); | 3849 __ Str(cp, FieldMemOperand(x0, JSGeneratorObject::kContextOffset)); |
| 3857 __ Mov(x1, cp); | 3850 __ Mov(x1, cp); |
| 3858 __ RecordWriteField(x0, JSGeneratorObject::kContextOffset, x1, x2, | 3851 __ RecordWriteField(x0, JSGeneratorObject::kContextOffset, x1, x2, |
| 3859 kLRHasBeenSaved, kDontSaveFPRegs); | 3852 kLRHasBeenSaved, kDontSaveFPRegs); |
| 3860 __ Add(x1, fp, StandardFrameConstants::kExpressionsOffset); | 3853 __ Add(x1, fp, StandardFrameConstants::kExpressionsOffset); |
| 3861 __ Cmp(__ StackPointer(), x1); | 3854 __ Cmp(__ StackPointer(), x1); |
| 3862 __ B(eq, &post_runtime); | 3855 __ B(eq, &post_runtime); |
| 3863 __ Push(x0); // generator object | 3856 __ Push(x0); // generator object |
| 3864 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); | 3857 __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 3865 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 3858 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 3866 __ Bind(&post_runtime); | 3859 __ Bind(&post_runtime); |
| 3867 PopOperand(result_register()); | 3860 PopOperand(result_register()); |
| 3868 EmitReturnSequence(); | 3861 EmitReturnSequence(); |
| 3869 | 3862 |
| 3870 __ Bind(&resume); | 3863 __ Bind(&resume); |
| 3871 context()->Plug(result_register()); | 3864 context()->Plug(result_register()); |
| 3872 break; | |
| 3873 } | |
| 3874 | |
| 3875 case Yield::kFinal: { | |
| 3876 // Pop value from top-of-stack slot, box result into result register. | |
| 3877 EmitCreateIteratorResult(true); | |
| 3878 EmitUnwindAndReturn(); | |
| 3879 break; | |
| 3880 } | |
| 3881 | |
| 3882 case Yield::kDelegating: | |
| 3883 UNREACHABLE(); | |
| 3884 } | |
| 3885 } | 3865 } |
| 3886 | 3866 |
| 3887 | 3867 |
| 3888 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 3868 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
| 3889 Expression *value, | 3869 Expression *value, |
| 3890 JSGeneratorObject::ResumeMode resume_mode) { | 3870 JSGeneratorObject::ResumeMode resume_mode) { |
| 3891 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume"); | 3871 ASM_LOCATION("FullCodeGenerator::EmitGeneratorResume"); |
| 3892 Register generator_object = x1; | 3872 Register generator_object = x1; |
| 3893 Register the_hole = x2; | 3873 Register the_hole = x2; |
| 3894 Register operand_stack_size = w3; | 3874 Register operand_stack_size = w3; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4256 } | 4236 } |
| 4257 | 4237 |
| 4258 return INTERRUPT; | 4238 return INTERRUPT; |
| 4259 } | 4239 } |
| 4260 | 4240 |
| 4261 | 4241 |
| 4262 } // namespace internal | 4242 } // namespace internal |
| 4263 } // namespace v8 | 4243 } // namespace v8 |
| 4264 | 4244 |
| 4265 #endif // V8_TARGET_ARCH_ARM64 | 4245 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |