Revert "Don't pack code size in CodeInfo."
This reverts commit e35ac04a1a9a22b1c4386b27f3a30cd840aa17b1.
Bug: 123510633
Bug: 127305289
Reason for revert: b/127305289
Change-Id: I18c2d9291411b31641333c14c47da8c4fdf317f7
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc
index c0e3206..e87f3c8 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;
- code_size_ = code_size;
+ packed_code_size_ = StackMap::PackNativePc(code_size, instruction_set_);
// Read the stack masks now. The compiler might have updated them.
for (size_t i = 0; i < lazy_stack_masks_.size(); i++) {
@@ -68,9 +68,8 @@
}
}
- 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_);
}
}
@@ -302,7 +301,7 @@
ScopedArenaVector<uint8_t> buffer(allocator_->Adapter(kArenaAllocStackMapStream));
BitMemoryWriter<ScopedArenaVector<uint8_t>> out(&buffer);
- out.WriteVarint(code_size_);
+ out.WriteVarint(packed_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 1fea3ef..164e902 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 code_size_ = 0;
+ uint32_t packed_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 d897bad..bd4a6e3 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: Don't pack code size in CodeInfo.
- static constexpr uint8_t kOatVersion[] = { '1', '6', '9', '\0' };
+ // Last oat version changed reason: Remove code size from OatQuickMethodHeader.
+ static constexpr uint8_t kOatVersion[] = { '1', '6', '8', '\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 8d2ae2f..5d30b77 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:" << code_size_
+ << " CodeSize:" << StackMap::UnpackNativePc(packed_code_size_, instruction_set)
<< " 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 af7d42a..59da923 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -438,8 +438,10 @@
// 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) {
- return BitMemoryReader(data).ReadVarint();
+ 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 QuickMethodFrameInfo DecodeFrameInfo(const uint8_t* data) {
@@ -466,7 +468,7 @@
// Invokes the callback with member pointer of each header field.
template<typename Callback>
ALWAYS_INLINE static void ForEachHeaderField(Callback callback) {
- callback(&CodeInfo::code_size_);
+ callback(&CodeInfo::packed_code_size_);
callback(&CodeInfo::packed_frame_size_);
callback(&CodeInfo::core_spill_mask_);
callback(&CodeInfo::fp_spill_mask_);
@@ -492,7 +494,7 @@
callback(&CodeInfo::dex_register_catalog_);
}
- uint32_t code_size_ = 0; // The size of native PC range.
+ uint32_t packed_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;