e8b62d509b
This reverts commitee89a26977
. Reason for revert: Speculative revert https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Mac64%20GC%20Stress/24078/overview Original change's description: > [wasm-gc] Add extern.externalize > > This adds `extern.externalize(ref null any): ref null extern` to wasm > which packs wasm objects into JS objects if the js-interop flag is not set. > This is the counterpart to extern.internalize introduced in >50ec8a11f2
. > > Bug: v8:7748 > Change-Id: I67b8fe6d70b9f526ff6c43b0a4d7861c7ff5dad0 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3825879 > Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> > Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> > Commit-Queue: Matthias Liedtke <mliedtke@chromium.org> > Cr-Commit-Position: refs/heads/main@{#82492} Bug: v8:7748 Change-Id: I22c84d69a1dc957208f60ae3125e80278ae739a5 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3832389 Owners-Override: Nico Hartmann <nicohartmann@chromium.org> Auto-Submit: Nico Hartmann <nicohartmann@chromium.org> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#82495}
109 lines
3.2 KiB
JavaScript
109 lines
3.2 KiB
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
|
|
"use strict";
|
|
|
|
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
let instance = (() => {
|
|
let builder = new WasmModuleBuilder();
|
|
let struct = builder.addStruct([makeField(kWasmI32, true)]);
|
|
|
|
builder.addFunction('struct_producer', makeSig([kWasmI32], [kWasmDataRef]))
|
|
.addBody([
|
|
kExprLocalGet, 0,
|
|
kGCPrefix, kExprStructNew, struct])
|
|
.exportFunc();
|
|
|
|
builder.addFunction('struct_consumer',
|
|
makeSig([kWasmExternRef], [kWasmI32, kWasmI32]))
|
|
.addBody([
|
|
kExprLocalGet, 0,
|
|
kExprRefIsNull,
|
|
kExprBlock, kWasmVoid,
|
|
kExprLocalGet, 0,
|
|
kGCPrefix, kExprExternInternalize,
|
|
kExprBrOnNull, 0,
|
|
kGCPrefix, kExprRefAsData,
|
|
kGCPrefix, kExprRefCastStatic, struct,
|
|
kGCPrefix, kExprStructGet, struct, 0, // value
|
|
kExprI32Const, 0, // isNull
|
|
kExprReturn,
|
|
kExprEnd,
|
|
kExprDrop,
|
|
kExprI32Const, 0, // value (placeholder)
|
|
kExprI32Const, 1, // isNull
|
|
])
|
|
.exportFunc();
|
|
|
|
builder.addFunction('i31_producer', makeSig([kWasmI32], [kWasmI31Ref]))
|
|
.addBody([
|
|
kExprLocalGet, 0,
|
|
kGCPrefix, kExprI31New])
|
|
.exportFunc();
|
|
|
|
builder.addFunction('i31_consumer',
|
|
makeSig([kWasmExternRef], [kWasmI32, kWasmI32]))
|
|
.addBody([
|
|
kExprLocalGet, 0,
|
|
kExprRefIsNull,
|
|
kExprBlock, kWasmVoid,
|
|
kExprLocalGet, 0,
|
|
kGCPrefix, kExprExternInternalize,
|
|
kExprBrOnNull, 0,
|
|
kGCPrefix, kExprRefAsI31,
|
|
kGCPrefix, kExprI31GetS, // value
|
|
kExprI32Const, 0, // isNull
|
|
kExprReturn,
|
|
kExprEnd,
|
|
kExprDrop,
|
|
kExprI32Const, 0, // value (placeholder)
|
|
kExprI32Const, 1, // isNull
|
|
])
|
|
.exportFunc();
|
|
|
|
let array = builder.addArray(kWasmI32, true);
|
|
|
|
builder.addFunction('array_producer', makeSig([kWasmI32], [kWasmArrayRef]))
|
|
.addBody([
|
|
kExprLocalGet, 0,
|
|
kGCPrefix, kExprArrayNewFixedStatic, array, 1])
|
|
.exportFunc();
|
|
|
|
builder.addFunction('array_consumer',
|
|
makeSig([kWasmExternRef], [kWasmI32, kWasmI32]))
|
|
.addBody([
|
|
kExprLocalGet, 0,
|
|
kExprRefIsNull,
|
|
kExprBlock, kWasmVoid,
|
|
kExprLocalGet, 0,
|
|
kGCPrefix, kExprExternInternalize,
|
|
kExprBrOnNull, 0,
|
|
kGCPrefix, kExprRefAsArray,
|
|
kGCPrefix, kExprRefCastStatic, array,
|
|
kExprI32Const, 0,
|
|
kGCPrefix, kExprArrayGet, array, // value
|
|
kExprI32Const, 0, // isNull
|
|
kExprReturn,
|
|
kExprEnd,
|
|
kExprDrop,
|
|
kExprI32Const, 0, // value (placeholder)
|
|
kExprI32Const, 1, // isNull
|
|
])
|
|
.exportFunc();
|
|
|
|
return builder.instantiate({});
|
|
})();
|
|
|
|
// struct
|
|
["struct", "i31", "array"].forEach((type) => {
|
|
var fnConsumer = instance.exports[`${type}_consumer`];
|
|
var fnProducer = instance.exports[`${type}_producer`];
|
|
assertEquals([0, 1], fnConsumer(null));
|
|
var obj42 = fnProducer(42);
|
|
assertEquals([42, 0], fnConsumer(obj42));
|
|
assertTraps(kTrapIllegalCast, () => fnConsumer({}));
|
|
});
|