Commit 3ff531f5 authored by Matthias Liedtke's avatar Matthias Liedtke Committed by V8 LUCI CQ

[wasm-gc] Use experimental wasm GC flag for string <-> array conversions

This CL decouples the Wasm GC JS interop from the experimental
string <-> array conversions as the interop is now enabled by
default, still there are some issues discovered with the
conversions.
The functions are fixed via https://chromium-review.googlesource.com/c/v8/v8/+/3916633.

Bug: chromium:1366881
Change-Id: I27730523a51d24a7ea18199e1668e8c76f0bcb4d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3916088Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Matthias Liedtke <mliedtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83435}
parent bf4d6b35
......@@ -17,6 +17,7 @@
#include "src/execution/execution.h"
#include "src/execution/isolate.h"
#include "src/execution/messages.h"
#include "src/flags/flags.h"
#include "src/handles/handles.h"
#include "src/heap/factory.h"
#include "src/objects/fixed-array.h"
......@@ -2989,9 +2990,10 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
InstallFunc(isolate, webassembly, "validate", WebAssemblyValidate, 1);
InstallFunc(isolate, webassembly, "instantiate", WebAssemblyInstantiate, 1);
// TODO(tebbi): Put this behind its own flag once --wasm-gc-js-interop gets
// closer to shipping.
if (v8_flags.wasm_gc_js_interop) {
// TODO(7748): These built-ins should not be shipped with wasm GC.
// Either a new flag will be needed or the built-ins have to be deleted prior
// to shipping.
if (v8_flags.experimental_wasm_gc) {
SimpleInstallFunction(
isolate, webassembly, "experimentalConvertArrayToString",
Builtin::kExperimentalWasmConvertArrayToString, 0, true);
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --experimental-wasm-gc --wasm-gc-js-interop
// Flags: --experimental-wasm-gc --allow-natives-syntax
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
......@@ -45,3 +45,24 @@ const array =
for (let i = 0; i < string.length; ++i) {
assertEquals(getChar(array, i), string.charCodeAt(i));
}
// Test calling built-ins with different amount of (invalid) arguments.
function arrayToString() {
WebAssembly.experimentalConvertArrayToString(...arguments);
}
function stringToArray() {
WebAssembly.experimentalConvertStringToArray(...arguments);
}
let args = [];
for (let i = 1; i <= 5; ++i) {
assertThrows(() => arrayToString(...args));
assertThrows(() => stringToArray(...args));
%PrepareFunctionForOptimization(arrayToString);
%PrepareFunctionForOptimization(stringToArray);
%OptimizeFunctionOnNextCall(arrayToString);
%OptimizeFunctionOnNextCall(stringToArray);
assertThrows(() => arrayToString(...args));
assertThrows(() => stringToArray(...args));
args.push(i);
}
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