Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: test/mjsunit/wasm/wasm-module-builder.js

Issue 2084573002: Upgrade Wasm JS API, step 1 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Separate test refactorings Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698