Skip to content

Commit

Permalink
Optimize the performance of CHA algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangt2333 committed Apr 3, 2024
1 parent 5225e84 commit 083f0cc
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/main/java/pascal/taie/analysis/graph/callgraph/CHABuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,18 @@ private CallGraph<Invoke, JMethod> buildCallGraph(JMethod entry) {
workList.add(entry);
while (!workList.isEmpty()) {
JMethod method = workList.poll();
callGraph.addReachableMethod(method);
callGraph.callSitesIn(method).forEach(invoke -> {
Set<JMethod> callees = resolveCalleesOf(invoke);
callees.forEach(callee -> {
if (!callGraph.contains(callee)) {
workList.add(callee);
}
callGraph.addEdge(new Edge<>(
CallGraphs.getCallKind(invoke), invoke, callee));
if (callGraph.addReachableMethod(method)) {
callGraph.callSitesIn(method).forEach(invoke -> {
Set<JMethod> callees = resolveCalleesOf(invoke);
callees.forEach(callee -> {
if (!callGraph.contains(callee)) {
workList.add(callee);
}
callGraph.addEdge(new Edge<>(
CallGraphs.getCallKind(invoke), invoke, callee));
});
});
});
}
}
return callGraph;
}
Expand Down

0 comments on commit 083f0cc

Please sign in to comment.