Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(934)

Unified Diff: src/a64/instructions-a64.h

Issue 201843003: Robustified address calculations on A64. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback. Rebased. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/a64/disasm-a64.cc ('k') | src/a64/instructions-a64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/a64/disasm-a64.cc ('k') | src/a64/instructions-a64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698