Commit 410bf961ea8b42dea73d52435bec504893649c03
fix useGas
wanderer committed on 9/13/2016, 5:08:31 PMParent: 643fe1d2f37714b0ada02a671a4c74924ce8437e
Files changed
interface.js | changed |
wasm/interface.wast | changed |
interface.js | ||
---|---|---|
@@ -83,10 +83,10 @@ | ||
83 | 83 | // convert from a 32-bit two's compliment |
84 | 84 | low = 0x100000000 - low |
85 | 85 | } |
86 | 86 | |
87 | - const amount = (high << 32) + low | |
88 | - | |
87 | + // JS only bitshift 32bits, so instead of high << 32 we have high * 2 ^ 32 | |
88 | + const amount = (high * 4294967296) + low | |
89 | 89 | this.takeGas(amount) |
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
wasm/interface.wast | ||
---|---|---|
@@ -1,8 +1,11 @@ | ||
1 | 1 | (module |
2 | 2 | (import $useGas "interface" "useGas" (param i32 i32)) |
3 | 3 | (func $useGasShim |
4 | 4 | (param $amount i64) |
5 | - (call_import $useGas (i32.wrap/i64 (i64.shr_u (get_local $amount) (i64.const 32))) (i32.wrap/i64 (get_local $amount))) | |
5 | + (call_import $useGas | |
6 | + (i32.wrap/i64 | |
7 | + (i64.shr_u (get_local $amount) (i64.const 32))) | |
8 | + (i32.wrap/i64 (get_local $amount))) | |
6 | 9 | ) |
7 | 10 | (export "useGas" $useGasShim) |
8 | 11 | ) |
Built with git-ssb-web