summaryrefslogtreecommitdiff
path: root/src/s2wasm.h
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2016-04-26 11:08:43 -0700
committerDerek Schuff <dschuff@chromium.org>2016-04-26 11:08:43 -0700
commita0ec089707a33be6a4e29d917a7664519df50afc (patch)
treec86ac2d1464989cf9c43d9c61604a1f560f8481f /src/s2wasm.h
parent25a81de39898b7acd4d813779f3f605784203d27 (diff)
downloadbinaryen-a0ec089707a33be6a4e29d917a7664519df50afc.tar.gz
binaryen-a0ec089707a33be6a4e29d917a7664519df50afc.tar.bz2
binaryen-a0ec089707a33be6a4e29d917a7664519df50afc.zip
Defer creation of CallImports to link time (#395)
s2wasm currently creates a Call AST node if the target is implemented in the current object (thus far assumed to be the final executable) and a CallImport node if not. In preparation for adding additional objects to the link before layout time, we make only Call nodes until link time, and then convert them to CallImport if they are undefined at that time.
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r--src/s2wasm.h26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index f70246d4f..94684facf 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -696,19 +696,15 @@ class S2WasmBuilder {
} else {
// non-indirect call
- CallBase* curr;
Name assign = getAssign();
Name target = linkerObj.resolveAlias(cleanFunction(getCommaSeparated()));
- if (linkerObj.isFunctionImplemented(target)) {
- auto specific = allocator.alloc<Call>();
- specific->target = target;
- curr = specific;
- } else {
- auto specific = allocator.alloc<CallImport>();
- specific->target = target;
- curr = specific;
- }
+
+ Call* curr = allocator.alloc<Call>();
+ curr->target = target;
curr->type = type;
+ if (!linkerObj.isFunctionImplemented(target)) {
+ linkerObj.addUndefinedFunctionCall(curr);
+ }
skipWhitespace();
if (*s == ',') {
skipComma();
@@ -719,16 +715,6 @@ class S2WasmBuilder {
}
}
setOutput(curr, assign);
- if (curr->is<CallImport>()) {
- auto target = curr->cast<CallImport>()->target;
- if (!wasm.checkImport(target)) {
- auto import = allocator.alloc<Import>();
- import->name = import->base = target;
- import->module = ENV;
- import->type = ensureFunctionType(getSig(curr), &wasm, allocator);
- wasm.addImport(import);
- }
- }
}
};
auto handleTyped = [&](WasmType type) {