build and runtime update

This commit is contained in:
NikVolf
2017-04-27 21:28:06 +03:00
parent 6238c1ce91
commit 3df0243f6a
2 changed files with 23 additions and 2 deletions
+8
View File
@@ -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
+15 -2
View File
@@ -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;