summaryrefslogtreecommitdiff
path: root/runtime/stack_map.h
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2019-05-30 22:45:40 +0100
committer David Srbecky <dsrbecky@google.com> 2019-06-30 18:04:44 +0000
commit0d4567f26701abae84b02389c379843c1dc851a8 (patch)
treef665e6d5db5af79a4afa3b97cd7cdb7a2069da3f /runtime/stack_map.h
parentcc08c50948d8b2a93b53a327717c7b2a146ac754 (diff)
Stack maps: Refactor constructors.
Create dedicated static methods instead of passing flags. This creates dedicated methods for the purpose and merges constructor and decoding into single optimized method. This speeds up CodeInfo by 10%, and maps startup by 0.1%. Test: ./art/test.py -b --host Change-Id: Ic7d43e22bca0be9fb13bc2c7544ebfdf46798cfe
Diffstat (limited to 'runtime/stack_map.h')
-rw-r--r--runtime/stack_map.h49
1 files changed, 10 insertions, 39 deletions
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index b438074d6d..598f3e4473 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -291,26 +291,14 @@ class CodeInfo {
std::map<BitMemoryRegion, uint32_t, BitMemoryRegion::Less> dedupe_map_;
};
- enum DecodeFlags {
- AllTables = 0,
- // Limits the decoding only to the data needed by GC.
- GcMasksOnly = 1,
- // 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 = 2,
- };
-
- CodeInfo() {}
-
- explicit CodeInfo(const uint8_t* data, DecodeFlags flags = AllTables) {
- Decode(reinterpret_cast<const uint8_t*>(data), flags);
- }
-
- explicit CodeInfo(const OatQuickMethodHeader* header, DecodeFlags flags = AllTables);
+ ALWAYS_INLINE CodeInfo() {}
+ ALWAYS_INLINE explicit CodeInfo(const uint8_t* data, size_t* num_read_bits = nullptr);
+ ALWAYS_INLINE explicit CodeInfo(const OatQuickMethodHeader* header);
- size_t Size() const {
- return BitsToBytesRoundUp(size_in_bits_);
- }
+ // The following methods decode only part of the data.
+ static QuickMethodFrameInfo DecodeFrameInfo(const uint8_t* data);
+ static CodeInfo DecodeGcMasksOnly(const OatQuickMethodHeader* header);
+ static CodeInfo DecodeInlineInfoOnly(const OatQuickMethodHeader* header);
ALWAYS_INLINE const BitTable<StackMap>& GetStackMaps() const {
return stack_maps_;
@@ -441,23 +429,14 @@ class CodeInfo {
return (*code_info_data & kHasInlineInfo) != 0;
}
- ALWAYS_INLINE static QuickMethodFrameInfo DecodeFrameInfo(const uint8_t* code_info_data) {
- BitMemoryReader reader(code_info_data);
- std::array<uint32_t, kNumHeaders> header = reader.ReadInterleavedVarints<kNumHeaders>();
- return QuickMethodFrameInfo(header[1] * kStackAlignment, header[2], header[3]);
- }
-
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).
- ALWAYS_INLINE BitTable<StackMap>::const_iterator BinarySearchNativePc(uint32_t packed_pc) const;
-
// Scan backward to determine dex register locations at given stack map.
void DecodeDexRegisterMap(uint32_t stack_map_index,
uint32_t first_dex_register,
/*out*/ DexRegisterMap* map) const;
- void Decode(const uint8_t* data, DecodeFlags flags);
+ template<typename DecodeCallback> // (size_t index, BitTable<...>*, BitMemoryRegion).
+ ALWAYS_INLINE CodeInfo(const uint8_t* data, size_t* num_read_bits, DecodeCallback callback);
// Invokes the callback with index and member pointer of each header field.
template<typename Callback>
@@ -474,19 +453,13 @@ class CodeInfo {
// Invokes the callback with index and member pointer of each BitTable field.
template<typename Callback>
- ALWAYS_INLINE static void ForEachBitTableField(Callback callback, DecodeFlags flags = AllTables) {
+ ALWAYS_INLINE static void ForEachBitTableField(Callback callback) {
size_t index = 0;
callback(index++, &CodeInfo::stack_maps_);
callback(index++, &CodeInfo::register_masks_);
callback(index++, &CodeInfo::stack_masks_);
- if (flags & DecodeFlags::GcMasksOnly) {
- return;
- }
callback(index++, &CodeInfo::inline_infos_);
callback(index++, &CodeInfo::method_infos_);
- if (flags & DecodeFlags::InlineInfoOnly) {
- return;
- }
callback(index++, &CodeInfo::dex_register_masks_);
callback(index++, &CodeInfo::dex_register_maps_);
callback(index++, &CodeInfo::dex_register_catalog_);
@@ -522,8 +495,6 @@ class CodeInfo {
BitTable<DexRegisterMapInfo> dex_register_maps_;
BitTable<DexRegisterInfo> dex_register_catalog_;
- uint32_t size_in_bits_ = 0;
-
friend class StackMapStream;
};