From d1606417eac35d4842f607b63eda48e868e8db1d Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Tue, 31 Jul 2018 15:05:14 +0100 Subject: Cleanup BitMemoryReader/Writer api. Test: test-art-host-gtest-stack_map_test Test: test-art-host-gtest-bit_table_test Change-Id: I15c624d2a70736aeb8422ce5babcef8e8fa82136 --- runtime/stack_map.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'runtime/stack_map.h') diff --git a/runtime/stack_map.h b/runtime/stack_map.h index d6db05a3b8..cde08f312b 100644 --- a/runtime/stack_map.h +++ b/runtime/stack_map.h @@ -269,6 +269,26 @@ class MethodInfo : public BitTableAccessor<1> { */ class CodeInfo { public: + class Deduper { + public: + explicit Deduper(std::vector* output) : writer_(output) { + DCHECK_EQ(output->size(), 0u); + } + + // Copy CodeInfo into output while de-duplicating the internal bit tables. + // It returns the byte offset of the copied CodeInfo within the output. + size_t Dedupe(const uint8_t* code_info); + + private: + template + void DedupeTable(BitMemoryReader& reader); + + BitMemoryWriter> writer_; + + // Deduplicate at BitTable level. The value is bit offset within the output. + std::map dedupe_map_; + }; + enum DecodeFlags { Default = 0, // Limits the decoding only to the data needed by GC. @@ -421,16 +441,6 @@ class CodeInfo { DecodeVarintBits(reader)); // fp_spill_mask_. } - typedef std::map DedupeMap; - - // Copy CodeInfo data while de-duplicating the internal bit tables. - // The 'out' vector must be reused between Dedupe calls (it does not have to be empty). - // The 'dedupe_map' stores the bit offsets of bit tables within the 'out' vector. - // It returns the byte offset of the copied CodeInfo within the 'out' vector. - static size_t Dedupe(std::vector* out, - const uint8_t* in, - /*inout*/ DedupeMap* dedupe_map); - 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). -- cgit v1.2.3-59-g8ed1b