[code-reflection] RFR: Partial evaluator transform [v2]

Paul Sandoz psandoz at openjdk.org
Tue Jun 10 16:35:20 UTC 2025


> This test contains an experimental partial evaluator transformer, which takes as input a model and a predicate function that can identify if an operation's result is to be considered as constant, evaluates the constant operations, and returns output model containing the evaluated results.
> 
> The transformer processes the model by traversing blocks and operations, operations in sequence and blocks in reserve post order. If an operation is classified as a constant operation as by the given predicate function returning true, and operation uses operands that are all constant, then the operation's result is considered constant. Such an operation is evaluated (interpreted) and is replaced with the explicit constant operation whose constant attribute value is the result of the evaluation. Otherwise, the operation is copied.
> 
> For forward control flow constant conditional branches, those whose predicate operand is constant, are replaced with direct branches, and constant arguments replace associated block parameters.
> 
> For loops we peel loop iterations until the iteration is not constant or the loop ends. A constant loop iteration is one whose arguments input to the loop header are constant and there is a constant path back to the loop header. Care needs to be taken when branching back to the loop header. In such cases associated state needs to be reset to peel the next iteration and determine if peeling should then continue. Supporting loops require that they are identified (the loop header, loop latches, loop body, and loop exits), including loops with multiple ways break out and continue.

Paul Sandoz has updated the pull request incrementally with one additional commit since the last revision:

  Add license.

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

Changes:
  - all: https://git.openjdk.org/babylon/pull/431/files
  - new: https://git.openjdk.org/babylon/pull/431/files/641fb7aa..673889c5

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=babylon&pr=431&range=01
 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=431&range=00-01

  Stats: 23 lines in 1 file changed: 23 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/babylon/pull/431.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/431/head:pull/431

PR: https://git.openjdk.org/babylon/pull/431


More information about the babylon-dev mailing list