summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/wasm-binary.cpp12
-rw-r--r--src/wasm/wasm-io.cpp1
2 files changed, 12 insertions, 1 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 1dac17e93..52aa4a6e0 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2137,7 +2137,17 @@ void WasmBinaryBuilder::readFunctions() {
assert(controlFlowStack.empty());
assert(letStack.empty());
assert(depth == 0);
- func->body = getBlockOrSingleton(func->sig.results);
+ if (!skipFunctionBodies) {
+ func->body = getBlockOrSingleton(func->sig.results);
+ } else {
+ // When skipping the function body we need to put something valid in
+ // their place so we validate. An unreachable is always acceptable
+ // there.
+ func->body = Builder(wasm).makeUnreachable();
+
+ // Skip reading the contents.
+ pos = endOfFunction;
+ }
assert(depth == 0);
assert(breakStack.empty());
assert(breakTargetNames.empty());
diff --git a/src/wasm/wasm-io.cpp b/src/wasm/wasm-io.cpp
index 2fb4af838..f2c5af6db 100644
--- a/src/wasm/wasm-io.cpp
+++ b/src/wasm/wasm-io.cpp
@@ -51,6 +51,7 @@ void ModuleReader::readBinaryData(std::vector<char>& input,
std::unique_ptr<std::ifstream> sourceMapStream;
WasmBinaryBuilder parser(wasm, input);
parser.setDWARF(DWARF);
+ parser.setSkipFunctionBodies(skipFunctionBodies);
if (sourceMapFilename.size()) {
sourceMapStream = make_unique<std::ifstream>();
sourceMapStream->open(sourceMapFilename);