Avoid ObjectRefs in two hot paths in compiler#8371
Conversation
Avoid capturing synthetic patmat vars in closures, etc, which gives rise to an ObjectRef to box the var. There is currently a bug in the pattern matcher that emits these more of these vars under `-optimize` -- the logic was not updated woth `-opt` was introduced in 2.12. Rewrite `RefChecks.transform` in terms of vals to avoid another ObjectRef.
| // inside annotations. | ||
| applyRefchecksToAnnotations(tree) | ||
| var result: Tree = tree match { | ||
| val result: Tree = tree match { |
There was a problem hiding this comment.
Renaming this variable result to result1 could make for a smaller diff.
There was a problem hiding this comment.
I went back and re-did the change with step-wise IDE refactorings starting with your suggestion and moving to the same end result as this PR to be sure I hadn't changed the meaning.
hrhino
left a comment
There was a problem hiding this comment.
LGTM. I suppose the idea was to make debugging easier by giving names to the bound variables?
|
@hrhino I think so. See #1060. |
|
It occurs to me that we could change the compiler to avoid boxing these synthetic It appears to be a pretty straightforward change: retronym#66 |
|
/cc @adriaanm |
Avoid capturing synthetic patmat vars in closures, etc, which
gives rise to an ObjectRef to box the var. There is currently a
bug in the pattern matcher that emits these more of these vars
under
-optimize-- the logic was not updated woth-optwasintroduced in 2.12.
Rewrite
RefChecks.transformin terms of vals to avoid anotherObjectRef.
I have experimented with fixing the disparity between
-optand-optimizein retronym#65but that's still WIP.