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

dart2js: stable order for compile time constant initializations #10989

Open
rakudrama opened this issue May 30, 2013 · 4 comments
Open

dart2js: stable order for compile time constant initializations #10989

rakudrama opened this issue May 30, 2013 · 4 comments
Labels
area-web Issues related to Dart Web. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@rakudrama
Copy link
Member

Compile time structured constant initializers are topo-sorted, but from an initially unstable set.
Minor perturbations of the source cause the constants block to be shuffled.

It is not clear what the 'source order' is since e.g. 'const Duration(0)' can occur in many places.

Option 1.
Maintain a map / field of the earliest source location, updated when the AST is resolved to a constant.

Option 2.
Since the naming of the constants is now stable, it would not be unreasonable to sort by JavaScript name before topo-sort. Not all constants have a name (e.g. numbers and top static functions), so the constants would be split into named and unnamed lists, sort the named, then append the two lists.

Minified names are rather arbitrary - sorting by the name of the constructor and then the constant name will cluster the 'new' expressions and likely improve gzip compression.

@kasperl
Copy link

kasperl commented Jun 10, 2013

Removed Priority-Unassigned label.
Added Priority-Medium label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@rakudrama
Copy link
Member Author

Things are much better but not quite done.

We now sort by the unminified name. This name is derived from the contents, but if often a deterministic hash.
The order of constants is stable due to deep sorting to break hash-name collisions.
What is less stable is the allocation of suffixes "0", "1" etc to clashing hash names. This is determined by some visit order which is easily perturbed.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Feb 29, 2016
@vsmenon vsmenon added the area-web Issues related to Dart Web. label Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Issues related to Dart Web. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants