Optimize stack maps: add fast path for no inline info.
Consumers of CodeInfo can skip significant chunks of work
if they can quickly determine that method has no inlining.
Store this fact as a flag bit at the start of code info.
This changes binary format and adds <0.1% to oat size.
I added the extra flag field as the simplest solution for now,
although I would like to use it for more things in the future.
(e.g. store the special cases of empty/deduped tables in it)
This improves app startup by 0.4% (maps,speed).
PMD on golem seems to gets around 15% faster.
Bug: 133257467
Test: ./art/test.py -b --host --64
Change-Id: Ia498a31bafc74b51cc95b8c70cf1da4b0e3d894e
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index a2f0019..a971467 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -438,11 +438,15 @@
// Accumulate code info size statistics into the given Stats tree.
static void CollectSizeStats(const uint8_t* code_info, /*out*/ Stats* parent);
- ALWAYS_INLINE static QuickMethodFrameInfo DecodeFrameInfo(const uint8_t* data) {
- BitMemoryReader reader(data);
- uint32_t args[3]; // packed_frame_size, core_spill_mask, fp_spill_mask.
- reader.ReadVarints(args);
- return QuickMethodFrameInfo(args[0] * kStackAlignment, args[1], args[2]);
+ ALWAYS_INLINE static bool HasInlineInfo(const uint8_t* code_info_data) {
+ return (*code_info_data & kHasInlineInfo) != 0;
+ }
+
+ ALWAYS_INLINE static QuickMethodFrameInfo DecodeFrameInfo(const uint8_t* code_info_data) {
+ BitMemoryReader reader(code_info_data);
+ uint32_t header[4]; // flags, packed_frame_size, core_spill_mask, fp_spill_mask.
+ reader.ReadVarints(header);
+ return QuickMethodFrameInfo(header[1] * kStackAlignment, header[2], header[3]);
}
private:
@@ -460,6 +464,7 @@
// Invokes the callback with member pointer of each header field.
template<typename Callback>
ALWAYS_INLINE static void ForEachHeaderField(Callback callback) {
+ callback(&CodeInfo::flags_);
callback(&CodeInfo::packed_frame_size_);
callback(&CodeInfo::core_spill_mask_);
callback(&CodeInfo::fp_spill_mask_);
@@ -485,6 +490,11 @@
callback(&CodeInfo::dex_register_catalog_);
}
+ enum Flags {
+ kHasInlineInfo = 1 << 0,
+ };
+
+ uint32_t flags_ = 0;
uint32_t packed_frame_size_ = 0; // Frame size in kStackAlignment units.
uint32_t core_spill_mask_ = 0;
uint32_t fp_spill_mask_ = 0;