@@ -184,7 +184,7 @@ public class MethodTypeFlowBuilder {
184
184
protected StructuredGraph graph ;
185
185
private NodeBitMap processedNodes ;
186
186
private Map <PhiNode , TypeFlowBuilder <?>> loopPhiFlows ;
187
- private final MethodFlowsGraph . GraphKind graphKind ;
187
+ private final GraphKind graphKind ;
188
188
private boolean processed = false ;
189
189
private final boolean newFlowsGraph ;
190
190
@@ -240,28 +240,7 @@ private boolean parse(Object reason, boolean forceReparse) {
240
240
graph = InlineBeforeAnalysis .decodeGraph (bb , method , analysisParsedGraph );
241
241
242
242
try (DebugContext .Scope s = graph .getDebug ().scope ("MethodTypeFlowBuilder" , graph )) {
243
- CanonicalizerPhase canonicalizerPhase = CanonicalizerPhase .create ();
244
- canonicalizerPhase .apply (graph , bb .getProviders (method ));
245
- if (PointstoOptions .ConditionalEliminationBeforeAnalysis .getValue (bb .getOptions ())) {
246
- /*
247
- * Removing unnecessary conditions before the static analysis runs reduces the size
248
- * of the type flow graph. For example, this removes redundant null checks: the
249
- * bytecode parser emits explicit null checks before e.g., all method calls, field
250
- * access, array accesses; many of those dominate each other.
251
- */
252
- new IterativeConditionalEliminationPhase (canonicalizerPhase , false ).apply (graph , bb .getProviders (method ));
253
- }
254
- if (PointstoOptions .EscapeAnalysisBeforeAnalysis .getValue (bb .getOptions ())) {
255
- if (method .isOriginalMethod ()) {
256
- /*
257
- * Deoptimization Targets cannot have virtual objects in frame states.
258
- *
259
- * Also, more work is needed to enable PEA in Runtime Compiled Methods.
260
- */
261
- new BoxNodeIdentityPhase ().apply (graph , bb .getProviders (method ));
262
- new PartialEscapePhase (false , canonicalizerPhase , bb .getOptions ()).apply (graph , bb .getProviders (method ));
263
- }
264
- }
243
+ optimizeGraphBeforeAnalysis (bb , method , graph );
265
244
266
245
if (!bb .getUniverse ().hostVM ().validateGraph (bb , graph )) {
267
246
graph = null ;
@@ -277,8 +256,33 @@ private boolean parse(Object reason, boolean forceReparse) {
277
256
}
278
257
}
279
258
280
- public static void registerUsedElements (PointsToAnalysis bb , StructuredGraph graph , boolean usePredicates ) {
281
- PointsToAnalysisMethod method = (PointsToAnalysisMethod ) graph .method ();
259
+ public static void optimizeGraphBeforeAnalysis (AbstractAnalysisEngine bb , AnalysisMethod method , StructuredGraph graph ) {
260
+ CanonicalizerPhase canonicalizerPhase = CanonicalizerPhase .create ();
261
+ canonicalizerPhase .apply (graph , bb .getProviders (method ));
262
+ if (PointstoOptions .ConditionalEliminationBeforeAnalysis .getValue (bb .getOptions ())) {
263
+ /*
264
+ * Removing unnecessary conditions before the static analysis runs reduces the size of
265
+ * the type flow graph. For example, this removes redundant null checks: the bytecode
266
+ * parser emits explicit null checks before e.g., all method calls, field access, array
267
+ * accesses; many of those dominate each other.
268
+ */
269
+ new IterativeConditionalEliminationPhase (canonicalizerPhase , false ).apply (graph , bb .getProviders (method ));
270
+ }
271
+ if (PointstoOptions .EscapeAnalysisBeforeAnalysis .getValue (bb .getOptions ())) {
272
+ if (method .isOriginalMethod ()) {
273
+ /*
274
+ * Deoptimization Targets cannot have virtual objects in frame states.
275
+ *
276
+ * Also, more work is needed to enable PEA in Runtime Compiled Methods.
277
+ */
278
+ new BoxNodeIdentityPhase ().apply (graph , bb .getProviders (method ));
279
+ new PartialEscapePhase (false , canonicalizerPhase , bb .getOptions ()).apply (graph , bb .getProviders (method ));
280
+ }
281
+ }
282
+ }
283
+
284
+ public static void registerUsedElements (AbstractAnalysisEngine bb , StructuredGraph graph , boolean usePredicates ) {
285
+ var method = (AnalysisMethod ) graph .method ();
282
286
HostedProviders providers = bb .getProviders (method );
283
287
for (Node n : graph .getNodes ()) {
284
288
if (n instanceof InstanceOfNode ) {
@@ -295,7 +299,8 @@ public static void registerUsedElements(PointsToAnalysis bb, StructuredGraph gra
295
299
type .registerAsInstantiated (AbstractAnalysisEngine .sourcePosition (node ));
296
300
for (var f : type .getInstanceFields (true )) {
297
301
var field = (AnalysisField ) f ;
298
- field .getInitialFlow ().addState (bb , TypeState .defaultValueForKind (bb , field .getStorageKind ()));
302
+ PointsToAnalysis pta = (PointsToAnalysis ) bb ;
303
+ field .getInitialFlow ().addState (pta , TypeState .defaultValueForKind (pta , field .getStorageKind ()));
299
304
}
300
305
}
301
306
@@ -416,7 +421,7 @@ public static void registerUsedElements(PointsToAnalysis bb, StructuredGraph gra
416
421
* {@link FrameState} are only used for debugging. We do not want to have larger images just so
417
422
* that users can see a constant value in the debugger.
418
423
*/
419
- protected static boolean ignoreConstant (PointsToAnalysis bb , ConstantNode node ) {
424
+ protected static boolean ignoreConstant (AbstractAnalysisEngine bb , ConstantNode node ) {
420
425
for (var u : node .usages ()) {
421
426
if (u instanceof ClassIsAssignableFromNode usage ) {
422
427
if (!bb .getHostVM ().isClosedTypeWorld () || usage .getOtherClass () == node || usage .getThisClass () != node ) {
@@ -472,7 +477,7 @@ protected static boolean needsUnsafeRegistration(FieldOffsetProvider node) {
472
477
* later. Therefore, we must mark the instanceof checked type as reachable. Moreover, stamp
473
478
* strengthening based on reachability status of types must be disabled.
474
479
*/
475
- protected static boolean ignoreInstanceOfType (PointsToAnalysis bb , AnalysisType type ) {
480
+ protected static boolean ignoreInstanceOfType (AbstractAnalysisEngine bb , AnalysisType type ) {
476
481
if (bb .getHostVM ().ignoreInstanceOfTypeDisallowed ()) {
477
482
return false ;
478
483
}
@@ -493,11 +498,11 @@ protected static boolean ignoreInstanceOfType(PointsToAnalysis bb, AnalysisType
493
498
return true ;
494
499
}
495
500
496
- private static void registerEmbeddedRoot (PointsToAnalysis bb , ConstantNode cn ) {
501
+ private static void registerEmbeddedRoot (AbstractAnalysisEngine bb , ConstantNode cn ) {
497
502
bb .getUniverse ().registerEmbeddedRoot (cn .asJavaConstant (), AbstractAnalysisEngine .sourcePosition (cn ));
498
503
}
499
504
500
- private static void registerForeignCall (PointsToAnalysis bb , ForeignCallsProvider foreignCallsProvider , ForeignCallDescriptor foreignCallDescriptor , ResolvedJavaMethod from ) {
505
+ private static void registerForeignCall (AbstractAnalysisEngine bb , ForeignCallsProvider foreignCallsProvider , ForeignCallDescriptor foreignCallDescriptor , ResolvedJavaMethod from ) {
501
506
Optional <AnalysisMethod > targetMethod = bb .getHostVM ().handleForeignCall (foreignCallDescriptor , foreignCallsProvider );
502
507
targetMethod .ifPresent (analysisMethod -> bb .addRootMethod (analysisMethod , true , from ));
503
508
}
@@ -725,7 +730,7 @@ protected void apply(boolean forceReparse, Object reason) {
725
730
}
726
731
727
732
boolean insertPlaceholderFlows = bb .getHostVM ().getMultiMethodAnalysisPolicy ().insertPlaceholderParamAndReturnFlows (method .getMultiMethodKey ());
728
- if (graphKind == MethodFlowsGraph . GraphKind .STUB ) {
733
+ if (graphKind == GraphKind .STUB ) {
729
734
AnalysisError .guarantee (insertPlaceholderFlows , "placeholder flows must be enabled for STUB graphkinds." );
730
735
insertPlaceholderParamAndReturnFlows ();
731
736
return ;
0 commit comments