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
SI-4859 Step back from mis-optimizations in qualifiers #1864
Conversation
Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1330/ |
jenkins job pr-rangepos: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1330/ |
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2044/ |
jenkins job pr-scala-testsuite-linux-opt: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2044/ |
As a sidenote, the experimental optimizer detects bytecode-level repeated reads of stable accessors, caching in a synthetic variable upon first access and reusing it afterwards (once per distinct control-flow path, which works pretty well for common cases). |
/localhome/jenkins/a/workspace/pr-scala-testsuite-linux-opt/test/files/run/t0091.scala [FAILED] |
This looks good to me if the verifier errors are gone. I think the idea of optimizer decisions being configurable at user level will also be necessary for a satisfying resolution to these inlining questions. A strict view that no behavioral change can take place rules out way too much; but how and where to relax the grip is another one-size-only-fits-some situations. |
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2140/ |
jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2140/ |
Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1415/ |
jenkins job pr-rangepos: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1415/ |
Rebased against master. |
Eez good, mistah retronym. |
But I guess somebody better run the tests since the kitteh is too good for us. I'll give them a whirl. |
Started jenkins job JenkinsJob(pr-rangepos) at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1488/ |
Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1573/ |
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2300/ |
Started jenkins job pr-rangepos at https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1593/ |
Started jenkins job pr-scala-testsuite-linux-opt at https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2318/ |
jenkins job pr-rangepos: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-rangepos/1593/ |
jenkins job pr-scala-testsuite-linux-opt: Failed - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/2318/ |
Where CC and CC2 are case classes. Attempting to do so leads to a "no legal prefix" error. Now, we restrict this optimization (living in RefChecks ?!) to case class applies with a "safe to inline" qualifier.
Otherwise we fail to throw in: {???; Predef}.DummyImplicit.dummyImplicit We still elide the initialization of `Outer` in `Outer.Inner.foo` as before, although that seems a little dubious to me. In total, we had to change RefChecks, Flatten, and GenICode to effect this change. A recently fixed bug in tail call elimination was also due to assuming that the the qualifier of a Select node wasn't worthy of traversal. Let's keep a close eye out for more instances of this problem.
Without this, the following test fails: SCALAC_OPTS="-optimize" ./test/partest test/files/run/t4859.scala
To solve SI-5304, we should change `isQualifierSafeToElide`.
PLS REBUILD ALL While we wait, Martin's viewpoint on whether
I'll add these comments to SI-5304. |
From the standpoint of performance, I think we should be a lot more worried about the impact the loading semantics have on the potential for optimization: ours, proguard's, and hotspot's. All of us have to allow for module loading side effects, because we offer no true statics. I'm not sure how large is the cumulative effect, but it rears its head in enough places to add up. |
Since we're still waiting for a peep, i started a manual test run. https://scala-webapps.epfl.ch/jenkins/job/scala-checkin-manual/769/console |
Yay, the tests passed. I'll fix the merge. |
SI-4859 Step back from mis-optimizations in qualifiers
Retargetting #1710 to master.
Widespread, invalid qualifier discarding in the apparent name of performance led to a variety of problems:
The compiler would crash in case of:
And the side effect would be elided in:
This change fixes these problems but stops short of fixing the last problem:
This could be fixed use a stronger condition than
isExprSafeToInline
throughout this patch. (It would beisExprSafeToElide
orisPure
.)Thoughts? Should that change be tackled in this ticket or separately?
Last time, @paulp opined:
Review by @paulp @magarcia