| Index: src/wasm/wasm-opcodes.cc
|
| diff --git a/src/wasm/wasm-opcodes.cc b/src/wasm/wasm-opcodes.cc
|
| index bbde4c62784f6205613551e48ab81feccffbfe31..a08fa8dbe6bc458f6ea0993881ed0f20d6bb9491 100644
|
| --- a/src/wasm/wasm-opcodes.cc
|
| +++ b/src/wasm/wasm-opcodes.cc
|
| @@ -79,11 +79,22 @@ static void InitSigTable() {
|
| #undef SET_SIG_TABLE
|
| }
|
|
|
| +class SigTable {
|
| + public:
|
| + SigTable() {
|
| + // TODO(ahaas): Move {InitSigTable} into the class.
|
| + InitSigTable();
|
| + }
|
| + FunctionSig* Signature(WasmOpcode opcode) const {
|
| + return const_cast<FunctionSig*>(
|
| + kSimpleExprSigs[kSimpleExprSigTable[static_cast<byte>(opcode)]]);
|
| + }
|
| +};
|
| +
|
| +static base::LazyInstance<SigTable>::type sig_table = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| FunctionSig* WasmOpcodes::Signature(WasmOpcode opcode) {
|
| - // TODO(titzer): use LazyInstance to make this thread safe.
|
| - if (kSimpleExprSigTable[kExprI32Add] == 0) InitSigTable();
|
| - return const_cast<FunctionSig*>(
|
| - kSimpleExprSigs[kSimpleExprSigTable[static_cast<byte>(opcode)]]);
|
| + return sig_table.Get().Signature(opcode);
|
| }
|
|
|
| // TODO(titzer): pull WASM_64 up to a common header.
|
|
|