diff options
author | 2018-07-30 16:46:53 +0100 | |
---|---|---|
committer | 2018-08-02 11:31:44 +0100 | |
commit | 3aaaa21055ab73562b8da7968ac4fa5fe9d44695 (patch) | |
tree | a3118eee8f5cc9c661e1480f2ce73691c3786f8a /runtime/stack_map.cc | |
parent | 605339045d347074b9149c0185fe2ca7fafe470d (diff) |
Encode frame info using varints.
This saves 0.3% of oat file size.
Test: test-art-host-gtest-stack_map_test
Change-Id: I85003946a9579f03cb1ed2b5e9b2c62b3efe6734
Diffstat (limited to 'runtime/stack_map.cc')
-rw-r--r-- | runtime/stack_map.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/runtime/stack_map.cc b/runtime/stack_map.cc index cd82284a9a..1b78b5ac1d 100644 --- a/runtime/stack_map.cc +++ b/runtime/stack_map.cc @@ -50,12 +50,11 @@ ALWAYS_INLINE static void DecodeTable(BitTable<Accessor>& table, } void CodeInfo::Decode(const uint8_t* data, DecodeFlags flags) { - const uint8_t* begin = data; - frame_size_in_bytes_ = DecodeUnsignedLeb128(&data); - core_spill_mask_ = DecodeUnsignedLeb128(&data); - fp_spill_mask_ = DecodeUnsignedLeb128(&data); - number_of_dex_registers_ = DecodeUnsignedLeb128(&data); - BitMemoryReader reader(data, /* bit_offset */ 0); + BitMemoryReader reader(data); + packed_frame_size_ = DecodeVarintBits(reader); + core_spill_mask_ = DecodeVarintBits(reader); + fp_spill_mask_ = DecodeVarintBits(reader); + number_of_dex_registers_ = DecodeVarintBits(reader); DecodeTable(stack_maps_, reader, data); DecodeTable(inline_infos_, reader, data); DecodeTable(method_infos_, reader, data); @@ -67,7 +66,7 @@ void CodeInfo::Decode(const uint8_t* data, DecodeFlags flags) { DecodeTable(dex_register_masks_, reader, data); DecodeTable(dex_register_maps_, reader, data); DecodeTable(dex_register_catalog_, reader, data); - size_in_bits_ = (data - begin) * kBitsPerByte + reader.GetBitOffset(); + size_in_bits_ = reader.GetBitOffset(); } template<typename Accessor> @@ -91,13 +90,12 @@ ALWAYS_INLINE static void DedupeTable(BitMemoryWriter<std::vector<uint8_t>>& wri size_t CodeInfo::Dedupe(std::vector<uint8_t>* out, const uint8_t* in, DedupeMap* dedupe_map) { // Remember the current offset in the output buffer so that we can return it later. const size_t result = out->size(); - // Copy the header which encodes QuickMethodFrameInfo. - EncodeUnsignedLeb128(out, DecodeUnsignedLeb128(&in)); - EncodeUnsignedLeb128(out, DecodeUnsignedLeb128(&in)); - EncodeUnsignedLeb128(out, DecodeUnsignedLeb128(&in)); - EncodeUnsignedLeb128(out, DecodeUnsignedLeb128(&in)); - BitMemoryReader reader(in, /* bit_offset */ 0); + BitMemoryReader reader(in); BitMemoryWriter<std::vector<uint8_t>> writer(out, /* bit_offset */ out->size() * kBitsPerByte); + EncodeVarintBits(writer, DecodeVarintBits(reader)); // packed_frame_size_. + EncodeVarintBits(writer, DecodeVarintBits(reader)); // core_spill_mask_. + EncodeVarintBits(writer, DecodeVarintBits(reader)); // fp_spill_mask_. + EncodeVarintBits(writer, DecodeVarintBits(reader)); // number_of_dex_registers_. DedupeTable<StackMap>(writer, reader, dedupe_map); DedupeTable<InlineInfo>(writer, reader, dedupe_map); DedupeTable<MethodInfo>(writer, reader, dedupe_map); |