From 0da770d9660919b03553374d36ce1d5ca93cf78f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 23 Jun 2016 15:06:40 -0700 Subject: add shared-constants.h for wasm constants --- src/wasm-linker.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/wasm-linker.cpp') diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index e89c324b4..eb7f9e00d 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -25,13 +25,6 @@ using namespace wasm; cashew::IString EMSCRIPTEN_ASM_CONST("emscripten_asm_const"); -namespace wasm { -// These are defined (not just declared) in shared-constants.h, so we can't just -// include that header. TODO: Move the definitions into a cpp file. -extern cashew::IString ENV; -extern cashew::IString MEMORY; -} - void Linker::placeStackPointer(Address stackAllocation) { // ensure this is the first allocation -- cgit v1.2.3 From 4ad7b4317d77c161cab69f5ae2b52b1583c96f11 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 26 Jun 2016 10:04:46 -0700 Subject: make makeCallImport more similar to makeCall; do not assume all imports exist, let functions be created in a way independent from global state --- src/ast_utils.h | 2 +- src/wasm-builder.h | 4 ++-- src/wasm-linker.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/wasm-linker.cpp') diff --git a/src/ast_utils.h b/src/ast_utils.h index c2a3db435..77bfaf1f3 100644 --- a/src/ast_utils.h +++ b/src/ast_utils.h @@ -258,7 +258,7 @@ struct ExpressionManipulator { return ret; } Expression* visitCallImport(CallImport *curr) { - auto* ret = builder.makeCallImport(curr->target, {}); + auto* ret = builder.makeCallImport(curr->target, {}, curr->type); for (Index i = 0; i < curr->operands.size(); i++) { ret->operands.push_back(copy(curr->operands[i])); } diff --git a/src/wasm-builder.h b/src/wasm-builder.h index e58d66795..501124999 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -107,9 +107,9 @@ public: call->operands.set(args); return call; } - CallImport* makeCallImport(Name target, const std::vector& args) { + CallImport* makeCallImport(Name target, const std::vector& args, WasmType type) { auto* call = wasm.allocator.alloc(); - call->type = wasm.getImport(target)->type->result; + call->type = type; // similar to makeCall, for consistency call->target = target; call->operands.set(args); return call; diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index eb7f9e00d..34dbc7f9c 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -396,7 +396,7 @@ Function* Linker::getImportThunk(Name name, const FunctionType* funcType) { for (Index i = 0; i < funcType->params.size(); ++i) { args.push_back(wasmBuilder.makeGetLocal(i, funcType->params[i])); } - Expression* call = wasmBuilder.makeCallImport(name, args); + Expression* call = wasmBuilder.makeCallImport(name, args, funcType->result); f->body = call; out.wasm.addFunction(f); return f; -- cgit v1.2.3