2016-10-06 15:43:10 +00:00
|
|
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-04-28 13:09:31 +00:00
|
|
|
// Flags: --expose-wasm --gc-interval=500 --stress-compaction
|
2016-10-06 15:43:10 +00:00
|
|
|
|
|
|
|
load("test/mjsunit/wasm/wasm-constants.js");
|
|
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
|
|
|
|
function run(f) {
|
|
|
|
var builder = new WasmModuleBuilder();
|
2016-12-20 15:32:56 +00:00
|
|
|
builder.addImport("m", "f", kSig_i_i);
|
2016-10-06 15:43:10 +00:00
|
|
|
builder.addFunction("main", kSig_i_i)
|
|
|
|
.addBody([
|
|
|
|
kExprGetLocal, 0,
|
|
|
|
kExprCallFunction, 0])
|
|
|
|
.exportAs("main");
|
|
|
|
|
|
|
|
print("module");
|
|
|
|
var module = new WebAssembly.Module(builder.toBuffer());
|
|
|
|
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
print(" instance " + i);
|
2016-12-20 15:32:56 +00:00
|
|
|
var instance = new WebAssembly.Instance(module, {m: {f: f}});
|
2016-10-06 15:43:10 +00:00
|
|
|
var g = instance.exports.main;
|
|
|
|
for (var j = 0; j < 10; j++) {
|
|
|
|
assertEquals(f(j), g(j));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(function test() {
|
2017-07-14 15:24:14 +00:00
|
|
|
for (var i = 0; i < 10; i++) {
|
|
|
|
run(x => (x + 19 + i));
|
2016-10-06 15:43:10 +00:00
|
|
|
run(x => (x - 18));
|
|
|
|
}
|
|
|
|
})();
|