Skip to content

[dart2wasm] Implement structs backed by TypedData #55083

@dcharkes

Description

@dcharkes

Currently, dart2wasm assumes that all structs are backed by a Pointer.

// _Compound._typedDataBase
if (cls == translator.ffiCompoundClass && name == '_typedDataBase') {
// A compound (subclass of Struct or Union) is represented by its i32
// address. The _typedDataBase field contains a Pointer pointing to the
// compound, whose representation is the same.
codeGen.wrap(receiver, w.NumType.i32);
return w.NumType.i32;
}

dart2wasm can currently assume this, because it does not implement support for:

  • Returning struct by value from FFI calls.
  • Struct.create.

If either of these features is implemented in dart2wasm, compounds cannot be represented as the int address of the pointer.

Also, it would break nested compounds if the suggestion in #54892 is implemented, as the _offsetInBytes would not be saved anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.area-dart2wasmIssues for the dart2wasm compiler.library-ffi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions