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

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

Issue 1942773002: [wasm] Split the wasm compilation into two phases for parallel compilation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 0e154016231ef4dd35877ceae7c3ec203978fb04..279c7e76c6845396086677c523ac06da373b2f31 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -509,6 +509,9 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
std::vector<compiler::WasmCompilationUnit*> compilation_units(
functions.size());
+ std::queue<compiler::WasmCompilationUnit*> executed_units;
+ std::vector<Handle<Code>> results(functions.size());
+
if (FLAG_wasm_parallel_compilation) {
// Create a placeholder code object for all functions.
// TODO(ahaas): Maybe we could skip this for external functions.
@@ -520,14 +523,26 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
i++) {
if (!functions[i].external) {
compilation_units[i] = compiler::CreateWasmCompilationUnit(
- &thrower, isolate, &module_env, &functions[i]);
+ &thrower, isolate, &module_env, &functions[i], i);
}
}
- for (uint32_t i = FLAG_skip_compiling_wasm_funcs; i < functions.size();
- i++) {
- if (!functions[i].external) {
- compiler::ExecuteCompilation(compilation_units[i]);
+ index = FLAG_skip_compiling_wasm_funcs;
+ while (true) {
+ while (!executed_units.empty()) {
+ compiler::WasmCompilationUnit* unit = executed_units.front();
+ executed_units.pop();
+ int i = compiler::GetIndexOfWasmCompilationUnit(unit);
+ results[i] = compiler::FinishCompilation(unit);
+ }
+ if (index < functions.size()) {
+ if (!functions[index].external) {
+ compiler::ExecuteCompilation(compilation_units[index]);
+ executed_units.push(compilation_units[index]);
+ index++;
+ }
+ } else {
+ break;
}
}
}
@@ -554,7 +569,7 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
func.sig, str, str_null);
} else {
if (FLAG_wasm_parallel_compilation) {
- code = compiler::FinishCompilation(compilation_units[i]);
+ code = results[i];
} else {
// Compile the function.
code = compiler::CompileWasmFunction(&thrower, isolate, &module_env,
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698