File tree Expand file tree Collapse file tree 2 files changed +25
-12
lines changed
substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -563,6 +563,29 @@ public AnalysisMethod getMethod(ResolvedJavaMethod resolvedJavaMethod) {
563
563
return methods .get (resolvedJavaMethod );
564
564
}
565
565
566
+ /**
567
+ * Returns the root {@link AnalysisMethod}s. Accessing the roots is useful when traversing the
568
+ * call graph.
569
+ *
570
+ * @param universe the universe from which the roots are derived from.
571
+ * @return the call tree roots.
572
+ */
573
+ public static List <AnalysisMethod > getCallTreeRoots (AnalysisUniverse universe ) {
574
+ List <AnalysisMethod > roots = new ArrayList <>();
575
+ for (AnalysisMethod m : universe .getMethods ()) {
576
+ if (m .isDirectRootMethod () && m .isSimplyImplementationInvoked ()) {
577
+ roots .add (m );
578
+ }
579
+ if (m .isVirtualRootMethod ()) {
580
+ for (AnalysisMethod impl : m .collectMethodImplementations (false )) {
581
+ AnalysisError .guarantee (impl .isImplementationInvoked ());
582
+ roots .add (impl );
583
+ }
584
+ }
585
+ }
586
+ return roots ;
587
+ }
588
+
566
589
public Map <Constant , Object > getEmbeddedRoots () {
567
590
return embeddedRoots ;
568
591
}
Original file line number Diff line number Diff line change 57
57
import com .oracle .graal .pointsto .BigBang ;
58
58
import com .oracle .graal .pointsto .meta .AnalysisMethod ;
59
59
import com .oracle .graal .pointsto .meta .AnalysisType ;
60
+ import com .oracle .graal .pointsto .meta .AnalysisUniverse ;
60
61
import com .oracle .graal .pointsto .meta .InvokeInfo ;
61
62
import com .oracle .graal .pointsto .meta .PointsToAnalysisMethod ;
62
63
import com .oracle .graal .pointsto .util .AnalysisError ;
@@ -182,18 +183,7 @@ public CallTreePrinter(BigBang bb) {
182
183
183
184
public void buildCallTree () {
184
185
/* Add all the roots to the tree. */
185
- List <AnalysisMethod > roots = new ArrayList <>();
186
- for (AnalysisMethod m : bb .getUniverse ().getMethods ()) {
187
- if (m .isDirectRootMethod () && m .isSimplyImplementationInvoked ()) {
188
- roots .add (m );
189
- }
190
- if (m .isVirtualRootMethod ()) {
191
- for (AnalysisMethod impl : m .collectMethodImplementations (false )) {
192
- AnalysisError .guarantee (impl .isImplementationInvoked ());
193
- roots .add (impl );
194
- }
195
- }
196
- }
186
+ List <AnalysisMethod > roots = AnalysisUniverse .getCallTreeRoots (bb .getUniverse ());
197
187
198
188
roots .sort (methodComparator );
199
189
for (AnalysisMethod m : roots ) {
You can’t perform that action at this time.
0 commit comments