OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-wasm --stress-gc |
| 6 |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 9 |
| 10 function run(f) { |
| 11 var builder = new WasmModuleBuilder(); |
| 12 builder.addImport("f", kSig_i_i); |
| 13 builder.addFunction("main", kSig_i_i) |
| 14 .addBody([ |
| 15 kExprGetLocal, 0, |
| 16 kExprCallFunction, 0]) |
| 17 .exportAs("main"); |
| 18 |
| 19 print("module"); |
| 20 var module = new WebAssembly.Module(builder.toBuffer()); |
| 21 |
| 22 for (var i = 0; i < 10; i++) { |
| 23 print(" instance " + i); |
| 24 var instance = new WebAssembly.Instance(module, {f: f}); |
| 25 var g = instance.exports.main; |
| 26 for (var j = 0; j < 10; j++) { |
| 27 assertEquals(f(j), g(j)); |
| 28 } |
| 29 } |
| 30 } |
| 31 |
| 32 (function test() { |
| 33 for (var i = 0; i < 100; i++) { |
| 34 run(x => (x + 19)); |
| 35 run(x => (x - 18)); |
| 36 } |
| 37 })(); |
OLD | NEW |