5#ifndef V8_WASM_WASM_OPCODES_INL_H_
6#define V8_WASM_WASM_OPCODES_INL_H_
8#if !V8_ENABLE_WEBASSEMBLY
9#error This header should only be included if WebAssembly is enabled.
28#define CASE(opcode, binary, sig, name, ...) \
44 return "invalid opcode";
50#define CHECK_PREFIX(name, opcode) case k##name##Prefix:
62#define CHECK_OPCODE(name, ...) case kExpr##name:
74 case kExprUnreachable:
79 case kExprReturnCallIndirect:
108 case kExprRefAsNonNull:
121 case kExprCallFunction:
122 case kExprCallIndirect:
133 static_assert(kSimdPrefix == 0xfd);
134#define CHECK_OPCODE(name, opcode, ...) \
135 static_assert((opcode & 0xfff00) == 0xfd100);
139 return (opcode & 0xfff00) == 0xfd100;
143 return (opcode >= kExprF16x8Splat && opcode <= kExprF16x8ReplaceLane) ||
144 (opcode >= kExprF16x8Abs && opcode <= kExprF16x8Qfms);
149constexpr bool WasmOpcodes::IsMemoryAccessOpcode(
WasmOpcode opcode) {
151#define MEM_OPCODE(name, ...) case WasmOpcode::kExpr##name:
166 return (opcode > 0xffff) ? opcode >> 12 : opcode >> 8;
171#define DECLARE_SIG_ENUM(name, ...) kSigEnum_##name,
176#undef DECLARE_SIG_ENUM
177#define DECLARE_SIG(name, ...) \
178 constexpr inline ValueType kTypes_##name[] = {__VA_ARGS__}; \
179 constexpr inline int kReturnsCount_##name = \
180 kTypes_##name[0] == kWasmVoid ? 0 : 1; \
181 constexpr inline FunctionSig kSig_##name( \
182 kReturnsCount_##name, static_cast<int>(arraysize(kTypes_##name)) - 1, \
183 kTypes_##name + (1 - kReturnsCount_##name));
187#define DECLARE_SIG_ENTRY(name, ...) &kSig_##name,
190#undef DECLARE_SIG_ENTRY
193#define CASE(name, opc, sig, ...) opcode == opc ? kSigEnum_##sig:
200#define CASE(name, opc, sig, ...) opcode == (opc & 0xFF) ? kSigEnum_##sig:
206#define CASE(name, opc, sig, ...) opcode == (opc & 0xFF) ? kSigEnum_##sig:
213#define CASE(name, opc, sig, ...) opcode == (opc & 0xFF) ? kSigEnum_##sig:
219#define CASE(name, opc, sig, ...) opcode == (opc & 0xFF) ? kSigEnum_##sig:
226#define CASE(name, opc, sig32, text, sig64) \
227 opcode == (opc & 0xFF) ? kSigEnum_##sig64:
234#define CASE(name, opc, sig, ...) opcode == (opc & 0xFF) ? kSigEnum_##sig:
263 if (opcode <= 0xfdff) {
299#define TRAPREASON_TO_MESSAGE(name) \
301 return MessageTemplate::kWasm##name;
303#undef TRAPREASON_TO_MESSAGE
312#define MESSAGE_TO_TRAPREASON(name) \
313 case MessageTemplate::kWasm##name: \
316#undef MESSAGE_TO_TRAPREASON
static constexpr const FunctionSig * Signature(WasmOpcode)
static constexpr bool IsBreakable(WasmOpcode)
static constexpr bool IsRelaxedSimdOpcode(WasmOpcode)
static constexpr bool IsExternRefOpcode(WasmOpcode)
static constexpr uint8_t ExtractPrefix(WasmOpcode)
static constexpr bool IsFP16SimdOpcode(WasmOpcode)
static constexpr const FunctionSig * SignatureForAtomicOp(WasmOpcode opcode, bool is_memory64)
static const char * TrapReasonMessage(TrapReason)
static constexpr const FunctionSig * AsmjsSignature(WasmOpcode)
static constexpr TrapReason MessageIdToTrapReason(MessageTemplate message)
static constexpr bool IsThrowingOpcode(WasmOpcode)
static constexpr const char * OpcodeName(WasmOpcode)
static constexpr bool IsUnconditionalJump(WasmOpcode)
static constexpr MessageTemplate TrapReasonToMessageId(TrapReason)
static constexpr bool IsControlOpcode(WasmOpcode)
static constexpr bool IsPrefixOpcode(WasmOpcode)
#define FOREACH_WASM_TRAPREASON(V)
constexpr auto make_array(Function f)
constexpr WasmOpcodeSig GetAtomicOpcodeMem64SigIndex(uint8_t opcode)
constexpr WasmOpcodeSig GetSimdOpcodeSigIndex(uint8_t opcode)
constexpr const FunctionSig * kCachedSigs[]
constexpr WasmOpcodeSig GetRelaxedSimdOpcodeSigIndex(uint8_t opcode)
constexpr std::array< WasmOpcodeSig, 256 > kRelaxedSimdExprSigTable
constexpr std::array< WasmOpcodeSig, 256 > kShortSigTable
constexpr std::array< WasmOpcodeSig, 256 > kAtomicExprSigTableMem32
constexpr std::array< WasmOpcodeSig, 256 > kSimpleAsmjsExprSigTable
constexpr WasmOpcodeSig GetAtomicOpcodeMem32SigIndex(uint8_t opcode)
constexpr WasmOpcodeSig GetNumericOpcodeSigIndex(uint8_t opcode)
constexpr std::array< WasmOpcodeSig, 256 > kNumericExprSigTable
constexpr WasmOpcodeSig GetShortOpcodeSigIndex(uint8_t opcode)
constexpr WasmOpcodeSig GetAsmJsOpcodeSigIndex(uint8_t opcode)
constexpr std::array< WasmOpcodeSig, 256 > kSimdExprSigTable
constexpr std::array< WasmOpcodeSig, 256 > kAtomicExprSigTableMem64
#define DCHECK_LE(v1, v2)
#define DCHECK_GT(v1, v2)
#define DECLARE_SIG_ENTRY(name,...)
#define DECLARE_SIG(name,...)
#define CHECK_OPCODE(name,...)
#define TRAPREASON_TO_MESSAGE(name)
#define MESSAGE_TO_TRAPREASON(name)
#define CHECK_PREFIX(name, opcode)
#define DECLARE_SIG_ENUM(name,...)
#define FOREACH_CONTROL_OPCODE(V)
#define FOREACH_PREFIX(V)
#define FOREACH_ATOMIC_OPCODE(V)
#define FOREACH_OPCODE(V)
#define FOREACH_SIMD_MEM_OPCODE(V)
#define FOREACH_LOAD_MEM_OPCODE(V)
#define FOREACH_SIMD_MEM_1_OPERAND_OPCODE(V)
#define FOREACH_SIMD_MVP_0_OPERAND_OPCODE(V)
#define FOREACH_SIMPLE_PROTOTYPE_OPCODE(V)
#define FOREACH_ASMJS_COMPAT_OPCODE(V)
#define FOREACH_STORE_MEM_OPCODE(V)
#define FOREACH_RELAXED_SIMD_OPCODE(V)
#define FOREACH_ATOMIC_0_OPERAND_OPCODE(V)
#define FOREACH_NUMERIC_OPCODE_WITH_SIG(V)
#define FOREACH_SIGNATURE(V)
#define FOREACH_SIMPLE_OPCODE(V)