Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1541)

Unified Diff: src/wasm/wasm-opcodes.cc

Issue 1961973002: [wasm] Implement parallel compilation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make the implementation thread-safe. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/mjsunit/wasm/parallel_compilation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/mjsunit/wasm/parallel_compilation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698