2022-05-10 21:27:54 +00:00
|
|
|
// Copyright 2022 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.
|
|
|
|
|
|
|
|
// Flags: --experimental-wasm-gc --experimental-wasm-ref-cast-nop
|
|
|
|
|
|
|
|
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
|
|
|
|
(function TestRefCastNop() {
|
|
|
|
var builder = new WasmModuleBuilder();
|
|
|
|
let struct = builder.addStruct([makeField(kWasmI32, true)]);
|
|
|
|
|
|
|
|
builder.addFunction("main", kSig_i_i)
|
2022-07-01 11:50:04 +00:00
|
|
|
.addLocals(wasmRefNullType(kWasmDataRef), 1)
|
2022-05-10 21:27:54 +00:00
|
|
|
.addBody([
|
|
|
|
kExprLocalGet, 0,
|
|
|
|
kGCPrefix, kExprStructNew, struct,
|
|
|
|
kExprLocalSet, 1,
|
|
|
|
kExprLocalGet, 1,
|
|
|
|
kGCPrefix, kExprRefCastNopStatic, struct,
|
|
|
|
kGCPrefix, kExprStructGet, struct, 0,
|
|
|
|
]).exportFunc();
|
|
|
|
|
|
|
|
var instance = builder.instantiate();
|
|
|
|
assertEquals(42, instance.exports.main(42));
|
|
|
|
})();
|