From 6ee06e97cef5ee92944deaeba0da4d10c4c33a2a Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Wed, 25 Jul 2018 21:45:54 +0100 Subject: Decode only the needed tables from CodeInfo. Most use cases need only the first two bit tables from CodeInfo. Add flag to the decode method so that only those two are loaded. We only touched the table header but that still made difference. This speeds up pmd by over 10%. Test: test-art-host-gtest Change-Id: I7740081bf18205dd69864503b5bcec7de5e1a901 --- runtime/stack_map.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'runtime/stack_map.h') diff --git a/runtime/stack_map.h b/runtime/stack_map.h index 26b95b0c2b..928f0f24d6 100644 --- a/runtime/stack_map.h +++ b/runtime/stack_map.h @@ -268,15 +268,22 @@ class RegisterMask : public BitTableAccessor<2> { */ class CodeInfo { public: - explicit CodeInfo(const void* data) { - Decode(reinterpret_cast(data)); + enum DecodeFlags { + Default = 0, + // Limits the decoding only to the main stack map table and inline info table. + // This is sufficient for many use cases and makes the header decoding faster. + InlineInfoOnly = 1, + }; + + explicit CodeInfo(const uint8_t* data, DecodeFlags flags = DecodeFlags::Default) { + Decode(reinterpret_cast(data), flags); } explicit CodeInfo(MemoryRegion region) : CodeInfo(region.begin()) { DCHECK_EQ(Size(), region.size()); } - explicit CodeInfo(const OatQuickMethodHeader* header); + explicit CodeInfo(const OatQuickMethodHeader* header, DecodeFlags flags = DecodeFlags::Default); size_t Size() const { return BitsToBytesRoundUp(size_in_bits_); @@ -421,20 +428,20 @@ class CodeInfo { uint32_t first_dex_register, /*out*/ DexRegisterMap* map) const; - void Decode(const uint8_t* data); + void Decode(const uint8_t* data, DecodeFlags flags); uint32_t frame_size_in_bytes_; uint32_t core_spill_mask_; uint32_t fp_spill_mask_; uint32_t number_of_dex_registers_; BitTable stack_maps_; + BitTable inline_infos_; BitTable register_masks_; BitTable stack_masks_; - BitTable inline_infos_; BitTable dex_register_masks_; BitTable dex_register_maps_; BitTable dex_register_catalog_; - uint32_t size_in_bits_; + uint32_t size_in_bits_ = 0; }; #undef ELEMENT_BYTE_OFFSET_AFTER -- cgit v1.2.3-59-g8ed1b