Skip to content

[dart2js] Improve HInstruction/HPhi type hierarchy #54920

Open
@fishythefish

Description

@fishythefish

Currently, HPhi is just one of the many subclasses of HInstruction, but it would be nice to have a stronger separation between phis and non-phis. Our current type hierarchy is insufficient to express some important invariants:

  • HPhi.next, if it exists, is another phi. Currently, we cast when necessary.
  • Phis can only be added to/removed from a basic block in certain ways. (Corollary: certain nodes are known to be HInstructions which are not HPhis.) Currently, we "enforce" this with assertions.

Likewise, it would be nice to have a clearer distinction between HInstructionList and HPhiList.

One hurdle is that the relevant features in the Dart system are not totally free:

  • Some subclassing is okay, but we want to avoid virtual dispatch on hot APIs (e.g. HInstruction.next). This is why we cast HPhi.next rather than overriding.
  • Generics (and covariant members) incur parameter checks.

/cc @rakudrama - feel free to add other invariants/hurdles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-code-healthInternal changes to our tools and workflows to make them cleaner, simpler, or more maintainableweb-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions