git ssb

0+

wanderer🌟 / js-primea-wasm-container



Commit f8edd54b6f0aad9dea31187b70342bb2abee2659

fix internalize

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 4/5/2018, 1:16:16 AM
Parent: 20210278852d79f3494721ea3f9eb36c5a93a767

Files changed

index.jschanged
tests/index.jschanged
tests/wasm/link.wasmchanged
tests/wasm/memory.wasmchanged
tests/wasm/storage.wasmchanged
tests/wasm/table.wasmchanged
tests/wast/link.wastchanged
tests/wast/memory.wastchanged
tests/wast/storage.wastchanged
tests/wast/table.wastchanged
index.jsView
@@ -162,9 +162,9 @@
162162 externalize: (index, length) => {
163163 const data = Buffer.from(this.get8Memory(index, length))
164164 return self.refs.add(data, 'data')
165165 },
166- internalize: (dataRef, srcOffset, sinkOffset, length) => {
166+ internalize: (sinkOffset, length, dataRef, srcOffset) => {
167167 let data = self.refs.get(dataRef, 'data')
168168 data = data.subarray(srcOffset, length)
169169 const mem = self.get8Memory(sinkOffset, data.length)
170170 mem.set(data)
@@ -184,9 +184,9 @@
184184 objects.unshift(obj)
185185 }
186186 return this.refs.add(objects, 'elem')
187187 },
188- internalize: (elemRef, srcOffset, sinkOffset, length) => {
188+ internalize: (sinkOffset, length, elemRef, srcOffset) => {
189189 let table = self.refs.get(elemRef, 'elem')
190190 const buf = table.slice(srcOffset, srcOffset + length).map(obj => self.refs.add(obj, getType(obj)))
191191 const mem = self.get32Memory(sinkOffset, length)
192192 mem.set(buf)
tests/index.jsView
@@ -392,9 +392,8 @@
392392 }
393393 })
394394
395395 tape('out of gas', async t => {
396- t.plan(1)
397396 tester = t
398397 const tree = new RadixTree({db})
399398 let wasm = fs.readFileSync(WASM_PATH + '/i64.wasm')
400399
@@ -406,8 +405,8 @@
406405
407406 const message = new Message({
408407 funcRef
409408 }).on('execution:error', e => {
410- t.pass()
409+ t.end()
411410 })
412411 hypervisor.send(message)
413412 })
tests/wasm/link.wasmView
@@ -1,3 +1,3 @@
11 asm types`n typeMap#```````� testchecktestprintmemory externalizestoragegetstoragesetelem externalizeelem internalizeelemlengthfunc internalizelinkwraplinkunwrappA  memorytablemain load A 
2-EAAA  6AA  $AAA(A
2+EAAA  6AA  $AAA(A
33 A# A A hello world
tests/wasm/memory.wasmView
@@ -1,3 +1,3 @@
11 asm````;memory externalizememory internalizememorylengthmemorytest
2-AA"AA 
2+AAA" A
33 A test
tests/wasm/storage.wasmView
@@ -1,2 +1,2 @@
11 asm types`n typeMap``````�testchecktestprintmemory externalizestoragegetstoragesetelem externalizeelem internalizefunc internalizep memorytablemainload
2-4AAA 6AA AAAA A(A A hello world
2+4AAA 6AA AAAA A(A A hello world
tests/wasm/table.wasmView
@@ -1,3 +1,3 @@
11 asm```<elem externalizememory externalizeelem internalizememorytest
2-(&AAAAAA66AAAAA
2+(&AAA6AAA6AAAAA
33 A test
tests/wast/link.wastView
@@ -29,12 +29,12 @@
2929 (func $load (param $egress i32)
3030 (set_global $egressRef (get_local $egress))
3131
3232 (call $elem.internalize
33- (call $storage.get)
3433 (i32.const 0)
35- (i32.const 0)
36- (call $elem.length (call $storage.get)))
34+ (call $elem.length (call $storage.get))
35+ (call $storage.get)
36+ (i32.const 0))
3737
3838 (call $link.unwrap
3939 (i32.load (i32.const 0))
4040 (i32.const 0)))
tests/wast/memory.wastView
@@ -6,13 +6,14 @@
66 (data (i32.const 0) "test")
77 (func $test
88 (local $dataRef i32)
99 (call $internalize
10- (tee_local $dataRef
11- (call $externalize
12- (i32.const 0)
13- (i32.const 4)))
14- (i32.const 0)
15- (i32.const 5)
16- (call $length (get_local $dataRef)))
10+ (i32.const 5)
11+ (call $length
12+ (tee_local $dataRef
13+ (call $externalize
14+ (i32.const 0)
15+ (i32.const 4))))
16+ (get_local $dataRef)
17+ (i32.const 0))
1718 )
1819 (export "test" (func $test)))
tests/wast/storage.wastView
@@ -20,13 +20,12 @@
2020 (call $elem.externalize (i32.const 0) (i32.const 1))))
2121
2222 (func $load (param $egress i32)
2323 (call $elem.internalize
24- (call $storage.get)
2524 (i32.const 0)
26- (i32.const 0)
2725 (i32.const 1)
28- )
26+ (call $storage.get)
27+ (i32.const 0))
2928
3029 (call $func.internalize
3130 (i32.const 0)
3231 (get_local $egress))
tests/wast/table.wastView
@@ -4,22 +4,20 @@
44 (import "elem" "internalize" (func $internalize (param i32 i32 i32 i32)))
55 (memory (export "memory") 1)
66 (data (i32.const 0) "test")
77 (func $test
8- (i32.const 0)
9- (call $mem_externalize (i32.const 0) (i32.const 4))
10- (i32.const 4)
11- (call $mem_externalize (i32.const 0) (i32.const 4))
12- (i32.store)
13- (i32.store)
8+ (i32.store
9+ (i32.const 0)
10+ (call $mem_externalize (i32.const 0) (i32.const 4)))
11+ (i32.store
12+ (i32.const 4)
13+ (call $mem_externalize (i32.const 0) (i32.const 4)))
1414
15-
16- i32.const 0
17- i32.const 2
18- call $externalize
19-
20- i32.const 0
21- i32.const 8
22- i32.const 2
23- call $internalize
15+ (call $internalize
16+ (i32.const 8)
17+ (i32.const 2)
18+ (call $externalize
19+ (i32.const 0)
20+ (i32.const 2))
21+ (i32.const 0))
2422 )
2523 (export "test" (func $test)))

Built with git-ssb-web