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/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // -- cp : generator context | 760 // -- cp : generator context |
761 // -- lr : return address | 761 // -- lr : return address |
762 // -- jssp[0] : generator receiver | 762 // -- jssp[0] : generator receiver |
763 // ----------------------------------- | 763 // ----------------------------------- |
764 | 764 |
765 // Push holes for arguments to generator function. Since the parser forced | 765 // Push holes for arguments to generator function. Since the parser forced |
766 // context allocation for any variables in generators, the actual argument | 766 // context allocation for any variables in generators, the actual argument |
767 // values have already been copied into the context and these dummy values | 767 // values have already been copied into the context and these dummy values |
768 // will never be used. | 768 // will never be used. |
769 __ Ldr(x10, FieldMemOperand(x4, JSFunction::kSharedFunctionInfoOffset)); | 769 __ Ldr(x10, FieldMemOperand(x4, JSFunction::kSharedFunctionInfoOffset)); |
770 | |
771 // Push holes for arguments to generator function. Since the parser forced | |
772 // context allocation for any variables in generators, the actual argument | |
773 // values have already been copied into the context and these dummy values | |
774 // will never be used. | |
775 __ Ldr(w10, | 770 __ Ldr(w10, |
776 FieldMemOperand(x10, SharedFunctionInfo::kFormalParameterCountOffset)); | 771 FieldMemOperand(x10, SharedFunctionInfo::kFormalParameterCountOffset)); |
777 __ LoadRoot(x11, Heap::kTheHoleValueRootIndex); | 772 __ LoadRoot(x11, Heap::kTheHoleValueRootIndex); |
778 __ PushMultipleTimes(x11, w10); | 773 __ PushMultipleTimes(x11, w10); |
779 | 774 |
780 // Enter a new JavaScript frame, and initialize its slots as they were when | 775 // Dispatch on the kind of generator object. |
781 // the generator was suspended. | 776 Label old_generator; |
782 FrameScope scope(masm, StackFrame::MANUAL); | 777 __ Ldr(x3, FieldMemOperand(x4, JSFunction::kSharedFunctionInfoOffset)); |
783 __ Push(lr, fp); | 778 __ Ldr(x3, FieldMemOperand(x3, SharedFunctionInfo::kFunctionDataOffset)); |
784 __ Move(fp, jssp); | 779 __ CompareObjectType(x3, x3, x3, BYTECODE_ARRAY_TYPE); |
785 __ Push(cp, x4); | 780 __ B(ne, &old_generator); |
786 | 781 |
787 // Restore the operand stack. | 782 // New-style (ignition/turbofan) generator object |
788 __ Ldr(x0, FieldMemOperand(x1, JSGeneratorObject::kOperandStackOffset)); | |
789 __ Ldr(w3, UntagSmiFieldMemOperand(x0, FixedArray::kLengthOffset)); | |
790 __ Add(x0, x0, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
791 __ Add(x3, x0, Operand(x3, LSL, kPointerSizeLog2)); | |
792 { | 783 { |
793 Label done_loop, loop; | 784 __ Ldr(x0, FieldMemOperand(x4, JSFunction::kSharedFunctionInfoOffset)); |
794 __ Bind(&loop); | 785 __ Ldr(x0, |
795 __ Cmp(x0, x3); | 786 FieldMemOperand(x0, SharedFunctionInfo::kFormalParameterCountOffset)); |
796 __ B(eq, &done_loop); | 787 __ SmiUntag(x0); |
797 __ Ldr(x10, MemOperand(x0, kPointerSize, PostIndex)); | 788 // We abuse new.target both to indicate that this is a resume call and to |
798 __ Push(x10); | 789 // pass in the generator object. In ordinary calls, new.target is always |
799 __ B(&loop); | 790 // undefined because generator functions are non-constructable. |
800 __ Bind(&done_loop); | 791 __ Move(x3, x1); |
| 792 __ Move(x1, x4); |
| 793 __ Ldr(x5, FieldMemOperand(x1, JSFunction::kCodeEntryOffset)); |
| 794 __ Jump(x5); |
801 } | 795 } |
802 | 796 |
803 // Reset operand stack so we don't leak. | 797 // Old-style (full-codegen) generator object |
804 __ LoadRoot(x10, Heap::kEmptyFixedArrayRootIndex); | 798 __ bind(&old_generator); |
805 __ Str(x10, FieldMemOperand(x1, JSGeneratorObject::kOperandStackOffset)); | 799 { |
| 800 // Enter a new JavaScript frame, and initialize its slots as they were when |
| 801 // the generator was suspended. |
| 802 FrameScope scope(masm, StackFrame::MANUAL); |
| 803 __ Push(lr, fp); |
| 804 __ Move(fp, jssp); |
| 805 __ Push(cp, x4); |
806 | 806 |
807 // Resume the generator function at the continuation. | 807 // Restore the operand stack. |
808 __ Ldr(x10, FieldMemOperand(x4, JSFunction::kSharedFunctionInfoOffset)); | 808 __ Ldr(x0, FieldMemOperand(x1, JSGeneratorObject::kOperandStackOffset)); |
809 __ Ldr(x10, FieldMemOperand(x10, SharedFunctionInfo::kCodeOffset)); | 809 __ Ldr(w3, UntagSmiFieldMemOperand(x0, FixedArray::kLengthOffset)); |
810 __ Add(x10, x10, Code::kHeaderSize - kHeapObjectTag); | 810 __ Add(x0, x0, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
811 __ Ldrsw(x11, | 811 __ Add(x3, x0, Operand(x3, LSL, kPointerSizeLog2)); |
812 UntagSmiFieldMemOperand(x1, JSGeneratorObject::kContinuationOffset)); | 812 { |
813 __ Add(x10, x10, x11); | 813 Label done_loop, loop; |
814 __ Mov(x12, Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); | 814 __ Bind(&loop); |
815 __ Str(x12, FieldMemOperand(x1, JSGeneratorObject::kContinuationOffset)); | 815 __ Cmp(x0, x3); |
816 __ Move(x0, x1); // Continuation expects generator object in x0. | 816 __ B(eq, &done_loop); |
817 __ Br(x10); | 817 __ Ldr(x10, MemOperand(x0, kPointerSize, PostIndex)); |
| 818 __ Push(x10); |
| 819 __ B(&loop); |
| 820 __ Bind(&done_loop); |
| 821 } |
| 822 |
| 823 // Reset operand stack so we don't leak. |
| 824 __ LoadRoot(x10, Heap::kEmptyFixedArrayRootIndex); |
| 825 __ Str(x10, FieldMemOperand(x1, JSGeneratorObject::kOperandStackOffset)); |
| 826 |
| 827 // Resume the generator function at the continuation. |
| 828 __ Ldr(x10, FieldMemOperand(x4, JSFunction::kSharedFunctionInfoOffset)); |
| 829 __ Ldr(x10, FieldMemOperand(x10, SharedFunctionInfo::kCodeOffset)); |
| 830 __ Add(x10, x10, Code::kHeaderSize - kHeapObjectTag); |
| 831 __ Ldrsw(x11, |
| 832 UntagSmiFieldMemOperand(x1, JSGeneratorObject::kContinuationOffset)); |
| 833 __ Add(x10, x10, x11); |
| 834 __ Mov(x12, Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); |
| 835 __ Str(x12, FieldMemOperand(x1, JSGeneratorObject::kContinuationOffset)); |
| 836 __ Move(x0, x1); // Continuation expects generator object in x0. |
| 837 __ Br(x10); |
| 838 } |
818 } | 839 } |
819 | 840 |
820 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; | 841 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; |
821 | 842 |
822 | 843 |
823 // Clobbers x10, x15; preserves all other registers. | 844 // Clobbers x10, x15; preserves all other registers. |
824 static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, | 845 static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, |
825 IsTagged argc_is_tagged) { | 846 IsTagged argc_is_tagged) { |
826 // Check the stack for overflow. | 847 // Check the stack for overflow. |
827 // We are not trying to catch interruptions (e.g. debug break and | 848 // We are not trying to catch interruptions (e.g. debug break and |
(...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2878 } | 2899 } |
2879 } | 2900 } |
2880 | 2901 |
2881 | 2902 |
2882 #undef __ | 2903 #undef __ |
2883 | 2904 |
2884 } // namespace internal | 2905 } // namespace internal |
2885 } // namespace v8 | 2906 } // namespace v8 |
2886 | 2907 |
2887 #endif // V8_TARGET_ARCH_ARM | 2908 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |