v8/test/mjsunit/wasm/gc-experiments.js
Manos Koukoutos a0a786656f [wasm-gc][refactor] Rename optRef -> refNull
This makes the internal V8 name consistent with the text-format name.

Bug: v8:7748
Change-Id: I44f7ac1eb5e634b4f829e596bf1f14caeb748d54
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3726291
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81491}
2022-07-01 12:33:23 +00:00

27 lines
853 B
JavaScript

// 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)
.addLocals(wasmRefNullType(kWasmDataRef), 1)
.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));
})();