Index: src/wasm/leb-helper.h |
diff --git a/src/wasm/leb-helper.h b/src/wasm/leb-helper.h |
index 0e4ba3418c3ba87ccc6298b69b3a3e7bc99d0a87..c3a74fdad7d1fba5f030ba4b974bcff7c32e8c83 100644 |
--- a/src/wasm/leb-helper.h |
+++ b/src/wasm/leb-helper.h |
@@ -5,6 +5,11 @@ |
#ifndef V8_WASM_LEB_HELPER_H_ |
#define V8_WASM_LEB_HELPER_H_ |
+#include <cstddef> // size_t |
+#include <cstdint> // int32_t, ... |
+ |
+#include "src/base/logging.h" |
+ |
namespace v8 { |
namespace internal { |
namespace wasm { |
@@ -125,6 +130,23 @@ class LEBHelper { |
} |
return size; |
} |
+ |
+ static inline uint32_t read_u32v(const uint8_t* src) { |
+ return read_u32v(&src); |
+ } |
+ |
+ static inline uint32_t read_u32v(const uint8_t** src) { |
+ uint32_t result = 0; |
+ int shift = 0; |
+ uint8_t b; |
+ do { |
+ b = *((*src)++); |
+ DCHECK_GE(28, shift); |
+ result = result | (static_cast<uint32_t>(b & 0x7F) << shift); |
+ shift += 7; |
+ } while ((b & 0x80) != 0); |
+ return result; |
+ } |
}; |
} // namespace wasm |