Skip to content

Implement shared native memory multithreading #56841

Open
@mraleph

Description

@mraleph

The Shared Memory Multithreading for Dart proposal outlines a number of modifications to the Dart native runtime and core libraries which would unlock interoperability use cases which currently require developers to writing additional native code.

These modifications include:

  • Introduction of shared fields - static fields which are shared between all isolates in a group. In shared native memory multithreading only fields containing trivially shareable objects are allowed to be marked as shared.
  • Introduction of shared isolates - each isolate group has a dedicated isolate which does not contain any isolated state. An attempt to run code in this isolate which accesses non-shared field will throw an exception.
  • API extensions to dart:ffi:
    • NativeCallable.shared

There might be other changes to core libraries which would help the cause but is not necessarily required:

  • Helpers for atomic reads and writes in dart:ffi.
  • API extensions to dart:isolate
    • Isolate.shared
    • Isolate.postTask.
    • Isolate.runSync.
  • Introduction of dart:concurrent.
    • AtomicRef, AtomicInt32, AtomicInt64
    • Mutex and Condition.

These changes do not fundamentally alter Dart's isolate model - pure Dart code running in different isolates remains isolated, but introduce more straightforward way to bridge concurrency chasm between native world (which is structured around threads) and Dart (which is structured around isolates).

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triagedIssue has been triaged by sub teamtype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions