Skip to content

Validating "joined" types for variant during lifting #34

@alexcrichton

Description

@alexcrichton

Currently the canonical ABI defines a "join" function to allow variants to be represented with a flat list of types to get lifted, currently only exposed as the parameters to functions imported by the wasm module. As-is I believe the current rules for validating these parameters are:

  • The discriminant, an i32, must be in-bounds
  • Used flat values must have zero'd upper bits if the upper bits are discarded for a particular case
  • Unused flat values for a particular case are not validated

In implementing this I'm finding it somewhat nontrivial to perform the second bit of validation here, ensuring that the upper bits of each flat type is zero when accessed during lowering. I could elaborate further about that as well, but before getting into that it felt like there was a bit of a discrepancy between validating that unused upper bits are zero but not validating that unused values entirely are zero. Given that, would it perhaps be reasonable to stop validating that the upper bits are zero? Instead allowing arbitrary bit-patterns there? (and variants just use the bits needed for each case)

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