Summary
Umbrella issue for ADR-029 Phase 5: target-aware compiler and stdlib optimizations that use PV11 features to reduce script size and/or execution budget.
No Phase 5 optimization should begin until the explicit V3/PV11 compiler target and feature enforcement in #76 are complete. Correctness and target legality come first. Each optimization accepted for implementation will receive its own focused issue and PR, linked back to this umbrella.
Related readiness umbrella: #65
Compiler-target prerequisite: #76
Phase 0 contract cleanup: #75
ADR tasks: PV11-050 through PV11-056
Cost/reference baseline: cardano-node 11.0.1 / Plutus 1.63.0.0 at f92b7d7d82622a26caf456a6be33859f697e2cfc
Initial policy
The initial compiler target is V3/PV11 only. Phase 5 therefore does not need to maintain PV10 fallback lowerings. If JuLC later adds a PV10 compiler target, each affected optimization must define a legal fallback or reject that feature for PV10 in a separate target-support issue.
This phase is not required for Java/Truffle evaluator parity. It improves generated code after the compiler can prove that the selected operations are legal for its target.
Candidate workstreams
PV11-050 — Lower JulcList.drop to DropList — P1 / S
Replace the current recursive NullList/TailList lowering with the native PV11 DropList builtin for the V3/PV11 target.
Required evidence:
- equivalent results and failure behavior;
- smaller generated UPLC;
- lower budget for representative list sizes and counts;
- regression tests demonstrating that the final program contains
DropList rather than the recursive template.
PV11-051 — Case-on-builtin lowering — P1 / L
Evaluate target-aware lowering of:
- boolean conditionals to
Case Bool;
- list matching/decomposition to
Case List;
- integer switches to
Case Integer;
- native pair destructuring to
Case Pair.
Each rewrite must preserve strictness and failure behavior and must beat the existing chooser/equality/list-builtin form under the pinned PV11 cost model. This may become more than one child issue if the lowerings are independently reviewable.
PV11-052 — Typed native Value API and lowering — P1 / M
Introduce a dedicated native Value type, tentatively JulcValue, instead of representing both ordinary Data and native Value as PlutusData.
Target flow:
Data-encoded Value
-> UnValueData once
-> native lookup/union/contains/scale operations
-> ValueData only at an external Data boundary
The design should prevent accidental Data/Value mixing and allow redundant conversions and nested-map scans to be eliminated safely.
PV11-053 — Cost-directed list-to-array promotion — P2 / L
Detect repeated indexed access to the same immutable list and, only when profitable, lower it to:
ListToArray once
-> repeated IndexArray calls
The child issue must define cost-model-derived break-even thresholds, use-count/escape analysis, and cases that must remain lists. Single or cheap sequential accesses must not be promoted blindly.
PV11-054 — BLS MSM fusion and typed API — P2 / M
Recognize or expose typed expressions equivalent to:
s1 * P1 + s2 * P2 + ... + sn * Pn
and lower them to the PV11 G1/G2 multi-scalar-multiplication builtins when list length, scalar bounds, and failure semantics match. Replace loosely typed PlutusData list surfaces where practical.
PV11-055 — ExpModInteger lowering and constant folding — P2 / M
- Add a target-aware mapping for explicit modular-exponentiation idioms.
- Constant-fold literal calls only when reference failure behavior is preserved.
- Never rewrite ordinary exponentiation without an explicit modulus.
PV11-056 — Target-aware Value/Array constant folding — P2 / M
Fold pure literal operations whose result or failure is statically known and legal for V3/PV11, including selected array length/index/drop and native Value operations. Known failures must remain failures at the correct semantic point.
Child-issue policy
Before implementing a workstream:
- Create a focused issue linked here.
- Record the exact source pattern and generated before/after UPLC.
- Define semantic, strictness, and failure-equivalence tests.
- Define representative script-size and CPU/memory benchmarks using the pinned PV11 costs.
- Decide whether the optimization is mandatory, optional, or behind a compiler flag.
- Document any generated-script hash change and migration impact.
- Have the implementation independently reviewed before merge.
Shared acceptance requirements
Every child optimization must:
Umbrella checklist
Out of scope
Deferred implementation follow-ups
ADR-032 research/disposition is complete. The checklist below tracks later implementation or prerequisite work. A rule must not be enabled merely because its PV11 builtin exists.
Each follow-up inherits this umbrella's shared acceptance requirements and adds operation-specific gates for semantic equivalence, evaluation order and strictness, reference failure behavior, deterministic output, pinned PV11 size/CPU/memory evidence, Java/Truffle agreement, Scalus language-level cross-checking where supported, affected-module and repository tests, documentation, and independent correctness review.
A follow-up may close without enabling a rewrite when its decision gate proves that no safe or useful source contract exists. Such a rejection must be recorded in ADR evidence; it must not be converted into an untyped peephole optimization.
Summary
Umbrella issue for ADR-029 Phase 5: target-aware compiler and stdlib optimizations that use PV11 features to reduce script size and/or execution budget.
No Phase 5 optimization should begin until the explicit V3/PV11 compiler target and feature enforcement in #76 are complete. Correctness and target legality come first. Each optimization accepted for implementation will receive its own focused issue and PR, linked back to this umbrella.
Related readiness umbrella: #65
Compiler-target prerequisite: #76
Phase 0 contract cleanup: #75
ADR tasks:
PV11-050throughPV11-056Cost/reference baseline: cardano-node 11.0.1 / Plutus 1.63.0.0 at
f92b7d7d82622a26caf456a6be33859f697e2cfcInitial policy
The initial compiler target is V3/PV11 only. Phase 5 therefore does not need to maintain PV10 fallback lowerings. If JuLC later adds a PV10 compiler target, each affected optimization must define a legal fallback or reject that feature for PV10 in a separate target-support issue.
This phase is not required for Java/Truffle evaluator parity. It improves generated code after the compiler can prove that the selected operations are legal for its target.
Candidate workstreams
PV11-050 — Lower
JulcList.droptoDropList— P1 / SReplace the current recursive
NullList/TailListlowering with the native PV11DropListbuiltin for the V3/PV11 target.Required evidence:
DropListrather than the recursive template.PV11-051 — Case-on-builtin lowering — P1 / L
Evaluate target-aware lowering of:
Case Bool;Case List;Case Integer;Case Pair.Each rewrite must preserve strictness and failure behavior and must beat the existing chooser/equality/list-builtin form under the pinned PV11 cost model. This may become more than one child issue if the lowerings are independently reviewable.
PV11-052 — Typed native Value API and lowering — P1 / M
Introduce a dedicated native Value type, tentatively
JulcValue, instead of representing both ordinaryDataand nativeValueasPlutusData.Target flow:
The design should prevent accidental Data/Value mixing and allow redundant conversions and nested-map scans to be eliminated safely.
PV11-053 — Cost-directed list-to-array promotion — P2 / L
Detect repeated indexed access to the same immutable list and, only when profitable, lower it to:
The child issue must define cost-model-derived break-even thresholds, use-count/escape analysis, and cases that must remain lists. Single or cheap sequential accesses must not be promoted blindly.
PV11-054 — BLS MSM fusion and typed API — P2 / M
Recognize or expose typed expressions equivalent to:
and lower them to the PV11 G1/G2 multi-scalar-multiplication builtins when list length, scalar bounds, and failure semantics match. Replace loosely typed
PlutusDatalist surfaces where practical.PV11-055 —
ExpModIntegerlowering and constant folding — P2 / MPV11-056 — Target-aware Value/Array constant folding — P2 / M
Fold pure literal operations whose result or failure is statically known and legal for V3/PV11, including selected array length/index/drop and native Value operations. Known failures must remain failures at the correct semantic point.
Child-issue policy
Before implementing a workstream:
Shared acceptance requirements
Every child optimization must:
Umbrella checklist
DropListlowering).ExpModIntegerlowering/folding).Out of scope
Deferred implementation follow-ups
ADR-032 research/disposition is complete. The checklist below tracks later implementation or prerequisite work. A rule must not be enabled merely because its PV11 builtin exists.
Each follow-up inherits this umbrella's shared acceptance requirements and adds operation-specific gates for semantic equivalence, evaluation order and strictness, reference failure behavior, deterministic output, pinned PV11 size/CPU/memory evidence, Java/Truffle agreement, Scalus language-level cross-checking where supported, affected-module and repository tests, documentation, and independent correctness review.
A follow-up may close without enabling a rewrite when its decision gate proves that no safe or useful source contract exists. Such a rejection must be recorded in ADR evidence; it must not be converted into an untyped peephole optimization.