From 06606b9c4a1c00154ed15f719ad8ea994e54ee8e Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Mon, 2 Dec 2013 15:31:08 +0000 Subject: Performance improvement for mapping table creation. Avoid the raw mapping tables altogether. Change-Id: I6d1c786325d369e899a75f15701edbafdd14363f --- compiler/leb128_encoder.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'compiler/leb128_encoder.h') diff --git a/compiler/leb128_encoder.h b/compiler/leb128_encoder.h index fe38c2f5cd..67666831f0 100644 --- a/compiler/leb128_encoder.h +++ b/compiler/leb128_encoder.h @@ -22,6 +22,31 @@ namespace art { +static inline uint8_t* EncodeUnsignedLeb128(uint8_t* dest, uint32_t value) { + uint8_t out = value & 0x7f; + value >>= 7; + while (value != 0) { + *dest++ = out | 0x80; + out = value & 0x7f; + value >>= 7; + } + *dest++ = out; + return dest; +} + +static inline uint8_t* EncodeSignedLeb128(uint8_t* dest, int32_t value) { + uint32_t extra_bits = static_cast(value ^ (value >> 31)) >> 6; + uint8_t out = value & 0x7f; + while (extra_bits != 0u) { + *dest++ = out | 0x80; + value >>= 7; + out = value & 0x7f; + extra_bits >>= 7; + } + *dest++ = out; + return dest; +} + // An encoder with an API similar to vector where the data is captured in ULEB128 format. class Leb128EncodingVector { public: -- cgit v1.2.3-59-g8ed1b