Add method frame info to CodeInfo.
The stored information will be used in follow-up CLs.
This temporarily increases .oat file size by 0.7%.
Test: test-art-host-gtest
Change-Id: Ie7d898b06398ae44287bb1e8153861ab112a216c
diff --git a/runtime/oat.h b/runtime/oat.h
index 22c6a39..02fad46 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -32,8 +32,8 @@
class PACKED(4) OatHeader {
public:
static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' };
- // Last oat version changed reason: Add Kind column to stack maps.
- static constexpr uint8_t kOatVersion[] = { '1', '4', '9', '\0' };
+ // Last oat version changed reason: Add method frame info to CodeInfo.
+ static constexpr uint8_t kOatVersion[] = { '1', '5', '0', '\0' };
static constexpr const char* kImageLocationKey = "image-location";
static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
diff --git a/runtime/stack_map.cc b/runtime/stack_map.cc
index 7f7f6fc..42d2478 100644
--- a/runtime/stack_map.cc
+++ b/runtime/stack_map.cc
@@ -22,14 +22,24 @@
#include "art_method.h"
#include "base/indenter.h"
#include "base/stats.h"
+#include "oat_quick_method_header.h"
#include "scoped_thread_state_change-inl.h"
namespace art {
+CodeInfo::CodeInfo(const OatQuickMethodHeader* header)
+ : CodeInfo(header->GetOptimizedCodeInfoPtr()) {
+}
+
void CodeInfo::Decode(const uint8_t* data) {
size_t non_header_size = DecodeUnsignedLeb128(&data);
size_ = UnsignedLeb128Size(non_header_size) + non_header_size;
- MemoryRegion region(const_cast<uint8_t*>(data), non_header_size);
+ const uint8_t* end = data + non_header_size;
+ frame_size_in_bytes_ = DecodeUnsignedLeb128(&data);
+ core_spill_mask_ = DecodeUnsignedLeb128(&data);
+ fp_spill_mask_ = DecodeUnsignedLeb128(&data);
+ number_of_dex_registers_ = DecodeUnsignedLeb128(&data);
+ MemoryRegion region(const_cast<uint8_t*>(data), end - data);
BitMemoryReader reader(BitMemoryRegion(region), /* bit_offset */ 0);
stack_maps_.Decode(reader);
register_masks_.Decode(reader);
@@ -39,8 +49,7 @@
dex_register_masks_.Decode(reader);
dex_register_maps_.Decode(reader);
dex_register_catalog_.Decode(reader);
- number_of_dex_registers_ = DecodeVarintBits(reader);
- CHECK_EQ(non_header_size, BitsToBytesRoundUp(reader.GetBitOffset())) << "Invalid CodeInfo";
+ CHECK_EQ(BitsToBytesRoundUp(reader.GetBitOffset()), region.size()) << "Invalid CodeInfo";
}
BitTable<StackMap>::const_iterator CodeInfo::BinarySearchNativePc(uint32_t packed_pc) const {
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 83f0c05..cb43ced 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -19,6 +19,7 @@
#include <limits>
+#include "arch/instruction_set.h"
#include "base/bit_memory_region.h"
#include "base/bit_table.h"
#include "base/bit_utils.h"
@@ -28,10 +29,11 @@
#include "dex/dex_file_types.h"
#include "dex_register_location.h"
#include "method_info.h"
-#include "oat_quick_method_header.h"
+#include "quick/quick_method_frame_info.h"
namespace art {
+class OatQuickMethodHeader;
class VariableIndentationOutputStream;
// Size of a frame slot, in bytes. This constant is a signed value,
@@ -290,9 +292,7 @@
DCHECK_EQ(size_, region.size());
}
- explicit CodeInfo(const OatQuickMethodHeader* header)
- : CodeInfo(header->GetOptimizedCodeInfoPtr()) {
- }
+ explicit CodeInfo(const OatQuickMethodHeader* header);
size_t Size() const {
return size_;
@@ -435,6 +435,14 @@
// Accumulate code info size statistics into the given Stats tree.
void AddSizeStats(/*out*/ Stats* parent) const;
+ ALWAYS_INLINE static QuickMethodFrameInfo DecodeFrameInfo(const uint8_t* data) {
+ DecodeUnsignedLeb128(&data);
+ return QuickMethodFrameInfo(
+ DecodeUnsignedLeb128(&data),
+ DecodeUnsignedLeb128(&data),
+ DecodeUnsignedLeb128(&data));
+ }
+
private:
// Returns lower bound (fist stack map which has pc greater or equal than the desired one).
// It ignores catch stack maps at the end (it is the same as if they had maximum pc value).
@@ -448,6 +456,10 @@
void Decode(const uint8_t* data);
size_t size_;
+ uint32_t frame_size_in_bytes_;
+ uint32_t core_spill_mask_;
+ uint32_t fp_spill_mask_;
+ uint32_t number_of_dex_registers_;
BitTable<StackMap> stack_maps_;
BitTable<RegisterMask> register_masks_;
BitTable<MaskInfo> stack_masks_;
@@ -456,7 +468,6 @@
BitTable<MaskInfo> dex_register_masks_;
BitTable<DexRegisterMapInfo> dex_register_maps_;
BitTable<DexRegisterInfo> dex_register_catalog_;
- uint32_t number_of_dex_registers_; // Excludes any inlined methods.
};
#undef ELEMENT_BYTE_OFFSET_AFTER