Commit 18c73fcab36d8356ed6384cceb0fa31e40c3895c
getMemory -> get8Memory
Norton Wang committed on 3/5/2018, 11:18:40 PMParent: a2c3cdf53481b4f87fc6fa54cbd9947efc9c6985
Files changed
tests/wasmContainer.js | changed |
wasmContainer.js | changed |
tests/wasmContainer.js | ||
---|---|---|
@@ -209,10 +209,10 @@ | ||
209 | 209 | const funcRef = module.getFuncRef('test') |
210 | 210 | funcRef.gas = 10000 |
211 | 211 | |
212 | 212 | const message = new Message({funcRef}).on('done', actor => { |
213 | - const a = actor.container.getMemory(0, 5) | |
214 | - const b = actor.container.getMemory(5, 5) | |
213 | + const a = actor.container.get8Memory(0, 5) | |
214 | + const b = actor.container.get8Memory(5, 5) | |
215 | 215 | t.deepEquals(a, b, 'should copy memory correctly') |
216 | 216 | }) |
217 | 217 | hypervisor.send(message) |
218 | 218 | }) |
@@ -233,10 +233,10 @@ | ||
233 | 233 | const funcRef = module.getFuncRef('test') |
234 | 234 | funcRef.gas = 10000 |
235 | 235 | |
236 | 236 | const message = new Message({funcRef}).on('done', actor => { |
237 | - const a = actor.container.getMemory(0, 8) | |
238 | - const b = actor.container.getMemory(8, 8) | |
237 | + const a = actor.container.get8Memory(0, 8) | |
238 | + const b = actor.container.get8Memory(8, 8) | |
239 | 239 | t.deepEquals(a, b, 'should copy memory correctly') |
240 | 240 | }) |
241 | 241 | hypervisor.send(message) |
242 | 242 | }) |
@@ -272,9 +272,9 @@ | ||
272 | 272 | const message = new Message({ |
273 | 273 | funcRef |
274 | 274 | }).on('done', actor => { |
275 | 275 | resolve() |
276 | - const b = actor.container.getMemory(5, 4) | |
276 | + const b = actor.container.get8Memory(5, 4) | |
277 | 277 | const result = Buffer.from(b).toString() |
278 | 278 | t.deepEquals(result, 'test', 'should copy memory correctly') |
279 | 279 | }) |
280 | 280 | hypervisor.send(message) |
wasmContainer.js | ||
---|---|---|
@@ -148,13 +148,13 @@ | ||
148 | 148 | } |
149 | 149 | }, |
150 | 150 | module: { |
151 | 151 | new: dataRef => { |
152 | - | |
152 | + | |
153 | 153 | }, |
154 | 154 | exports: (modRef, offset, length) => { |
155 | 155 | const mod = this.refs.get(modRef, 'mod') |
156 | - let name = this.getMemory(offset, length) | |
156 | + let name = this.get8Memory(offset, length) | |
157 | 157 | name = Buffer.from(name).toString() |
158 | 158 | const funcRef = mod.getFuncRef(name) |
159 | 159 | return this.refs.add(funcRef, 'func') |
160 | 160 | }, |
@@ -163,15 +163,15 @@ | ||
163 | 163 | } |
164 | 164 | }, |
165 | 165 | memory: { |
166 | 166 | externalize: (index, length) => { |
167 | - const buf = Buffer.from(this.getMemory(index, length)) | |
167 | + const buf = Buffer.from(this.get8Memory(index, length)) | |
168 | 168 | return this.refs.add(buf, 'buf') |
169 | 169 | }, |
170 | 170 | internalize: (dataRef, srcOffset, sinkOffset, length) => { |
171 | 171 | let buf = this.refs.get(dataRef, 'buf') |
172 | 172 | buf = buf.subarray(srcOffset, length) |
173 | - const mem = this.getMemory(sinkOffset, buf.length) | |
173 | + const mem = this.get8Memory(sinkOffset, buf.length) | |
174 | 174 | mem.set(buf) |
175 | 175 | }, |
176 | 176 | length (dataRef) { |
177 | 177 | let buf = this.refs.get(dataRef, 'buf') |
@@ -179,9 +179,9 @@ | ||
179 | 179 | } |
180 | 180 | }, |
181 | 181 | table: { |
182 | 182 | externalize: (index, length) => { |
183 | - const mem = Buffer.from(this.getMemory(index, length * 4)) | |
183 | + const mem = Buffer.from(this.get8Memory(index, length * 4)) | |
184 | 184 | const objects = [] |
185 | 185 | while (length--) { |
186 | 186 | const ref = mem.readUInt32LE(length * 4) |
187 | 187 | const obj = this.refs.get(ref) |
Built with git-ssb-web