Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lambda support to CHACallGraph #1476

Merged
merged 27 commits into from
Nov 30, 2024
Merged

Conversation

msridhar
Copy link
Member

@msridhar msridhar commented Nov 28, 2024

Fixes #1459

To support lambdas, we re-use logic from the LambdaMethodTargetSelector to handle calls that use invokedynamic. CHACallGraph only includes edges for methods reachable from given entrypoints, and our handling of lambdas adds new synthetic classes to the class hierarchy (representing the classes generated for lambdas). So to ensure a complete call graph, we do a second pass after adding these synthetic classes to recompute call targets. This is probably not the most efficient way to do things, but I'm not sure it's the bottleneck; if we need to optimize in the future we should do so based on profiling.

Note that the handling of lambdas here is very imprecise; every call site of a functional interface method will have an edge to every lambda of that functional interface type. Still, it could be practically useful, e.g., when combined with other heuristic filtering of irrelevant code.

We add new tests, and also fix a couple other minor bugs (e.g., there was no edge before to the synthetic method that invokes class initializers, so it wasn't being processed properly).

Copy link

github-actions bot commented Nov 28, 2024

Test Results

  813 files  ± 0    813 suites  ±0   4h 12m 4s ⏱️ + 1m 47s
  739 tests + 3    722 ✅ + 3   17 💤 ±0  0 ❌ ±0 
5 057 runs  +21  4 936 ✅ +21  121 💤 ±0  0 ❌ ±0 

Results for commit a81546d. ± Comparison against base commit 6d62392.

♻️ This comment has been updated with latest results.

@msridhar msridhar marked this pull request as ready for review November 29, 2024 18:59
Copy link
Contributor

@liblit liblit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I suggest a few minor tweaks to improve code and Javadoc style.

@msridhar msridhar requested a review from liblit November 30, 2024 17:56
@msridhar
Copy link
Member Author

Looks good. I suggest a few minor tweaks to improve code and Javadoc style.

Thanks for the detailed review! All suggestions applied.

@msridhar msridhar enabled auto-merge (squash) November 30, 2024 17:58
@msridhar msridhar merged commit 9f71651 into wala:master Nov 30, 2024
10 checks passed
@msridhar msridhar deleted the cha-lambda-tinkering branch November 30, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support lambdas in CHA call graph construction
2 participants