2018-01-24 20:16:06 +01:00
|
|
|
// Copyright 2017 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.
|
|
|
|
|
2025-04-29 08:03:15 +02:00
|
|
|
// Flags: --expose-gc --verify-heap
|
2018-01-24 20:16:06 +01:00
|
|
|
|
2021-08-29 14:20:49 +02:00
|
|
|
d8.file.execute("test/mjsunit/wasm/user-properties-common.js");
|
2018-01-24 20:16:06 +01:00
|
|
|
|
|
|
|
(function ExportedFunctionTest() {
|
|
|
|
print("ExportedFunctionTest");
|
|
|
|
|
|
|
|
print(" instance 1, exporting");
|
|
|
|
var builder = new WasmModuleBuilder();
|
|
|
|
builder.addFunction("exp", kSig_i_i)
|
|
|
|
.addBody([
|
2019-11-08 15:39:11 +01:00
|
|
|
kExprLocalGet, 0,
|
2018-01-24 20:16:06 +01:00
|
|
|
kExprCallFunction, 0])
|
|
|
|
.exportAs("exp");
|
|
|
|
let module1 = builder.toModule();
|
|
|
|
let instance1 = new WebAssembly.Instance(module1);
|
|
|
|
let g = instance1.exports.exp;
|
|
|
|
|
|
|
|
testProperties(g);
|
|
|
|
|
2020-05-05 09:19:02 +02:00
|
|
|
// The Wasm-internal fields of {g} are only inspected when {g} is
|
2018-01-24 20:16:06 +01:00
|
|
|
// used as an import into another instance.
|
|
|
|
print(" instance 2, importing");
|
|
|
|
var builder = new WasmModuleBuilder();
|
|
|
|
builder.addImport("imp", "func", kSig_i_i);
|
|
|
|
let module2 = builder.toModule();
|
|
|
|
let instance2 = new WebAssembly.Instance(module2, {imp: {func: g}});
|
|
|
|
|
|
|
|
testProperties(g);
|
|
|
|
})();
|