Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 function WasmFunctionBuilder(name, sig_index) { | 5 function WasmFunctionBuilder(name, sig_index) { | 
| 6 this.name = name; | 6 this.name = name; | 
| 7 this.sig_index = sig_index; | 7 this.sig_index = sig_index; | 
| 8 this.exports = []; | 8 this.exports = []; | 
| 9 } | 9 } | 
| 10 | 10 | 
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 } | 335 } | 
| 336 | 336 | 
| 337 WasmModuleBuilder.prototype.instantiate = function(ffi, memory) { | 337 WasmModuleBuilder.prototype.instantiate = function(ffi, memory) { | 
| 338 var buffer = this.toBuffer(); | 338 var buffer = this.toBuffer(); | 
| 339 if (memory != undefined) { | 339 if (memory != undefined) { | 
| 340 return Wasm.instantiateModule(buffer, ffi, memory); | 340 return Wasm.instantiateModule(buffer, ffi, memory); | 
| 341 } else { | 341 } else { | 
| 342 return Wasm.instantiateModule(buffer, ffi); | 342 return Wasm.instantiateModule(buffer, ffi); | 
| 343 } | 343 } | 
| 344 } | 344 } | 
| 345 | |
| 346 function assertModule(module, memsize) { | |
| 
 
titzer
2016/05/10 12:32:11
These are assertion (testing) functions, so they d
 
ahaas
2016/05/11 09:52:21
I duplicated the code now.
 
 | |
| 347 // Check the module exists. | |
| 348 assertFalse(module === undefined); | |
| 349 assertFalse(module === null); | |
| 350 assertFalse(module === 0); | |
| 351 assertEquals("object", typeof module); | |
| 352 | |
| 353 // Check the memory is an ArrayBuffer. | |
| 354 var mem = module.exports.memory; | |
| 355 assertFalse(mem === undefined); | |
| 356 assertFalse(mem === null); | |
| 357 assertFalse(mem === 0); | |
| 358 assertEquals("object", typeof mem); | |
| 359 assertTrue(mem instanceof ArrayBuffer); | |
| 360 for (var i = 0; i < 4; i++) { | |
| 361 module.exports.memory = 0; // should be ignored | |
| 362 assertEquals(mem, module.exports.memory); | |
| 363 } | |
| 364 | |
| 365 assertEquals(memsize, module.exports.memory.byteLength); | |
| 366 } | |
| 367 | |
| 368 function assertFunction(module, func) { | |
| 369 assertEquals("object", typeof module.exports); | |
| 370 | |
| 371 var exp = module.exports[func]; | |
| 372 assertFalse(exp === undefined); | |
| 373 assertFalse(exp === null); | |
| 374 assertFalse(exp === 0); | |
| 375 assertEquals("function", typeof exp); | |
| 376 return exp; | |
| 377 } | |
| OLD | NEW |