From d9096704dfa84aea94bb6ac2ffa02d88fa546bfa Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 22 Apr 2016 22:01:43 -0700 Subject: add an ArenaVector for internal array allocations in expression nodes --- src/wasm-linker.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/wasm-linker.cpp') diff --git a/src/wasm-linker.cpp b/src/wasm-linker.cpp index 7524f439a..8fc4f18c8 100644 --- a/src/wasm-linker.cpp +++ b/src/wasm-linker.cpp @@ -58,18 +58,19 @@ void Linker::layout() { auto import = out.wasm.allocator.alloc(); import->name = import->base = target; import->module = ENV; - import->type = ensureFunctionType(getSig(*f.second.begin()), &out.wasm, - out.wasm.allocator); + import->type = ensureFunctionType(getSig(*f.second.begin()), &out.wasm); out.wasm.addImport(import); } // Change each call. The target is the same since it's still the name. // Delete and re-allocate the Expression as CallImport to avoid undefined // behavior. for (auto* call : f.second) { - Call callCopy = std::move(*call); - CallImport* newCall = ExpressionManipulator::convert(call); - newCall->type = callCopy.type; - newCall->operands = std::move(callCopy.operands); + auto type = call->type; + auto operands = std::move(call->operands); + auto target = call->target; + CallImport* newCall = ExpressionManipulator::convert(call, out.wasm.allocator); + newCall->type = type; + newCall->operands = std::move(operands); newCall->target = target; } } @@ -181,7 +182,7 @@ void Linker::layout() { // ensure an explicit function type for indirect call targets for (auto& name : out.wasm.table.names) { auto* func = out.wasm.getFunction(name); - func->type = ensureFunctionType(getSig(func), &out.wasm, out.wasm.allocator)->name; + func->type = ensureFunctionType(getSig(func), &out.wasm)->name; } } @@ -226,7 +227,7 @@ void Linker::emscriptenGlue(std::ostream& o) { auto import = parent->out.wasm.allocator.alloc(); import->name = import->base = curr->target; import->module = ENV; - import->type = ensureFunctionType(getSig(curr), &parent->out.wasm, parent->out.wasm.allocator); + import->type = ensureFunctionType(getSig(curr), &parent->out.wasm); parent->out.wasm.addImport(import); } } @@ -290,7 +291,7 @@ void Linker::makeDynCallThunks() { wasm::Builder wasmBuilder(out.wasm); for (const auto& indirectFunc : out.wasm.table.names) { std::string sig(getSig(out.wasm.getFunction(indirectFunc))); - auto* funcType = ensureFunctionType(sig, &out.wasm, out.wasm.allocator); + auto* funcType = ensureFunctionType(sig, &out.wasm); if (!sigs.insert(sig).second) continue; // Sig is already in the set std::vector params; params.emplace_back("fptr", i32); // function pointer param -- cgit v1.2.3