Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar committed Nov 28, 2024
1 parent f0abe5a commit aefa0c0
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class CHACallGraph extends BasicCallGraph<CHAContextInterpreter> {
*/
private final boolean applicationOnly;

/** To handle lambdas. We pass a selector that always returns null as the base selector. */
private final LambdaMethodTargetSelector lambdaMethodTargetSelector =
new LambdaMethodTargetSelector((caller, site, receiver) -> null);

Expand Down Expand Up @@ -196,12 +197,15 @@ private Iterator<IMethod> getOrUpdatePossibleTargets(CGNode caller, CallSiteRefe
if (calleeTarget != null) {
// it's for a lambda
result = Collections.singleton(calleeTarget);
// we eagerly create a CGNode for the "trampoline" method that invokes the body of the
// lambda. This way, the new node gets added to the worklist, so we process all methods
// reachable from the lambda body in the first pass.
LambdaSummaryClass lambdaSummaryClass =
lambdaMethodTargetSelector.getLambdaSummaryClass(caller, site);
IMethod target = lambdaSummaryClass.getDeclaredMethods().iterator().next();
CGNode callee = getNode(target, Everywhere.EVERYWHERE);
IMethod trampoline = lambdaSummaryClass.getDeclaredMethods().iterator().next();
CGNode callee = getNode(trampoline, Everywhere.EVERYWHERE);
if (callee == null) {
callee = findOrCreateNode(target, Everywhere.EVERYWHERE);
callee = findOrCreateNode(trampoline, Everywhere.EVERYWHERE);
}
}
}
Expand Down

0 comments on commit aefa0c0

Please sign in to comment.