[vm/isolates] Allow typed data types in aruments for spawnUri isolates Fixes https://github.com/dart-lang/sdk/issues/53890 TEST=isolates/send_list_typed_data_spawn_uri_test Change-Id: Iaf1c2757897c61d0d0da2463bfea398cdcb67959 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332743 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
diff --git a/runtime/tests/vm/dart/isolates/send_list_typed_data_spawn_uri_test.dart b/runtime/tests/vm/dart/isolates/send_list_typed_data_spawn_uri_test.dart new file mode 100644 index 0000000..e27367e --- /dev/null +++ b/runtime/tests/vm/dart/isolates/send_list_typed_data_spawn_uri_test.dart
@@ -0,0 +1,92 @@ +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// +// This test ensures that lists of typed data can be sent to an isolate +// spawned via spawnUri. + +import 'dart:io'; +import 'dart:isolate'; +import 'dart:typed_data'; + +import 'package:async_helper/async_helper.dart'; + +void main(List<String> args) async { + asyncStart(); + if (args.length == 0) { + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Uint8List>[ + Uint8List.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Uint8ClampedList>[ + Uint8ClampedList.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Uint16List>[ + Uint16List.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Uint32List>[ + Uint32List.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Uint64List>[ + Uint64List.fromList([1]) + ]); + + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Int8List>[ + Int8List.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Int16List>[ + Int16List.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Int32List>[ + Int32List.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Int64List>[ + Int64List.fromList([1]) + ]); + + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Float32List>[ + Float32List.fromList([1]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Float64List>[ + Float64List.fromList([1]) + ]); + + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Int32x4List>[ + Int32x4List.fromList([Int32x4(1, 2, 3, 4)]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Float32x4List>[ + Float32x4List.fromList([Float32x4(1, 2, 3, 4)]) + ]); + await Isolate.spawnUri(Platform.script, [ + "42" + ], <Float64x2List>[ + Float64x2List.fromList([Float64x2(1, 2)]) + ]); + } + asyncEnd(); +}
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 13b6c52..eeaf9d8 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc
@@ -21529,6 +21529,17 @@ candidate_cls = object_store->transferable_class(); if (cid == candidate_cls.id()) return true; + const auto& typed_data_lib = + Library::Handle(object_store->typed_data_library()); + +#define IS_CHECK(name) \ + candidate_cls = typed_data_lib.LookupClass(Symbols::name##List()); \ + if (cid == candidate_cls.id()) { \ + return true; \ + } + DART_CLASS_LIST_TYPED_DATA(IS_CHECK) +#undef IS_CHECK + return false; }