git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 5f3238f523d36fc8df666fb57dcef2f8ecdd2a37

use tables for callbacks instead of exports

wanderer committed on 1/2/2017, 7:04:13 PM
Parent: 26787afda66ed5f43ebf8e40d4edefbbcc133e01

Files changed

tests/interface/balance.wasmchanged
tests/interface/balance.wastchanged
tests/interface/call.wasmchanged
tests/interface/call.wastchanged
tests/interface/sstore.wasmchanged
tests/interface/sstore.wastchanged
tests/interfaceRunner.jschanged
vm.jschanged
tests/interface/balance.wasmView
@@ -1,5 +1,5 @@
11 asm 
22 ``ethereum
3-getBalancememorymain1
3+getBalancepmemorymaincallback A 
44 '
5-AAA @A)B��������Q@ A ]H���r�h)���oJ-�{
5+AAA @A)B��������Q@ A ]H���r�h)���oJ-�{
tests/interface/balance.wastView
@@ -4,12 +4,19 @@
44 (memory 1 )
55 (data (i32.const 0) "\5d\48\c1\01\89\04\a1\72\88\68\29\bb\bd\9c\6f\4a\2d\06\c4\7b")
66 (export "memory" (memory 0))
77 (export "main" (func $main))
8- (export "1" (func $callback))
98
9+ (table
10+ (export "callback")
11+ anyfunc
12+ (elem
13+ $callback
14+ )
15+ )
16+
1017 (func $main
11- (call $balance (i32.const 0) (i32.const 0) (i32.const 1))
18+ (call $balance (i32.const 0) (i32.const 0) (i32.const 0))
1219 )
1320
1421 (func $callback
1522 (block
tests/interface/call.wasmView
@@ -1,2 +1,2 @@
1-asm `~``ethereumcallmemorymain1
2-:+@AA6A4A����6B�AAA4AA8AA A F@
1+asm `~``ethereumcallpmemorymaincallback A 
2+:+@AA6A4A����6B�AAA4AA8AA A F@
tests/interface/call.wastView
@@ -3,8 +3,17 @@
33 (import "ethereum" "call" (func $call (param i64 i32 i32 i32 i32 i32 i32 i32) (result i32)))
44 (memory 1)
55 (export "memory" (memory 0))
66 (export "main" (func $main))
7+
8+ (table
9+ (export "callback")
10+ anyfunc
11+ (elem
12+ $callback
13+ )
14+ )
15+
716 (func $main
817 (block
918 ;; Memory layout:
1019 ;; 0 - 20 bytes: address (4)
@@ -12,14 +21,13 @@
1221 ;; 52 - 56 bytes: data (0x42004200)
1322 ;; 56 - 60 bytes: result
1423 (i32.store (i32.const 0) (i32.const 0x4))
1524 (i32.store (i32.const 52) (i32.const 0x42004200))
16- (call $call (i64.const 2000) (i32.const 0) (i32.const 20) (i32.const 52) (i32.const 4) (i32.const 56) (i32.const 4) (i32.const 1))
25+ (call $call (i64.const 2000) (i32.const 0) (i32.const 20) (i32.const 52) (i32.const 4) (i32.const 56) (i32.const 4) (i32.const 0))
1726 drop
1827 )
1928 )
2029
21- (export "1" (func $callback))
2230 (func $callback (param $result i32)
2331 (if (i32.eq (i32.const 1) (get_local $result))
2432 (return)
2533 )
tests/interface/sstore.wasmView
@@ -1,3 +1,3 @@
11 asm 
2-``0ethereum storageStoreethereum storageLoadmainmemory12
3-L~@AB���݄ƥ�7A�AA @A�A�A @A�)B���݄ƥ�R@
2+``0ethereum storageStoreethereum storageLoadpmemorycallbackmain A 
3+L~@AB���݄ƥ�7A�AA @A�A�A @A�)B���݄ƥ�R@
tests/interface/sstore.wastView
@@ -3,27 +3,35 @@
33 (import "ethereum" "storageStore" (func $sstore (param i32 i32 i32)))
44 (import "ethereum" "storageLoad" (func $sload (param i32 i32 i32)))
55
66 (memory 1)
7- (export "main" (func $main))
87 (export "memory" (memory 0))
8+
9+ (table
10+ (export "callback")
11+ anyfunc
12+ (elem
13+ $callback
14+ $callback2
15+ )
16+ )
17+
918 (func $main
19+ (export "main")
1020 (local $temp i64)
1121 (block
1222 ;; should roundtrip store and load a value from storage
1323 (i64.store (i32.const 0) (i64.const 173553719826446289))
14- (call $sstore (i32.const 64) (i32.const 0) (i32.const 1))
24+ (call $sstore (i32.const 64) (i32.const 0) (i32.const 0))
1525 )
1626 )
1727
18- (export "1" (func $callback))
1928 (func $callback
2029 (block
21- (call $sload (i32.const 64) (i32.const 64) (i32.const 2))
30+ (call $sload (i32.const 64) (i32.const 64) (i32.const 1))
2231 )
2332 )
2433
25- (export "2" (func $callback2))
2634 (func $callback2
2735 (block
2836 (if (i64.ne (i64.load (i32.const 64)) (i64.const 173553719826446289))
2937 (unreachable))
tests/interfaceRunner.jsView
@@ -10,9 +10,8 @@
1010
1111 const dir = path.join(__dirname, '/interface')
1212 // get the test names
1313 let tests = fs.readdirSync(dir).filter((file) => file.endsWith('.wast'))
14-// tests = ['callDataSize.wast']
1514
1615 runTests(tests)
1716
1817 function runTests (tests) {
vm.jsView
@@ -36,9 +36,9 @@
3636 */
3737 pushOpsQueue (promise, callbackIndex, intefaceCallback) {
3838 this._opsQueue = Promise.all([this._opsQueue, promise]).then(values => {
3939 const result = intefaceCallback(values.pop())
40- this._instance.exports[callbackIndex.toString()](result)
40+ this._instance.exports.callback.get(callbackIndex)(result)
4141 })
4242 }
4343
4444 sendMessage (message) {

Built with git-ssb-web