-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix remaining initialization warnings in bootstrapping #15682
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c427046
Add test
liufengyun d7754d9
Refine error message
liufengyun 3d28731
Use hot instead of fully initialized
liufengyun b6af7ee
Update check files
liufengyun 80d9975
Fix crash in member selection from type cast
liufengyun 920d4a9
Code refactoring
liufengyun 41a4f71
Faster promotion
liufengyun dd1e724
Reclassify test
liufengyun b7dba0d
Rename variable
liufengyun 4a4affd
Add assertions to tryPromote
liufengyun 0ae7346
Fix typo in doc
liufengyun df875ee
Improve error messages
liufengyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I agree that this is correct but it is very subtle.
If A extends B, is it possible that
hotSegmentCountered
is true for the A part of an object but false for the B part of an object? In other words, ifclass A(a) extends B(b)
, is it possible fora
(generally all arguments ofA
) to be hot but forb
to somehow be cold? I would think that local reasoning would rule it out, but if it is possible, that might point us to possible flaws in the correctness reasoning. So I would suggest adding an assertion to say that ifhotSegmentCountered
is true for some subclass, then it also has to be true for all of the later super- baseclasses in the chain, just to catch some potential bugs in the reasoning.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a valid concern, and it makes subtle assumptions about the ordering of the traversal. We've changed the logic in later commits to address this concern.
Edit: It's already in this commit, but we changed the name in a later commit to avoid misunderstanding. We do check each individual class separately now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the ordering of the traversal would be relevant and from your comment I think we have different intuitions about why this code is correct. It would be good to unify those intuitions and document the unified understanding in a comment.
My understanding is one of local reasoning. If I write
x = new Foo(a)
and a is hot, thenx
is hot (assuming outer is also hot). If I haveclass Bar(a,b) extends Foo(a)
, then I can think ofnew Bar(a,b)
as first creating aFoo(a)
but then adding some more (Bar) stuff onto it. TheFoo(a)
part enjoys local reasoning: everything in it, including superclasses ofFoo
, should be all hot due to being instantiated in a hot environment. So it's just the Bar added on that we need to worry about, because it can access coldb
. Calls ofFoo
methods can accessb
if they virtually dispatch to methods implemented inBar
, but that's OK because we'll analyze those overriding methods inBar
when we analyzeBar
.So the assertion is to confirm my understanding that of
Foo(a)
is instantiated in a hot environment then the constructors of superclasses ofFoo
also are.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point --- actually the initial implementation tries to profit from the insight you mentioned above. However, the existence of traits and linearization complicate the logic.
In the end, I find it simpler to perform the check for all classes and not profit inheritance to skip some checks. The check is cheap, so it's not a problem.
Assertions are always good. After linearization, adding the assertion incurs some complexity. I'll see if there is a simpler way to add that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we added the assertion.