Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Unified Diff: src/wasm/wasm-macro-gen.h

Issue 1746653002: [wasm] Add support and unittests for decoding signed LEB128. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/decoder.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-macro-gen.h
diff --git a/src/wasm/wasm-macro-gen.h b/src/wasm/wasm-macro-gen.h
index 2b7d16af5459e876c2e61004aad5f5744ec68ec6..e40a2d4aaccc5633115d99c74aad5dfb66bb7b17 100644
--- a/src/wasm/wasm-macro-gen.h
+++ b/src/wasm/wasm-macro-gen.h
@@ -277,4 +277,28 @@
#define FUNC_INDEX(v) U16_LE(v)
#define NAME_OFFSET(v) U32_LE(v)
+#define MASK_7 ((1 << 7) - 1)
+#define MASK_14 ((1 << 14) - 1)
+#define MASK_21 ((1 << 21) - 1)
+#define MASK_28 ((1 << 28) - 1)
+
+#define U32V_1(x) static_cast<byte>(x & MASK_7)
+#define U32V_2(x) \
+ static_cast<byte>((x & MASK_7) | 0x80), static_cast<byte>((x >> 7) & MASK_7)
+#define U32V_3(x) \
+ static_cast<byte>((x & MASK_7) | 0x80), \
+ static_cast<byte>(((x >> 7) & MASK_7) | 0x80), \
+ static_cast<byte>((x >> 14) & MASK_7)
+#define U32V_4(x) \
+ static_cast<byte>((x & MASK_7) | 0x80), \
+ static_cast<byte>(((x >> 7) & MASK_7) | 0x80), \
+ static_cast<byte>(((x >> 14) & MASK_7) | 0x80), \
+ static_cast<byte>((x >> 21) & MASK_7)
+#define U32V_5(x) \
+ static_cast<byte>((x & MASK_7) | 0x80), \
+ static_cast<byte>(((x >> 7) & MASK_7) | 0x80), \
+ static_cast<byte>(((x >> 14) & MASK_7) | 0x80), \
+ static_cast<byte>(((x >> 21) & MASK_7) | 0x80), \
+ static_cast<byte>((x >> 28) & 0xF)
+
#endif // V8_WASM_MACRO_GEN_H_
« no previous file with comments | « src/wasm/decoder.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698