Skip to content

[vm/ffi] Allocate structs by default with TypedData #45697

@dcharkes

Description

@dcharkes

When working with a C API that takes structs by value users need to malloc structs in C memory before they can pass them to a C function call, and remember to free the afterwards.

Instead, we should explore changing the API so that the default is that we create structs backed by TypedData rather than allocating them in C memory.

The same argument can be made for Arrays.

TODO: Design an API taking the following into account:

  • Users subtype Struct, do they need to create factories/constructors?
  • How does the no-argument const default constructor interact with this? We need the consts for annotations. But the non-name constructor would be an ideal candidate for this behavior.

Metadata

Metadata

Assignees

No one assigned

    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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions