Rewrite prof:variables()
to preserve known variables
#2380
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.
This is an attempt to solve #1115, based on the suggestion made there to rewrite the call to
prof:variables()
by fixing the set of variables early.The approach taken here is to evaluate the
VarScope
obtained fromcc.vs()
at optimization time and replaceprof:variables()
with a new function call that takes the values of the known variables as arguments. The new function is instantiated with the corresponding list of variable names.One problem with
VarScope
is that it may contain additional variables that are undefined whereprof:variables()
is called. Their references are carried along, but they cannot be evaluated. This is handled by allowing them to be evaluated to Javanull
and filtering them out on that basis. Admittedly, it would be nicer if one could only handle defined variables, but I have not found an equally simple and isolated solution for this.