Skip to content

[GR-78214] Make @Fold layer-aware by reusing values across layers - #14531

Merged
graalvmbot merged 2 commits into
masterfrom
scoppey/GR-78214/fold-layer-support
Sep 26, 2026
Merged

graalvmbot merged 2 commits into
masterfrom
scoppey/GR-78214/fold-layer-support

Conversation

@graalvmbot

Copy link
Copy Markdown
Collaborator

Route generated @Fold evaluation through GraphBuilderContext.executeFold, preserving the target method and non-injected constant arguments so layered image builds can control when each invocation is resolved.

Add resolver-based layer policy to @Fold. The default DefaultResolver preserves the existing behavior by resolving independently in each layer. LayeredFoldResolver.InitialLayer and LayeredFoldResolver.ApplicationLayer allow a Fold to resolve in the initial layer or the application layer. Custom resolvers can choose when to run the supplied computation through LayeredFoldResolver.LayeredResolutionContext.

For results shared across layers, LayeredFoldFeature creates stable invocation keys from tracked method IDs and encoded arguments, including image-heap IDs for object arguments and raw bits for primitive arguments, and stores the results through CrossLayerConstantRegistry. Application-layer resolution exposes relocatable future constants to earlier layers, replays supported Fold invocations in the application layer, and finalizes both object and primitive results. Object constants originating in previous layers are relinked before being embedded in new graphs.

This preserves the Fold contract: evaluation remains a build-time constant replacement, and Fold bodies are never parsed or inlined as a runtime fallback.

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Sep 26, 2026
@graalvmbot
graalvmbot merged commit 758b75e into master Sep 26, 2026
3 checks passed
@graalvmbot
graalvmbot deleted the scoppey/GR-78214/fold-layer-support branch September 26, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants