git ssb

0+

wanderer🌟 / js-primea-wasm-container



Commit dedbdb9619e01004a741639e07faafaae9d66039

Merge pull request #20 from primea/greenkeeper/primea-hypervisor-0.3.0

Update primea-hypervisor to the latest version 🚀
wanderer authored on 10/22/2017, 8:55:02 PM
GitHub committed on 10/22/2017, 8:55:02 PM
Parent: 8e8b072392a8aac05d02676a611c3d06af113986
Parent: 78df5549b3d8b084519490f3fb698ff93970c907

Files changed

index.jschanged
package-lock.jsonchanged
package.jsonchanged
tests/index.jschanged
index.jsView
@@ -16,9 +16,9 @@
1616 this.referanceMap = new ReferanceMap()
1717 }
1818
1919 async onCreation (message) {
20- let code = message.data.code
20 + let code = this.kernel.code
2121 if (!WebAssembly.validate(code)) {
2222 throw new Error('invalid wasm binary')
2323 } else {
2424 for (const name in this.imports) {
@@ -57,9 +57,9 @@
5757 }
5858 }
5959 }
6060
61- const result = await WebAssembly.instantiate(this.kernel.state.code, importMap)
61 + const result = await WebAssembly.instantiate(this.kernel.code, importMap)
6262 this.instance = result.instance
6363
6464 // add the message and ports to the refereance map
6565 const messageRef = this.referanceMap.add(message)
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 183413 bytes
New file size: 182822 bytes
package.jsonView
@@ -25,9 +25,9 @@
2525 "dfinity-radix-tree": "0.0.4",
2626 "coveralls": "^3.0.0",
2727 "level": "^2.0.0",
2828 "nyc": "^11.2.1",
29- "primea-hypervisor": "0.2.0",
29 + "primea-hypervisor": "0.3.0",
3030 "primea-message": "0.0.2",
3131 "standard": "^10.0.0",
3232 "tape": "^4.6.3",
3333 "wast2wasm": "0.0.1"
tests/index.jsView
@@ -48,12 +48,9 @@
4848
4949 const port = hypervisor.creationService.getPort()
5050
5151 let instance = await hypervisor.send(port, new Message({
52- data: {
53- type: WasmContainer.typeId,
54- code: main
55- }
52 + data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), main])
5653 }))
5754 instance.message(instance.createMessage())
5855 })
5956
@@ -68,12 +65,9 @@
6865 const ports = hypervisor.createChannel()
6966 const port = hypervisor.creationService.getPort()
7067
7168 hypervisor.send(port, new Message({
72- data: {
73- type: WasmContainer.typeId,
74- code: main
75- },
69 + data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), main]),
7670 ports: ports
7771 }))
7872 })
7973
@@ -88,12 +82,9 @@
8882
8983 const port = hypervisor.creationService.getPort()
9084
9185 hypervisor.send(port, new Message({
92- data: {
93- type: WasmContainer.typeId,
94- code: readMem
95- }
86 + data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), readMem])
9687 }))
9788 })
9889
9990 tape('write mem', async t => {
@@ -105,12 +96,9 @@
10596 })
10697
10798 const port = hypervisor.creationService.getPort()
10899 const root = await hypervisor.send(port, new Message({
109- data: {
110- type: WasmContainer.typeId,
111- code: readMem
112- }
100 + data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), readMem])
113101 }))
114102 const mem = root.container.getMemory(0, 1)
115103 t.equals(mem[0], 9)
116104 t.end()
@@ -126,12 +114,9 @@
126114 })
127115
128116 const port = hypervisor.creationService.getPort()
129117 await hypervisor.send(port, new Message({
130- data: {
131- type: WasmContainer.typeId,
132- code: callBackWasm
133- }
118 + data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), callBackWasm])
134119 }))
135120 })
136121
137122 tape('wasm container - invalid', async t => {
@@ -142,12 +127,9 @@
142127 test: testInterface(t)
143128 })
144129
145130 const message = new Message({
146- data: {
147- type: WasmContainer.typeId,
148- code: Buffer.from([0x00])
149- }
131 + data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), Buffer.from([0])])
150132 })
151133
152134 const rp = message.responsePort = {destPort: {messages: []}}
153135
@@ -166,12 +148,8 @@
166148 constructor (wasmContainer) {
167149 this.wasmContainer = wasmContainer
168150 }
169151
170- readMem (offset) {
171- return this.wasmContainer.getMemory(offset, 1)
172- }
173-
174152 async callback (cb) {
175153 const promise = new Promise((resolve, reject) => {
176154 resolve()
177155 })
@@ -179,9 +157,9 @@
179157 this.wasmContainer.execute(cb)
180158 }
181159
182160 static initialize (code) {
183- t.equals(code, callBackWasm)
161 + t.deepEquals(code, callBackWasm)
184162 return code
185163 }
186164 }
187165
@@ -192,10 +170,7 @@
192170 })
193171
194172 const port = hypervisor.creationService.getPort()
195173 hypervisor.send(port, new Message({
196- data: {
197- type: WasmContainer.typeId,
198- code: callBackWasm
199- }
174 + data: Buffer.concat([Buffer.from([0]), Buffer.from([WasmContainer.typeId]), callBackWasm])
200175 }))
201176 })

Built with git-ssb-web