ART: Convert pointer size to enum
Move away from size_t to dedicated enum (class).
Bug: 30373134
Bug: 30419309
Test: m test-art-host
Change-Id: Id453c330f1065012e7d4f9fc24ac477cc9bb9269
diff --git a/patchoat/patchoat.h b/patchoat/patchoat.h
index 61ec695..64efea9d 100644
--- a/patchoat/patchoat.h
+++ b/patchoat/patchoat.h
@@ -18,6 +18,7 @@
#define ART_PATCHOAT_PATCHOAT_H_
#include "arch/instruction_set.h"
+#include "base/enums.h"
#include "base/macros.h"
#include "base/mutex.h"
#include "elf_file.h"
@@ -168,7 +169,7 @@
}
auto ret = reinterpret_cast<uintptr_t>(obj) + delta_;
// Trim off high bits in case negative relocation with 64 bit patchoat.
- if (InstructionSetPointerSize(isa_) == sizeof(uint32_t)) {
+ if (Is32BitISA()) {
ret = static_cast<uintptr_t>(static_cast<uint32_t>(ret));
}
return reinterpret_cast<T*>(ret);
@@ -181,12 +182,16 @@
}
T ret = obj + delta_;
// Trim off high bits in case negative relocation with 64 bit patchoat.
- if (InstructionSetPointerSize(isa_) == 4) {
+ if (Is32BitISA()) {
ret = static_cast<T>(static_cast<uint32_t>(ret));
}
return ret;
}
+ bool Is32BitISA() const {
+ return InstructionSetPointerSize(isa_) == PointerSize::k32;
+ }
+
// Walks through the old image and patches the mmap'd copy of it to the new offset. It does not
// change the heap.
class PatchVisitor {