Verifier now generates register maps, though nothing uses them yet.
The code to generate the maps is enabled for testing, but currently
nothing is done with them. Will work out what to do with them later.
Change-Id: Ifa5b7a9dd1233813d4f4040cacfb83e9b4a5330b
diff --git a/src/leb128.h b/src/leb128.h
index bc5dd1a..ad55199 100644
--- a/src/leb128.h
+++ b/src/leb128.h
@@ -79,6 +79,32 @@
return result;
}
+// Returns the number of bytes needed to encode the value in unsigned LEB128.
+static inline uint32_t UnsignedLeb128Size(uint32_t data) {
+ uint32_t count = 0;
+ do {
+ data >>= 7;
+ count++;
+ } while (data != 0);
+ return count;
+}
+
+// Writes a 32-bit value in unsigned ULEB128 format.
+// Returns the updated pointer.
+static inline uint8_t* WriteUnsignedLeb128(uint8_t* ptr, uint32_t data) {
+ while (true) {
+ uint8_t out = data & 0x7f;
+ if (out != data) {
+ *ptr++ = out | 0x80;
+ data >>= 7;
+ } else {
+ *ptr++ = out;
+ break;
+ }
+ }
+ return ptr;
+}
+
} // namespace art
#endif // ART_SRC_LEB128_H_