git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit a2c3cdf53481b4f87fc6fa54cbd9947efc9c6985

get{8,32}Memory

Norton Wang committed on 3/5/2018, 11:11:47 PM
Parent: bb6ef21471bd09c766ab63064037d371607de931

Files changed

wasmContainer.jschanged
wasmContainer.jsView
@@ -191,9 +191,9 @@
191191 },
192192 internalize: (elemRef, srcOffset, sinkOffset, length) => {
193193 let table = this.refs.get(elemRef, 'elem')
194194 const buf = table.slice(srcOffset, srcOffset + length).map(obj => this.refs.add(obj))
195- const mem = this.getMemory(sinkOffset, length)
195+ const mem = this.get32Memory(sinkOffset, length)
196196 mem.set(buf)
197197 },
198198 length (elemRef) {
199199 let elem = this.refs.get(elemRef, 'elem')
@@ -260,9 +260,9 @@
260260 numOfGlobals = this.json.globals.length
261261 if (numOfGlobals) {
262262 this.actor.storage = []
263263 this.instance.exports.getter_globals()
264- const mem = this.getMemory(0, numOfGlobals)
264+ const mem = this.get32Memory(0, numOfGlobals)
265265 while (numOfGlobals--) {
266266 const ref = mem[numOfGlobals]
267267 this.actor.storage.push(this.refs.get(ref, this.json.globals[numOfGlobals].type))
268268 }
@@ -320,12 +320,16 @@
320320 this.json = json
321321 this.modSelf = ModuleRef.fromMetaJSON(json, this.actor.id)
322322 }
323323
324- getMemory (offset, length) {
324+ get8Memory (offset, length) {
325325 return new Uint8Array(this.instance.exports.memory.buffer, offset, length)
326326 }
327327
328+ get32Memory (offset, length) {
329+ return new Uint32Array(this.instance.exports.memory.buffer, offset, length)
330+ }
331+
328332 static get typeId () {
329333 return 9
330334 }
331335 }

Built with git-ssb-web