Skip to content

[RFC] Supporting reference types in struct fields in AOT mod #4134

@lum1n0us

Description

@lum1n0us

This is to track the need for supporting reference types in struct fields when in AOT mode. At present, only primitive types are handled correctly during the wasm-to-AOT compilation process. References need to be reconstructed in the AOT world rather than reusing the results from the wasm world.

Below is a code snippet that illustrates this requirement, though it does not encompass all scenarios.

(module
  (type $f1 (func (param i32) (result i32)))

  (type $vt1
    (sub
      (struct
        (field (ref null $f1))
      )
    )
  )

  (global $g1 (ref $vt1)
    ref.func $f1   ;; // <- TBD
    struct.new $vt1
  )

  (func $f1 (type $f1) (param i32) (result i32)
    i32.const 0
  )

  (func (export "run") (result i32)
    global.get $g1
    struct.get $vt1 0
    ref.test (ref null $f1)  ;; // should be 1 as true
  )
)

#4097

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions