dart-sdk/tests/ffi/snapshot_test.dart
Martin Kustermann eba0e68e1a [vm/ffi] Allow Pointer objects to be shared across isolates
We consider `Pointer` objects as simple value types. We may unbox them
in the future to be simple integers - at which point our message sending
code wouldn't even know they are pointers anymore. There's therefore no
reason to prevent sending them across `SendPort`s.

Owners of `Pointer`s may implement `Finalizable` and sending such
finalizables across `SendPort`s is prohibited.

Closes https://github.com/dart-lang/sdk/issues/50457

TEST=vm/dart/isiolates/fast_object_copy*_test

Change-Id: Ia215d119c5bb0e48e2c5dc83cc82e132f46931c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350822
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-02-07 12:48:50 +00:00

28 lines
695 B
Dart

// Copyright (c) 2019, 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.
// Checks that the VM throws an appropriate exception when FFI objects are
// passed between isolates.
import 'dart:ffi';
import 'dart:isolate';
import 'package:expect/expect.dart';
class Foo implements Finalizable {
final Pointer<Void> value;
Foo(this.value);
}
main(args) async {
try {
await Isolate.spawn(print, Foo(Pointer<Void>.fromAddress(1)));
} catch (e) {
Expect.type<ArgumentError>(e);
return;
}
throw "Test didn't throw an exception!";
}