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 | 907 |
917 void BranchPatchable(const StubEntry& stub_entry); | |
918 | |
919 void BranchLink(const ExternalLabel* label, Patchability patchable); | |
920 void BranchLink(const StubEntry& stub_entry, | 908 void BranchLink(const StubEntry& stub_entry, |
921 Patchability patchable = kNotPatchable); | 909 Patchability patchable = kNotPatchable); |
922 | 910 |
923 void BranchLinkPatchable(const StubEntry& stub_entry); | 911 void BranchLinkPatchable(const StubEntry& stub_entry); |
924 | 912 |
925 void Drop(intptr_t stack_elements) { | 913 void Drop(intptr_t stack_elements) { |
926 ASSERT(stack_elements >= 0); | 914 ASSERT(stack_elements >= 0); |
927 if (stack_elements > 0) { | 915 if (stack_elements > 0) { |
928 addiu(SP, SP, Immediate(stack_elements * kWordSize)); | 916 addiu(SP, SP, Immediate(stack_elements * kWordSize)); |
929 } | 917 } |
930 } | 918 } |
931 | 919 |
932 void LoadPoolPointer() { | 920 void LoadPoolPointer(Register reg = PP) { |
933 ASSERT(!in_delay_slot_); | 921 ASSERT(!in_delay_slot_); |
934 GetNextPC(TMP); // TMP gets the address of the next instruction. | 922 CheckCodePointer(); |
935 const intptr_t object_pool_pc_dist = | 923 lw(reg, FieldAddress(CODE_REG, Code::object_pool_offset())); |
936 Instructions::HeaderSize() - Instructions::object_pool_offset() + | 924 set_constant_pool_allowed(reg == PP); |
937 CodeSize(); | |
938 lw(PP, Address(TMP, -object_pool_pc_dist)); | |
939 } | 925 } |
940 | 926 |
| 927 void CheckCodePointer(); |
| 928 |
| 929 void RestoreCodePointer(); |
| 930 |
941 void LoadImmediate(Register rd, int32_t value) { | 931 void LoadImmediate(Register rd, int32_t value) { |
942 ASSERT(!in_delay_slot_); | 932 ASSERT(!in_delay_slot_); |
943 if (Utils::IsInt(kImmBits, value)) { | 933 if (Utils::IsInt(kImmBits, value)) { |
944 addiu(rd, ZR, Immediate(value)); | 934 addiu(rd, ZR, Immediate(value)); |
945 } else { | 935 } else { |
946 const uint16_t low = Utils::Low16Bits(value); | 936 const uint16_t low = Utils::Low16Bits(value); |
947 const uint16_t high = Utils::High16Bits(value); | 937 const uint16_t high = Utils::High16Bits(value); |
948 lui(rd, Immediate(high)); | 938 lui(rd, Immediate(high)); |
949 if (low != 0) { | 939 if (low != 0) { |
950 ori(rd, rd, Immediate(low)); | 940 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); | 1501 void GetNextPC(Register dest, Register temp = kNoRegister); |
1512 | 1502 |
1513 void ReserveAlignedFrameSpace(intptr_t frame_space); | 1503 void ReserveAlignedFrameSpace(intptr_t frame_space); |
1514 | 1504 |
1515 // Create a frame for calling into runtime that preserves all volatile | 1505 // Create a frame for calling into runtime that preserves all volatile |
1516 // registers. Frame's SP is guaranteed to be correctly aligned and | 1506 // registers. Frame's SP is guaranteed to be correctly aligned and |
1517 // frame_space bytes are reserved under it. | 1507 // frame_space bytes are reserved under it. |
1518 void EnterCallRuntimeFrame(intptr_t frame_space); | 1508 void EnterCallRuntimeFrame(intptr_t frame_space); |
1519 void LeaveCallRuntimeFrame(); | 1509 void LeaveCallRuntimeFrame(); |
1520 | 1510 |
1521 void LoadWordFromPoolOffset(Register rd, int32_t offset); | |
1522 void LoadObject(Register rd, const Object& object); | 1511 void LoadObject(Register rd, const Object& object); |
1523 void LoadUniqueObject(Register rd, const Object& object); | 1512 void LoadUniqueObject(Register rd, const Object& object); |
1524 void LoadExternalLabel(Register rd, | 1513 void LoadExternalLabel(Register rd, |
1525 const ExternalLabel* label, | 1514 const ExternalLabel* label, |
1526 Patchability patchable); | 1515 Patchability patchable); |
| 1516 void LoadFunctionFromCalleePool(Register dst, |
| 1517 const Function& function, |
| 1518 Register new_pp); |
1527 void PushObject(const Object& object); | 1519 void PushObject(const Object& object); |
1528 | 1520 |
1529 void LoadIsolate(Register result); | 1521 void LoadIsolate(Register result); |
1530 | 1522 |
1531 void LoadClassId(Register result, Register object); | 1523 void LoadClassId(Register result, Register object); |
1532 void LoadClassById(Register result, Register class_id); | 1524 void LoadClassById(Register result, Register class_id); |
1533 void LoadClass(Register result, Register object); | 1525 void LoadClass(Register result, Register object); |
1534 void LoadClassIdMayBeSmi(Register result, Register object); | 1526 void LoadClassIdMayBeSmi(Register result, Register object); |
1535 void LoadTaggedClassIdMayBeSmi(Register result, Register object); | 1527 void LoadTaggedClassIdMayBeSmi(Register result, Register object); |
1536 | 1528 |
(...skipping 28 matching lines...) Expand all Loading... |
1565 void StoreIntoObjectNoBarrierOffset(Register object, | 1557 void StoreIntoObjectNoBarrierOffset(Register object, |
1566 int32_t offset, | 1558 int32_t offset, |
1567 const Object& value); | 1559 const Object& value); |
1568 | 1560 |
1569 void CallRuntime(const RuntimeEntry& entry, intptr_t argument_count); | 1561 void CallRuntime(const RuntimeEntry& entry, intptr_t argument_count); |
1570 | 1562 |
1571 // Set up a Dart frame on entry with a frame pointer and PC information to | 1563 // Set up a Dart frame on entry with a frame pointer and PC information to |
1572 // enable easy access to the RawInstruction object of code corresponding | 1564 // enable easy access to the RawInstruction object of code corresponding |
1573 // to this frame. | 1565 // to this frame. |
1574 void EnterDartFrame(intptr_t frame_size); | 1566 void EnterDartFrame(intptr_t frame_size); |
1575 void LeaveDartFrame(); | 1567 void LeaveDartFrame(RestorePP restore_pp = kRestoreCallerPP); |
1576 void LeaveDartFrameAndReturn(); | 1568 void LeaveDartFrameAndReturn(Register ra = RA); |
1577 | 1569 |
1578 // Set up a Dart frame for a function compiled for on-stack replacement. | 1570 // Set up a Dart frame for a function compiled for on-stack replacement. |
1579 // The frame layout is a normal Dart frame, but the frame is partially set | 1571 // The frame layout is a normal Dart frame, but the frame is partially set |
1580 // up on entry (it is the frame of the unoptimized code). | 1572 // up on entry (it is the frame of the unoptimized code). |
1581 void EnterOsrFrame(intptr_t extra_size); | 1573 void EnterOsrFrame(intptr_t extra_size); |
1582 | 1574 |
1583 Address ElementAddressForIntIndex(bool is_external, | 1575 Address ElementAddressForIntIndex(bool is_external, |
1584 intptr_t cid, | 1576 intptr_t cid, |
1585 intptr_t index_scale, | 1577 intptr_t index_scale, |
1586 Register array, | 1578 Register array, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1627 const String& comment_; | 1619 const String& comment_; |
1628 | 1620 |
1629 DISALLOW_COPY_AND_ASSIGN(CodeComment); | 1621 DISALLOW_COPY_AND_ASSIGN(CodeComment); |
1630 }; | 1622 }; |
1631 | 1623 |
1632 GrowableArray<CodeComment*> comments_; | 1624 GrowableArray<CodeComment*> comments_; |
1633 | 1625 |
1634 bool constant_pool_allowed_; | 1626 bool constant_pool_allowed_; |
1635 | 1627 |
1636 void BranchLink(const ExternalLabel* label); | 1628 void BranchLink(const ExternalLabel* label); |
| 1629 void BranchLink(const Code& code, Patchability patchable); |
1637 | 1630 |
| 1631 void LoadWordFromPoolOffset(Register rd, int32_t offset, Register pp = PP); |
1638 void LoadObjectHelper(Register rd, const Object& object, bool is_unique); | 1632 void LoadObjectHelper(Register rd, const Object& object, bool is_unique); |
1639 | 1633 |
1640 void Emit(int32_t value) { | 1634 void Emit(int32_t value) { |
1641 // Emitting an instruction clears the delay slot state. | 1635 // Emitting an instruction clears the delay slot state. |
1642 in_delay_slot_ = false; | 1636 in_delay_slot_ = false; |
1643 delay_slot_available_ = false; | 1637 delay_slot_available_ = false; |
1644 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1638 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
1645 buffer_.Emit<int32_t>(value); | 1639 buffer_.Emit<int32_t>(value); |
1646 } | 1640 } |
1647 | 1641 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 Register value, | 1730 Register value, |
1737 Label* no_update); | 1731 Label* no_update); |
1738 | 1732 |
1739 DISALLOW_ALLOCATION(); | 1733 DISALLOW_ALLOCATION(); |
1740 DISALLOW_COPY_AND_ASSIGN(Assembler); | 1734 DISALLOW_COPY_AND_ASSIGN(Assembler); |
1741 }; | 1735 }; |
1742 | 1736 |
1743 } // namespace dart | 1737 } // namespace dart |
1744 | 1738 |
1745 #endif // VM_ASSEMBLER_MIPS_H_ | 1739 #endif // VM_ASSEMBLER_MIPS_H_ |
OLD | NEW |