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 var buffer = new ArrayBuffer(bytes.length); | 335 var buffer = new ArrayBuffer(bytes.length); |
336 var view = new Uint8Array(buffer); | 336 var view = new Uint8Array(buffer); |
337 for (var i = 0; i < bytes.length; i++) { | 337 for (var i = 0; i < bytes.length; i++) { |
338 var val = bytes[i]; | 338 var val = bytes[i]; |
339 if ((typeof val) == "string") val = val.charCodeAt(0); | 339 if ((typeof val) == "string") val = val.charCodeAt(0); |
340 view[i] = val | 0; | 340 view[i] = val | 0; |
341 } | 341 } |
342 return buffer; | 342 return buffer; |
343 } | 343 } |
344 | 344 |
345 WasmModuleBuilder.prototype.instantiate = function(ffi, memory) { | 345 WasmModuleBuilder.prototype.instantiate = function(...args) { |
346 var buffer = this.toBuffer(); | 346 var module = new WebAssembly.Module(this.toBuffer()); |
347 if (memory != undefined) { | 347 var instance = new WebAssembly.Instance(module, ...args); |
348 return Wasm.instantiateModule(buffer, ffi, memory); | 348 return instance; |
349 } else { | |
350 return Wasm.instantiateModule(buffer, ffi); | |
351 } | |
352 } | 349 } |
OLD | NEW |