| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 | 805 |
| 806 // Called when invoking Dart code from C++ (VM code). | 806 // Called when invoking Dart code from C++ (VM code). |
| 807 // Input parameters: | 807 // Input parameters: |
| 808 // LR : points to return address. | 808 // LR : points to return address. |
| 809 // R0 : entrypoint of the Dart function to call. | 809 // R0 : entrypoint of the Dart function to call. |
| 810 // R1 : arguments descriptor array. | 810 // R1 : arguments descriptor array. |
| 811 // R2 : arguments array. | 811 // R2 : arguments array. |
| 812 // R3 : new context containing the current isolate pointer. | 812 // R3 : new context containing the current isolate pointer. |
| 813 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { | 813 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { |
| 814 __ Comment("InvokeDartCodeStub"); | 814 __ Comment("InvokeDartCodeStub"); |
| 815 // The new context, saved vm tag, the top exit frame, and the old context. | |
| 816 const intptr_t kNewContextOffsetFromFp = | |
| 817 -(1 + kAbiPreservedCpuRegCount + kAbiPreservedFpuRegCount) * kWordSize; | |
| 818 | 815 |
| 819 // Copy the C stack pointer (R31) into the stack pointer we'll actually use | 816 // Copy the C stack pointer (R31) into the stack pointer we'll actually use |
| 820 // to access the stack, and put the C stack pointer at the stack limit. | 817 // to access the stack, and put the C stack pointer at the stack limit. |
| 821 __ SetupDartSP(Isolate::GetSpecifiedStackSize()); | 818 __ SetupDartSP(Isolate::GetSpecifiedStackSize()); |
| 822 __ EnterFrame(0); | 819 __ EnterFrame(0); |
| 823 | 820 |
| 824 // Save the callee-saved registers. | 821 // Save the callee-saved registers. |
| 825 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { | 822 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { |
| 826 const Register r = static_cast<Register>(i); | 823 const Register r = static_cast<Register>(i); |
| 827 // We use str instead of the Push macro because we will be pushing the PP | 824 // We use str instead of the Push macro because we will be pushing the PP |
| 828 // register when it is not holding a pool-pointer since we are coming from | 825 // register when it is not holding a pool-pointer since we are coming from |
| 829 // C++ code. | 826 // C++ code. |
| 830 __ str(r, Address(SP, -1 * kWordSize, Address::PreIndex)); | 827 __ str(r, Address(SP, -1 * kWordSize, Address::PreIndex)); |
| 831 } | 828 } |
| 832 | 829 |
| 833 // Save the bottom 64-bits of callee-saved V registers. | 830 // Save the bottom 64-bits of callee-saved V registers. |
| 834 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { | 831 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { |
| 835 const VRegister r = static_cast<VRegister>(i); | 832 const VRegister r = static_cast<VRegister>(i); |
| 836 __ PushDouble(r); | 833 __ PushDouble(r); |
| 837 } | 834 } |
| 838 | 835 |
| 839 // Push new context. | 836 // Push new context. |
| 840 __ Push(R3); | 837 __ Push(R3); |
| 841 #if defined(DEBUG) | 838 #if defined(DEBUG) |
| 842 { | 839 { |
| 843 Label ok; | 840 Label ok; |
| 841 // The new context, saved vm tag, the top exit frame, and the old context. |
| 842 const intptr_t kNewContextOffsetFromFp = |
| 843 -(1 + kAbiPreservedCpuRegCount + kAbiPreservedFpuRegCount) * kWordSize; |
| 844 __ AddImmediate(R4, FP, kNewContextOffsetFromFp, kNoPP); | 844 __ AddImmediate(R4, FP, kNewContextOffsetFromFp, kNoPP); |
| 845 __ CompareRegisters(R4, SP); | 845 __ CompareRegisters(R4, SP); |
| 846 __ b(&ok, EQ); | 846 __ b(&ok, EQ); |
| 847 __ Stop("kNewContextOffsetFromFp mismatch"); | 847 __ Stop("kNewContextOffsetFromFp mismatch"); |
| 848 __ Bind(&ok); | 848 __ Bind(&ok); |
| 849 } | 849 } |
| 850 #endif | 850 #endif |
| 851 | 851 |
| 852 // We now load the pool pointer(PP) as we are about to invoke dart code and we | 852 // We now load the pool pointer(PP) as we are about to invoke dart code and we |
| 853 // could potentially invoke some intrinsic functions which need the PP to be | 853 // could potentially invoke some intrinsic functions which need the PP to be |
| 854 // set up. | 854 // set up. |
| 855 __ LoadPoolPointer(PP); | 855 __ LoadPoolPointer(PP); |
| 856 | 856 |
| 857 // The new Context structure contains a pointer to the current Isolate | 857 // The new Context structure contains a pointer to the current Isolate |
| 858 // structure. Cache the Context pointer in the CTX register so that it is | 858 // structure. Cache the Context pointer in the CTX register so that it is |
| 859 // available in generated code and calls to Isolate::Current() need not be | 859 // available in generated code and calls to Isolate::Current() need not be |
| 860 // done. The assumption is that this register will never be clobbered by | 860 // done. The assumption is that this register will never be clobbered by |
| 861 // compiled or runtime stub code. | 861 // compiled or runtime stub code. |
| 862 | 862 |
| 863 // Cache the new Context pointer into CTX while executing Dart code. | 863 // Cache the new Context pointer into CTX while executing Dart code. |
| 864 __ LoadFromOffset(CTX, R3, VMHandles::kOffsetOfRawPtrInHandle, PP); | 864 __ LoadFromOffset(CTX, R3, VMHandles::kOffsetOfRawPtrInHandle, PP); |
| 865 | 865 |
| 866 // Load Isolate pointer into temporary register R5. | 866 // Load Isolate pointer into temporary register R5. |
| 867 __ LoadIsolate(R5, PP); | 867 __ LoadIsolate(R5, PP); |
| 868 | 868 |
| 869 // Cache the new Context pointer into CTX while executing Dart code. | |
| 870 __ LoadFromOffset(CTX, R3, VMHandles::kOffsetOfRawPtrInHandle, PP); | |
| 871 | |
| 872 // Save the current VMTag on the stack. | 869 // Save the current VMTag on the stack. |
| 873 ASSERT(kSavedVMTagSlotFromEntryFp == -20); | 870 ASSERT(kSavedVMTagSlotFromEntryFp == -20); |
| 874 __ LoadFromOffset(R4, R5, Isolate::vm_tag_offset(), PP); | 871 __ LoadFromOffset(R4, R5, Isolate::vm_tag_offset(), PP); |
| 875 __ Push(R4); | 872 __ Push(R4); |
| 876 | 873 |
| 877 // Mark that the isolate is executing Dart code. | 874 // Mark that the isolate is executing Dart code. |
| 878 __ LoadImmediate(R6, VMTag::kDartTagId, PP); | 875 __ LoadImmediate(R6, VMTag::kDartTagId, PP); |
| 879 __ StoreToOffset(R6, R5, Isolate::vm_tag_offset(), PP); | 876 __ StoreToOffset(R6, R5, Isolate::vm_tag_offset(), PP); |
| 880 | 877 |
| 881 // Save the top exit frame info. Use R6 as a temporary register. | 878 // Save the top exit frame info. Use R6 as a temporary register. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 __ b(&push_arguments, LT); | 920 __ b(&push_arguments, LT); |
| 924 __ Bind(&done_push_arguments); | 921 __ Bind(&done_push_arguments); |
| 925 | 922 |
| 926 // Call the Dart code entrypoint. | 923 // Call the Dart code entrypoint. |
| 927 __ blr(R0); // R4 is the arguments descriptor array. | 924 __ blr(R0); // R4 is the arguments descriptor array. |
| 928 __ Comment("InvokeDartCodeStub return"); | 925 __ Comment("InvokeDartCodeStub return"); |
| 929 | 926 |
| 930 // Restore constant pool pointer after return. | 927 // Restore constant pool pointer after return. |
| 931 __ LoadPoolPointer(PP); | 928 __ LoadPoolPointer(PP); |
| 932 | 929 |
| 933 // Read the saved new Context pointer. | |
| 934 __ LoadFromOffset(CTX, FP, kNewContextOffsetFromFp, PP); | |
| 935 __ LoadFromOffset(CTX, CTX, VMHandles::kOffsetOfRawPtrInHandle, PP); | |
| 936 | |
| 937 // Get rid of arguments pushed on the stack. | 930 // Get rid of arguments pushed on the stack. |
| 938 __ AddImmediate(SP, FP, kSavedContextSlotFromEntryFp * kWordSize, PP); | 931 __ AddImmediate(SP, FP, kSavedContextSlotFromEntryFp * kWordSize, PP); |
| 939 | 932 |
| 940 // Load Isolate pointer into CTX. Drop Context. | 933 // Load Isolate pointer into CTX. Drop Context. |
| 941 __ LoadIsolate(CTX, PP); | 934 __ LoadIsolate(CTX, PP); |
| 942 | 935 |
| 943 // Restore the current VMTag from the stack. | 936 // Restore the current VMTag from the stack. |
| 944 __ ldr(R4, Address(SP, 2 * kWordSize)); | 937 __ ldr(R4, Address(SP, 2 * kWordSize)); |
| 945 __ StoreToOffset(R4, CTX, Isolate::vm_tag_offset(), PP); | 938 __ StoreToOffset(R4, CTX, Isolate::vm_tag_offset(), PP); |
| 946 | 939 |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 const Register right = R0; | 2104 const Register right = R0; |
| 2112 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); | 2105 __ LoadFromOffset(left, SP, 1 * kWordSize, kNoPP); |
| 2113 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); | 2106 __ LoadFromOffset(right, SP, 0 * kWordSize, kNoPP); |
| 2114 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2107 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
| 2115 __ ret(); | 2108 __ ret(); |
| 2116 } | 2109 } |
| 2117 | 2110 |
| 2118 } // namespace dart | 2111 } // namespace dart |
| 2119 | 2112 |
| 2120 #endif // defined TARGET_ARCH_ARM64 | 2113 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |