Commit a2c3cdf53481b4f87fc6fa54cbd9947efc9c6985
get{8,32}Memory
Norton Wang committed on 3/5/2018, 11:11:47 PMParent: bb6ef21471bd09c766ab63064037d371607de931
Files changed
wasmContainer.js | changed |
wasmContainer.js | ||
---|---|---|
@@ -191,9 +191,9 @@ | ||
191 | 191 | }, |
192 | 192 | internalize: (elemRef, srcOffset, sinkOffset, length) => { |
193 | 193 | let table = this.refs.get(elemRef, 'elem') |
194 | 194 | 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) | |
196 | 196 | mem.set(buf) |
197 | 197 | }, |
198 | 198 | length (elemRef) { |
199 | 199 | let elem = this.refs.get(elemRef, 'elem') |
@@ -260,9 +260,9 @@ | ||
260 | 260 | numOfGlobals = this.json.globals.length |
261 | 261 | if (numOfGlobals) { |
262 | 262 | this.actor.storage = [] |
263 | 263 | this.instance.exports.getter_globals() |
264 | - const mem = this.getMemory(0, numOfGlobals) | |
264 | + const mem = this.get32Memory(0, numOfGlobals) | |
265 | 265 | while (numOfGlobals--) { |
266 | 266 | const ref = mem[numOfGlobals] |
267 | 267 | this.actor.storage.push(this.refs.get(ref, this.json.globals[numOfGlobals].type)) |
268 | 268 | } |
@@ -320,12 +320,16 @@ | ||
320 | 320 | this.json = json |
321 | 321 | this.modSelf = ModuleRef.fromMetaJSON(json, this.actor.id) |
322 | 322 | } |
323 | 323 | |
324 | - getMemory (offset, length) { | |
324 | + get8Memory (offset, length) { | |
325 | 325 | return new Uint8Array(this.instance.exports.memory.buffer, offset, length) |
326 | 326 | } |
327 | 327 | |
328 | + get32Memory (offset, length) { | |
329 | + return new Uint32Array(this.instance.exports.memory.buffer, offset, length) | |
330 | + } | |
331 | + | |
328 | 332 | static get typeId () { |
329 | 333 | return 9 |
330 | 334 | } |
331 | 335 | } |
Built with git-ssb-web