| 36 | reinterpret_cast<const uint32_t*>(data_begin)[1]) {} |
| 37 | |
| 38 | uint32_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 | |
| 63 | void CompactOffsetTable::Build(const std::vector<uint32_t>& offsets, |
| 64 | std::vector<uint8_t>* out_data) { |
no test coverage detected