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_MIPS_H_ | 5 #ifndef VM_ASSEMBLER_MIPS_H_ |
6 #define VM_ASSEMBLER_MIPS_H_ | 6 #define VM_ASSEMBLER_MIPS_H_ |
7 | 7 |
8 #ifndef VM_ASSEMBLER_H_ | 8 #ifndef VM_ASSEMBLER_H_ |
9 #error Do not include assembler_mips.h directly; use assembler.h instead. | 9 #error Do not include assembler_mips.h directly; use assembler.h instead. |
10 #endif | 10 #endif |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 void set_use_far_branches(bool b) { | 281 void set_use_far_branches(bool b) { |
282 ASSERT(buffer_.Size() == 0); | 282 ASSERT(buffer_.Size() == 0); |
283 use_far_branches_ = b; | 283 use_far_branches_ = b; |
284 } | 284 } |
285 | 285 |
286 void EnterFrame(); | 286 void EnterFrame(); |
287 void LeaveFrameAndReturn(); | 287 void LeaveFrameAndReturn(); |
288 | 288 |
289 // Set up a stub frame so that the stack traversal code can easily identify | 289 // Set up a stub frame so that the stack traversal code can easily identify |
290 // a stub frame. | 290 // a stub frame. |
291 void EnterStubFrame(intptr_t frame_size = 0); | 291 void EnterStubFrame(); |
292 void LeaveStubFrame(); | 292 void LeaveStubFrame(); |
293 // A separate macro for when a Ret immediately follows, so that we can use | 293 // A separate macro for when a Ret immediately follows, so that we can use |
294 // the branch delay slot. | 294 // the branch delay slot. |
295 void LeaveStubFrameAndReturn(Register ra = RA); | 295 void LeaveStubFrameAndReturn(Register ra = RA); |
296 | 296 |
| 297 // Instruction pattern from entrypoint is used in dart frame prologs |
| 298 // to set up the frame and save a PC which can be used to figure out the |
| 299 // RawInstruction object corresponding to the code running in the frame. |
| 300 // See EnterDartFrame. There are 6 instructions before we know the PC. |
| 301 static const intptr_t kEntryPointToPcMarkerOffset = 6 * Instr::kInstrSize; |
| 302 static intptr_t EntryPointToPcMarkerOffset() { |
| 303 return kEntryPointToPcMarkerOffset; |
| 304 } |
| 305 |
297 void UpdateAllocationStats(intptr_t cid, | 306 void UpdateAllocationStats(intptr_t cid, |
298 Register temp_reg, | 307 Register temp_reg, |
299 Heap::Space space, | 308 Heap::Space space, |
300 bool inline_isolate = true); | 309 bool inline_isolate = true); |
301 | 310 |
302 void UpdateAllocationStatsWithSize(intptr_t cid, | 311 void UpdateAllocationStatsWithSize(intptr_t cid, |
303 Register size_reg, | 312 Register size_reg, |
304 Register temp_reg, | 313 Register temp_reg, |
305 Heap::Space space, | 314 Heap::Space space, |
306 bool inline_isolate = true); | 315 bool inline_isolate = true); |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 | 905 |
897 // ro must be different from rd and rs. | 906 // ro must be different from rd and rs. |
898 // None of rd, rs, rt, or ro may be TMP. | 907 // None of rd, rs, rt, or ro may be TMP. |
899 void SubImmediateDetectOverflow(Register rd, Register rs, int32_t imm, | 908 void SubImmediateDetectOverflow(Register rd, Register rs, int32_t imm, |
900 Register ro) { | 909 Register ro) { |
901 ASSERT(!in_delay_slot_); | 910 ASSERT(!in_delay_slot_); |
902 LoadImmediate(rd, imm); | 911 LoadImmediate(rd, imm); |
903 SubuDetectOverflow(rd, rs, rd, ro); | 912 SubuDetectOverflow(rd, rs, rd, ro); |
904 } | 913 } |
905 | 914 |
906 void Branch(const StubEntry& stub_entry, Register pp = PP); | 915 void Branch(const StubEntry& stub_entry); |
| 916 |
| 917 void BranchPatchable(const StubEntry& stub_entry); |
907 | 918 |
908 void BranchLink(const ExternalLabel* label, Patchability patchable); | 919 void BranchLink(const ExternalLabel* label, Patchability patchable); |
909 | |
910 void BranchLink(const StubEntry& stub_entry, | 920 void BranchLink(const StubEntry& stub_entry, |
911 Patchability patchable = kNotPatchable); | 921 Patchability patchable = kNotPatchable); |
912 | 922 |
913 void BranchLinkPatchable(const StubEntry& stub_entry); | 923 void BranchLinkPatchable(const StubEntry& stub_entry); |
914 | 924 |
915 void Drop(intptr_t stack_elements) { | 925 void Drop(intptr_t stack_elements) { |
916 ASSERT(stack_elements >= 0); | 926 ASSERT(stack_elements >= 0); |
917 if (stack_elements > 0) { | 927 if (stack_elements > 0) { |
918 addiu(SP, SP, Immediate(stack_elements * kWordSize)); | 928 addiu(SP, SP, Immediate(stack_elements * kWordSize)); |
919 } | 929 } |
920 } | 930 } |
921 | 931 |
922 void LoadPoolPointer(Register reg = PP) { | 932 void LoadPoolPointer() { |
923 ASSERT(!in_delay_slot_); | 933 ASSERT(!in_delay_slot_); |
924 CheckCodePointer(); | 934 GetNextPC(TMP); // TMP gets the address of the next instruction. |
925 lw(reg, FieldAddress(CODE_REG, Code::object_pool_offset())); | 935 const intptr_t object_pool_pc_dist = |
926 set_constant_pool_allowed(reg == PP); | 936 Instructions::HeaderSize() - Instructions::object_pool_offset() + |
| 937 CodeSize(); |
| 938 lw(PP, Address(TMP, -object_pool_pc_dist)); |
927 } | 939 } |
928 | 940 |
929 void CheckCodePointer(); | |
930 | |
931 void RestoreCodePointer(); | |
932 | |
933 void LoadImmediate(Register rd, int32_t value) { | 941 void LoadImmediate(Register rd, int32_t value) { |
934 ASSERT(!in_delay_slot_); | 942 ASSERT(!in_delay_slot_); |
935 if (Utils::IsInt(kImmBits, value)) { | 943 if (Utils::IsInt(kImmBits, value)) { |
936 addiu(rd, ZR, Immediate(value)); | 944 addiu(rd, ZR, Immediate(value)); |
937 } else { | 945 } else { |
938 const uint16_t low = Utils::Low16Bits(value); | 946 const uint16_t low = Utils::Low16Bits(value); |
939 const uint16_t high = Utils::High16Bits(value); | 947 const uint16_t high = Utils::High16Bits(value); |
940 lui(rd, Immediate(high)); | 948 lui(rd, Immediate(high)); |
941 if (low != 0) { | 949 if (low != 0) { |
942 ori(rd, rd, Immediate(low)); | 950 ori(rd, rd, Immediate(low)); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 void GetNextPC(Register dest, Register temp = kNoRegister); | 1511 void GetNextPC(Register dest, Register temp = kNoRegister); |
1504 | 1512 |
1505 void ReserveAlignedFrameSpace(intptr_t frame_space); | 1513 void ReserveAlignedFrameSpace(intptr_t frame_space); |
1506 | 1514 |
1507 // Create a frame for calling into runtime that preserves all volatile | 1515 // Create a frame for calling into runtime that preserves all volatile |
1508 // registers. Frame's SP is guaranteed to be correctly aligned and | 1516 // registers. Frame's SP is guaranteed to be correctly aligned and |
1509 // frame_space bytes are reserved under it. | 1517 // frame_space bytes are reserved under it. |
1510 void EnterCallRuntimeFrame(intptr_t frame_space); | 1518 void EnterCallRuntimeFrame(intptr_t frame_space); |
1511 void LeaveCallRuntimeFrame(); | 1519 void LeaveCallRuntimeFrame(); |
1512 | 1520 |
| 1521 void LoadWordFromPoolOffset(Register rd, int32_t offset); |
1513 void LoadObject(Register rd, const Object& object); | 1522 void LoadObject(Register rd, const Object& object); |
1514 void LoadUniqueObject(Register rd, const Object& object); | 1523 void LoadUniqueObject(Register rd, const Object& object); |
1515 void LoadExternalLabel(Register rd, | 1524 void LoadExternalLabel(Register rd, |
1516 const ExternalLabel* label, | 1525 const ExternalLabel* label, |
1517 Patchability patchable); | 1526 Patchability patchable); |
1518 void LoadFunctionFromCalleePool(Register dst, | |
1519 const Function& function, | |
1520 Register new_pp); | |
1521 void LoadNativeEntry(Register rd, | 1527 void LoadNativeEntry(Register rd, |
1522 const ExternalLabel* label, | 1528 const ExternalLabel* label, |
1523 Patchability patchable); | 1529 Patchability patchable); |
1524 void PushObject(const Object& object); | 1530 void PushObject(const Object& object); |
1525 | 1531 |
1526 void LoadIsolate(Register result); | 1532 void LoadIsolate(Register result); |
1527 | 1533 |
1528 void LoadClassId(Register result, Register object); | 1534 void LoadClassId(Register result, Register object); |
1529 void LoadClassById(Register result, Register class_id); | 1535 void LoadClassById(Register result, Register class_id); |
1530 void LoadClass(Register result, Register object); | 1536 void LoadClass(Register result, Register object); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 void StoreIntoObjectNoBarrierOffset(Register object, | 1568 void StoreIntoObjectNoBarrierOffset(Register object, |
1563 int32_t offset, | 1569 int32_t offset, |
1564 const Object& value); | 1570 const Object& value); |
1565 | 1571 |
1566 void CallRuntime(const RuntimeEntry& entry, intptr_t argument_count); | 1572 void CallRuntime(const RuntimeEntry& entry, intptr_t argument_count); |
1567 | 1573 |
1568 // Set up a Dart frame on entry with a frame pointer and PC information to | 1574 // Set up a Dart frame on entry with a frame pointer and PC information to |
1569 // enable easy access to the RawInstruction object of code corresponding | 1575 // enable easy access to the RawInstruction object of code corresponding |
1570 // to this frame. | 1576 // to this frame. |
1571 void EnterDartFrame(intptr_t frame_size); | 1577 void EnterDartFrame(intptr_t frame_size); |
1572 void LeaveDartFrame(RestorePP restore_pp = kRestoreCallerPP); | 1578 void LeaveDartFrame(); |
1573 void LeaveDartFrameAndReturn(Register ra = RA); | 1579 void LeaveDartFrameAndReturn(); |
1574 | 1580 |
1575 // Set up a Dart frame for a function compiled for on-stack replacement. | 1581 // Set up a Dart frame for a function compiled for on-stack replacement. |
1576 // The frame layout is a normal Dart frame, but the frame is partially set | 1582 // The frame layout is a normal Dart frame, but the frame is partially set |
1577 // up on entry (it is the frame of the unoptimized code). | 1583 // up on entry (it is the frame of the unoptimized code). |
1578 void EnterOsrFrame(intptr_t extra_size); | 1584 void EnterOsrFrame(intptr_t extra_size); |
1579 | 1585 |
1580 Address ElementAddressForIntIndex(bool is_external, | 1586 Address ElementAddressForIntIndex(bool is_external, |
1581 intptr_t cid, | 1587 intptr_t cid, |
1582 intptr_t index_scale, | 1588 intptr_t index_scale, |
1583 Register array, | 1589 Register array, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 const String& comment_; | 1630 const String& comment_; |
1625 | 1631 |
1626 DISALLOW_COPY_AND_ASSIGN(CodeComment); | 1632 DISALLOW_COPY_AND_ASSIGN(CodeComment); |
1627 }; | 1633 }; |
1628 | 1634 |
1629 GrowableArray<CodeComment*> comments_; | 1635 GrowableArray<CodeComment*> comments_; |
1630 | 1636 |
1631 bool constant_pool_allowed_; | 1637 bool constant_pool_allowed_; |
1632 | 1638 |
1633 void BranchLink(const ExternalLabel* label); | 1639 void BranchLink(const ExternalLabel* label); |
1634 void BranchLink(const Code& code, Patchability patchable); | |
1635 | 1640 |
1636 void LoadWordFromPoolOffset(Register rd, int32_t offset, Register pp = PP); | |
1637 void LoadObjectHelper(Register rd, const Object& object, bool is_unique); | 1641 void LoadObjectHelper(Register rd, const Object& object, bool is_unique); |
1638 | 1642 |
1639 void Emit(int32_t value) { | 1643 void Emit(int32_t value) { |
1640 // Emitting an instruction clears the delay slot state. | 1644 // Emitting an instruction clears the delay slot state. |
1641 in_delay_slot_ = false; | 1645 in_delay_slot_ = false; |
1642 delay_slot_available_ = false; | 1646 delay_slot_available_ = false; |
1643 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1647 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
1644 buffer_.Emit<int32_t>(value); | 1648 buffer_.Emit<int32_t>(value); |
1645 } | 1649 } |
1646 | 1650 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 Register value, | 1739 Register value, |
1736 Label* no_update); | 1740 Label* no_update); |
1737 | 1741 |
1738 DISALLOW_ALLOCATION(); | 1742 DISALLOW_ALLOCATION(); |
1739 DISALLOW_COPY_AND_ASSIGN(Assembler); | 1743 DISALLOW_COPY_AND_ASSIGN(Assembler); |
1740 }; | 1744 }; |
1741 | 1745 |
1742 } // namespace dart | 1746 } // namespace dart |
1743 | 1747 |
1744 #endif // VM_ASSEMBLER_MIPS_H_ | 1748 #endif // VM_ASSEMBLER_MIPS_H_ |
OLD | NEW |