[code-reflection] Integrated: Partial evaluator transform

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


On Tue, 20 May 2025 23:08:45 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> 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.

This pull request has now been integrated.

Changeset: 49f0d9bb
Author:    Paul Sandoz <psandoz at openjdk.org>
URL:       https://git.openjdk.org/babylon/commit/49f0d9bbc035be5b2f25f3ca9b380c7b2ac20812
Stats:     1641 lines in 7 files changed: 1636 ins; 4 del; 1 mod

Partial evaluator transform

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

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


More information about the babylon-dev mailing list