Skip to content

[DDC] Rework representation of Enums to be less redundant #59972

@Markzipan

Description

@Markzipan

Enums' representation was updated to better match the VM's hot reload semantics in 6edbfd9.

The new representation now diverges significantly from how they're represented in kernel nodes:

  • Enum fields are canonicalized solely based on their name
  • All non-name fields are appended to the canonicalized enum fields later (after types have been linked but after canonicalization)
  • The index field is represented as a static lookup on the enclosing Enum's values field.

Our changes introduce some low hanging fruit optimization opportunities:

  • index iterates through values, which is a list, using indexOf. We could make this a map for faster lookups.
  • our extendEnum function effectively immediately accesses and initializes const enum fields in the const table. We should just emit these once ahead of time - likely in a separate enum handler (separate from normal consts).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-dev-compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions