| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #ifndef VM_ASSEMBLER_X64_H_ | 5 #ifndef VM_ASSEMBLER_X64_H_ |
| 6 #define VM_ASSEMBLER_X64_H_ | 6 #define VM_ASSEMBLER_X64_H_ |
| 7 | 7 |
| 8 #ifndef VM_ASSEMBLER_H_ | 8 #ifndef VM_ASSEMBLER_H_ |
| 9 #error Do not include assembler_x64.h directly; use assembler.h instead. | 9 #error Do not include assembler_x64.h directly; use assembler.h instead. |
| 10 #endif | 10 #endif |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 static const bool kFarJump = false; | 359 static const bool kFarJump = false; |
| 360 | 360 |
| 361 /* | 361 /* |
| 362 * Emit Machine Instructions. | 362 * Emit Machine Instructions. |
| 363 */ | 363 */ |
| 364 void call(Register reg); | 364 void call(Register reg); |
| 365 void call(const Address& address); | 365 void call(const Address& address); |
| 366 void call(Label* label); | 366 void call(Label* label); |
| 367 void call(const ExternalLabel* label); | 367 void call(const ExternalLabel* label); |
| 368 | 368 |
| 369 static const intptr_t kCallExternalLabelSize = 7; | 369 static const intptr_t kCallExternalLabelSize = 15; |
| 370 | 370 |
| 371 void pushq(Register reg); | 371 void pushq(Register reg); |
| 372 void pushq(const Address& address); | 372 void pushq(const Address& address); |
| 373 void pushq(const Immediate& imm); | 373 void pushq(const Immediate& imm); |
| 374 void PushImmediate(const Immediate& imm); | 374 void PushImmediate(const Immediate& imm); |
| 375 | 375 |
| 376 void popq(Register reg); | 376 void popq(Register reg); |
| 377 void popq(const Address& address); | 377 void popq(const Address& address); |
| 378 | 378 |
| 379 void setcc(Condition condition, ByteRegister dst); | 379 void setcc(Condition condition, ByteRegister dst); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 void LoadExternalLabel(Register dst, | 763 void LoadExternalLabel(Register dst, |
| 764 const ExternalLabel* label, | 764 const ExternalLabel* label, |
| 765 Patchability patchable); | 765 Patchability patchable); |
| 766 void LoadNativeEntry(Register dst, | 766 void LoadNativeEntry(Register dst, |
| 767 const ExternalLabel* label, | 767 const ExternalLabel* label, |
| 768 Patchability patchable); | 768 Patchability patchable); |
| 769 void LoadFunctionFromCalleePool(Register dst, | 769 void LoadFunctionFromCalleePool(Register dst, |
| 770 const Function& function, | 770 const Function& function, |
| 771 Register new_pp); | 771 Register new_pp); |
| 772 void JmpPatchable(const StubEntry& stub_entry, Register pp); | 772 void JmpPatchable(const StubEntry& stub_entry, Register pp); |
| 773 void Jmp(const StubEntry& stub_entry, Register pp); | 773 void Jmp(const StubEntry& stub_entry, Register pp = PP); |
| 774 void J(Condition condition, const StubEntry& stub_entry, Register pp); | 774 void J(Condition condition, const StubEntry& stub_entry, Register pp); |
| 775 void CallPatchable(const StubEntry& stub_entry); | 775 void CallPatchable(const StubEntry& stub_entry); |
| 776 void Call(const StubEntry& stub_entry); | 776 void Call(const StubEntry& stub_entry); |
| 777 // Unaware of write barrier (use StoreInto* methods for storing to objects). | 777 // Unaware of write barrier (use StoreInto* methods for storing to objects). |
| 778 // TODO(koda): Add StackAddress/HeapAddress types to prevent misuse. | 778 // TODO(koda): Add StackAddress/HeapAddress types to prevent misuse. |
| 779 void StoreObject(const Address& dst, const Object& obj); | 779 void StoreObject(const Address& dst, const Object& obj); |
| 780 void PushObject(const Object& object); | 780 void PushObject(const Object& object); |
| 781 void CompareObject(Register reg, const Object& object); | 781 void CompareObject(Register reg, const Object& object); |
| 782 | 782 |
| 783 // When storing into a heap object field, knowledge of the previous content | 783 // When storing into a heap object field, knowledge of the previous content |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 void DoubleAbs(XmmRegister reg); | 825 void DoubleAbs(XmmRegister reg); |
| 826 | 826 |
| 827 void LockCmpxchgq(const Address& address, Register reg) { | 827 void LockCmpxchgq(const Address& address, Register reg) { |
| 828 lock(); | 828 lock(); |
| 829 cmpxchgq(address, reg); | 829 cmpxchgq(address, reg); |
| 830 } | 830 } |
| 831 | 831 |
| 832 void PushRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); | 832 void PushRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); |
| 833 void PopRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); | 833 void PopRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); |
| 834 | 834 |
| 835 void CheckCodePointer(); |
| 836 |
| 835 void EnterFrame(intptr_t frame_space); | 837 void EnterFrame(intptr_t frame_space); |
| 836 void LeaveFrame(); | 838 void LeaveFrame(); |
| 837 void ReserveAlignedFrameSpace(intptr_t frame_space); | 839 void ReserveAlignedFrameSpace(intptr_t frame_space); |
| 838 | 840 |
| 839 // Create a frame for calling into runtime that preserves all volatile | 841 // Create a frame for calling into runtime that preserves all volatile |
| 840 // registers. Frame's RSP is guaranteed to be correctly aligned and | 842 // registers. Frame's RSP is guaranteed to be correctly aligned and |
| 841 // frame_space bytes are reserved under it. | 843 // frame_space bytes are reserved under it. |
| 842 void EnterCallRuntimeFrame(intptr_t frame_space); | 844 void EnterCallRuntimeFrame(intptr_t frame_space); |
| 843 void LeaveCallRuntimeFrame(); | 845 void LeaveCallRuntimeFrame(); |
| 844 | 846 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 ObjectPoolWrapper& object_pool_wrapper() { return object_pool_wrapper_; } | 917 ObjectPoolWrapper& object_pool_wrapper() { return object_pool_wrapper_; } |
| 916 | 918 |
| 917 RawObjectPool* MakeObjectPool() { | 919 RawObjectPool* MakeObjectPool() { |
| 918 return object_pool_wrapper_.MakeObjectPool(); | 920 return object_pool_wrapper_.MakeObjectPool(); |
| 919 } | 921 } |
| 920 | 922 |
| 921 void FinalizeInstructions(const MemoryRegion& region) { | 923 void FinalizeInstructions(const MemoryRegion& region) { |
| 922 buffer_.FinalizeInstructions(region); | 924 buffer_.FinalizeInstructions(region); |
| 923 } | 925 } |
| 924 | 926 |
| 927 void RestoreCodePointer(); |
| 925 void LoadPoolPointer(Register pp = PP); | 928 void LoadPoolPointer(Register pp = PP); |
| 926 | 929 |
| 927 // Set up a Dart frame on entry with a frame pointer and PC information to | 930 // Set up a Dart frame on entry with a frame pointer and PC information to |
| 928 // enable easy access to the RawInstruction object of code corresponding | 931 // enable easy access to the RawInstruction object of code corresponding |
| 929 // to this frame. | 932 // to this frame. |
| 930 // The dart frame layout is as follows: | 933 // The dart frame layout is as follows: |
| 931 // .... | 934 // .... |
| 932 // locals space <=== RSP | 935 // locals space <=== RSP |
| 933 // saved PP | 936 // saved PP |
| 934 // pc (used to derive the RawInstruction Object of the dart code) | 937 // pc (used to derive the RawInstruction Object of the dart code) |
| 935 // saved RBP <=== RBP | 938 // saved RBP <=== RBP |
| 936 // ret PC | 939 // ret PC |
| 937 // ..... | 940 // ..... |
| 938 // This code sets this up with the sequence: | 941 // This code sets this up with the sequence: |
| 939 // pushq rbp | 942 // pushq rbp |
| 940 // movq rbp, rsp | 943 // movq rbp, rsp |
| 941 // call L | 944 // call L |
| 942 // L: <code to adjust saved pc if there is any intrinsification code> | 945 // L: <code to adjust saved pc if there is any intrinsification code> |
| 943 // ... | 946 // ... |
| 944 // pushq r15 | 947 // pushq r15 |
| 945 // ..... | 948 // ..... |
| 946 void EnterDartFrame(intptr_t frame_size, | 949 void EnterDartFrame(intptr_t frame_size, Register new_pp); |
| 947 Register new_pp, | 950 void LeaveDartFrame(RestorePP restore_pp = kRestoreCallerPP); |
| 948 Register pc_marker_override); | |
| 949 void LeaveDartFrame(); | |
| 950 | 951 |
| 951 // Set up a Dart frame for a function compiled for on-stack replacement. | 952 // Set up a Dart frame for a function compiled for on-stack replacement. |
| 952 // The frame layout is a normal Dart frame, but the frame is partially set | 953 // The frame layout is a normal Dart frame, but the frame is partially set |
| 953 // up on entry (it is the frame of the unoptimized code). | 954 // up on entry (it is the frame of the unoptimized code). |
| 954 void EnterOsrFrame(intptr_t extra_size, | 955 void EnterOsrFrame(intptr_t extra_size); |
| 955 Register new_pp, Register pc_marker_override); | |
| 956 | 956 |
| 957 // Set up a stub frame so that the stack traversal code can easily identify | 957 // Set up a stub frame so that the stack traversal code can easily identify |
| 958 // a stub frame. | 958 // a stub frame. |
| 959 // The stub frame layout is as follows: | 959 // The stub frame layout is as follows: |
| 960 // .... <=== RSP | 960 // .... <=== RSP |
| 961 // pc (used to derive the RawInstruction Object of the stub) | 961 // pc (used to derive the RawInstruction Object of the stub) |
| 962 // saved RBP <=== RBP | 962 // saved RBP <=== RBP |
| 963 // ret PC | 963 // ret PC |
| 964 // ..... | 964 // ..... |
| 965 // This code sets this up with the sequence: | 965 // This code sets this up with the sequence: |
| 966 // pushq rbp | 966 // pushq rbp |
| 967 // movq rbp, rsp | 967 // movq rbp, rsp |
| 968 // pushq immediate(0) | 968 // pushq immediate(0) |
| 969 // ..... | 969 // ..... |
| 970 void EnterStubFrame(); | 970 void EnterStubFrame(); |
| 971 void LeaveStubFrame(); | 971 void LeaveStubFrame(); |
| 972 | 972 |
| 973 // Instruction pattern from entrypoint is used in dart frame prologues | |
| 974 // to set up the frame and save a PC which can be used to figure out the | |
| 975 // RawInstruction object corresponding to the code running in the frame. | |
| 976 // entrypoint: | |
| 977 // pushq rbp (size is 1 byte) | |
| 978 // movq rbp, rsp (size is 3 bytes) | |
| 979 // call L (size is 5 bytes) | |
| 980 // L: | |
| 981 static const intptr_t kEntryPointToPcMarkerOffset = 0; | |
| 982 static intptr_t EntryPointToPcMarkerOffset() { | |
| 983 return kEntryPointToPcMarkerOffset; | |
| 984 } | |
| 985 | |
| 986 void UpdateAllocationStats(intptr_t cid, | 973 void UpdateAllocationStats(intptr_t cid, |
| 987 Heap::Space space, | 974 Heap::Space space, |
| 988 bool inline_isolate = true); | 975 bool inline_isolate = true); |
| 989 | 976 |
| 990 void UpdateAllocationStatsWithSize(intptr_t cid, | 977 void UpdateAllocationStatsWithSize(intptr_t cid, |
| 991 Register size_reg, | 978 Register size_reg, |
| 992 Heap::Space space, | 979 Heap::Space space, |
| 993 bool inline_isolate = true); | 980 bool inline_isolate = true); |
| 994 void UpdateAllocationStatsWithSize(intptr_t cid, | 981 void UpdateAllocationStatsWithSize(intptr_t cid, |
| 995 intptr_t instance_size, | 982 intptr_t instance_size, |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 } | 1197 } |
| 1211 | 1198 |
| 1212 | 1199 |
| 1213 inline void Assembler::EmitOperandSizeOverride() { | 1200 inline void Assembler::EmitOperandSizeOverride() { |
| 1214 EmitUint8(0x66); | 1201 EmitUint8(0x66); |
| 1215 } | 1202 } |
| 1216 | 1203 |
| 1217 } // namespace dart | 1204 } // namespace dart |
| 1218 | 1205 |
| 1219 #endif // VM_ASSEMBLER_X64_H_ | 1206 #endif // VM_ASSEMBLER_X64_H_ |
| OLD | NEW |