MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / GetOffset

Method GetOffset

Bcore/src/main/cpp/dex/compact_offset_table.cc:38–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36 reinterpret_cast<const uint32_t*>(data_begin)[1]) {}
37
38uint32_t CompactOffsetTable::Accessor::GetOffset(uint32_t index) const {
39 const uint32_t offset = table_[index / kElementsPerIndex];
40 const size_t bit_index = index % kElementsPerIndex;
41
42 const uint8_t* block = data_begin_ + offset;
43 uint16_t bit_mask = *block;
44 ++block;
45 bit_mask = (bit_mask << kBitsPerByte) | *block;
46 ++block;
47 if ((bit_mask & (1 << bit_index)) == 0) {
48 // Bit is not set means the offset is 0.
49 return 0u;
50 }
51 // Trim off the bits above the index we want and count how many bits are set. This is how many
52 // lebs we need to decode.
53 size_t count = POPCOUNT(static_cast<uintptr_t>(bit_mask) << (kBitsPerIntPtrT - 1 - bit_index));
54 DCHECK_GT(count, 0u);
55 uint32_t current_offset = minimum_offset_;
56 do {
57 current_offset += DecodeUnsignedLeb128(&block);
58 --count;
59 } while (count > 0);
60 return current_offset;
61}
62
63void CompactOffsetTable::Build(const std::vector<uint32_t>& offsets,
64 std::vector<uint8_t>* out_data) {

Callers 1

GetDebugInfoOffsetMethod · 0.80

Calls 2

POPCOUNTFunction · 0.85
DecodeUnsignedLeb128Function · 0.85

Tested by

no test coverage detected