[GR-45250] [GR-45734] Strict Dynamic Access Inference #11079
Merged
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.
Additions from this PR
The current implementation of the analysis for constant reflection (and other dynamic access) invocations is optimization dependent, leading to the possibility of different image run-time behavior when compiled with different optimization options (specifically related to
InlineBeforeAnalysis).This PR introduced a bytecode-level analysis for such invocations, thus avoiding any graph optimizations.
Two new hosted options are introduced:
-H:StrictDynamicAccessInference=Disable|Warn|Enforce-H:+ReportDynamicAccessInferenceReview guide
The PR is roughly split into the following components:
com.oracle.svm.hosted.dynamicaccessinference.dataflowpackage. The main classes here are:com.oracle.svm.hosted.dynamicaccessinference.dataflow.ForwardDataFlowAnalyzer- a generic data flow analyzer;com.oracle.svm.hosted.dynamicaccessinference.dataflow.AbstractInterpreter- an abstract bytecode interpreter built on top ofForwardDataFlowAnalyzerby propagating abstract bytecode execution frames through the data-flow.AbstractInterpreter. It is implemented in thecom.oracle.svm.hosted.dynamicaccessinferencepackage.The entry point of the analysis is in the
com.oracle.svm.hosted.dynamicaccessinference.StrictDynamicAccessInferenceFeatureclass. The main steps are:com.oracle.svm.hosted.dynamicaccessinference.ConstantExpressionRegistryand register it as an image singleton. The registry maps method and BCI pairs into the abstract frame state before the execution of the corresponding instruction. That abstract state holds the information on constant expressions.AnalysisBytecodeParserusing acom.oracle.svm.hosted.dynamicaccessinference.ConstantExpressionAnalyzer. The results are stored in the constant expression registry.Class.forName(String).Additionally, report generation for inferred calls is handled by the
com.oracle.svm.hosted.dynamicaccessinference.DynamicAccessInferenceReportFeaturefeature.One important implementation detail to note is that
ConstantExpressionAnalyzerunwraps analysis methods in order to avoid lookups through the analysis universe, and thus potential unsupported feature exceptions.