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

[CP] [dart2js] Bailout tracing of record fields when record is bailed out #53001

Closed
fishythefish opened this issue Jul 20, 2023 · 5 comments
Closed
Assignees
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. cherry-pick-approved Label for approved cherrypick request cherry-pick-merged Cherry-pick has been merged to the stable or beta branch. cherry-pick-review Issue that need cherry pick triage to approve

Comments

@fishythefish
Copy link
Member

fishythefish commented Jul 20, 2023

Commit(s) to merge

b336f39

Target

beta and stable

Prepared changelist for beta/stable

beta: https://dart-review.googlesource.com/c/sdk/+/315240
stable: https://dart-review.googlesource.com/c/sdk/+/315242

Issue Description

Some additional context in #52968

This issue can occur in any compilation using dart2js. Our global inference phase has a tracing pass, which allows us to infer more precise types for composite values (e.g. lists, sets, maps, records) when their elements do not escape. If a value escapes, we bail out and fall back to a conservative inferred type. In particular, if a list/set/map itself escapes, we consider the values it contains to escape as well.

Due to a bug in record tracing, if a record escaped, we would stop attempting to trace its fields, but would fail to default them to conservative types. This meant these record fields would end up with narrower (possibly empty) inferred types than they should have, leading to bad codegen.

What is the fix

The fix is simply to check if we bailed out on tracing the record itself, in which case we bail out on tracing the contained value. This matches what we already do for other composite values, like lists, sets, and maps.

Why cherry-pick

The fix is small and addresses the issue, and it makes the record tracing code match what the list/set/map tracing code already does.

Risk

low

Issue link(s)

#52968

Extra Info

I've created a CP to beta. However, although the cutoff for 3.1 already happened, the release won't be for about a month. This is long enough that it might be worth considering stable as well.

/cc @sigmundch

@fishythefish fishythefish added the cherry-pick-review Issue that need cherry pick triage to approve label Jul 20, 2023
@sigmundch
Copy link
Member

I strongly support the cherry-pick to beta: the old behavior was unsound and customers have run into it. Risk is very low (2 line change if you exclude indentation and braces)

I'm also support the cherry-pick to stable, but I don't know what is our threshold for that at this point. @itsjustkevin should we discuss that here? or in the scrum chat?

@fishythefish
Copy link
Member Author

Update: This also appears to fix #52933.

@sigmundch
Copy link
Member

That makes me even more inclined to push for cherry-picking to stable as well.

@fishythefish
Copy link
Member Author

Pre-emptive stable CP CL as well: https://dart-review.googlesource.com/c/sdk/+/315242

@itsjustkevin
Copy link
Contributor

@sigmundch and @fishythefish both sound good to me

@itsjustkevin itsjustkevin added the cherry-pick-approved Label for approved cherrypick request label Jul 20, 2023
copybara-service bot pushed a commit that referenced this issue Jul 20, 2023
…d out

Bug: #52968
Fixes: #53001
Cherry-Pick: https://dart-review.googlesource.com/c/sdk/+/315020
Change-Id: Iad450fa342f33d38a23367bbac280b464a4d618d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315240
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
copybara-service bot pushed a commit that referenced this issue Jul 20, 2023
out

Fixes: #53001
Cherry-Pick: https://dart-review.googlesource.com/c/sdk/+/315020
Change-Id: Ife4e01c4f623f9b2c701a051eb435266b3290de1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/315242
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
@a-siva a-siva added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jul 21, 2023
@itsjustkevin itsjustkevin added the cherry-pick-merged Cherry-pick has been merged to the stable or beta branch. label Jul 24, 2023
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. cherry-pick-approved Label for approved cherrypick request cherry-pick-merged Cherry-pick has been merged to the stable or beta branch. cherry-pick-review Issue that need cherry pick triage to approve
Projects
None yet
Development

No branches or pull requests

8 participants