RFR: 8317336: Assertion error thrown during 'this' escape analysis [v4]
Archie Cobbs
acobbs at openjdk.org
Tue Oct 3 21:46:50 UTC 2023
> The 'this' escape analyzer was assuming that lambas could always be treated like blocks, in the sense that we can assume a block can never end in a plain expression. This assumption is not true for lambda's of the form `() -> foo` which do exactly that. In the case that `foo` was `this`, an assertion failure would ensue.
>
> This patch explicitly clears any leftover `ExprRef`'s after evaluating a lambda body; this restores the asserted invariant when the lambda body is an expression.
>
> This also fixes another variant of the same bug caused by certain enhanced `for()` loops. In this case, the leftover `ExprRef` was from evaluating the loop expression. This was just a side-effect of the analyzer failing to override `TreeScanner` to actually assign the loop expression to the loop variable.
Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
- Merge branch 'master' into JDK-8317336
- Replace 8ad1247a with more correct fix.
The mistaken assumption was that a lambda body is always a JCBlock.
It can also be a JCExpression, in which case it could result in an
ExprRef 'this' reference.
- Add fix and unit test for another variant of the assertion failure.
- Fix incorrect invariant assertion in this escape analysis.
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/16001/files
- new: https://git.openjdk.org/jdk/pull/16001/files/457bcca6..09e42837
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=16001&range=03
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=16001&range=02-03
Stats: 6519 lines in 237 files changed: 2427 ins; 1294 del; 2798 mod
Patch: https://git.openjdk.org/jdk/pull/16001.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/16001/head:pull/16001
PR: https://git.openjdk.org/jdk/pull/16001
More information about the compiler-dev
mailing list