| Index: src/wasm/wasm-opcodes.cc
|
| diff --git a/src/wasm/wasm-opcodes.cc b/src/wasm/wasm-opcodes.cc
|
| index afb1eff36687a622a4bb62b3a118281d0af8c10a..8f54207661363ca59b2fa41134d500cade481fa1 100644
|
| --- a/src/wasm/wasm-opcodes.cc
|
| +++ b/src/wasm/wasm-opcodes.cc
|
| @@ -68,34 +68,54 @@ FOREACH_SIGNATURE(DECLARE_SIG)
|
| static const FunctionSig* kSimpleExprSigs[] = {
|
| nullptr, FOREACH_SIGNATURE(DECLARE_SIG_ENTRY)};
|
|
|
| +#define DECLARE_SIMD_SIG_ENTRY(name, ...) &kSig_##name,
|
| +
|
| +static const FunctionSig* kSimdExprSigs[] = {
|
| + nullptr, FOREACH_SIMD_SIGNATURE(DECLARE_SIMD_SIG_ENTRY)};
|
| +
|
| static byte kSimpleExprSigTable[256];
|
| +static byte kSimdExprSigTable[256];
|
|
|
| // Initialize the signature table.
|
| -static void InitSigTable() {
|
| +static void InitSigTables() {
|
| #define SET_SIG_TABLE(name, opcode, sig) \
|
| kSimpleExprSigTable[opcode] = static_cast<int>(kSigEnum_##sig) + 1;
|
| FOREACH_SIMPLE_OPCODE(SET_SIG_TABLE);
|
| FOREACH_SIMPLE_MEM_OPCODE(SET_SIG_TABLE);
|
| FOREACH_ASMJS_COMPAT_OPCODE(SET_SIG_TABLE);
|
| #undef SET_SIG_TABLE
|
| + byte simd_index;
|
| +#define SET_SIG_TABLE(name, opcode, sig) \
|
| + simd_index = opcode & 0xff; \
|
| + kSimdExprSigTable[simd_index] = static_cast<int>(kSigEnum_##sig) + 1;
|
| + FOREACH_SIMD_OPCODE(SET_SIG_TABLE)
|
| +#undef SET_SIG_TABLE
|
| }
|
|
|
| class SigTable {
|
| public:
|
| SigTable() {
|
| // TODO(ahaas): Move {InitSigTable} into the class.
|
| - InitSigTable();
|
| + InitSigTables();
|
| }
|
| FunctionSig* Signature(WasmOpcode opcode) const {
|
| return const_cast<FunctionSig*>(
|
| kSimpleExprSigs[kSimpleExprSigTable[static_cast<byte>(opcode)]]);
|
| }
|
| + FunctionSig* SimdSignature(WasmOpcode opcode) const {
|
| + return const_cast<FunctionSig*>(
|
| + kSimdExprSigs[kSimdExprSigTable[static_cast<byte>(opcode & 0xff)]]);
|
| + }
|
| };
|
|
|
| static base::LazyInstance<SigTable>::type sig_table = LAZY_INSTANCE_INITIALIZER;
|
|
|
| FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) {
|
| - return sig_table.Get().Signature(opcode);
|
| + if (opcode >> 8 == kSimdPrefix) {
|
| + return sig_table.Get().SimdSignature(opcode);
|
| + } else {
|
| + return sig_table.Get().Signature(opcode);
|
| + }
|
| }
|
|
|
| // TODO(titzer): pull WASM_64 up to a common header.
|
|
|