[code-reflection] RFR: Replace the use of Interpreter to create Quoted instance with specialized code
Paul Sandoz
psandoz at openjdk.org
Tue May 13 20:22:10 UTC 2025
On Mon, 12 May 2025 15:10:21 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
> Creating Quoted instance was done by invoking the Interpreter. The Interpreter is too general and if someone could somehow inject any code model we will interpret that as well. This PR replace the use of the interpreter with specialized code.
We need to formalize this more. We could have two static factory methods:
1. `FuncOp CoreOp.quoteOp(Op l)` that transforms an op into a quoted func op. (There should be code around that already does this, but i have not checked where it is.)
2. `Quoted CoreOp.quotedOp(FuncOp f, Object... args)` that computes a `Quoted` instance from a quoted func op.
Such that:
LambdaOp l1 = ...
FuncOp qlf1 = quoteOp(l1);
Quoted q1 = quotedOp(qlf1, args);
LambdaOp l2 = (LambdaOp) q1.op();
FuncOp qlf2 = quoteOp(l2);
// l1 and l2 are structurally the same
// qlf1 and qlf2 are structurally the same
We need to clearly specify the model produced by `quoteOp` and therefore the validation requirements of `quoted` become clear. We might be able to present as a transformation to aid the specification.
At least the following needs to be validated.
- the func op's body contains one block consisting of, in order, zero or more var ops, a quoted op, and a return op
- there are N var ops for N block parameters
- each var op is uniquely initialized with a block parameter (possibly in order)
- the return op returns the result of the quoted op
- the quoted op's body contains one block
- the block consist in order of the op that is quoted and a yield op yielding the result of that op to be quoted
- the op to be quoted captures the results of all the var ops declared in the func op, and all such usages are for var load ops
That is applicable to quoting of lambda ops and closure ops.
-------------
PR Review: https://git.openjdk.org/babylon/pull/424#pullrequestreview-2838021289
More information about the babylon-dev
mailing list