summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-03-22 16:33:37 -0700
committerGitHub <noreply@github.com>2021-03-22 16:33:37 -0700
commit418804035056bcd133ff5e292bf645d5d26d8d0d (patch)
tree3c6f60a0a07e35cf0d15cd669d93413ff72f5bb3 /src/wasm/wasm-binary.cpp
parent8dddd9f3a3060d831af48387165703e1d8efcc63 (diff)
downloadbinaryen-418804035056bcd133ff5e292bf645d5d26d8d0d.tar.gz
binaryen-418804035056bcd133ff5e292bf645d5d26d8d0d.tar.bz2
binaryen-418804035056bcd133ff5e292bf645d5d26d8d0d.zip
wasm-emscripten-finalize: Do not skip the start function body (#3714)
When we can skip function bodies, we still need to parse the start function for the pthreads case, see details in the comments. This still gives us 99% of the speedup as the start function is just 1 function and it's not that big, so with this we return to full speed after the reversion in #3705
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 37fa1ab78..6cb837296 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2141,7 +2141,14 @@ void WasmBinaryBuilder::readFunctions() {
assert(controlFlowStack.empty());
assert(letStack.empty());
assert(depth == 0);
- if (!skipFunctionBodies) {
+ // Even if we are skipping function bodies we need to not skip the start
+ // function. That contains important code for wasm-emscripten-finalize in
+ // the form of pthread-related segment initializations. As this is just
+ // one function, it doesn't add significant time, so the optimization of
+ // skipping bodies is still very useful.
+ auto currFunctionIndex = functionImports.size() + functions.size();
+ bool isStart = startIndex == currFunctionIndex;
+ if (!skipFunctionBodies || isStart) {
func->body = getBlockOrSingleton(func->sig.results);
} else {
// When skipping the function body we need to put something valid in