From 3df0243f6ac1da061220c100a2ff819016f1f074 Mon Sep 17 00:00:00 2001 From: NikVolf Date: Thu, 27 Apr 2017 21:28:06 +0300 Subject: [PATCH] build and runtime update --- runner/build.sh | 8 ++++++++ runner/index.html | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/runner/build.sh b/runner/build.sh index 3065691..afded07 100755 --- a/runner/build.sh +++ b/runner/build.sh @@ -14,4 +14,12 @@ else emcc $file -Os -s WASM=1 -s SIDE_MODULE=1 -o out/contract.wasm fi +# Gas injector cargo run --manifest-path=./../gas/Cargo.toml --release -- ./out/contract.wasm ./out/contract.wasm + +# Allocator replacer +cargo run --manifest-path=./../ext/Cargo.toml --release -- ./out/contract.wasm ./out/contract.wasm + +# Symbols optimizer +cargo run --manifest-path=./../opt/Cargo.toml --release -- ./out/contract.wasm ./out/contract.wasm + diff --git a/runner/index.html b/runner/index.html index 8764c03..d8a76d4 100644 --- a/runner/index.html +++ b/runner/index.html @@ -125,12 +125,23 @@ // todo: figure out how to do counter with multiple executables self.gasCounter = 0; + self.dynamicTopPtr = 1024; + + self.malloc = function(size) { + let result = self.dynamicTopPtr; + self.dynamicTopPtr += size; + return result; + } + + self.free = function() { + } + self.resolveAlloc = function(instance) { - return instance.exports._malloc; + return self.malloc; } self.resolveFree = function(instance) { - return instance.exports._free; + return self.free; } self.gas = function(val) { @@ -237,6 +248,8 @@ env._storage_write = runtime.storage.write; env._storage_size = runtime.storage.size; env.gas = runtime.gas; + env._malloc = runtime.malloc; + env._free = runtime.free; if (!imports.env.memory) { imports.env.memory = runtime.memory;