Index: src/wasm/wasm-text.cc |
diff --git a/src/wasm/wasm-text.cc b/src/wasm/wasm-text.cc |
index 1878095b09fcf75d9be5ebd964657599957a176d..b0d32fd51b6eea06aeab4a2bd6b5d8fdf4dc9dec 100644 |
--- a/src/wasm/wasm-text.cc |
+++ b/src/wasm/wasm-text.cc |
@@ -17,106 +17,6 @@ using namespace v8::internal; |
using namespace v8::internal::wasm; |
namespace { |
-const char *GetOpName(WasmOpcode opcode) { |
-#define CASE_OP(name, str) \ |
- case kExpr##name: \ |
- return str; |
-#define CASE_I32_OP(name, str) CASE_OP(I32##name, "i32." str) |
-#define CASE_I64_OP(name, str) CASE_OP(I64##name, "i64." str) |
-#define CASE_F32_OP(name, str) CASE_OP(F32##name, "f32." str) |
-#define CASE_F64_OP(name, str) CASE_OP(F64##name, "f64." str) |
-#define CASE_INT_OP(name, str) CASE_I32_OP(name, str) CASE_I64_OP(name, str) |
-#define CASE_FLOAT_OP(name, str) CASE_F32_OP(name, str) CASE_F64_OP(name, str) |
-#define CASE_ALL_OP(name, str) CASE_FLOAT_OP(name, str) CASE_INT_OP(name, str) |
-#define CASE_SIGN_OP(TYPE, name, str) \ |
- CASE_##TYPE##_OP(name##S, str "_s") CASE_##TYPE##_OP(name##U, str "_u") |
-#define CASE_ALL_SIGN_OP(name, str) \ |
- CASE_FLOAT_OP(name, str) CASE_SIGN_OP(INT, name, str) |
-#define CASE_CONVERT_OP(name, RES, SRC, src_suffix, str) \ |
- CASE_##RES##_OP(U##name##SRC, str "_u/" src_suffix) \ |
- CASE_##RES##_OP(S##name##SRC, str "_s/" src_suffix) |
- |
- switch (opcode) { |
- CASE_INT_OP(Eqz, "eqz") |
- CASE_ALL_OP(Eq, "eq") |
- CASE_ALL_OP(Ne, "ne") |
- CASE_ALL_OP(Add, "add") |
- CASE_ALL_OP(Sub, "sub") |
- CASE_ALL_OP(Mul, "mul") |
- CASE_ALL_SIGN_OP(Lt, "lt") |
- CASE_ALL_SIGN_OP(Gt, "gt") |
- CASE_ALL_SIGN_OP(Le, "le") |
- CASE_ALL_SIGN_OP(Ge, "ge") |
- CASE_INT_OP(Clz, "clz") |
- CASE_INT_OP(Ctz, "ctz") |
- CASE_INT_OP(Popcnt, "popcnt") |
- CASE_ALL_SIGN_OP(Div, "div") |
- CASE_SIGN_OP(INT, Rem, "rem") |
- CASE_INT_OP(And, "and") |
- CASE_INT_OP(Ior, "or") |
- CASE_INT_OP(Xor, "xor") |
- CASE_INT_OP(Shl, "shl") |
- CASE_SIGN_OP(INT, Shr, "shr") |
- CASE_INT_OP(Rol, "rol") |
- CASE_INT_OP(Ror, "ror") |
- CASE_FLOAT_OP(Abs, "abs") |
- CASE_FLOAT_OP(Neg, "neg") |
- CASE_FLOAT_OP(Ceil, "ceil") |
- CASE_FLOAT_OP(Floor, "floor") |
- CASE_FLOAT_OP(Trunc, "trunc") |
- CASE_FLOAT_OP(NearestInt, "nearest") |
- CASE_FLOAT_OP(Sqrt, "sqrt") |
- CASE_FLOAT_OP(Min, "min") |
- CASE_FLOAT_OP(Max, "max") |
- CASE_FLOAT_OP(CopySign, "copysign") |
- CASE_I32_OP(ConvertI64, "wrap/i64") |
- CASE_CONVERT_OP(Convert, INT, F32, "f32", "trunc") |
- CASE_CONVERT_OP(Convert, INT, F64, "f64", "trunc") |
- CASE_CONVERT_OP(Convert, I64, I32, "i32", "extend") |
- CASE_CONVERT_OP(Convert, F32, I32, "i32", "convert") |
- CASE_CONVERT_OP(Convert, F32, I64, "i64", "convert") |
- CASE_F32_OP(ConvertF64, "demote/f64") |
- CASE_CONVERT_OP(Convert, F64, I32, "i32", "convert") |
- CASE_CONVERT_OP(Convert, F64, I64, "i64", "convert") |
- CASE_F64_OP(ConvertF32, "promote/f32") |
- CASE_I32_OP(ReinterpretF32, "reinterpret/f32") |
- CASE_I64_OP(ReinterpretF64, "reinterpret/f64") |
- CASE_F32_OP(ReinterpretI32, "reinterpret/i32") |
- CASE_F64_OP(ReinterpretI64, "reinterpret/i64") |
- CASE_OP(Unreachable, "unreachable") |
- CASE_OP(Nop, "nop") |
- CASE_OP(Return, "return") |
- CASE_OP(MemorySize, "current_memory") |
- CASE_OP(GrowMemory, "grow_memory") |
- CASE_OP(Loop, "loop") |
- CASE_OP(If, "if") |
- CASE_OP(Block, "block") |
- CASE_OP(Try, "try") |
- CASE_OP(Throw, "throw") |
- CASE_OP(Catch, "catch") |
- CASE_OP(Drop, "drop") |
- CASE_OP(Select, "select") |
- CASE_ALL_OP(LoadMem, "load") |
- CASE_SIGN_OP(INT, LoadMem8, "load8") |
- CASE_SIGN_OP(INT, LoadMem16, "load16") |
- CASE_SIGN_OP(I64, LoadMem32, "load32") |
- CASE_ALL_OP(StoreMem, "store") |
- CASE_INT_OP(StoreMem8, "store8") |
- CASE_INT_OP(StoreMem16, "store16") |
- CASE_I64_OP(StoreMem32, "store32") |
- CASE_OP(SetLocal, "set_local") |
- CASE_OP(GetLocal, "get_local") |
- CASE_OP(TeeLocal, "tee_local") |
- CASE_OP(GetGlobal, "get_global") |
- CASE_OP(SetGlobal, "set_global") |
- CASE_OP(Br, "br") |
- CASE_OP(BrIf, "br_if") |
- default: |
- UNREACHABLE(); |
- return ""; |
- } |
-} |
- |
bool IsValidFunctionName(const Vector<const char> &name) { |
if (name.is_empty()) return false; |
const char *special_chars = "_.+-*/\\^~=<>!?@#$%&|:'`"; |
@@ -205,7 +105,7 @@ void wasm::PrintWasmText(const WasmModule *module, |
case kExprBlock: |
case kExprTry: { |
BlockTypeOperand operand(&i, i.pc()); |
- os << GetOpName(opcode); |
+ os << WasmOpcodes::OpcodeName(opcode); |
for (unsigned i = 0; i < operand.arity; i++) { |
os << " " << WasmOpcodes::TypeName(operand.read_entry(i)); |
} |
@@ -215,7 +115,7 @@ void wasm::PrintWasmText(const WasmModule *module, |
case kExprBr: |
case kExprBrIf: { |
BreakDepthOperand operand(&i, i.pc()); |
- os << GetOpName(opcode) << ' ' << operand.depth; |
+ os << WasmOpcodes::OpcodeName(opcode) << ' ' << operand.depth; |
break; |
} |
case kExprElse: |
@@ -248,13 +148,13 @@ void wasm::PrintWasmText(const WasmModule *module, |
case kExprTeeLocal: |
case kExprCatch: { |
LocalIndexOperand operand(&i, i.pc()); |
- os << GetOpName(opcode) << ' ' << operand.index; |
+ os << WasmOpcodes::OpcodeName(opcode) << ' ' << operand.index; |
break; |
} |
case kExprGetGlobal: |
case kExprSetGlobal: { |
GlobalIndexOperand operand(&i, i.pc()); |
- os << GetOpName(opcode) << ' ' << operand.index; |
+ os << WasmOpcodes::OpcodeName(opcode) << ' ' << operand.index; |
break; |
} |
#define CASE_CONST(type, str, cast_type) \ |
@@ -272,7 +172,7 @@ void wasm::PrintWasmText(const WasmModule *module, |
FOREACH_LOAD_MEM_OPCODE(CASE_OPCODE) |
FOREACH_STORE_MEM_OPCODE(CASE_OPCODE) { |
MemoryAccessOperand operand(&i, i.pc(), kMaxUInt32); |
- os << GetOpName(opcode) << " offset=" << operand.offset |
+ os << WasmOpcodes::OpcodeName(opcode) << " offset=" << operand.offset |
<< " align=" << (1ULL << operand.alignment); |
break; |
} |
@@ -286,7 +186,7 @@ void wasm::PrintWasmText(const WasmModule *module, |
case kExprDrop: |
case kExprSelect: |
case kExprThrow: |
- os << GetOpName(opcode); |
+ os << WasmOpcodes::OpcodeName(opcode); |
break; |
// This group is just printed by their internal opcode name, as they |