Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Markzipan opened this issue Jan 23, 2025 · 0 comments
Open

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

Markzipan opened this issue Jan 23, 2025 · 0 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P2 A bug or feature request we're likely to work on web-dev-compiler

Comments

@Markzipan
Copy link
Contributor

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).
@Markzipan Markzipan added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P2 A bug or feature request we're likely to work on web-dev-compiler labels Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P2 A bug or feature request we're likely to work on web-dev-compiler
Projects
None yet
Development

No branches or pull requests

1 participant