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

Ruby: Summarized type-tracking stores should target post-update nodes #14628

Merged
merged 3 commits into from
Nov 1, 2023

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 30, 2023

No description provided.

@hvitved hvitved added the no-change-note-required This PR does not need a change note label Oct 30, 2023
@hvitved hvitved marked this pull request as ready for review October 30, 2023 18:45
@hvitved hvitved requested review from a team as code owners October 30, 2023 18:45
Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main request is for adding comments. I know this is library code, but I think it is too hard to infer the recursive role of isOutput without guidance.

Comment on lines 75 to 77
// Relating nodes to summaries
/** Gets a dataflow node respresenting the argument of `call` indicated by `arg`. */
Node argumentOf(Node call, SummaryComponent arg);
Node argumentOf(Node call, SummaryComponent arg, boolean isOutput);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we explain the role of isOutput in the comment?

Comment on lines 303 to 313
result = I::parameterOf(prev, head) and
isOutput0 = false and
isOutput = true
or
result = I::returnOf(prev, head)
result = I::returnOf(prev, head) and
isOutput0 = false and
isOutput = false
or
componentLevelStep(head) and
result = prev
result = prev and
isOutput = isOutput0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am struggling to reconstruct the logic here. isOutput, in the base case is only true for returns. Here we preclude taking the parameter of an output and we claim that a return is not an output. Could you add a comment with the guiding principle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first case for when there is output that goes into a callback: output = Argument[0].Parameter[1]; in this case the Argument[0] bit should resolve to the normal argument node and not the post-update node.

The second case is for when there is input from a callback: input = Argument[0].ReturnValue, where we again don't want Argument[0] to give us the post-update node.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should isOutput (not-0) be true in the second case, then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because it is for cases like input = Argument[0].ReturnValue

nodeFrom = evaluateSummaryComponentStackLocal(callable, call, input) and
nodeTo = evaluateSummaryComponentStackLocal(callable, call, output)
nodeFrom = evaluateSummaryComponentStackLocal(callable, call, input, false) and
nodeTo = evaluateSummaryComponentStackLocal(callable, call, output, true)
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This predicate is not a store step, should it have the same treatment? (The commit title indicates maybe not.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should have the same treatment, good question though.

result = I::parameterOf(prev, head) and
isOutput0 = false and
isOutput = true
or
// `ReturnValue` is only allowed int the input of flow summaries (hence `isOutput = false`),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// `ReturnValue` is only allowed int the input of flow summaries (hence `isOutput = false`),
// `ReturnValue` is only allowed in the input of flow summaries (hence `isOutput = false`),

result = I::parameterOf(prev, head) and
isOutput0 = false and
isOutput = true
or
// `ReturnValue` is only allowed int the input of flow summaries (hence `isOutput = false`),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// `ReturnValue` is only allowed int the input of flow summaries (hence `isOutput = false`),
// `ReturnValue` is only allowed in the input of flow summaries (hence `isOutput = false`),

@hvitved hvitved force-pushed the ruby/type-tracking-store-post-update branch from a68278b to 0c5b528 Compare November 1, 2023 10:33
@hvitved hvitved requested a review from yoff November 1, 2023 10:33
Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the nice comments! I was secretly hoping that the reasoning around isOutput did not have to refer to post-update nodes, but I can accept that it does :-)

@hvitved hvitved merged commit 3c86aad into github:main Nov 1, 2023
19 checks passed
@hvitved hvitved deleted the ruby/type-tracking-store-post-update branch November 1, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Python Ruby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants