LCOV - code coverage report
Current view: top level - test/common/wasm - wasm-macro-gen.h (source / functions) Hit Total Coverage
Test: app.info Lines: 8 10 80.0 %
Date: 2019-04-17 Functions: 1 1 100.0 %

          Line data    Source code
       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
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_WASM_MACRO_GEN_H_
       6             : #define V8_WASM_MACRO_GEN_H_
       7             : 
       8             : #include "src/wasm/wasm-opcodes.h"
       9             : 
      10             : #include "src/zone/zone-containers.h"
      11             : 
      12             : #define U32_LE(v)                                    \
      13             :   static_cast<byte>(v), static_cast<byte>((v) >> 8), \
      14             :       static_cast<byte>((v) >> 16), static_cast<byte>((v) >> 24)
      15             : 
      16             : #define U16_LE(v) static_cast<byte>(v), static_cast<byte>((v) >> 8)
      17             : 
      18             : #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion)
      19             : 
      20             : #define SIG_INDEX(v) U32V_1(v)
      21             : #define FUNC_INDEX(v) U32V_1(v)
      22             : #define EXCEPTION_INDEX(v) U32V_1(v)
      23             : #define NO_NAME U32V_1(0)
      24             : #define ENTRY_COUNT(v) U32V_1(v)
      25             : 
      26             : // Segment flags
      27             : #define ACTIVE_NO_INDEX 0
      28             : #define PASSIVE 1
      29             : #define ACTIVE_WITH_INDEX 2
      30             : 
      31             : // The table index field in an element segment was repurposed as a flags field.
      32             : // To specify a table index, we have to set the flag value to 2, followed by
      33             : // the table index.
      34             : #define TABLE_INDEX0 U32V_1(ACTIVE_NO_INDEX)
      35             : #define TABLE_INDEX(v) U32V_1(ACTIVE_WITH_INDEX), U32V_1(v)
      36             : 
      37             : #define ZERO_ALIGNMENT 0
      38             : #define ZERO_OFFSET 0
      39             : 
      40             : #define BR_TARGET(v) U32V_1(v)
      41             : 
      42             : #define MASK_7 ((1 << 7) - 1)
      43             : #define MASK_14 ((1 << 14) - 1)
      44             : #define MASK_21 ((1 << 21) - 1)
      45             : #define MASK_28 ((1 << 28) - 1)
      46             : 
      47             : #define U32V_1(x) static_cast<byte>((x)&MASK_7)
      48             : #define U32V_2(x) \
      49             :   static_cast<byte>(((x)&MASK_7) | 0x80), static_cast<byte>(((x) >> 7) & MASK_7)
      50             : #define U32V_3(x)                                      \
      51             :   static_cast<byte>((((x)) & MASK_7) | 0x80),          \
      52             :       static_cast<byte>((((x) >> 7) & MASK_7) | 0x80), \
      53             :       static_cast<byte>(((x) >> 14) & MASK_7)
      54             : #define U32V_4(x)                                       \
      55             :   static_cast<byte>(((x)&MASK_7) | 0x80),               \
      56             :       static_cast<byte>((((x) >> 7) & MASK_7) | 0x80),  \
      57             :       static_cast<byte>((((x) >> 14) & MASK_7) | 0x80), \
      58             :       static_cast<byte>(((x) >> 21) & MASK_7)
      59             : #define U32V_5(x)                                       \
      60             :   static_cast<byte>(((x)&MASK_7) | 0x80),               \
      61             :       static_cast<byte>((((x) >> 7) & MASK_7) | 0x80),  \
      62             :       static_cast<byte>((((x) >> 14) & MASK_7) | 0x80), \
      63             :       static_cast<byte>((((x) >> 21) & MASK_7) | 0x80), \
      64             :       static_cast<byte>((((x) >> 28) & MASK_7))
      65             : 
      66             : // Convenience macros for building Wasm bytecode directly into a byte array.
      67             : 
      68             : //------------------------------------------------------------------------------
      69             : // Control.
      70             : //------------------------------------------------------------------------------
      71             : #define WASM_NOP kExprNop
      72             : #define WASM_END kExprEnd
      73             : 
      74             : #define ARITY_0 0
      75             : #define ARITY_1 1
      76             : #define ARITY_2 2
      77             : #define DEPTH_0 0
      78             : #define DEPTH_1 1
      79             : #define DEPTH_2 2
      80             : #define ARITY_2 2
      81             : 
      82             : #define WASM_BLOCK(...) kExprBlock, kLocalVoid, __VA_ARGS__, kExprEnd
      83             : #define WASM_BLOCK_I(...) kExprBlock, kLocalI32, __VA_ARGS__, kExprEnd
      84             : #define WASM_BLOCK_L(...) kExprBlock, kLocalI64, __VA_ARGS__, kExprEnd
      85             : #define WASM_BLOCK_F(...) kExprBlock, kLocalF32, __VA_ARGS__, kExprEnd
      86             : #define WASM_BLOCK_D(...) kExprBlock, kLocalF64, __VA_ARGS__, kExprEnd
      87             : 
      88             : #define WASM_BLOCK_T(t, ...)                                                   \
      89             :   kExprBlock, static_cast<byte>(ValueTypes::ValueTypeCodeFor(t)), __VA_ARGS__, \
      90             :       kExprEnd
      91             : 
      92             : #define WASM_BLOCK_X(index, ...)                                  \
      93             :   kExprBlock, static_cast<byte>(index), __VA_ARGS__, kExprEnd
      94             : 
      95             : #define WASM_INFINITE_LOOP kExprLoop, kLocalVoid, kExprBr, DEPTH_0, kExprEnd
      96             : 
      97             : #define WASM_LOOP(...) kExprLoop, kLocalVoid, __VA_ARGS__, kExprEnd
      98             : #define WASM_LOOP_I(...) kExprLoop, kLocalI32, __VA_ARGS__, kExprEnd
      99             : #define WASM_LOOP_L(...) kExprLoop, kLocalI64, __VA_ARGS__, kExprEnd
     100             : #define WASM_LOOP_F(...) kExprLoop, kLocalF32, __VA_ARGS__, kExprEnd
     101             : #define WASM_LOOP_D(...) kExprLoop, kLocalF64, __VA_ARGS__, kExprEnd
     102             : 
     103             : #define WASM_LOOP_T(t, ...)                                                   \
     104             :   kExprLoop, static_cast<byte>(ValueTypes::ValueTypeCodeFor(t)), __VA_ARGS__, \
     105             :       kExprEnd
     106             : 
     107             : #define WASM_LOOP_X(index, ...)                                   \
     108             :   kExprLoop, static_cast<byte>(index), __VA_ARGS__, kExprEnd
     109             : 
     110             : #define WASM_IF(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd
     111             : 
     112             : #define WASM_IF_T(t, cond, ...)                                      \
     113             :   cond, kExprIf, static_cast<byte>(ValueTypes::ValueTypeCodeFor(t)), \
     114             :       __VA_ARGS__, kExprEnd
     115             : 
     116             : #define WASM_IF_X(index, cond, ...)                                   \
     117             :   cond, kExprIf, static_cast<byte>(index), __VA_ARGS__, kExprEnd
     118             : 
     119             : #define WASM_IF_ELSE(cond, tstmt, fstmt) \
     120             :   cond, kExprIf, kLocalVoid, tstmt, kExprElse, fstmt, kExprEnd
     121             : 
     122             : #define WASM_IF_ELSE_I(cond, tstmt, fstmt) \
     123             :   cond, kExprIf, kLocalI32, tstmt, kExprElse, fstmt, kExprEnd
     124             : #define WASM_IF_ELSE_L(cond, tstmt, fstmt) \
     125             :   cond, kExprIf, kLocalI64, tstmt, kExprElse, fstmt, kExprEnd
     126             : #define WASM_IF_ELSE_F(cond, tstmt, fstmt) \
     127             :   cond, kExprIf, kLocalF32, tstmt, kExprElse, fstmt, kExprEnd
     128             : #define WASM_IF_ELSE_D(cond, tstmt, fstmt) \
     129             :   cond, kExprIf, kLocalF64, tstmt, kExprElse, fstmt, kExprEnd
     130             : 
     131             : #define WASM_IF_ELSE_T(t, cond, tstmt, fstmt)                               \
     132             :   cond, kExprIf, static_cast<byte>(ValueTypes::ValueTypeCodeFor(t)), tstmt, \
     133             :       kExprElse, fstmt, kExprEnd
     134             : 
     135             : #define WASM_IF_ELSE_X(index, cond, tstmt, fstmt)                            \
     136             :   cond, kExprIf, static_cast<byte>(index), tstmt, kExprElse, fstmt, kExprEnd
     137             : 
     138             : #define WASM_TRY_CATCH_T(t, trystmt, catchstmt)                          \
     139             :   kExprTry, static_cast<byte>(ValueTypes::ValueTypeCodeFor(t)), trystmt, \
     140             :       kExprCatch, catchstmt, kExprEnd
     141             : 
     142             : #define WASM_SELECT(tval, fval, cond) tval, fval, cond, kExprSelect
     143             : 
     144             : #define WASM_RETURN0 kExprReturn
     145             : #define WASM_RETURN1(val) val, kExprReturn
     146             : #define WASM_RETURNN(count, ...) __VA_ARGS__, kExprReturn
     147             : 
     148             : #define WASM_BR(depth) kExprBr, static_cast<byte>(depth)
     149             : #define WASM_BR_IF(depth, cond) cond, kExprBrIf, static_cast<byte>(depth)
     150             : #define WASM_BR_IFD(depth, val, cond) \
     151             :   val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop
     152             : #define WASM_CONTINUE(depth) kExprBr, static_cast<byte>(depth)
     153             : #define WASM_UNREACHABLE kExprUnreachable
     154             : 
     155             : #define WASM_BR_TABLE(key, count, ...) \
     156             :   key, kExprBrTable, U32V_1(count), __VA_ARGS__
     157             : 
     158             : #define WASM_CASE(x) static_cast<byte>(x), static_cast<byte>(x >> 8)
     159             : #define WASM_CASE_BR(x) static_cast<byte>(x), static_cast<byte>(0x80 | (x) >> 8)
     160             : 
     161             : #define WASM_THROW(index) kExprThrow, static_cast<byte>(index)
     162             : 
     163             : //------------------------------------------------------------------------------
     164             : // Misc expressions.
     165             : //------------------------------------------------------------------------------
     166             : #define WASM_STMTS(...) __VA_ARGS__
     167             : #define WASM_ZERO kExprI32Const, 0
     168             : #define WASM_ONE kExprI32Const, 1
     169             : 
     170             : #define I32V_MIN(length) -(1 << (6 + (7 * ((length)-1))))
     171             : #define I32V_MAX(length) ((1 << (6 + (7 * ((length)-1)))) - 1)
     172             : #define I64V_MIN(length) -(1LL << (6 + (7 * ((length)-1))))
     173             : #define I64V_MAX(length) ((1LL << (6 + 7 * ((length)-1))) - 1)
     174             : 
     175             : #define I32V_IN_RANGE(value, length) \
     176             :   ((value) >= I32V_MIN(length) && (value) <= I32V_MAX(length))
     177             : #define I64V_IN_RANGE(value, length) \
     178             :   ((value) >= I64V_MIN(length) && (value) <= I64V_MAX(length))
     179             : 
     180             : #define WASM_NO_LOCALS 0
     181             : 
     182             : namespace v8 {
     183             : namespace internal {
     184             : namespace wasm {
     185             : 
     186             : inline void CheckI32v(int32_t value, int length) {
     187             :   DCHECK(length >= 1 && length <= 5);
     188             :   DCHECK(length == 5 || I32V_IN_RANGE(value, length));
     189             : }
     190             : 
     191             : inline void CheckI64v(int64_t value, int length) {
     192             :   DCHECK(length >= 1 && length <= 10);
     193             :   DCHECK(length == 10 || I64V_IN_RANGE(value, length));
     194             : }
     195             : 
     196       65811 : inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
     197       65811 :   switch (type.representation()) {
     198             :     case MachineRepresentation::kWord8:
     199             :       return store ? kExprI32StoreMem8
     200         330 :                    : type.IsSigned() ? kExprI32LoadMem8S : kExprI32LoadMem8U;
     201             :     case MachineRepresentation::kWord16:
     202             :       return store ? kExprI32StoreMem16
     203         282 :                    : type.IsSigned() ? kExprI32LoadMem16S : kExprI32LoadMem16U;
     204             :     case MachineRepresentation::kWord32:
     205       33215 :       return store ? kExprI32StoreMem : kExprI32LoadMem;
     206             :     case MachineRepresentation::kWord64:
     207       25564 :       return store ? kExprI64StoreMem : kExprI64LoadMem;
     208             :     case MachineRepresentation::kFloat32:
     209        3093 :       return store ? kExprF32StoreMem : kExprF32LoadMem;
     210             :     case MachineRepresentation::kFloat64:
     211        3559 :       return store ? kExprF64StoreMem : kExprF64LoadMem;
     212             :     case MachineRepresentation::kSimd128:
     213           0 :       return store ? kExprS128StoreMem : kExprS128LoadMem;
     214             :     default:
     215           0 :       UNREACHABLE();
     216             :   }
     217             : }
     218             : 
     219             : }  // namespace wasm
     220             : }  // namespace internal
     221             : }  // namespace v8
     222             : 
     223             : //------------------------------------------------------------------------------
     224             : // Int32 Const operations
     225             : //------------------------------------------------------------------------------
     226             : #define WASM_I32V(val) kExprI32Const, U32V_5(val)
     227             : 
     228             : #define WASM_I32V_1(val) \
     229             :   static_cast<byte>(CheckI32v((val), 1), kExprI32Const), U32V_1(val)
     230             : #define WASM_I32V_2(val) \
     231             :   static_cast<byte>(CheckI32v((val), 2), kExprI32Const), U32V_2(val)
     232             : #define WASM_I32V_3(val) \
     233             :   static_cast<byte>(CheckI32v((val), 3), kExprI32Const), U32V_3(val)
     234             : #define WASM_I32V_4(val) \
     235             :   static_cast<byte>(CheckI32v((val), 4), kExprI32Const), U32V_4(val)
     236             : #define WASM_I32V_5(val) \
     237             :   static_cast<byte>(CheckI32v((val), 5), kExprI32Const), U32V_5(val)
     238             : 
     239             : //------------------------------------------------------------------------------
     240             : // Int64 Const operations
     241             : //------------------------------------------------------------------------------
     242             : #define WASM_I64V(val)                                                        \
     243             :   kExprI64Const,                                                              \
     244             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     245             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     246             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     247             :       static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
     248             :       static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
     249             :       static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
     250             :       static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
     251             :       static_cast<byte>(((static_cast<int64_t>(val) >> 49) & MASK_7) | 0x80), \
     252             :       static_cast<byte>(((static_cast<int64_t>(val) >> 56) & MASK_7) | 0x80), \
     253             :       static_cast<byte>((static_cast<int64_t>(val) >> 63) & MASK_7)
     254             : 
     255             : #define WASM_I64V_1(val)                                                     \
     256             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 1), kExprI64Const), \
     257             :       static_cast<byte>(static_cast<int64_t>(val) & MASK_7)
     258             : #define WASM_I64V_2(val)                                                     \
     259             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 2), kExprI64Const), \
     260             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),        \
     261             :       static_cast<byte>((static_cast<int64_t>(val) >> 7) & MASK_7)
     262             : #define WASM_I64V_3(val)                                                     \
     263             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 3), kExprI64Const), \
     264             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),        \
     265             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80), \
     266             :       static_cast<byte>((static_cast<int64_t>(val) >> 14) & MASK_7)
     267             : #define WASM_I64V_4(val)                                                      \
     268             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 4), kExprI64Const),  \
     269             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     270             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     271             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     272             :       static_cast<byte>((static_cast<int64_t>(val) >> 21) & MASK_7)
     273             : #define WASM_I64V_5(val)                                                      \
     274             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 5), kExprI64Const),  \
     275             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     276             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     277             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     278             :       static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
     279             :       static_cast<byte>((static_cast<int64_t>(val) >> 28) & MASK_7)
     280             : #define WASM_I64V_6(val)                                                      \
     281             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 6), kExprI64Const),  \
     282             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     283             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     284             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     285             :       static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
     286             :       static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
     287             :       static_cast<byte>((static_cast<int64_t>(val) >> 35) & MASK_7)
     288             : #define WASM_I64V_7(val)                                                      \
     289             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 7), kExprI64Const),  \
     290             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     291             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     292             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     293             :       static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
     294             :       static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
     295             :       static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
     296             :       static_cast<byte>((static_cast<int64_t>(val) >> 42) & MASK_7)
     297             : #define WASM_I64V_8(val)                                                      \
     298             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 8), kExprI64Const),  \
     299             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     300             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     301             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     302             :       static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
     303             :       static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
     304             :       static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
     305             :       static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
     306             :       static_cast<byte>((static_cast<int64_t>(val) >> 49) & MASK_7)
     307             : #define WASM_I64V_9(val)                                                      \
     308             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 9), kExprI64Const),  \
     309             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     310             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     311             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     312             :       static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
     313             :       static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
     314             :       static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
     315             :       static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
     316             :       static_cast<byte>(((static_cast<int64_t>(val) >> 49) & MASK_7) | 0x80), \
     317             :       static_cast<byte>((static_cast<int64_t>(val) >> 56) & MASK_7)
     318             : #define WASM_I64V_10(val)                                                     \
     319             :   static_cast<byte>(CheckI64v(static_cast<int64_t>(val), 10), kExprI64Const), \
     320             :       static_cast<byte>((static_cast<int64_t>(val) & MASK_7) | 0x80),         \
     321             :       static_cast<byte>(((static_cast<int64_t>(val) >> 7) & MASK_7) | 0x80),  \
     322             :       static_cast<byte>(((static_cast<int64_t>(val) >> 14) & MASK_7) | 0x80), \
     323             :       static_cast<byte>(((static_cast<int64_t>(val) >> 21) & MASK_7) | 0x80), \
     324             :       static_cast<byte>(((static_cast<int64_t>(val) >> 28) & MASK_7) | 0x80), \
     325             :       static_cast<byte>(((static_cast<int64_t>(val) >> 35) & MASK_7) | 0x80), \
     326             :       static_cast<byte>(((static_cast<int64_t>(val) >> 42) & MASK_7) | 0x80), \
     327             :       static_cast<byte>(((static_cast<int64_t>(val) >> 49) & MASK_7) | 0x80), \
     328             :       static_cast<byte>(((static_cast<int64_t>(val) >> 56) & MASK_7) | 0x80), \
     329             :       static_cast<byte>((static_cast<int64_t>(val) >> 63) & MASK_7)
     330             : 
     331             : #define WASM_F32(val)                                                       \
     332             :   kExprF32Const,                                                            \
     333             :       static_cast<byte>(bit_cast<int32_t>(static_cast<float>(val))),        \
     334             :       static_cast<byte>(bit_cast<uint32_t>(static_cast<float>(val)) >> 8),  \
     335             :       static_cast<byte>(bit_cast<uint32_t>(static_cast<float>(val)) >> 16), \
     336             :       static_cast<byte>(bit_cast<uint32_t>(static_cast<float>(val)) >> 24)
     337             : #define WASM_F64(val)                                                        \
     338             :   kExprF64Const,                                                             \
     339             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val))),       \
     340             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val)) >> 8),  \
     341             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val)) >> 16), \
     342             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val)) >> 24), \
     343             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val)) >> 32), \
     344             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val)) >> 40), \
     345             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val)) >> 48), \
     346             :       static_cast<byte>(bit_cast<uint64_t>(static_cast<double>(val)) >> 56)
     347             : 
     348             : #define WASM_REF_NULL kExprRefNull
     349             : #define WASM_REF_IS_NULL(val) val, kExprRefIsNull
     350             : 
     351             : #define WASM_GET_LOCAL(index) kExprGetLocal, static_cast<byte>(index)
     352             : #define WASM_SET_LOCAL(index, val) val, kExprSetLocal, static_cast<byte>(index)
     353             : #define WASM_TEE_LOCAL(index, val) val, kExprTeeLocal, static_cast<byte>(index)
     354             : #define WASM_DROP kExprDrop
     355             : #define WASM_GET_GLOBAL(index) kExprGetGlobal, static_cast<byte>(index)
     356             : #define WASM_SET_GLOBAL(index, val) \
     357             :   val, kExprSetGlobal, static_cast<byte>(index)
     358             : #define WASM_GET_TABLE(table_index, index) \
     359             :   index, kExprGetTable, static_cast<byte>(table_index)
     360             : #define WASM_SET_TABLE(table_index, index, val) \
     361             :   index, val, kExprSetTable, static_cast<byte>(table_index)
     362             : #define WASM_LOAD_MEM(type, index)                                           \
     363             :   index,                                                                     \
     364             :       static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, false)), \
     365             :       ZERO_ALIGNMENT, ZERO_OFFSET
     366             : #define WASM_STORE_MEM(type, index, val)                                    \
     367             :   index, val,                                                               \
     368             :       static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, true)), \
     369             :       ZERO_ALIGNMENT, ZERO_OFFSET
     370             : #define WASM_LOAD_MEM_OFFSET(type, offset, index)                            \
     371             :   index,                                                                     \
     372             :       static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, false)), \
     373             :       ZERO_ALIGNMENT, offset
     374             : #define WASM_STORE_MEM_OFFSET(type, offset, index, val)                     \
     375             :   index, val,                                                               \
     376             :       static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, true)), \
     377             :       ZERO_ALIGNMENT, offset
     378             : #define WASM_LOAD_MEM_ALIGNMENT(type, index, alignment)                      \
     379             :   index,                                                                     \
     380             :       static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, false)), \
     381             :       alignment, ZERO_OFFSET
     382             : #define WASM_STORE_MEM_ALIGNMENT(type, index, alignment, val)               \
     383             :   index, val,                                                               \
     384             :       static_cast<byte>(v8::internal::wasm::LoadStoreOpcodeOf(type, true)), \
     385             :       alignment, ZERO_OFFSET
     386             : 
     387             : #define WASM_CALL_FUNCTION0(index) kExprCallFunction, static_cast<byte>(index)
     388             : #define WASM_CALL_FUNCTION(index, ...) \
     389             :   __VA_ARGS__, kExprCallFunction, static_cast<byte>(index)
     390             : 
     391             : #define WASM_RETURN_CALL_FUNCTION0(index) \
     392             :   kExprReturnCall, static_cast<byte>(index)
     393             : #define WASM_RETURN_CALL_FUNCTION(index, ...) \
     394             :   __VA_ARGS__, kExprReturnCall, static_cast<byte>(index)
     395             : 
     396             : #define TABLE_ZERO 0
     397             : 
     398             : // TODO(titzer): change usages of these macros to put func last.
     399             : #define WASM_CALL_INDIRECT0(index, func) \
     400             :   func, kExprCallIndirect, static_cast<byte>(index), TABLE_ZERO
     401             : #define WASM_CALL_INDIRECT1(index, func, a) \
     402             :   a, func, kExprCallIndirect, static_cast<byte>(index), TABLE_ZERO
     403             : #define WASM_CALL_INDIRECT2(index, func, a, b) \
     404             :   a, b, func, kExprCallIndirect, static_cast<byte>(index), TABLE_ZERO
     405             : #define WASM_CALL_INDIRECT3(index, func, a, b, c) \
     406             :   a, b, c, func, kExprCallIndirect, static_cast<byte>(index), TABLE_ZERO
     407             : #define WASM_CALL_INDIRECT4(index, func, a, b, c, d) \
     408             :   a, b, c, d, func, kExprCallIndirect, static_cast<byte>(index), TABLE_ZERO
     409             : #define WASM_CALL_INDIRECT5(index, func, a, b, c, d, e) \
     410             :   a, b, c, d, e, func, kExprCallIndirect, static_cast<byte>(index), TABLE_ZERO
     411             : #define WASM_CALL_INDIRECTN(arity, index, func, ...) \
     412             :   __VA_ARGS__, func, kExprCallIndirect, static_cast<byte>(index), TABLE_ZERO
     413             : 
     414             : #define WASM_RETURN_CALL_INDIRECT0(index, func) \
     415             :   func, kExprReturnCallIndirect, static_cast<byte>(index), TABLE_ZERO
     416             : #define WASM_RETURN_CALL_INDIRECT(index, func, ...)                     \
     417             :   __VA_ARGS__, func, kExprReturnCallIndirect, static_cast<byte>(index), \
     418             :       TABLE_ZERO
     419             : 
     420             : #define WASM_NOT(x) x, kExprI32Eqz
     421             : #define WASM_SEQ(...) __VA_ARGS__
     422             : 
     423             : //------------------------------------------------------------------------------
     424             : // Constructs that are composed of multiple bytecodes.
     425             : //------------------------------------------------------------------------------
     426             : #define WASM_WHILE(x, y)                                              \
     427             :   kExprLoop, kLocalVoid, x, kExprIf, kLocalVoid, y, kExprBr, DEPTH_1, \
     428             :       kExprEnd, kExprEnd
     429             : #define WASM_INC_LOCAL(index)                                             \
     430             :   kExprGetLocal, static_cast<byte>(index), kExprI32Const, 1, kExprI32Add, \
     431             :       kExprTeeLocal, static_cast<byte>(index)
     432             : #define WASM_INC_LOCAL_BYV(index, count)                    \
     433             :   kExprGetLocal, static_cast<byte>(index), kExprI32Const,   \
     434             :       static_cast<byte>(count), kExprI32Add, kExprTeeLocal, \
     435             :       static_cast<byte>(index)
     436             : #define WASM_INC_LOCAL_BY(index, count)                     \
     437             :   kExprGetLocal, static_cast<byte>(index), kExprI32Const,   \
     438             :       static_cast<byte>(count), kExprI32Add, kExprSetLocal, \
     439             :       static_cast<byte>(index)
     440             : #define WASM_UNOP(opcode, x) x, static_cast<byte>(opcode)
     441             : #define WASM_BINOP(opcode, x, y) x, y, static_cast<byte>(opcode)
     442             : 
     443             : //------------------------------------------------------------------------------
     444             : // Int32 operations
     445             : //------------------------------------------------------------------------------
     446             : #define WASM_I32_ADD(x, y) x, y, kExprI32Add
     447             : #define WASM_I32_SUB(x, y) x, y, kExprI32Sub
     448             : #define WASM_I32_MUL(x, y) x, y, kExprI32Mul
     449             : #define WASM_I32_DIVS(x, y) x, y, kExprI32DivS
     450             : #define WASM_I32_DIVU(x, y) x, y, kExprI32DivU
     451             : #define WASM_I32_REMS(x, y) x, y, kExprI32RemS
     452             : #define WASM_I32_REMU(x, y) x, y, kExprI32RemU
     453             : #define WASM_I32_AND(x, y) x, y, kExprI32And
     454             : #define WASM_I32_IOR(x, y) x, y, kExprI32Ior
     455             : #define WASM_I32_XOR(x, y) x, y, kExprI32Xor
     456             : #define WASM_I32_SHL(x, y) x, y, kExprI32Shl
     457             : #define WASM_I32_SHR(x, y) x, y, kExprI32ShrU
     458             : #define WASM_I32_SAR(x, y) x, y, kExprI32ShrS
     459             : #define WASM_I32_ROR(x, y) x, y, kExprI32Ror
     460             : #define WASM_I32_ROL(x, y) x, y, kExprI32Rol
     461             : #define WASM_I32_EQ(x, y) x, y, kExprI32Eq
     462             : #define WASM_I32_NE(x, y) x, y, kExprI32Ne
     463             : #define WASM_I32_LTS(x, y) x, y, kExprI32LtS
     464             : #define WASM_I32_LES(x, y) x, y, kExprI32LeS
     465             : #define WASM_I32_LTU(x, y) x, y, kExprI32LtU
     466             : #define WASM_I32_LEU(x, y) x, y, kExprI32LeU
     467             : #define WASM_I32_GTS(x, y) x, y, kExprI32GtS
     468             : #define WASM_I32_GES(x, y) x, y, kExprI32GeS
     469             : #define WASM_I32_GTU(x, y) x, y, kExprI32GtU
     470             : #define WASM_I32_GEU(x, y) x, y, kExprI32GeU
     471             : #define WASM_I32_CLZ(x) x, kExprI32Clz
     472             : #define WASM_I32_CTZ(x) x, kExprI32Ctz
     473             : #define WASM_I32_POPCNT(x) x, kExprI32Popcnt
     474             : #define WASM_I32_EQZ(x) x, kExprI32Eqz
     475             : 
     476             : //------------------------------------------------------------------------------
     477             : // Asmjs Int32 operations
     478             : //------------------------------------------------------------------------------
     479             : #define WASM_I32_ASMJS_DIVS(x, y) x, y, kExprI32AsmjsDivS
     480             : #define WASM_I32_ASMJS_REMS(x, y) x, y, kExprI32AsmjsRemS
     481             : #define WASM_I32_ASMJS_DIVU(x, y) x, y, kExprI32AsmjsDivU
     482             : #define WASM_I32_ASMJS_REMU(x, y) x, y, kExprI32AsmjsRemU
     483             : 
     484             : //------------------------------------------------------------------------------
     485             : // Int64 operations
     486             : //------------------------------------------------------------------------------
     487             : #define WASM_I64_ADD(x, y) x, y, kExprI64Add
     488             : #define WASM_I64_SUB(x, y) x, y, kExprI64Sub
     489             : #define WASM_I64_MUL(x, y) x, y, kExprI64Mul
     490             : #define WASM_I64_DIVS(x, y) x, y, kExprI64DivS
     491             : #define WASM_I64_DIVU(x, y) x, y, kExprI64DivU
     492             : #define WASM_I64_REMS(x, y) x, y, kExprI64RemS
     493             : #define WASM_I64_REMU(x, y) x, y, kExprI64RemU
     494             : #define WASM_I64_AND(x, y) x, y, kExprI64And
     495             : #define WASM_I64_IOR(x, y) x, y, kExprI64Ior
     496             : #define WASM_I64_XOR(x, y) x, y, kExprI64Xor
     497             : #define WASM_I64_SHL(x, y) x, y, kExprI64Shl
     498             : #define WASM_I64_SHR(x, y) x, y, kExprI64ShrU
     499             : #define WASM_I64_SAR(x, y) x, y, kExprI64ShrS
     500             : #define WASM_I64_ROR(x, y) x, y, kExprI64Ror
     501             : #define WASM_I64_ROL(x, y) x, y, kExprI64Rol
     502             : #define WASM_I64_EQ(x, y) x, y, kExprI64Eq
     503             : #define WASM_I64_NE(x, y) x, y, kExprI64Ne
     504             : #define WASM_I64_LTS(x, y) x, y, kExprI64LtS
     505             : #define WASM_I64_LES(x, y) x, y, kExprI64LeS
     506             : #define WASM_I64_LTU(x, y) x, y, kExprI64LtU
     507             : #define WASM_I64_LEU(x, y) x, y, kExprI64LeU
     508             : #define WASM_I64_GTS(x, y) x, y, kExprI64GtS
     509             : #define WASM_I64_GES(x, y) x, y, kExprI64GeS
     510             : #define WASM_I64_GTU(x, y) x, y, kExprI64GtU
     511             : #define WASM_I64_GEU(x, y) x, y, kExprI64GeU
     512             : #define WASM_I64_CLZ(x) x, kExprI64Clz
     513             : #define WASM_I64_CTZ(x) x, kExprI64Ctz
     514             : #define WASM_I64_POPCNT(x) x, kExprI64Popcnt
     515             : #define WASM_I64_EQZ(x) x, kExprI64Eqz
     516             : 
     517             : //------------------------------------------------------------------------------
     518             : // Float32 operations
     519             : //------------------------------------------------------------------------------
     520             : #define WASM_F32_ADD(x, y) x, y, kExprF32Add
     521             : #define WASM_F32_SUB(x, y) x, y, kExprF32Sub
     522             : #define WASM_F32_MUL(x, y) x, y, kExprF32Mul
     523             : #define WASM_F32_DIV(x, y) x, y, kExprF32Div
     524             : #define WASM_F32_MIN(x, y) x, y, kExprF32Min
     525             : #define WASM_F32_MAX(x, y) x, y, kExprF32Max
     526             : #define WASM_F32_ABS(x) x, kExprF32Abs
     527             : #define WASM_F32_NEG(x) x, kExprF32Neg
     528             : #define WASM_F32_COPYSIGN(x, y) x, y, kExprF32CopySign
     529             : #define WASM_F32_CEIL(x) x, kExprF32Ceil
     530             : #define WASM_F32_FLOOR(x) x, kExprF32Floor
     531             : #define WASM_F32_TRUNC(x) x, kExprF32Trunc
     532             : #define WASM_F32_NEARESTINT(x) x, kExprF32NearestInt
     533             : #define WASM_F32_SQRT(x) x, kExprF32Sqrt
     534             : #define WASM_F32_EQ(x, y) x, y, kExprF32Eq
     535             : #define WASM_F32_NE(x, y) x, y, kExprF32Ne
     536             : #define WASM_F32_LT(x, y) x, y, kExprF32Lt
     537             : #define WASM_F32_LE(x, y) x, y, kExprF32Le
     538             : #define WASM_F32_GT(x, y) x, y, kExprF32Gt
     539             : #define WASM_F32_GE(x, y) x, y, kExprF32Ge
     540             : 
     541             : //------------------------------------------------------------------------------
     542             : // Float64 operations
     543             : //------------------------------------------------------------------------------
     544             : #define WASM_F64_ADD(x, y) x, y, kExprF64Add
     545             : #define WASM_F64_SUB(x, y) x, y, kExprF64Sub
     546             : #define WASM_F64_MUL(x, y) x, y, kExprF64Mul
     547             : #define WASM_F64_DIV(x, y) x, y, kExprF64Div
     548             : #define WASM_F64_MIN(x, y) x, y, kExprF64Min
     549             : #define WASM_F64_MAX(x, y) x, y, kExprF64Max
     550             : #define WASM_F64_ABS(x) x, kExprF64Abs
     551             : #define WASM_F64_NEG(x) x, kExprF64Neg
     552             : #define WASM_F64_COPYSIGN(x, y) x, y, kExprF64CopySign
     553             : #define WASM_F64_CEIL(x) x, kExprF64Ceil
     554             : #define WASM_F64_FLOOR(x) x, kExprF64Floor
     555             : #define WASM_F64_TRUNC(x) x, kExprF64Trunc
     556             : #define WASM_F64_NEARESTINT(x) x, kExprF64NearestInt
     557             : #define WASM_F64_SQRT(x) x, kExprF64Sqrt
     558             : #define WASM_F64_EQ(x, y) x, y, kExprF64Eq
     559             : #define WASM_F64_NE(x, y) x, y, kExprF64Ne
     560             : #define WASM_F64_LT(x, y) x, y, kExprF64Lt
     561             : #define WASM_F64_LE(x, y) x, y, kExprF64Le
     562             : #define WASM_F64_GT(x, y) x, y, kExprF64Gt
     563             : #define WASM_F64_GE(x, y) x, y, kExprF64Ge
     564             : 
     565             : //------------------------------------------------------------------------------
     566             : // Type conversions.
     567             : //------------------------------------------------------------------------------
     568             : #define WASM_I32_SCONVERT_F32(x) x, kExprI32SConvertF32
     569             : #define WASM_I32_SCONVERT_F64(x) x, kExprI32SConvertF64
     570             : #define WASM_I32_UCONVERT_F32(x) x, kExprI32UConvertF32
     571             : #define WASM_I32_UCONVERT_F64(x) x, kExprI32UConvertF64
     572             : #define WASM_I32_CONVERT_I64(x) x, kExprI32ConvertI64
     573             : #define WASM_I64_SCONVERT_F32(x) x, kExprI64SConvertF32
     574             : #define WASM_I64_SCONVERT_F64(x) x, kExprI64SConvertF64
     575             : #define WASM_I64_UCONVERT_F32(x) x, kExprI64UConvertF32
     576             : #define WASM_I64_UCONVERT_F64(x) x, kExprI64UConvertF64
     577             : #define WASM_I64_SCONVERT_I32(x) x, kExprI64SConvertI32
     578             : #define WASM_I64_UCONVERT_I32(x) x, kExprI64UConvertI32
     579             : #define WASM_F32_SCONVERT_I32(x) x, kExprF32SConvertI32
     580             : #define WASM_F32_UCONVERT_I32(x) x, kExprF32UConvertI32
     581             : #define WASM_F32_SCONVERT_I64(x) x, kExprF32SConvertI64
     582             : #define WASM_F32_UCONVERT_I64(x) x, kExprF32UConvertI64
     583             : #define WASM_F32_CONVERT_F64(x) x, kExprF32ConvertF64
     584             : #define WASM_F32_REINTERPRET_I32(x) x, kExprF32ReinterpretI32
     585             : #define WASM_F64_SCONVERT_I32(x) x, kExprF64SConvertI32
     586             : #define WASM_F64_UCONVERT_I32(x) x, kExprF64UConvertI32
     587             : #define WASM_F64_SCONVERT_I64(x) x, kExprF64SConvertI64
     588             : #define WASM_F64_UCONVERT_I64(x) x, kExprF64UConvertI64
     589             : #define WASM_F64_CONVERT_F32(x) x, kExprF64ConvertF32
     590             : #define WASM_F64_REINTERPRET_I64(x) x, kExprF64ReinterpretI64
     591             : #define WASM_I32_REINTERPRET_F32(x) x, kExprI32ReinterpretF32
     592             : #define WASM_I64_REINTERPRET_F64(x) x, kExprI64ReinterpretF64
     593             : 
     594             : //------------------------------------------------------------------------------
     595             : // Numeric operations
     596             : //------------------------------------------------------------------------------
     597             : #define WASM_NUMERIC_OP(op) kNumericPrefix, static_cast<byte>(op)
     598             : #define WASM_I32_SCONVERT_SAT_F32(x) x, WASM_NUMERIC_OP(kExprI32SConvertSatF32)
     599             : #define WASM_I32_UCONVERT_SAT_F32(x) x, WASM_NUMERIC_OP(kExprI32UConvertSatF32)
     600             : #define WASM_I32_SCONVERT_SAT_F64(x) x, WASM_NUMERIC_OP(kExprI32SConvertSatF64)
     601             : #define WASM_I32_UCONVERT_SAT_F64(x) x, WASM_NUMERIC_OP(kExprI32UConvertSatF64)
     602             : #define WASM_I64_SCONVERT_SAT_F32(x) x, WASM_NUMERIC_OP(kExprI64SConvertSatF32)
     603             : #define WASM_I64_UCONVERT_SAT_F32(x) x, WASM_NUMERIC_OP(kExprI64UConvertSatF32)
     604             : #define WASM_I64_SCONVERT_SAT_F64(x) x, WASM_NUMERIC_OP(kExprI64SConvertSatF64)
     605             : #define WASM_I64_UCONVERT_SAT_F64(x) x, WASM_NUMERIC_OP(kExprI64UConvertSatF64)
     606             : 
     607             : #define MEMORY_ZERO 0
     608             : 
     609             : #define WASM_MEMORY_INIT(seg, dst, src, size) \
     610             :   dst, src, size, WASM_NUMERIC_OP(kExprMemoryInit), U32V_1(seg), MEMORY_ZERO
     611             : #define WASM_DATA_DROP(seg) WASM_NUMERIC_OP(kExprDataDrop), U32V_1(seg)
     612             : #define WASM_MEMORY_COPY(dst, src, size) \
     613             :   dst, src, size, WASM_NUMERIC_OP(kExprMemoryCopy), MEMORY_ZERO, MEMORY_ZERO
     614             : #define WASM_MEMORY_FILL(dst, val, size) \
     615             :   dst, val, size, WASM_NUMERIC_OP(kExprMemoryFill), MEMORY_ZERO
     616             : #define WASM_TABLE_INIT(seg, dst, src, size) \
     617             :   dst, src, size, WASM_NUMERIC_OP(kExprTableInit), U32V_1(seg), TABLE_ZERO
     618             : #define WASM_ELEM_DROP(seg) WASM_NUMERIC_OP(kExprElemDrop), U32V_1(seg)
     619             : #define WASM_TABLE_COPY(dst, src, size) \
     620             :   dst, src, size, WASM_NUMERIC_OP(kExprTableCopy), TABLE_ZERO, TABLE_ZERO
     621             : 
     622             : //------------------------------------------------------------------------------
     623             : // Memory Operations.
     624             : //------------------------------------------------------------------------------
     625             : #define WASM_GROW_MEMORY(x) x, kExprMemoryGrow, 0
     626             : #define WASM_MEMORY_SIZE kExprMemorySize, 0
     627             : 
     628             : #define SIG_ENTRY_v_v kWasmFunctionTypeCode, 0, 0
     629             : #define SIZEOF_SIG_ENTRY_v_v 3
     630             : 
     631             : #define SIG_ENTRY_v_x(a) kWasmFunctionTypeCode, 1, a, 0
     632             : #define SIG_ENTRY_v_xx(a, b) kWasmFunctionTypeCode, 2, a, b, 0
     633             : #define SIG_ENTRY_v_xxx(a, b, c) kWasmFunctionTypeCode, 3, a, b, c, 0
     634             : #define SIZEOF_SIG_ENTRY_v_x 4
     635             : #define SIZEOF_SIG_ENTRY_v_xx 5
     636             : #define SIZEOF_SIG_ENTRY_v_xxx 6
     637             : 
     638             : #define SIG_ENTRY_x(r) kWasmFunctionTypeCode, 0, 1, r
     639             : #define SIG_ENTRY_x_x(r, a) kWasmFunctionTypeCode, 1, a, 1, r
     640             : #define SIG_ENTRY_x_xx(r, a, b) kWasmFunctionTypeCode, 2, a, b, 1, r
     641             : #define SIG_ENTRY_xx_xx(r, s, a, b) kWasmFunctionTypeCode, 2, a, b, 2, r, s
     642             : #define SIG_ENTRY_x_xxx(r, a, b, c) kWasmFunctionTypeCode, 3, a, b, c, 1, r
     643             : #define SIZEOF_SIG_ENTRY_x 4
     644             : #define SIZEOF_SIG_ENTRY_x_x 5
     645             : #define SIZEOF_SIG_ENTRY_x_xx 6
     646             : #define SIZEOF_SIG_ENTRY_xx_xx 7
     647             : #define SIZEOF_SIG_ENTRY_x_xxx 7
     648             : 
     649             : #define WASM_BRV(depth, ...) __VA_ARGS__, kExprBr, static_cast<byte>(depth)
     650             : #define WASM_BRV_IF(depth, val, cond) \
     651             :   val, cond, kExprBrIf, static_cast<byte>(depth)
     652             : #define WASM_BRV_IFD(depth, val, cond) \
     653             :   val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop
     654             : #define WASM_IFB(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd
     655             : #define WASM_BR_TABLEV(val, key, count, ...) \
     656             :   val, key, kExprBrTable, U32V_1(count), __VA_ARGS__
     657             : 
     658             : //------------------------------------------------------------------------------
     659             : // Atomic Operations.
     660             : //------------------------------------------------------------------------------
     661             : #define WASM_ATOMICS_OP(op) kAtomicPrefix, static_cast<byte>(op)
     662             : #define WASM_ATOMICS_BINOP(op, x, y, representation) \
     663             :   x, y, WASM_ATOMICS_OP(op),                         \
     664             :       static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET
     665             : #define WASM_ATOMICS_TERNARY_OP(op, x, y, z, representation) \
     666             :   x, y, z, WASM_ATOMICS_OP(op),                              \
     667             :       static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET
     668             : #define WASM_ATOMICS_LOAD_OP(op, x, representation) \
     669             :   x, WASM_ATOMICS_OP(op),                           \
     670             :       static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET
     671             : #define WASM_ATOMICS_STORE_OP(op, x, y, representation) \
     672             :   x, y, WASM_ATOMICS_OP(op),                            \
     673             :       static_cast<byte>(ElementSizeLog2Of(representation)), ZERO_OFFSET
     674             : #define WASM_ATOMICS_WAIT(op, index, value, timeout, offset) \
     675             :   index, value, timeout, WASM_ATOMICS_OP(op), ZERO_ALIGNMENT, offset
     676             : 
     677             : //------------------------------------------------------------------------------
     678             : // Sign Externsion Operations.
     679             : //------------------------------------------------------------------------------
     680             : #define WASM_I32_SIGN_EXT_I8(x) x, kExprI32SExtendI8
     681             : #define WASM_I32_SIGN_EXT_I16(x) x, kExprI32SExtendI16
     682             : #define WASM_I64_SIGN_EXT_I8(x) x, kExprI64SExtendI8
     683             : #define WASM_I64_SIGN_EXT_I16(x) x, kExprI64SExtendI16
     684             : #define WASM_I64_SIGN_EXT_I32(x) x, kExprI64SExtendI32
     685             : 
     686             : //------------------------------------------------------------------------------
     687             : // Compilation Hints.
     688             : //------------------------------------------------------------------------------
     689             : #define COMPILE_STRATEGY_DEFAULT (0x00)
     690             : #define COMPILE_STRATEGY_LAZY (0x01)
     691             : #define COMPILE_STRATEGY_EAGER (0x02)
     692             : #define BASELINE_TIER_DEFAULT (0x00 << 2)
     693             : #define BASELINE_TIER_INTERPRETER (0x01 << 2)
     694             : #define BASELINE_TIER_BASELINE (0x02 << 2)
     695             : #define BASELINE_TIER_OPTIMIZED (0x03 << 2)
     696             : #define TOP_TIER_DEFAULT (0x00 << 4)
     697             : #define TOP_TIER_INTERPRETER (0x01 << 4)
     698             : #define TOP_TIER_BASELINE (0x02 << 4)
     699             : #define TOP_TIER_OPTIMIZED (0x03 << 4)
     700             : 
     701             : #endif  // V8_WASM_MACRO_GEN_H_

Generated by: LCOV version 1.10