diff options
author | simonb@chromium.org <simonb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 15:31:28 +0000 |
---|---|---|
committer | simonb@chromium.org <simonb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 15:33:34 +0000 |
commit | 4c72c38c3366f44ef9165eec04d02a7d70bfb0db (patch) | |
tree | f4ca415b6d6ac614f30ffb20e70ef5214b42af29 /third_party | |
parent | 2f3298eb86931ea18568ffb2c8db8d0f2a3b4953 (diff) | |
download | chromium_src-4c72c38c3366f44ef9165eec04d02a7d70bfb0db.zip chromium_src-4c72c38c3366f44ef9165eec04d02a7d70bfb0db.tar.gz chromium_src-4c72c38c3366f44ef9165eec04d02a7d70bfb0db.tar.bz2 |
Implement the LEB128 decoder for packed relocations more efficiently.
Replace the current two-loop LEB128 decoder in the crazy linker with a
slight more efficient single-loop implementation.
BUG=385553
Review URL: https://codereview.chromium.org/475093002
Cr-Commit-Position: refs/heads/master@{#289870}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/android_crazy_linker/README.chromium | 2 | ||||
-rw-r--r-- | third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/third_party/android_crazy_linker/README.chromium b/third_party/android_crazy_linker/README.chromium index 3b36cea..ef5087d 100644 --- a/third_party/android_crazy_linker/README.chromium +++ b/third_party/android_crazy_linker/README.chromium @@ -37,3 +37,5 @@ Local Modifications: - Add support for x86_64. - Speculative fix for crbug/397634. + +- Implement LEB128 decoding more efficiently. diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp index a5e53fe..33c385a 100644 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp +++ b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp @@ -370,17 +370,17 @@ class Leb128Decoder { : encoding_(encoding), cursor_(0) { } uint32_t Dequeue() { - size_t extent = cursor_; - while (encoding_[extent] >> 7) - extent++; - uint32_t value = 0; - for (size_t i = extent; i > cursor_; --i) { - value = (value << 7) | (encoding_[i] & 127); - } - value = (value << 7) | (encoding_[cursor_] & 127); - cursor_ = extent + 1; + size_t shift = 0; + uint8_t byte; + + do { + byte = encoding_[cursor_++]; + value |= static_cast<uint32_t>(byte & 127) << shift; + shift += 7; + } while (byte & 128); + return value; } |