Revert "Remove code size from OatQuickMethodHeader"
This reverts commit 131f23a4c2c34b689c07e6efd05cea74190f0113.
Bug: 123510633
Bug: 127305289
Reason for revert: b/127305289
Change-Id: I59905779fe8c7d7551c0fa6c8693fb64eb6760b2
diff --git a/runtime/oat_quick_method_header.h b/runtime/oat_quick_method_header.h
index 745be40..6c123c4 100644
--- a/runtime/oat_quick_method_header.h
+++ b/runtime/oat_quick_method_header.h
@@ -31,8 +31,12 @@
class PACKED(4) OatQuickMethodHeader {
public:
OatQuickMethodHeader() = default;
- OatQuickMethodHeader(uint32_t code_info_offset) : code_info_offset_(code_info_offset) {
- DCHECK_NE(code_info_offset, 0u);
+ OatQuickMethodHeader(uint32_t vmap_table_offset,
+ uint32_t code_size)
+ : vmap_table_offset_(vmap_table_offset),
+ code_size_(code_size) {
+ DCHECK_NE(vmap_table_offset, 0u);
+ DCHECK_NE(code_size, 0u);
}
static OatQuickMethodHeader* FromCodePointer(const void* code_ptr) {
@@ -56,17 +60,17 @@
}
bool IsOptimized() const {
- return true;
+ return (code_size_ & kCodeSizeMask) != 0 && vmap_table_offset_ != 0;
}
const uint8_t* GetOptimizedCodeInfoPtr() const {
- DCHECK_NE(code_info_offset_, 0u);
- return code_ - GetVmapTableOffset();
+ DCHECK(IsOptimized());
+ return code_ - vmap_table_offset_;
}
uint8_t* GetOptimizedCodeInfoPtr() {
- DCHECK_NE(code_info_offset_, 0u);
- return code_ - GetVmapTableOffset();
+ DCHECK(IsOptimized());
+ return code_ - vmap_table_offset_;
}
const uint8_t* GetCode() const {
@@ -74,26 +78,32 @@
}
uint32_t GetCodeSize() const {
- return CodeInfo::DecodeCodeSize(GetOptimizedCodeInfoPtr());
+ DCHECK(IsOptimized());
+ size_t code_size1 = code_size_ & kCodeSizeMask;
+ size_t code_size2 = CodeInfo::DecodeCodeSize(GetOptimizedCodeInfoPtr());
+ DCHECK_EQ(code_size1, code_size2);
+ return code_size2;
+ }
+
+ const uint32_t* GetCodeSizeAddr() const {
+ return &code_size_;
}
uint32_t GetVmapTableOffset() const {
- return code_info_offset_ & kCodeInfoMask;
+ return vmap_table_offset_;
}
void SetVmapTableOffset(uint32_t offset) {
- DCHECK(!HasShouldDeoptimizeFlag());
- code_info_offset_ = offset;
- DCHECK_EQ(GetVmapTableOffset(), offset);
+ vmap_table_offset_ = offset;
}
const uint32_t* GetVmapTableOffsetAddr() const {
- return &code_info_offset_;
+ return &vmap_table_offset_;
}
const uint8_t* GetVmapTable() const {
CHECK(!IsOptimized()) << "Unimplemented vmap table for optimizing compiler";
- return (code_info_offset_ == 0) ? nullptr : code_ - code_info_offset_;
+ return (vmap_table_offset_ == 0) ? nullptr : code_ - vmap_table_offset_;
}
bool Contains(uintptr_t pc) const {
@@ -139,21 +149,23 @@
uint32_t ToDexPc(ArtMethod* method, const uintptr_t pc, bool abort_on_failure = true) const;
void SetHasShouldDeoptimizeFlag() {
- DCHECK_EQ(code_info_offset_ & kShouldDeoptimizeMask, 0u);
- code_info_offset_ |= kShouldDeoptimizeMask;
+ DCHECK_EQ(code_size_ & kShouldDeoptimizeMask, 0u);
+ code_size_ |= kShouldDeoptimizeMask;
}
bool HasShouldDeoptimizeFlag() const {
- return (code_info_offset_ & kShouldDeoptimizeMask) != 0;
+ return (code_size_ & kShouldDeoptimizeMask) != 0;
}
private:
static constexpr uint32_t kShouldDeoptimizeMask = 0x80000000;
- static constexpr uint32_t kCodeInfoMask = ~kShouldDeoptimizeMask;
+ static constexpr uint32_t kCodeSizeMask = ~kShouldDeoptimizeMask;
- // The offset in bytes from the start of the code_info to the end of the header.
- // The highest bit is used to store the should_deoptimize flag.
- uint32_t code_info_offset_ = 0u;
+ // The offset in bytes from the start of the vmap table to the end of the header.
+ uint32_t vmap_table_offset_ = 0u;
+ // The code size in bytes. The highest bit is used to signify if the compiled
+ // code with the method header has should_deoptimize flag.
+ uint32_t code_size_ = 0u;
// The actual code.
uint8_t code_[0];
};