Skip to content

[vm/ffi] Remove memory management from API #38520

@sjindel-google

Description

@sjindel-google

Presently, the Pointer class contains wrappers for malloc and free.

However, we should consider a more neutral position on memory management. It doesn't makes sense to expose these as primitives in WebAssembly, and we can already implement them in Dart.

We can:

  1. Remove Pointer.allocate and Pointer.free and move them to package:ffi.
  2. Introduce an Allocator API, e.g.:
class Allocator {
  Pointer<Void> allocate(int bytes);
  void deallocate(Pointer<Void> memory);
}

However, the Allocator API should arguably live in package:ffi anyway. That would facilitate using dependency injection to mock or replace the allocator and implement different allocation strategies.

Metadata

Metadata

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffi

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions