| 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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 __ BranchPatchable(&stub_code->FixAllocateArrayStubTargetLabel()); | 763 __ BranchPatchable(&stub_code->FixAllocateArrayStubTargetLabel()); |
| 764 } | 764 } |
| 765 | 765 |
| 766 | 766 |
| 767 // Called when invoking Dart code from C++ (VM code). | 767 // Called when invoking Dart code from C++ (VM code). |
| 768 // Input parameters: | 768 // Input parameters: |
| 769 // LR : points to return address. | 769 // LR : points to return address. |
| 770 // R0 : entrypoint of the Dart function to call. | 770 // R0 : entrypoint of the Dart function to call. |
| 771 // R1 : arguments descriptor array. | 771 // R1 : arguments descriptor array. |
| 772 // R2 : arguments array. | 772 // R2 : arguments array. |
| 773 // R3 : new context containing the current isolate pointer. | 773 // R3 : current thread. |
| 774 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { | 774 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { |
| 775 __ Comment("InvokeDartCodeStub"); | 775 __ Comment("InvokeDartCodeStub"); |
| 776 | 776 |
| 777 // Copy the C stack pointer (R31) into the stack pointer we'll actually use | 777 // Copy the C stack pointer (R31) into the stack pointer we'll actually use |
| 778 // to access the stack, and put the C stack pointer at the stack limit. | 778 // to access the stack, and put the C stack pointer at the stack limit. |
| 779 __ SetupDartSP(Isolate::GetSpecifiedStackSize()); | 779 __ SetupDartSP(Isolate::GetSpecifiedStackSize()); |
| 780 __ EnterFrame(0); | 780 __ EnterFrame(0); |
| 781 | 781 |
| 782 // Save the callee-saved registers. | 782 // Save the callee-saved registers. |
| 783 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { | 783 for (int i = kAbiFirstPreservedCpuReg; i <= kAbiLastPreservedCpuReg; i++) { |
| 784 const Register r = static_cast<Register>(i); | 784 const Register r = static_cast<Register>(i); |
| 785 // We use str instead of the Push macro because we will be pushing the PP | 785 // We use str instead of the Push macro because we will be pushing the PP |
| 786 // register when it is not holding a pool-pointer since we are coming from | 786 // register when it is not holding a pool-pointer since we are coming from |
| 787 // C++ code. | 787 // C++ code. |
| 788 __ str(r, Address(SP, -1 * kWordSize, Address::PreIndex)); | 788 __ str(r, Address(SP, -1 * kWordSize, Address::PreIndex)); |
| 789 } | 789 } |
| 790 | 790 |
| 791 // Save the bottom 64-bits of callee-saved V registers. | 791 // Save the bottom 64-bits of callee-saved V registers. |
| 792 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { | 792 for (int i = kAbiFirstPreservedFpuReg; i <= kAbiLastPreservedFpuReg; i++) { |
| 793 const VRegister r = static_cast<VRegister>(i); | 793 const VRegister r = static_cast<VRegister>(i); |
| 794 __ PushDouble(r); | 794 __ PushDouble(r); |
| 795 } | 795 } |
| 796 | 796 |
| 797 // We now load the pool pointer(PP) as we are about to invoke dart code and we | 797 // We now load the pool pointer(PP) as we are about to invoke dart code and we |
| 798 // could potentially invoke some intrinsic functions which need the PP to be | 798 // could potentially invoke some intrinsic functions which need the PP to be |
| 799 // set up. | 799 // set up. |
| 800 __ LoadPoolPointer(PP); | 800 __ LoadPoolPointer(PP); |
| 801 | 801 |
| 802 // Set up THR, which caches the current thread in Dart code. |
| 803 if (THR != R3) { |
| 804 __ mov(THR, R3); |
| 805 } |
| 802 // Load Isolate pointer into temporary register R5. | 806 // Load Isolate pointer into temporary register R5. |
| 803 __ LoadIsolate(R5, PP); | 807 __ LoadIsolate(R5, PP); |
| 804 | 808 |
| 805 // Save the current VMTag on the stack. | 809 // Save the current VMTag on the stack. |
| 806 __ LoadFromOffset(R4, R5, Isolate::vm_tag_offset(), PP); | 810 __ LoadFromOffset(R4, R5, Isolate::vm_tag_offset(), PP); |
| 807 __ Push(R4); | 811 __ Push(R4); |
| 808 | 812 |
| 809 // Mark that the isolate is executing Dart code. | 813 // Mark that the isolate is executing Dart code. |
| 810 __ LoadImmediate(R6, VMTag::kDartTagId, PP); | 814 __ LoadImmediate(R6, VMTag::kDartTagId, PP); |
| 811 __ StoreToOffset(R6, R5, Isolate::vm_tag_offset(), PP); | 815 __ StoreToOffset(R6, R5, Isolate::vm_tag_offset(), PP); |
| (...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1976 // R5: isolate. | 1980 // R5: isolate. |
| 1977 // Does not return. | 1981 // Does not return. |
| 1978 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { | 1982 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { |
| 1979 ASSERT(kExceptionObjectReg == R0); | 1983 ASSERT(kExceptionObjectReg == R0); |
| 1980 ASSERT(kStackTraceObjectReg == R1); | 1984 ASSERT(kStackTraceObjectReg == R1); |
| 1981 __ mov(LR, R0); // Program counter. | 1985 __ mov(LR, R0); // Program counter. |
| 1982 __ mov(SP, R1); // Stack pointer. | 1986 __ mov(SP, R1); // Stack pointer. |
| 1983 __ mov(FP, R2); // Frame_pointer. | 1987 __ mov(FP, R2); // Frame_pointer. |
| 1984 __ mov(R0, R3); // Exception object. | 1988 __ mov(R0, R3); // Exception object. |
| 1985 __ mov(R1, R4); // StackTrace object. | 1989 __ mov(R1, R4); // StackTrace object. |
| 1990 // TODO(koda): Pass thread instead of isolate. |
| 1991 __ LoadFromOffset(THR, R5, Isolate::mutator_thread_offset(), kNoPP); |
| 1986 // Set the tag. | 1992 // Set the tag. |
| 1987 __ LoadImmediate(R2, VMTag::kDartTagId, kNoPP); | 1993 __ LoadImmediate(R2, VMTag::kDartTagId, kNoPP); |
| 1988 __ StoreToOffset(R2, R5, Isolate::vm_tag_offset(), kNoPP); | 1994 __ StoreToOffset(R2, R5, Isolate::vm_tag_offset(), kNoPP); |
| 1989 // Clear top exit frame. | 1995 // Clear top exit frame. |
| 1990 __ StoreToOffset(ZR, R5, Isolate::top_exit_frame_info_offset(), kNoPP); | 1996 __ StoreToOffset(ZR, R5, Isolate::top_exit_frame_info_offset(), kNoPP); |
| 1991 __ ret(); // Jump to the exception handler code. | 1997 __ ret(); // Jump to the exception handler code. |
| 1992 } | 1998 } |
| 1993 | 1999 |
| 1994 | 2000 |
| 1995 // Calls to the runtime to optimize the given function. | 2001 // Calls to the runtime to optimize the given function. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 // Result: | 2186 // Result: |
| 2181 // R1: entry point. | 2187 // R1: entry point. |
| 2182 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2188 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
| 2183 EmitMegamorphicLookup(assembler, R0, R1, R1); | 2189 EmitMegamorphicLookup(assembler, R0, R1, R1); |
| 2184 __ ret(); | 2190 __ ret(); |
| 2185 } | 2191 } |
| 2186 | 2192 |
| 2187 } // namespace dart | 2193 } // namespace dart |
| 2188 | 2194 |
| 2189 #endif // defined TARGET_ARCH_ARM64 | 2195 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |