RFR: 8340786: Introduce Predicate classes with predicate iterators and visitors for simplified walking
Christian Hagedorn
chagedorn at openjdk.org
Tue Sep 24 16:00:20 UTC 2024
This patch introduces new predicate classes which implement a new `Predicate` interface. These classes represent the different predicates in the C2 IR. They are used in combination with new predicate iterator and visitors classes to provide an easy way to walk and process predicates in the IR.
### Predicate Interfaces and Implementing Classes
- `Predicate` interface is implemented by four predicate classes:
- `ParsePredicate` (existing class)
- `RuntimePredicate` (existing and updated class)
- `TemplateAssertionPredicate` (new class)
- `InitializedAssertionPredicate` (new class, renamed old `InitializedAssertionPredicate` class to `InitializedAssertionPredicateCreator`)
### Predicate Iterator with Visitor classes
There is a new `PredicateIterator` class which can be used to iterate through the predicates of a loop. For each predicate, a `PredicateVisitor` can be applied. The user can implement the `PredicateIterator` interface and override the default do-nothing implementations to the specific needs of the code. I've done this for a couple of places in the code by defining new visitors:
- `ParsePredicateUsefulMarker`: This visitor marks all Parse Predicates as useful.
- Replaces the old now retired `ParsePredicateIterator`.
- `DominatedPredicates`: This visitor checks the dominance relation to an `early` node when trying to figure out the latest legal placement for a node. The goal is to skip as many predicates as possible to avoid interference with Loop Predication and/or creating a Loop Limit Check Predicate.
- Replaces the old now retired `PredicateEntryIterator`.
- `Predicates::dump()`: Newly added dumping code for the predicates above a loop which uses a new `PredicatePrinter` visitor. This helps debugging issues with predicates.
#### To Be Replaced soon
There are a couple of places where we use similar code to walk predicates and apply some transformation/modifications to the IR. The goal is to replace these locations with the new visitors as well. This will incrementally be done with the next couple of PRs.
### More Information
More information about specific classes and changes can be found as code comments and PR comments.
Thanks,
Christian
-------------
Commit messages:
- update
- 8340786: Introduce Predicate classes with predicate visitors for simplified walking
Changes: https://git.openjdk.org/jdk/pull/21161/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=21161&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8340786
Stats: 565 lines in 4 files changed: 419 ins; 62 del; 84 mod
Patch: https://git.openjdk.org/jdk/pull/21161.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/21161/head:pull/21161
PR: https://git.openjdk.org/jdk/pull/21161
More information about the hotspot-compiler-dev
mailing list