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

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: Undo malloc change. 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
Index: src/wasm/wasm-macro-gen.h
diff --git a/src/wasm/wasm-macro-gen.h b/src/wasm/wasm-macro-gen.h
index 7e50d03fd6335563b9a2de5cabf5b5e3bd1a59a8..1d188c2b5d7030e06b4c6c1abeb5f03849ffadff 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)
bradn 2016/02/29 06:30:00 These are only used in one test, move them there?
titzer 2016/02/29 16:51:46 The plan is to use U32V_1, U32V_2, etc in more tes
+#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_

Powered by Google App Engine
This is Rietveld 408576698