Commit 67106ff4 authored by Matthias Liedtke's avatar Matthias Liedtke Committed by V8 LUCI CQ

[wasm-gc] JS interop: Do not wrap structs/arrays by default

Bug: v8:7748
Change-Id: I441fd294bc0f31c0396217bc55c27159abacdbd1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905725Reviewed-by: 's avatarManos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Auto-Submit: Matthias Liedtke <mliedtke@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83338}
parent 979b1374
......@@ -1095,7 +1095,7 @@ FOREACH_WASM_FEATURE_FLAG(DECL_WASM_FLAG)
DEFINE_IMPLICATION(experimental_wasm_gc, experimental_wasm_typed_funcref)
DEFINE_BOOL(wasm_gc_js_interop, false, "experimental WasmGC-JS interop")
DEFINE_BOOL(wasm_gc_js_interop, true, "experimental WasmGC-JS interop")
DEFINE_BOOL(wasm_staging, false, "enable staged wasm features")
......
......@@ -22,18 +22,15 @@ let instance = (() => {
})();
let obj = instance.exports.createStruct(123);
// The struct is wrapped in the special wrapper.
// It doesn't have any observable properties.
assertTrue(obj instanceof Object);
// The struct is opaque and doesn't have any observable properties.
assertFalse(obj instanceof Object);
assertEquals([], Object.getOwnPropertyNames(obj));
assertEquals("{}", JSON.stringify(obj));
// It can be passed as externref without any observable change.
let passObj = instance.exports.passObj;
obj = passObj(obj);
assertTrue(obj instanceof Object);
assertEquals([], Object.getOwnPropertyNames(obj));
assertEquals("{}", JSON.stringify(obj));
let obj2 = passObj(obj);
assertFalse(obj2 instanceof Object);
assertEquals([], Object.getOwnPropertyNames(obj2));
assertSame(obj, obj2);
// A JavaScript object can be passed as externref.
// It will not be wrapped.
obj = passObj({"hello": "world"});
assertEquals({"hello": "world"}, obj);
let jsObject = {"hello": "world"};
assertSame(jsObject, passObj(jsObject));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment