Don't pack code size in CodeInfo.
The unpacking is tricky for host tooling as we need to propagate ISA.
This adds 0.05% to oat file size.
Bug: 123510633
Change-Id: I5618db5e5dbe83d8a2bb89aef61cb0b10e336f40
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc
index e87f3c8..c0e3206 100644
--- a/compiler/optimizing/stack_map_stream.cc
+++ b/compiler/optimizing/stack_map_stream.cc
@@ -57,7 +57,7 @@
void StackMapStream::EndMethod(size_t code_size) {
DCHECK(in_method_) << "Mismatched Begin/End calls";
in_method_ = false;
- packed_code_size_ = StackMap::PackNativePc(code_size, instruction_set_);
+ code_size_ = code_size;
// Read the stack masks now. The compiler might have updated them.
for (size_t i = 0; i < lazy_stack_masks_.size(); i++) {
@@ -68,8 +68,9 @@
}
}
+ uint32_t packed_code_size = StackMap::PackNativePc(code_size, instruction_set_);
for (size_t i = 0; i < stack_maps_.size(); i++) {
- DCHECK_LE(stack_maps_[i][StackMap::kPackedNativePc], packed_code_size_);
+ DCHECK_LE(stack_maps_[i][StackMap::kPackedNativePc], packed_code_size);
}
}
@@ -301,7 +302,7 @@
ScopedArenaVector<uint8_t> buffer(allocator_->Adapter(kArenaAllocStackMapStream));
BitMemoryWriter<ScopedArenaVector<uint8_t>> out(&buffer);
- out.WriteVarint(packed_code_size_);
+ out.WriteVarint(code_size_);
out.WriteVarint(packed_frame_size_);
out.WriteVarint(core_spill_mask_);
out.WriteVarint(fp_spill_mask_);
diff --git a/compiler/optimizing/stack_map_stream.h b/compiler/optimizing/stack_map_stream.h
index 164e902..1fea3ef 100644
--- a/compiler/optimizing/stack_map_stream.h
+++ b/compiler/optimizing/stack_map_stream.h
@@ -99,7 +99,7 @@
ScopedArenaAllocator* allocator_;
const InstructionSet instruction_set_;
- uint32_t packed_code_size_ = 0;
+ uint32_t code_size_ = 0;
uint32_t packed_frame_size_ = 0;
uint32_t core_spill_mask_ = 0;
uint32_t fp_spill_mask_ = 0;
diff --git a/runtime/oat.h b/runtime/oat.h
index bd4a6e3..d897bad 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -31,8 +31,8 @@
class PACKED(4) OatHeader {
public:
static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' };
- // Last oat version changed reason: Remove code size from OatQuickMethodHeader.
- static constexpr uint8_t kOatVersion[] = { '1', '6', '8', '\0' };
+ // Last oat version changed reason: Don't pack code size in CodeInfo.
+ static constexpr uint8_t kOatVersion[] = { '1', '6', '9', '\0' };
static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
static constexpr const char* kDebuggableKey = "debuggable";
diff --git a/runtime/stack_map.cc b/runtime/stack_map.cc
index 5d30b77..8d2ae2f 100644
--- a/runtime/stack_map.cc
+++ b/runtime/stack_map.cc
@@ -227,7 +227,7 @@
bool verbose,
InstructionSet instruction_set) const {
vios->Stream() << "CodeInfo BitSize=" << size_in_bits_
- << " CodeSize:" << StackMap::UnpackNativePc(packed_code_size_, instruction_set)
+ << " CodeSize:" << code_size_
<< " FrameSize:" << packed_frame_size_ * kStackAlignment
<< " CoreSpillMask:" << std::hex << core_spill_mask_
<< " FpSpillMask:" << std::hex << fp_spill_mask_
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 59da923..af7d42a 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -438,10 +438,8 @@
// Accumulate code info size statistics into the given Stats tree.
static void CollectSizeStats(const uint8_t* code_info, /*out*/ Stats* parent);
- ALWAYS_INLINE static size_t DecodeCodeSize(const uint8_t* data,
- InstructionSet isa = kRuntimeISA) {
- uint32_t packed_code_size = BitMemoryReader(data).ReadVarint();
- return StackMap::UnpackNativePc(packed_code_size, isa);
+ ALWAYS_INLINE static size_t DecodeCodeSize(const uint8_t* data) {
+ return BitMemoryReader(data).ReadVarint();
}
ALWAYS_INLINE static QuickMethodFrameInfo DecodeFrameInfo(const uint8_t* data) {
@@ -468,7 +466,7 @@
// Invokes the callback with member pointer of each header field.
template<typename Callback>
ALWAYS_INLINE static void ForEachHeaderField(Callback callback) {
- callback(&CodeInfo::packed_code_size_);
+ callback(&CodeInfo::code_size_);
callback(&CodeInfo::packed_frame_size_);
callback(&CodeInfo::core_spill_mask_);
callback(&CodeInfo::fp_spill_mask_);
@@ -494,7 +492,7 @@
callback(&CodeInfo::dex_register_catalog_);
}
- uint32_t packed_code_size_ = 0; // The size of native PC range.
+ uint32_t code_size_ = 0; // The size of native PC range.
uint32_t packed_frame_size_ = 0; // Frame size in kStackAlignment units.
uint32_t core_spill_mask_ = 0;
uint32_t fp_spill_mask_ = 0;