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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 void LoadIsolate(Register dst); | 760 void LoadIsolate(Register dst); |
761 void LoadObject(Register dst, const Object& obj); | 761 void LoadObject(Register dst, const Object& obj); |
762 void LoadUniqueObject(Register dst, const Object& obj); | 762 void LoadUniqueObject(Register dst, const Object& obj); |
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 LoadFunctionFromCalleePool(Register dst, | 766 void LoadFunctionFromCalleePool(Register dst, |
767 const Function& function, | 767 const Function& function, |
768 Register new_pp); | 768 Register new_pp); |
769 void JmpPatchable(const StubEntry& stub_entry, Register pp); | 769 void JmpPatchable(const StubEntry& stub_entry, Register pp); |
770 void Jmp(const StubEntry& stub_entry, Register pp); | 770 void Jmp(const StubEntry& stub_entry, Register pp = PP); |
771 void J(Condition condition, const StubEntry& stub_entry, Register pp); | 771 void J(Condition condition, const StubEntry& stub_entry, Register pp); |
772 void CallPatchable(const StubEntry& stub_entry); | 772 void CallPatchable(const StubEntry& stub_entry); |
773 void Call(const StubEntry& stub_entry); | 773 void Call(const StubEntry& stub_entry); |
774 // Unaware of write barrier (use StoreInto* methods for storing to objects). | 774 // Unaware of write barrier (use StoreInto* methods for storing to objects). |
775 // TODO(koda): Add StackAddress/HeapAddress types to prevent misuse. | 775 // TODO(koda): Add StackAddress/HeapAddress types to prevent misuse. |
776 void StoreObject(const Address& dst, const Object& obj); | 776 void StoreObject(const Address& dst, const Object& obj); |
777 void PushObject(const Object& object); | 777 void PushObject(const Object& object); |
778 void CompareObject(Register reg, const Object& object); | 778 void CompareObject(Register reg, const Object& object); |
779 | 779 |
780 // When storing into a heap object field, knowledge of the previous content | 780 // 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... |
822 void DoubleAbs(XmmRegister reg); | 822 void DoubleAbs(XmmRegister reg); |
823 | 823 |
824 void LockCmpxchgq(const Address& address, Register reg) { | 824 void LockCmpxchgq(const Address& address, Register reg) { |
825 lock(); | 825 lock(); |
826 cmpxchgq(address, reg); | 826 cmpxchgq(address, reg); |
827 } | 827 } |
828 | 828 |
829 void PushRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); | 829 void PushRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); |
830 void PopRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); | 830 void PopRegisters(intptr_t cpu_register_set, intptr_t xmm_register_set); |
831 | 831 |
| 832 void CheckCodePointer(); |
| 833 |
832 void EnterFrame(intptr_t frame_space); | 834 void EnterFrame(intptr_t frame_space); |
833 void LeaveFrame(); | 835 void LeaveFrame(); |
834 void ReserveAlignedFrameSpace(intptr_t frame_space); | 836 void ReserveAlignedFrameSpace(intptr_t frame_space); |
835 | 837 |
836 // Create a frame for calling into runtime that preserves all volatile | 838 // Create a frame for calling into runtime that preserves all volatile |
837 // registers. Frame's RSP is guaranteed to be correctly aligned and | 839 // registers. Frame's RSP is guaranteed to be correctly aligned and |
838 // frame_space bytes are reserved under it. | 840 // frame_space bytes are reserved under it. |
839 void EnterCallRuntimeFrame(intptr_t frame_space); | 841 void EnterCallRuntimeFrame(intptr_t frame_space); |
840 void LeaveCallRuntimeFrame(); | 842 void LeaveCallRuntimeFrame(); |
841 | 843 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 ObjectPoolWrapper& object_pool_wrapper() { return object_pool_wrapper_; } | 914 ObjectPoolWrapper& object_pool_wrapper() { return object_pool_wrapper_; } |
913 | 915 |
914 RawObjectPool* MakeObjectPool() { | 916 RawObjectPool* MakeObjectPool() { |
915 return object_pool_wrapper_.MakeObjectPool(); | 917 return object_pool_wrapper_.MakeObjectPool(); |
916 } | 918 } |
917 | 919 |
918 void FinalizeInstructions(const MemoryRegion& region) { | 920 void FinalizeInstructions(const MemoryRegion& region) { |
919 buffer_.FinalizeInstructions(region); | 921 buffer_.FinalizeInstructions(region); |
920 } | 922 } |
921 | 923 |
| 924 void RestoreCodePointer(); |
922 void LoadPoolPointer(Register pp = PP); | 925 void LoadPoolPointer(Register pp = PP); |
923 | 926 |
924 // Set up a Dart frame on entry with a frame pointer and PC information to | 927 // Set up a Dart frame on entry with a frame pointer and PC information to |
925 // enable easy access to the RawInstruction object of code corresponding | 928 // enable easy access to the RawInstruction object of code corresponding |
926 // to this frame. | 929 // to this frame. |
927 // The dart frame layout is as follows: | 930 // The dart frame layout is as follows: |
928 // .... | 931 // .... |
929 // locals space <=== RSP | 932 // locals space <=== RSP |
930 // saved PP | 933 // saved PP |
931 // pc (used to derive the RawInstruction Object of the dart code) | 934 // pc (used to derive the RawInstruction Object of the dart code) |
932 // saved RBP <=== RBP | 935 // saved RBP <=== RBP |
933 // ret PC | 936 // ret PC |
934 // ..... | 937 // ..... |
935 // This code sets this up with the sequence: | 938 // This code sets this up with the sequence: |
936 // pushq rbp | 939 // pushq rbp |
937 // movq rbp, rsp | 940 // movq rbp, rsp |
938 // call L | 941 // call L |
939 // L: <code to adjust saved pc if there is any intrinsification code> | 942 // L: <code to adjust saved pc if there is any intrinsification code> |
940 // ... | 943 // ... |
941 // pushq r15 | 944 // pushq r15 |
942 // ..... | 945 // ..... |
943 void EnterDartFrame(intptr_t frame_size, | 946 void EnterDartFrame(intptr_t frame_size, Register new_pp); |
944 Register new_pp, | 947 void LeaveDartFrame(RestorePP restore_pp = kRestoreCallerPP); |
945 Register pc_marker_override); | |
946 void LeaveDartFrame(); | |
947 | 948 |
948 // Set up a Dart frame for a function compiled for on-stack replacement. | 949 // Set up a Dart frame for a function compiled for on-stack replacement. |
949 // The frame layout is a normal Dart frame, but the frame is partially set | 950 // The frame layout is a normal Dart frame, but the frame is partially set |
950 // up on entry (it is the frame of the unoptimized code). | 951 // up on entry (it is the frame of the unoptimized code). |
951 void EnterOsrFrame(intptr_t extra_size, | 952 void EnterOsrFrame(intptr_t extra_size); |
952 Register new_pp, Register pc_marker_override); | |
953 | 953 |
954 // Set up a stub frame so that the stack traversal code can easily identify | 954 // Set up a stub frame so that the stack traversal code can easily identify |
955 // a stub frame. | 955 // a stub frame. |
956 // The stub frame layout is as follows: | 956 // The stub frame layout is as follows: |
957 // .... <=== RSP | 957 // .... <=== RSP |
958 // pc (used to derive the RawInstruction Object of the stub) | 958 // pc (used to derive the RawInstruction Object of the stub) |
959 // saved RBP <=== RBP | 959 // saved RBP <=== RBP |
960 // ret PC | 960 // ret PC |
961 // ..... | 961 // ..... |
962 // This code sets this up with the sequence: | 962 // This code sets this up with the sequence: |
963 // pushq rbp | 963 // pushq rbp |
964 // movq rbp, rsp | 964 // movq rbp, rsp |
965 // pushq immediate(0) | 965 // pushq immediate(0) |
966 // ..... | 966 // ..... |
967 void EnterStubFrame(); | 967 void EnterStubFrame(); |
968 void LeaveStubFrame(); | 968 void LeaveStubFrame(); |
969 | 969 |
970 // Instruction pattern from entrypoint is used in dart frame prologues | |
971 // to set up the frame and save a PC which can be used to figure out the | |
972 // RawInstruction object corresponding to the code running in the frame. | |
973 // entrypoint: | |
974 // pushq rbp (size is 1 byte) | |
975 // movq rbp, rsp (size is 3 bytes) | |
976 // call L (size is 5 bytes) | |
977 // L: | |
978 static const intptr_t kEntryPointToPcMarkerOffset = 0; | |
979 static intptr_t EntryPointToPcMarkerOffset() { | |
980 return kEntryPointToPcMarkerOffset; | |
981 } | |
982 | |
983 void UpdateAllocationStats(intptr_t cid, | 970 void UpdateAllocationStats(intptr_t cid, |
984 Heap::Space space, | 971 Heap::Space space, |
985 bool inline_isolate = true); | 972 bool inline_isolate = true); |
986 | 973 |
987 void UpdateAllocationStatsWithSize(intptr_t cid, | 974 void UpdateAllocationStatsWithSize(intptr_t cid, |
988 Register size_reg, | 975 Register size_reg, |
989 Heap::Space space, | 976 Heap::Space space, |
990 bool inline_isolate = true); | 977 bool inline_isolate = true); |
991 void UpdateAllocationStatsWithSize(intptr_t cid, | 978 void UpdateAllocationStatsWithSize(intptr_t cid, |
992 intptr_t instance_size, | 979 intptr_t instance_size, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1194 } |
1208 | 1195 |
1209 | 1196 |
1210 inline void Assembler::EmitOperandSizeOverride() { | 1197 inline void Assembler::EmitOperandSizeOverride() { |
1211 EmitUint8(0x66); | 1198 EmitUint8(0x66); |
1212 } | 1199 } |
1213 | 1200 |
1214 } // namespace dart | 1201 } // namespace dart |
1215 | 1202 |
1216 #endif // VM_ASSEMBLER_X64_H_ | 1203 #endif // VM_ASSEMBLER_X64_H_ |
OLD | NEW |