[GR-78214] Make @Fold layer-aware by reusing values across layers - #14531
Merged
Merged
Conversation
…value is resolved and reuse it across all layers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Route generated
@Foldevaluation throughGraphBuilderContext.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 defaultDefaultResolverpreserves the existing behavior by resolving independently in each layer.LayeredFoldResolver.InitialLayerandLayeredFoldResolver.ApplicationLayerallow aFoldto resolve in the initial layer or the application layer. Custom resolvers can choose when to run the supplied computation throughLayeredFoldResolver.LayeredResolutionContext.For results shared across layers,
LayeredFoldFeaturecreates 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 throughCrossLayerConstantRegistry. Application-layer resolution exposes relocatable future constants to earlier layers, replays supportedFoldinvocations 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
Foldcontract: evaluation remains a build-time constant replacement, andFoldbodies are never parsed or inlined as a runtime fallback.