git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 410bf961ea8b42dea73d52435bec504893649c03

fix useGas

wanderer committed on 9/13/2016, 5:08:31 PM
Parent: 643fe1d2f37714b0ada02a671a4c74924ce8437e

Files changed

interface.jschanged
wasm/interface.wastchanged
interface.jsView
@@ -83,10 +83,10 @@
8383 // convert from a 32-bit two's compliment
8484 low = 0x100000000 - low
8585 }
8686
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
8989 this.takeGas(amount)
9090 }
9191
9292 /**
wasm/interface.wastView
@@ -1,8 +1,11 @@
11 (module
22 (import $useGas "interface" "useGas" (param i32 i32))
33 (func $useGasShim
44 (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)))
69 )
710 (export "useGas" $useGasShim)
811 )

Built with git-ssb-web