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