git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 276e1f2ef76f665728f308c95464327233c1ba98

convert to 0x0d

wanderer committed on 12/28/2016, 4:55:46 PM
Parent: e46c31f9eba336c3c5c1cec482e028a89c0940be

Files changed

package.jsonchanged
tests/buildTests.jschanged
tests/interface/address.wasmchanged
tests/interface/address.wastchanged
tests/interface/balance.wasmchanged
tests/interface/balance.wastchanged
tests/interface/basic_gas_ops.wasmchanged
tests/interface/basic_gas_ops.wastchanged
tests/interface/call.wasmchanged
tests/interface/call.wastchanged
tests/interface/callDataCopy.wasmchanged
tests/interface/callDataCopy.wastchanged
tests/interface/callDataSize.wasmchanged
tests/interface/callDataSize.wastchanged
tests/interface/callValue.wasmchanged
tests/interface/callValue.wastchanged
tests/interface/caller.wasmchanged
tests/interface/caller.wastchanged
tests/interface/coinbase.wasmchanged
tests/interface/coinbase.wastchanged
tests/interface/origin.wasmchanged
tests/interface/origin.wastchanged
tests/interface/sstore.wasmchanged
tests/interface/sstore.wastchanged
wasm/interface.wasmchanged
wasm/interface.wastchanged
package.jsonView
@@ -4,9 +4,9 @@
44 "description": "This is a JS prototype of the eWASM kernal.",
55 "scripts": {
66 "lint": "standard",
77 "test": "node --harmony --expose-wasm ./tests/interfaceRunner.js",
8- "build": "node ./tests/buildTests.js"
8+ "build": "node ./tests/buildTests.js && ./tools/wabt/out/wast2wasm ./wasm/interface.wast -o ./wasm/interface.wasm"
99 },
1010 "repository": {
1111 "type": "git",
1212 "url": "git+https://github.com/ewasm/ewasm-kernel.git"
tests/buildTests.jsView
@@ -9,6 +9,6 @@
99 // run the tests
1010 for (let testName of tests) {
1111 testName = testName.split('.')[0]
1212 // Compile Command
13- cp.execSync(`${__dirname}/../tools/sexpr-wasm-prototype/out/sexpr-wasm ${dir}/${testName}.wast -o ${dir}/${testName}.wasm`)
13+ cp.execSync(`${__dirname}/../tools/wabt/out/wast2wasm ${dir}/${testName}.wast -o ${dir}/${testName}.wasm`)
1414 }
tests/interface/address.wasmView
@@ -1,3 +1,3 @@
1-asm type@@importethereum
2-getAddressfunctionmemoryexportmaincode +ݐ�������h 
3-
1+asm ``ethereum
2+getAddressmainmemory
3+!@AA)Bݐ�������Q@
tests/interface/address.wastView
@@ -1,15 +1,15 @@
11 ;; starts with an address of 5d48c1018904a172886829bbbd9c6f4a2d06c47b
22 (module
3+ (import "ethereum" "getAddress" (func $address (param i32)))
4+
35 (memory 1)
4-
5- (import $address "ethereum" "getAddress" (param i32))
6- (export "main" 0)
7- (export "a" memory)
6+ (export "main" (func 0))
7+ (export "memory" (memory 0))
88 (func
99 (block
1010 ;; loads the address into memory
11- (call_import $address (i32.const 0))
11+ (call $address (i32.const 0))
1212 (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x72a1048901c1485d))
1313 (return)
1414 )
1515 (unreachable)
tests/interface/balance.wasmView
@@ -1,6 +1,5 @@
1-asm type
2-@@importethereum
3-getBalancefunctionmemoryexport
4-main1code%
5-+��������h 
6-data]H���r�h)���oJ-�{
1+asm 
2+``ethereum
3+getBalancememorymain1
4+'
5+AAA @A)B��������Q@ A ]H���r�h)���oJ-�{
tests/interface/balance.wastView
@@ -1,16 +1,18 @@
11 ;; address of 5d48c1018904a172886829bbbd9c6f4a2d06c47b has a balance of 0x056bc75e2d63100000 (100 ETH)
22 (module
3- (memory 1 (segment 0 "\5d\48\c1\01\89\04\a1\72\88\68\29\bb\bd\9c\6f\4a\2d\06\c4\7b"))
4- (import $balance "ethereum" "getBalance" (param i32 i32 i32))
5- (export "a" memory)
6- (export "main" 0)
7- (func
8- (call_import $balance (i32.const 0) (i32.const 0) (i32.const 1))
3+ (import "ethereum" "getBalance" (func $balance (param i32 i32 i32)))
4+ (memory 1 )
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+ (export "memory" (memory 0))
7+ (export "main" (func $main))
8+ (export "1" (func $callback))
9+
10+ (func $main
11+ (call $balance (i32.const 0) (i32.const 0) (i32.const 1))
912 )
10-
11- (export "1" 1)
12- (func
13+
14+ (func $callback
1315 (block
1416 (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x0500000000000000))
1517 (return)
1618 )
tests/interface/basic_gas_ops.wasmView
@@ -1,4 +1,3 @@
1-asm type @@@import'ethereumuseGasethereum
2-getGasLeftfunctionexporttestcode)'�M 
3-�M 
4-
1+asm  ```)ethereumuseGasethereum
2+getGasLefttest
3+(&@AA�F@ @AA�F@
tests/interface/basic_gas_ops.wastView
@@ -1,22 +1,22 @@
11 ;; starts with 1000 gas
22 (module
3- (import $useGas "ethereum" "useGas" (param i32))
4- (import $gas "ethereum" "getGasLeft" (result i32))
3+ (import "ethereum" "useGas" (func $useGas (param i32)))
4+ (import "ethereum" "getGasLeft" (func $gas(result i32)))
55
6- (export "test" 0)
7- (func
6+ (export "test" (func $main))
7+ (func $main
88 ;; test adding gas
99 (block
10- (call_import $useGas (i32.const 1))
11- (if (i32.eq (call_import $gas) (i32.const 997))
10+ (call $useGas (i32.const 1))
11+ (if (i32.eq (call $gas) (i32.const 997))
1212 (return)
1313 )
1414 (unreachable)
1515 )
1616 (block
17- (call_import $useGas (i32.const 1))
18- (if (i32.eq (call_import $gas) (i32.const 996))
17+ (call $useGas (i32.const 1))
18+ (if (i32.eq (call $gas) (i32.const 996))
1919 (return)
2020 )
2121 (unreachable)
2222 )
tests/interface/call.wasmView
@@ -1,2 +1,2 @@
1-asm type@@@importethereumcallfunctionmemoryexport
2-main1code7)34����3�48 M 
1+asm ```ethereumcallamain1
2+:+@AA6A4A����6A�AAA4AA8AA A F@
tests/interface/call.wastView
@@ -1,26 +1,26 @@
11 ;; starts with an address of 5d48c1018904a172886829bbbd9c6f4a2d06c47b
22 (module
3- (memory 1)
4-
5- (import $call "ethereum" "call" (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32))
6- (export "a" memory)
7- (export "main" 0)
8- (func
3+ (import "ethereum" "call" (func $call (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32)))
4+ (memory 1)
5+ (export "a" (memory 0))
6+ (export "main" (func $main))
7+ (func $main
98 (block
109 ;; Memory layout:
1110 ;; 0 - 20 bytes: address (4)
1211 ;; 20 - 52 bytes: value (0)
1312 ;; 52 - 56 bytes: data (0x42004200)
1413 ;; 56 - 60 bytes: result
1514 (i32.store (i32.const 0) (i32.const 0x4))
1615 (i32.store (i32.const 52) (i32.const 0x42004200))
17- (call_import $call (i32.const 2000) (i32.const 0) (i32.const 20) (i32.const 52) (i32.const 4) (i32.const 56) (i32.const 4) (i32.const 1))
16+ (call $call (i32.const 2000) (i32.const 0) (i32.const 20) (i32.const 52) (i32.const 4) (i32.const 56) (i32.const 4) (i32.const 1))
17+ drop
1818 )
1919 )
2020
21- (export "1" 1)
22- (func (param $result i32)
21+ (export "1" (func $callback))
22+ (func $callback (param $result i32)
2323 (if (i32.eq (i32.const 1) (get_local $result))
2424 (return)
2525 )
2626 (unreachable)
tests/interface/callDataCopy.wasmView
@@ -1,3 +1,3 @@
1-asm type
2-@@importethereum callDataCopyfunctionmemoryexportmaincode#!+��Ճ��ܲ h 
3-
1+asm 
2+``ethereum callDataCopymemorymain
3+$"@AAAA)B��Ճ��ܲ Q@
tests/interface/callDataCopy.wastView
@@ -1,14 +1,13 @@
11 ;; calldata is "596f75206172652077616974...", but i64.load works in LSB mode
22 (module
3+ (import "ethereum" "callDataCopy" (func $callDataCopy (param i32 i32 i32)))
34 (memory 1)
4- (import $callDataCopy "ethereum" "callDataCopy" (param i32 i32 i32))
5-
6- (export "memory" memory)
7- (export "main" 0)
8- (func
5+ (export "memory" (memory 0))
6+ (export "main" (func $main))
7+ (func $main
98 (block
10- (call_import $callDataCopy (i32.const 0) (i32.const 0) (i32.const 8))
9+ (call $callDataCopy (i32.const 0) (i32.const 0) (i32.const 8))
1110 (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x2065726120756f59))
1211 (return)
1312 )
1413 (unreachable)
tests/interface/callDataSize.wasmView
@@ -1,2 +1,2 @@
1-asm type@@importethereumgetCallDataSizefunctionmemoryexportmaincode�h 
2-
1+asm `~`ethereumgetCallDataSizemain
2+@B�Q@
tests/interface/callDataSize.wastView
@@ -1,12 +1,11 @@
11 (module
2+ (import"ethereum" "getCallDataSize" (func $callDataSize (result i64)))
23 (memory 1)
3- (import $callDataSize "ethereum" "getCallDataSize" (result i64))
4-
5- (export "main" 0)
6- (func
4+ (export "main" (func $main))
5+ (func $main
76 (block
8- (if (i64.eq (call_import $callDataSize) (i64.const 277))
7+ (if (i64.eq (call $callDataSize) (i64.const 277))
98 (return)
109 )
1110 (unreachable)
1211 )
tests/interface/callValue.wasmView
@@ -1,2 +1,2 @@
1-asm type@@importethereum getCallValuefunctionmemoryexportmaincode+��������h 
2-
1+asm ``ethereum getCallValue amain
2+ @AA)B��������Q@
tests/interface/callValue.wastView
@@ -1,14 +1,13 @@
11 ;; call value of 0x056bc75e2d63100000 (100 ETH)
22 (module
3+ (import "ethereum" "getCallValue" (func $callValue (param i32)))
34 (memory 1)
4- (import $callValue "ethereum" "getCallValue" (param i32))
5-
6- (export "a" memory)
7- (export "main" 0)
8- (func
5+ (export "a" (memory 0))
6+ (export "main" (func $main))
7+ (func $main
98 (block
10- (call_import $callValue (i32.const 0))
9+ (call $callValue (i32.const 0))
1110 (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x0500000000000000))
1211 (return)
1312 )
1413 (unreachable)
tests/interface/caller.wasmView
@@ -1,2 +1,2 @@
1-asm type@@importethereum getCallerfunctionmemoryexportmaincode +ݐ�������h 
2-
1+asm ``ethereum getCaller maina
2+!@AA)Bݐ�������Q@
tests/interface/caller.wastView
@@ -1,15 +1,14 @@
11 ;; starts with an caller of 5d48c1018904a172886829bbbd9c6f4a2d06c47b
22 (module
3+ (import "ethereum" "getCaller" (func $caller (param i32)))
34 (memory 1)
4- (import $caller "ethereum" "getCaller" (param i32))
5-
6- (export "main" 0)
7- (export "a" memory)
8- (func
5+ (export "main" (func $main))
6+ (export "a" (memory 0))
7+ (func $main
98 (block
109 ;; loads the caller into memory
11- (call_import $caller (i32.const 0))
10+ (call $caller (i32.const 0))
1211 (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x72a1048901c1485d))
1312 (return)
1413 )
1514 (unreachable)
tests/interface/coinbase.wasmView
@@ -1,2 +1,2 @@
1-asm type@@importethereumgetBlockCoinbasefunctionmemoryexportmaincode +ݐ�������h 
2-
1+asm ``ethereumgetBlockCoinbase maina
2+!@AA)Bݐ�������Q@
tests/interface/coinbase.wastView
@@ -1,15 +1,14 @@
11 ;; starts with a coinbase of 5d48c1018904a172886829bbbd9c6f4a2d06c47b
22 (module
3+ (import "ethereum" "getBlockCoinbase" (func $coinbase (param i32)))
34 (memory 1)
4-
5- (import $coinbase "ethereum" "getBlockCoinbase" (param i32))
6- (export "main" 0)
7- (export "a" memory)
8- (func
5+ (export "main" (func $main))
6+ (export "a" (memory 0))
7+ (func $main
98 (block
109 ;; loads the coinbase into memory
11- (call_import $coinbase (i32.const 0))
10+ (call $coinbase (i32.const 0))
1211 (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x72a1048901c1485d))
1312 (return)
1413 )
1514 (unreachable)
tests/interface/origin.wasmView
@@ -1,2 +1,2 @@
1-asm type@@importethereum getTxOriginfunctionmemoryexportmaincode +ݐ�������h 
2-
1+asm ``ethereum getTxOrigin maina
2+!@AA)Bݐ�������Q@
tests/interface/origin.wastView
@@ -1,15 +1,15 @@
11 ;; starts with an origin of 5d48c1018904a172886829bbbd9c6f4a2d06c47b
22 (module
3+ (import "ethereum" "getTxOrigin" (func $origin (param i32)))
34 (memory 1)
4- (import $origin "ethereum" "getTxOrigin" (param i32))
55
6- (export "main" 0)
7- (export "a" memory)
8- (func
6+ (export "main" (func $main))
7+ (export "a" (memory 0))
8+ (func $main
99 (block
1010 ;; loads the address into memory
11- (call_import $origin (i32.const 0))
11+ (call $origin (i32.const 0))
1212 (if (i64.eq (i64.load (i32.const 0)) (i64.const 0x72a1048901c1485d))
1313 (return)
1414 )
1515 (unreachable)
tests/interface/sstore.wasmView
@@ -1,3 +1,3 @@
1-asm type
2-@@import.ethereum storageStoreethereum storageLoadfunctionmemoryexport main12codeG���݄ƥ�4����+���݄ƥ�i
3-
1+asm 
2+``0ethereum storageStoreethereum storageLoadmaina12
3+L~@AB���݄ƥ�7A�AA @A�A�A @A�)B���݄ƥ�R@
tests/interface/sstore.wastView
@@ -1,30 +1,30 @@
11 ;; starts with an caller of 5d48c1018904a172886829bbbd9c6f4a2d06c47b
22 (module
3+ (import "ethereum" "storageStore" (func $sstore (param i32 i32 i32)))
4+ (import "ethereum" "storageLoad" (func $sload (param i32 i32 i32)))
5+
36 (memory 1)
4- (import $sstore "ethereum" "storageStore" (param i32 i32 i32))
5- (import $sload "ethereum" "storageLoad" (param i32 i32 i32))
6-
7- (export "main" 0)
8- (export "a" memory)
9- (func
7+ (export "main" (func $main))
8+ (export "a" (memory 0))
9+ (func $main
1010 (local $temp i64)
1111 (block
1212 ;; should roundtrip store and load a value from storage
1313 (i64.store (i32.const 0) (i64.const 173553719826446289))
14- (call_import $sstore (i32.const 64) (i32.const 0) (i32.const 1))
14+ (call $sstore (i32.const 64) (i32.const 0) (i32.const 1))
1515 )
1616 )
1717
18- (export "1" 1)
19- (func
18+ (export "1" (func $callback))
19+ (func $callback
2020 (block
21- (call_import $sload (i32.const 64) (i32.const 64) (i32.const 2))
21+ (call $sload (i32.const 64) (i32.const 64) (i32.const 2))
2222 )
2323 )
2424
25- (export "2" 2)
26- (func
25+ (export "2" (func $callback2))
26+ (func $callback2
2727 (block
2828 (if (i64.ne (i64.load (i32.const 64)) (i64.const 173553719826446289))
2929 (unreachable))
3030
wasm/interface.wasmView
@@ -1,2 +1,3 @@
1-asm type+@@@ @@@importV interfaceuseGas interfacegetGasLeftHigh interface getGasLeftLow interfacecallfunctionexportuseGas
2-getGasLeftcallcodeB  f��� e�[  f�� 
1+asm +``` `~`~`~Z interfaceuseGas interfacegetGasLeftHigh interface getGasLeftLow interfacecalluseGas
2+getGasLeftcall
3+? B �� � AA�B ��|  B �� �       
wasm/interface.wastView
@@ -1,36 +1,37 @@
11 (module
2- ;; useGas
3- (import $useGas "interface" "useGas" (param i32 i32))
2+ (import "interface" "useGas" (func $useGas (param i32 i32)))
3+ (import "interface" "getGasLeftHigh" (func $getGasLeftHigh (result i32)))
4+ (import "interface" "getGasLeftLow" (func $getGasLeftLow (result i32)))
5+ (import "interface" "call" (func $call (param i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32)))
6+
7+ (export "useGas" (func $useGasShim))
8+ (export "getGasLeft" (func $getGasLeft))
9+ (export "call" (func $callShim))
10+
411 (func $useGasShim
512 (param $amount i64)
6- (call_import $useGas
13+ (call $useGas
714 (i32.wrap/i64
815 (i64.shr_u (get_local $amount) (i64.const 32)))
916 (i32.wrap/i64 (get_local $amount)))
10- )
11- (export "useGas" $useGasShim)
17+ )
1218
13- ;; getGasLeft
14- (import $getGasLeftHigh "interface" "getGasLeftHigh" (result i32))
15- (import $getGasLeftLow "interface" "getGasLeftLow" (result i32))
1619 (func $getGasLeft
1720 (result i64)
18- (call_import $useGas (i32.const 0) (i32.const 2))
21+ (call $useGas (i32.const 0) (i32.const 2))
1922 (return
2023 (i64.add
21- (i64.shl (i64.extend_u/i32 (call_import $getGasLeftHigh)) (i64.const 32))
22- (i64.extend_u/i32 (call_import $getGasLeftLow))))
24+ (i64.shl (i64.extend_u/i32 (call $getGasLeftHigh)) (i64.const 32))
25+ (i64.extend_u/i32 (call $getGasLeftLow))))
2326 )
24- (export "getGasLeft" $getGasLeft)
2527
2628 ;; call
2729 ;; (import $call "ethereum" "call" (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32))
28- (import $call "interface" "call" (param i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32))
2930 (func $callShim
3031 (param i64 i32 i32 i32 i32 i32 i32 i32)
3132 (result i32)
32- (call_import $call
33+ (call $call
3334 (i32.wrap/i64
3435 (i64.shr_u (get_local 0) (i64.const 32)))
3536 (i32.wrap/i64 (get_local 0))
3637 (get_local 1)
@@ -41,6 +42,5 @@
4142 (get_local 6)
4243 (get_local 7)
4344 )
4445 )
45- (export "call" $callShim)
4646 )

Built with git-ssb-web