RFR: 8288180: C2: VectorPhase must ensure that SafePointNode memory input is a MergeMemNode [v2]
Emanuel Peter
epeter at openjdk.org
Tue Sep 13 13:12:37 UTC 2022
> **Context:**
> The `GraphKit` seems to assume that the memory input of the map (`SafePointNode`) is always a `MergeMemNode`. It requires this so that it can easily access the memory slices.
>
> **Analysis:**
> However, the `VectorPhase` also generates some `GraphKit` instances, for example in `PhaseVector::expand_vbox_alloc_node`. But at that point we are not in parsing, and the `SafePointNode` might have a folded memory state (not `MergeMemNode`). The assert in `GrahpKit::merged_memory` can thus be triggered.
>
> In this particular failure case, the `SafePointNode` was constructed/initialized with memory as a memory-phi, which was the result of a previous `GraphKit::reset_memory` call, which in turn folded the memory (the `MergeMemNode` had only one input, the memory-phi). This on its own does not necessarily trigger our assert. In many cases, the new `GraphKit` first transforms the memory input and calls `GraphKit::set_all_memory`, which makes sure there is a `MergeMemNode`. But in our failure case, `GraphKit::set_all_memory` is never called before we call `GraphKit::merged_memory`.
>
> **Side-Note:**
> The flag (`StressReflectiveCode`) was relevant because it disabled `GraphKit::get_layout_helper` from taking a constant layout helper for `T_LONG`, and instead it had to create a load (which then called `GraphKit::merged_memory`).
>
> **Suggested Solution:**
> `VectorPhase` must ensure that the map's memory input is `MergeMemNode`. We can do this in `clone_jvms`, which is called before we instanciate the `GraphKit`.
>
> I added a regression test, which fails without the fix, and passes with it.
> Ran regression tests, passed.
Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
Apply suggestions from code review
Updated comments according to Tobias' review suggestions
Co-authored-by: Tobias Hartmann <tobias.hartmann at oracle.com>
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/10215/files
- new: https://git.openjdk.org/jdk/pull/10215/files/5fcc329a..0d58d085
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=10215&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=10215&range=00-01
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/10215.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/10215/head:pull/10215
PR: https://git.openjdk.org/jdk/pull/10215
More information about the hotspot-compiler-dev
mailing list