diff options
author | Vladimir Marko <vmarko@google.com> | 2013-11-28 16:27:29 +0000 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2013-11-29 10:14:39 +0000 |
commit | 1e6cb63d77090ddc6aa19c755d7066f66e9ff87e (patch) | |
tree | 7cffe82e563757521da204c5dfbd3fff41dde7ed /runtime/mapping_table.h | |
parent | 00ce185371be9930dfd75e5acc2258a1139b558e (diff) | |
download | art-1e6cb63d77090ddc6aa19c755d7066f66e9ff87e.zip art-1e6cb63d77090ddc6aa19c755d7066f66e9ff87e.tar.gz art-1e6cb63d77090ddc6aa19c755d7066f66e9ff87e.tar.bz2 |
Delta-encoding of mapping tables.
Both PC offsets and dalvik offsets are delta-encoded. Since
PC offsets are increasing, the deltas are then compressed as
unsigned LEB128. Dalvik offsets are not monotonic, so their
deltas are compressed as signed LEB128.
This reduces the size of the mapping tables by about 30%
on average, 25% from the PC offset and 5% from the dalvik
offset delta encoding.
Bug: 9437697
Change-Id: I600ab9c22dec178088d4947a811cca3bc8bd4cf4
Diffstat (limited to 'runtime/mapping_table.h')
-rw-r--r-- | runtime/mapping_table.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/mapping_table.h b/runtime/mapping_table.h index c468c1e..a82bc1c 100644 --- a/runtime/mapping_table.h +++ b/runtime/mapping_table.h @@ -72,7 +72,8 @@ class MappingTable { if (end_ > 0) { encoded_table_ptr_ = table_->FirstDexToPcPtr(); native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_); - dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_); + // First delta is always positive. + dex_pc_ = static_cast<uint32_t>(DecodeSignedLeb128(&encoded_table_ptr_)); } } else { // An iterator wanted from the end. DCHECK_EQ(table_->DexToPcSize(), element); @@ -87,8 +88,9 @@ class MappingTable { void operator++() { ++element_; if (element_ != end_) { // Avoid reading beyond the end of the table. - native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_); - dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_); + native_pc_offset_ += DecodeUnsignedLeb128(&encoded_table_ptr_); + // For negative delta, unsigned overflow after static_cast does exactly what we need. + dex_pc_ += static_cast<uint32_t>(DecodeSignedLeb128(&encoded_table_ptr_)); } } bool operator==(const DexToPcIterator& rhs) const { @@ -147,7 +149,8 @@ class MappingTable { if (end_ > 0) { encoded_table_ptr_ = table_->FirstPcToDexPtr(); native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_); - dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_); + // First delta is always positive. + dex_pc_ = static_cast<uint32_t>(DecodeSignedLeb128(&encoded_table_ptr_)); } } else { // An iterator wanted from the end. DCHECK_EQ(table_->PcToDexSize(), element); @@ -162,8 +165,9 @@ class MappingTable { void operator++() { ++element_; if (element_ != end_) { // Avoid reading beyond the end of the table. - native_pc_offset_ = DecodeUnsignedLeb128(&encoded_table_ptr_); - dex_pc_ = DecodeUnsignedLeb128(&encoded_table_ptr_); + native_pc_offset_ += DecodeUnsignedLeb128(&encoded_table_ptr_); + // For negative delta, unsigned overflow after static_cast does exactly what we need. + dex_pc_ += static_cast<uint32_t>(DecodeSignedLeb128(&encoded_table_ptr_)); } } bool operator==(const PcToDexIterator& rhs) const { |