Index: src/a64/instructions-a64.h |
diff --git a/src/a64/instructions-a64.h b/src/a64/instructions-a64.h |
index ccab39e3ac84e18f4c85b35cce2abdf171e78b40..caeae9fefeb2e26b26204f26aabfa73fc6e5aabf 100644 |
--- a/src/a64/instructions-a64.h |
+++ b/src/a64/instructions-a64.h |
@@ -144,12 +144,12 @@ class Instruction { |
return InstructionBits() & mask; |
} |
- Instruction* following(int count = 1) { |
- return this + count * kInstructionSize; |
+ V8_INLINE Instruction* following(int count = 1) { |
+ return InstructionAtOffset(count * static_cast<int>(kInstructionSize)); |
} |
- Instruction* preceding(int count = 1) { |
- return this - count * kInstructionSize; |
+ V8_INLINE Instruction* preceding(int count = 1) { |
+ return following(-count); |
} |
#define DEFINE_GETTER(Name, HighBit, LowBit, Func) \ |
@@ -367,20 +367,25 @@ class Instruction { |
return reinterpret_cast<uint8_t*>(this) + offset; |
} |
- Instruction* NextInstruction() { |
- return this + kInstructionSize; |
- } |
+ enum CheckAlignment { NO_CHECK, CHECK_ALIGNMENT }; |
- Instruction* InstructionAtOffset(int64_t offset) { |
- ASSERT(IsAligned(reinterpret_cast<uintptr_t>(this) + offset, |
- kInstructionSize)); |
- return this + offset; |
+ V8_INLINE Instruction* InstructionAtOffset( |
+ int64_t offset, |
+ CheckAlignment check = CHECK_ALIGNMENT) { |
+ Address addr = reinterpret_cast<Address>(this) + offset; |
+ // The FUZZ_disasm test relies on no check being done. |
+ ASSERT(check == NO_CHECK || IsAddressAligned(addr, kInstructionSize)); |
+ return Cast(addr); |
} |
- template<typename T> static Instruction* Cast(T src) { |
+ template<typename T> V8_INLINE static Instruction* Cast(T src) { |
return reinterpret_cast<Instruction*>(src); |
} |
+ V8_INLINE ptrdiff_t DistanceTo(Instruction* target) { |
+ return reinterpret_cast<Address>(target) - reinterpret_cast<Address>(this); |
+ } |
+ |
void SetPCRelImmTarget(Instruction* target); |
void SetBranchImmTarget(Instruction* target); |