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

Side by Side Diff: src/wasm/wasm-macro-gen.h

Issue 1775123003: [wasm] Encode immediates to Load and Store as varint. (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/encoder.cc ('k') | src/wasm/wasm-opcodes.h » ('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 #define U32_LE(v) \ 10 #define U32_LE(v) \
11 static_cast<byte>(v), static_cast<byte>((v) >> 8), \ 11 static_cast<byte>(v), static_cast<byte>((v) >> 8), \
12 static_cast<byte>((v) >> 16), static_cast<byte>((v) >> 24) 12 static_cast<byte>((v) >> 16), static_cast<byte>((v) >> 24)
13 13
14 #define U16_LE(v) static_cast<byte>(v), static_cast<byte>((v) >> 8) 14 #define U16_LE(v) static_cast<byte>(v), static_cast<byte>((v) >> 8)
15 15
16 #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion) 16 #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion)
17 17
18 #define SIG_INDEX(v) U16_LE(v) 18 #define SIG_INDEX(v) U16_LE(v)
19 #define FUNC_INDEX(v) U32V_1(v) 19 #define FUNC_INDEX(v) U32V_1(v)
20 #define NAME_OFFSET(v) U32_LE(v) 20 #define NAME_OFFSET(v) U32_LE(v)
21 21
22 #define ZERO_ALIGNMENT 0
23 #define ZERO_OFFSET 0
24
22 #define BR_TARGET(v) U32_LE(v) 25 #define BR_TARGET(v) U32_LE(v)
23 26
24 #define MASK_7 ((1 << 7) - 1) 27 #define MASK_7 ((1 << 7) - 1)
25 #define MASK_14 ((1 << 14) - 1) 28 #define MASK_14 ((1 << 14) - 1)
26 #define MASK_21 ((1 << 21) - 1) 29 #define MASK_21 ((1 << 21) - 1)
27 #define MASK_28 ((1 << 28) - 1) 30 #define MASK_28 ((1 << 28) - 1)
28 31
29 #define U32V_1(x) static_cast<byte>((x)&MASK_7) 32 #define U32V_1(x) static_cast<byte>((x)&MASK_7)
30 #define U32V_2(x) \ 33 #define U32V_2(x) \
31 static_cast<byte>(((x)&MASK_7) | 0x80), static_cast<byte>(((x) >> 7) & MASK_7) 34 static_cast<byte>(((x)&MASK_7) | 0x80), static_cast<byte>(((x) >> 7) & MASK_7)
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 static_cast<byte>(bit_cast<uint64_t>(val) >> 48), \ 321 static_cast<byte>(bit_cast<uint64_t>(val) >> 48), \
319 static_cast<byte>(bit_cast<uint64_t>(val) >> 56) 322 static_cast<byte>(bit_cast<uint64_t>(val) >> 56)
320 #define WASM_GET_LOCAL(index) kExprGetLocal, static_cast<byte>(index) 323 #define WASM_GET_LOCAL(index) kExprGetLocal, static_cast<byte>(index)
321 #define WASM_SET_LOCAL(index, val) kExprSetLocal, static_cast<byte>(index), val 324 #define WASM_SET_LOCAL(index, val) kExprSetLocal, static_cast<byte>(index), val
322 #define WASM_LOAD_GLOBAL(index) kExprLoadGlobal, static_cast<byte>(index) 325 #define WASM_LOAD_GLOBAL(index) kExprLoadGlobal, static_cast<byte>(index)
323 #define WASM_STORE_GLOBAL(index, val) \ 326 #define WASM_STORE_GLOBAL(index, val) \
324 kExprStoreGlobal, static_cast<byte>(index), val 327 kExprStoreGlobal, static_cast<byte>(index), val
325 #define WASM_LOAD_MEM(type, index) \ 328 #define WASM_LOAD_MEM(type, index) \
326 static_cast<byte>( \ 329 static_cast<byte>( \
327 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \ 330 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \
328 v8::internal::wasm::WasmOpcodes::LoadStoreAccessOf(false), index 331 ZERO_ALIGNMENT, ZERO_OFFSET, index
329 #define WASM_STORE_MEM(type, index, val) \ 332 #define WASM_STORE_MEM(type, index, val) \
330 static_cast<byte>( \ 333 static_cast<byte>( \
331 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, true)), \ 334 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, true)), \
332 v8::internal::wasm::WasmOpcodes::LoadStoreAccessOf(false), index, val 335 ZERO_ALIGNMENT, ZERO_OFFSET, index, val
333 #define WASM_LOAD_MEM_OFFSET(type, offset, index) \ 336 #define WASM_LOAD_MEM_OFFSET(type, offset, index) \
334 static_cast<byte>( \ 337 static_cast<byte>( \
335 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \ 338 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, false)), \
336 v8::internal::wasm::WasmOpcodes::LoadStoreAccessOf(true), \ 339 ZERO_ALIGNMENT, U32V_1(offset), index
337 static_cast<byte>(offset), index
338 #define WASM_STORE_MEM_OFFSET(type, offset, index, val) \ 340 #define WASM_STORE_MEM_OFFSET(type, offset, index, val) \
339 static_cast<byte>( \ 341 static_cast<byte>( \
340 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, true)), \ 342 v8::internal::wasm::WasmOpcodes::LoadStoreOpcodeOf(type, true)), \
341 v8::internal::wasm::WasmOpcodes::LoadStoreAccessOf(true), \ 343 ZERO_ALIGNMENT, U32V_1(offset), index, val
342 static_cast<byte>(offset), index, val
343 #define WASM_CALL_FUNCTION(index, ...) \ 344 #define WASM_CALL_FUNCTION(index, ...) \
344 kExprCallFunction, static_cast<byte>(index), __VA_ARGS__ 345 kExprCallFunction, static_cast<byte>(index), __VA_ARGS__
345 #define WASM_CALL_IMPORT(index, ...) \ 346 #define WASM_CALL_IMPORT(index, ...) \
346 kExprCallImport, static_cast<byte>(index), __VA_ARGS__ 347 kExprCallImport, static_cast<byte>(index), __VA_ARGS__
347 #define WASM_CALL_INDIRECT(index, func, ...) \ 348 #define WASM_CALL_INDIRECT(index, func, ...) \
348 kExprCallIndirect, static_cast<byte>(index), func, __VA_ARGS__ 349 kExprCallIndirect, static_cast<byte>(index), func, __VA_ARGS__
349 #define WASM_CALL_FUNCTION0(index) kExprCallFunction, static_cast<byte>(index) 350 #define WASM_CALL_FUNCTION0(index) kExprCallFunction, static_cast<byte>(index)
350 #define WASM_CALL_IMPORT0(index) kExprCallImport, static_cast<byte>(index) 351 #define WASM_CALL_IMPORT0(index) kExprCallImport, static_cast<byte>(index)
351 #define WASM_CALL_INDIRECT0(index, func) \ 352 #define WASM_CALL_INDIRECT0(index, func) \
352 kExprCallIndirect, static_cast<byte>(index), func 353 kExprCallIndirect, static_cast<byte>(index), func
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 #define WASM_F64_SCONVERT_I32(x) kExprF64SConvertI32, x 502 #define WASM_F64_SCONVERT_I32(x) kExprF64SConvertI32, x
502 #define WASM_F64_UCONVERT_I32(x) kExprF64UConvertI32, x 503 #define WASM_F64_UCONVERT_I32(x) kExprF64UConvertI32, x
503 #define WASM_F64_SCONVERT_I64(x) kExprF64SConvertI64, x 504 #define WASM_F64_SCONVERT_I64(x) kExprF64SConvertI64, x
504 #define WASM_F64_UCONVERT_I64(x) kExprF64UConvertI64, x 505 #define WASM_F64_UCONVERT_I64(x) kExprF64UConvertI64, x
505 #define WASM_F64_CONVERT_F32(x) kExprF64ConvertF32, x 506 #define WASM_F64_CONVERT_F32(x) kExprF64ConvertF32, x
506 #define WASM_F64_REINTERPRET_I64(x) kExprF64ReinterpretI64, x 507 #define WASM_F64_REINTERPRET_I64(x) kExprF64ReinterpretI64, x
507 #define WASM_I32_REINTERPRET_F32(x) kExprI32ReinterpretF32, x 508 #define WASM_I32_REINTERPRET_F32(x) kExprI32ReinterpretF32, x
508 #define WASM_I64_REINTERPRET_F64(x) kExprI64ReinterpretF64, x 509 #define WASM_I64_REINTERPRET_F64(x) kExprI64ReinterpretF64, x
509 510
510 #endif // V8_WASM_MACRO_GEN_H_ 511 #endif // V8_WASM_MACRO_GEN_H_
OLDNEW
« no previous file with comments | « src/wasm/encoder.cc ('k') | src/wasm/wasm-opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698