RFR: 8300273: [IR framework] Handle <!-- safepoint while printing --> message instead of bailing out

Christian Hagedorn chagedorn at openjdk.org
Fri Jan 27 09:39:42 UTC 2023


This is yet another attempt to fix the IR framework in cases where the `tty` lock is broken for a safepoint. This time, however, I've decided to not add another bailout but to just rewrite the `hotspot_pid*` parsing code to completely parse everything. This means that `` messages are now skipped and then parsing continues for the reminder of a `PrintIdeal` output block.

#### When are `tty` locks broken?
This can only happen when dumping `PrintIdeal` for various compile phases. For `PrintOptoAssembly`, we have a `NoSafePointVerifier` object that ensures that we are not safepointing during the dump:
https://github.com/openjdk/jdk/blob/f7da09c34918eea434c82af22b1da1f2a5b35f35/src/hotspot/share/opto/output.cpp#L1814-L1822
The last interesting message printed by `LogCompilation` that needs to be parsed is the compilation queued message. This message is emitted in `CompileTask::log_task_queued()` where we also take the `tty` lock. Since we do not seem to safepoint during this method, I've added a `NoSafepointVerifier` object - just to be sure.

#### Implementation details
The idea is that we keep track of writer thread ids and currently parsed `PrintIdeal` blocks when parsing the `hotspot_pid*` file. If a new writer thread starts writing, it emits a `<writer thread='1683670'/>` message with the id. If that happens while we are still parsing a `PrintIdeal` block (i.e. not found the `</ideal>` end tag for the `<ideal ... />` opening tag), we store the currently parsed method (i.e. a `LoggedMethod` object) with its `WriterThread` in `WriterThread::saveLoggedMethod()`. When later parsing the same writer id again, we restore the method with `WriterThread::restoreLoggedMethod()` and continue parsing.

Each line of a `PrintIdeal` output block is stored within a `CompilePhaseBlock` object. This class makes sure to remove any `` message (always at the end of a line with a line break) and to merge such a split line again.

I've removed all previously added bailout fixes as they are not needed anymore with this fix.

I've added some more classes and did some renamings to better structure the parsing steps. 

#### Testing
On top of normal tier testing, I've added a separate test that parses a manually written `hotspot_pid*` file that simulates various cases of breaking the tty log and emitting the `` message with a line break.

Thanks,
Christian

-------------

Commit messages:
 - 8300273: [IR framework] Handle <!-- safepoint while printing --> message instead of bailing out

Changes: https://git.openjdk.org/jdk/pull/12246/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12246&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8300273
  Stats: 1877 lines in 32 files changed: 1158 ins; 678 del; 41 mod
  Patch: https://git.openjdk.org/jdk/pull/12246.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12246/head:pull/12246

PR: https://git.openjdk.org/jdk/pull/12246


More information about the hotspot-compiler-dev mailing list