Commit 05c4e2d027ee79f709d87c92e48f83e9cb3489ad
Merge branch 'master' into env
wanderer committed on 1/20/2017, 5:40:25 PMParent: ccc86c04a14c0346d7695e768be928faf4c41267
Parent: de87b9b68f0638e5deda64385e6c49c506325b8e
Files changed
package.json | changed |
tests/interface/balance.wasm | changed |
tests/interface/balance.wast | changed |
tests/interface/call.wasm | changed |
tests/interface/call.wast | changed |
tests/interface/sstore.wasm | changed |
tests/interface/sstore.wast | changed |
vm.js | changed |
package.json | ||
---|---|---|
@@ -37,9 +37,9 @@ | ||
37 | 37 | ] |
38 | 38 | }, |
39 | 39 | "dependencies": { |
40 | 40 | "bn.js": "^4.11.6", |
41 | - "ethereumjs-block": "^1.2.2", | |
41 | + "ethereumjs-block": "^1.4.1", | |
42 | 42 | "ethereumjs-tx": "^1.1.2", |
43 | 43 | "ethereumjs-util": "^5.0.0", |
44 | 44 | "merkle-trie": "0.1.2", |
45 | 45 | "promise-queue": "^2.2.3" |
tests/interface/balance.wasm | ||
---|---|---|
@@ -1,5 +1,5 @@ | ||
1 | 1 | asm |
2 | 2 | ` ` ethereum |
3 | -getBalance memory main 1 | |
3 | +getBalance p memory main callback A | |
4 | 4 | ' |
5 | - A A A @A ) B��������Q@ A ]H���r�h)���oJ-�{ | |
5 | + A A A @A ) B��������Q@ A ]H���r�h)���oJ-�{ |
tests/interface/balance.wast | ||
---|---|---|
@@ -4,12 +4,19 @@ | ||
4 | 4 | (memory 1 ) |
5 | 5 | (data (i32.const 0) "\5d\48\c1\01\89\04\a1\72\88\68\29\bb\bd\9c\6f\4a\2d\06\c4\7b") |
6 | 6 | (export "memory" (memory 0)) |
7 | 7 | (export "main" (func $main)) |
8 | - (export "1" (func $callback)) | |
9 | 8 | |
9 | + (table | |
10 | + (export "callback") | |
11 | + anyfunc | |
12 | + (elem | |
13 | + $callback | |
14 | + ) | |
15 | + ) | |
16 | + | |
10 | 17 | (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)) | |
12 | 19 | ) |
13 | 20 | |
14 | 21 | (func $callback |
15 | 22 | (block |
tests/interface/call.wasm | ||
---|---|---|
@@ -1,2 +1,2 @@ | ||
1 | - asm `~` ` ethereumcall memory main 1 | |
2 | -:+ @A A6 A4A����6 B�A AA4AA8AA A F@ | |
1 | + asm `~` ` ethereumcall p memory main callback A | |
2 | +:+ @A A6 A4A����6 B�A AA4AA8AA A F@ |
tests/interface/call.wast | ||
---|---|---|
@@ -3,8 +3,17 @@ | ||
3 | 3 | (import "ethereum" "call" (func $call (param i64 i32 i32 i32 i32 i32 i32 i32) (result i32))) |
4 | 4 | (memory 1) |
5 | 5 | (export "memory" (memory 0)) |
6 | 6 | (export "main" (func $main)) |
7 | + | |
8 | + (table | |
9 | + (export "callback") | |
10 | + anyfunc | |
11 | + (elem | |
12 | + $callback | |
13 | + ) | |
14 | + ) | |
15 | + | |
7 | 16 | (func $main |
8 | 17 | (block |
9 | 18 | ;; Memory layout: |
10 | 19 | ;; 0 - 20 bytes: address (4) |
@@ -12,14 +21,13 @@ | ||
12 | 21 | ;; 52 - 56 bytes: data (0x42004200) |
13 | 22 | ;; 56 - 60 bytes: result |
14 | 23 | (i32.store (i32.const 0) (i32.const 0x4)) |
15 | 24 | (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)) | |
17 | 26 | drop |
18 | 27 | ) |
19 | 28 | ) |
20 | 29 | |
21 | - (export "1" (func $callback)) | |
22 | 30 | (func $callback (param $result i32) |
23 | 31 | (if (i32.eq (i32.const 1) (get_local $result)) |
24 | 32 | (return) |
25 | 33 | ) |
tests/interface/sstore.wasm | ||
---|---|---|
@@ -1,3 +1,3 @@ | ||
1 | 1 | asm |
2 | -` ` 0ethereumstorageStore ethereumstorageLoad main memory 1 2 | |
3 | -L~@A B���݄ƥ�7 A� A A @A� A� A @A� ) B���݄ƥ�R@ | |
2 | +` ` 0ethereumstorageStore ethereumstorageLoad p memory callback main A | |
3 | +L~@A B���݄ƥ�7 A� A A @A� A� A @A� ) B���݄ƥ�R@ |
tests/interface/sstore.wast | ||
---|---|---|
@@ -3,27 +3,35 @@ | ||
3 | 3 | (import "ethereum" "storageStore" (func $sstore (param i32 i32 i32))) |
4 | 4 | (import "ethereum" "storageLoad" (func $sload (param i32 i32 i32))) |
5 | 5 | |
6 | 6 | (memory 1) |
7 | - (export "main" (func $main)) | |
8 | 7 | (export "memory" (memory 0)) |
8 | + | |
9 | + (table | |
10 | + (export "callback") | |
11 | + anyfunc | |
12 | + (elem | |
13 | + $callback | |
14 | + $callback2 | |
15 | + ) | |
16 | + ) | |
17 | + | |
9 | 18 | (func $main |
19 | + (export "main") | |
10 | 20 | (local $temp i64) |
11 | 21 | (block |
12 | 22 | ;; should roundtrip store and load a value from storage |
13 | 23 | (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)) | |
15 | 25 | ) |
16 | 26 | ) |
17 | 27 | |
18 | - (export "1" (func $callback)) | |
19 | 28 | (func $callback |
20 | 29 | (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)) | |
22 | 31 | ) |
23 | 32 | ) |
24 | 33 | |
25 | - (export "2" (func $callback2)) | |
26 | 34 | (func $callback2 |
27 | 35 | (block |
28 | 36 | (if (i64.ne (i64.load (i32.const 64)) (i64.const 173553719826446289)) |
29 | 37 | (unreachable)) |
vm.js | ||
---|---|---|
@@ -33,9 +33,9 @@ | ||
33 | 33 | */ |
34 | 34 | pushOpsQueue: (promise, callbackIndex, intefaceCallback) => { |
35 | 35 | this._opsQueue = Promise.all([this._opsQueue, promise]).then(values => { |
36 | 36 | const result = intefaceCallback(values.pop()) |
37 | - instance.exports[callbackIndex.toString()](result) | |
37 | + instance.exports.callback.get(callbackIndex)(result) | |
38 | 38 | }) |
39 | 39 | }, |
40 | 40 | memory: () => { |
41 | 41 | return instance.exports.memory.buffer |
Built with git-ssb-web