Chromium Code Reviews| Index: src/wasm/wasm-opcodes.cc |
| diff --git a/src/wasm/wasm-opcodes.cc b/src/wasm/wasm-opcodes.cc |
| index afb1eff36687a622a4bb62b3a118281d0af8c10a..535b0aafbbdd6100257c825f277fa29663a57873 100644 |
| --- a/src/wasm/wasm-opcodes.cc |
| +++ b/src/wasm/wasm-opcodes.cc |
| @@ -68,7 +68,13 @@ 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() { |
| @@ -80,22 +86,41 @@ static void InitSigTable() { |
| #undef SET_SIG_TABLE |
| } |
| +// Initialize the signature table. |
|
titzer
2016/07/08 14:16:03
You can just merge this with the above function an
gdeepti
2016/07/11 09:50:34
Done.
|
| +static void InitSimdSigTable() { |
| + 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(); |
| + InitSimdSigTable(); |
| } |
| 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. |