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

Side by Side 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, 9 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 unified diff | Download patch
« no previous file with comments | « src/wasm/decoder.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_WASM_MACRO_GEN_H_ 5 #ifndef V8_WASM_MACRO_GEN_H_
6 #define V8_WASM_MACRO_GEN_H_ 6 #define V8_WASM_MACRO_GEN_H_
7 7
8 #include "src/wasm/wasm-opcodes.h" 8 #include "src/wasm/wasm-opcodes.h"
9 9
10 // Convenience macros for building Wasm bytecode directly into a byte array. 10 // Convenience macros for building Wasm bytecode directly into a byte array.
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 static_cast<byte>((v) >> 16), static_cast<byte>((v) >> 24) 270 static_cast<byte>((v) >> 16), static_cast<byte>((v) >> 24)
271 271
272 #define U16_LE(v) static_cast<byte>(v), static_cast<byte>((v) >> 8) 272 #define U16_LE(v) static_cast<byte>(v), static_cast<byte>((v) >> 8)
273 273
274 #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion) 274 #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion)
275 275
276 #define SIG_INDEX(v) U16_LE(v) 276 #define SIG_INDEX(v) U16_LE(v)
277 #define FUNC_INDEX(v) U16_LE(v) 277 #define FUNC_INDEX(v) U16_LE(v)
278 #define NAME_OFFSET(v) U32_LE(v) 278 #define NAME_OFFSET(v) U32_LE(v)
279 279
280 #define MASK_7 ((1 << 7) - 1)
281 #define MASK_14 ((1 << 14) - 1)
282 #define MASK_21 ((1 << 21) - 1)
283 #define MASK_28 ((1 << 28) - 1)
284
285 #define U32V_1(x) static_cast<byte>(x & MASK_7)
286 #define U32V_2(x) \
287 static_cast<byte>((x & MASK_7) | 0x80), static_cast<byte>((x >> 7) & MASK_7)
288 #define U32V_3(x) \
289 static_cast<byte>((x & MASK_7) | 0x80), \
290 static_cast<byte>(((x >> 7) & MASK_7) | 0x80), \
291 static_cast<byte>((x >> 14) & MASK_7)
292 #define U32V_4(x) \
293 static_cast<byte>((x & MASK_7) | 0x80), \
294 static_cast<byte>(((x >> 7) & MASK_7) | 0x80), \
295 static_cast<byte>(((x >> 14) & MASK_7) | 0x80), \
296 static_cast<byte>((x >> 21) & MASK_7)
297 #define U32V_5(x) \
298 static_cast<byte>((x & MASK_7) | 0x80), \
299 static_cast<byte>(((x >> 7) & MASK_7) | 0x80), \
300 static_cast<byte>(((x >> 14) & MASK_7) | 0x80), \
301 static_cast<byte>(((x >> 21) & MASK_7) | 0x80), \
302 static_cast<byte>((x >> 28) & 0xF)
303
280 #endif // V8_WASM_MACRO_GEN_H_ 304 #endif // V8_WASM_MACRO_GEN_H_
OLDNEW
« 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