-
Notifications
You must be signed in to change notification settings - Fork 328
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
Node added inside collapsed node is never executed #11341
Node added inside collapsed node is never executed #11341
Conversation
|main = | ||
| x = Main.inc 3 | ||
| y = Main.inc 7 | ||
| IO.println x+y |
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.
Why this example was not working before this PR?
Why it is working 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.
It was not working because the self
argument was not invalidated after the method was edited. With the cached self
we observed some stale nodes during the runtime, and the function call may return incorrect results (the result before the edit was done). Why it was the behavior is another question and I was not able to find the answer.
* @param kind the node kind | ||
*/ | ||
public void set(UUID id, Kind kind) { | ||
preferences.put(id, kind); |
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 am afraid of a data structure read from persistance that can be modified. At certain moment such a structure must become immutable. We cannot have a mutable structures flying around in the system. There are already plenty of such structures and we don't want to introduce new ones.
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 am afraid of a data structure read from persistance that can be modified.
From what I can see, all the compiler metadata is mutable currently. I introduced the CachePreferences
to avoid copying and simply pass it to runtime after the compilation.
If we want to introduce an immutable object for persistence, we would need to convert mutable prefs to immutable to pass it to the persistence. And then convert immutable prefs to mutable again when we pass it to the runtime.
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.
LGTM
@@ -403,6 +403,12 @@ class EnsureCompiledJob( | |||
CacheInvalidation.StackSelector.All, | |||
invalidateStaleCommand, | |||
Set(CacheInvalidation.IndexSelector.All) | |||
), | |||
CacheInvalidation( |
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.
So that's the crucial point of this PR, right?
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.
Yes
@@ -177,13 +166,13 @@ case object CachePreferenceAnalysis extends IRPass { | |||
callArgument: CallArgument, | |||
weights: WeightInfo | |||
): CallArgument = { | |||
callArgument.value.getExternalId.foreach(weights.update(_, Weight.Always)) | |||
callArgument.value.getExternalId | |||
.foreach(weights.update(_, CachePreferences.Kind.SELF_ARGUMENT)) |
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.
👍
Pull Request Description
close #11251
Changelog:
CachePreferences
configuration of the expressions that are marked for cachingself
keywords in the parent frames on function editImportant Notes
The demo shows that:
main
method are updated correctlyenso-11251-collapsed.mp4
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.