Skip to content

Add special handling for zero-length arrays to enhance PTA precision - #140

Merged
zhangt2333 merged 2 commits into
pascal-lab:masterfrom
cs-cat:master
Feb 16, 2025
Merged

zhangt2333 merged 2 commits into
pascal-lab:masterfrom
cs-cat:master

Conversation

@cs-cat

@cs-cat cs-cat commented Feb 13, 2025 •

Copy link
Copy Markdown
Collaborator

Maintaining a points-to-set for components of a zero-length array is unnecessary. Use a mock object ZeroLengthArray to represent the zero-length array object instead.

Some microbenchmarks suggest improvements in both precision and performance.

benchmark result on dacapo-2006:eclipse

context sensitivity var points-to (insens) var points-to (sens) array points-to
ci 2509,6346 N/A 65,1524
ci+patch 2496,6038 (-0.5%) N/A 62,7517 (-3.7%)
1obj 1142,7739 8890,1119 21,2872
1obj+patch 1136,7029 (-0.5%) 8829,0413 (-0.7%) 20,8039 (-2.3%)

@codecov-commenter

codecov-commenter commented Feb 13, 2025 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.94%. Comparing base (3f3b802) to head (c7237a2).

Files with missing lines Patch % Lines
...taie/analysis/pta/core/heap/AbstractHeapModel.java 91.66% 0 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #140      +/-   ##
============================================
+ Coverage     71.91%   71.94%   +0.02%     
- Complexity     4354     4365      +11     
============================================
  Files           479      479              
  Lines         15856    15868      +12     
  Branches       2175     2179       +4     
============================================
+ Hits          11403    11416      +13     
- Misses         3571     3573       +2     
+ Partials        882      879       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhangt2333 zhangt2333 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very great optimization. Thanks for your work.

I've left some suggestions for improving the clarity of the code. Please give feedback. Finally, don't forget to rerun and update the "*-expected.txt" file.

Comment thread src/main/java/pascal/taie/analysis/pta/core/heap/AbstractHeapModel.java Outdated
Comment thread src/main/java/pascal/taie/analysis/pta/core/heap/AbstractHeapModel.java Outdated
Comment thread src/test/resources/pta/basic/ZeroSizedArray.java
@cs-cat cs-cat changed the title Use mock objects for zero-length array Enhance precision and performance of PTA by special handling of new T[0] Feb 15, 2025
@cs-cat

cs-cat commented Feb 15, 2025

Copy link
Copy Markdown
Collaborator Author

Thanks, @zhangt2333 !
Here are changes since the first version:

  • code: Factor out method isZeroSizedArrayAllocation to improve readability.
  • code: Include array type in alloc of the mock object.
  • tests: Use PTAAssert in ZeroSizedArray test.
  • misc: Reword commit and PR. Attach benchmark results in PR descriptopn.

@cs-cat

cs-cat commented Feb 15, 2025

Copy link
Copy Markdown
Collaborator Author

revision 2:

  • ZeroSized -> ZeroLength
  • Add this PR to changelog

@cs-cat cs-cat changed the title Enhance precision and performance of PTA by special handling of new T[0] Add special handling for zero-length arrays to enhance PTA precision Feb 15, 2025
Signed-off-by: cs-cat <118669451+cs-cat@users.noreply.github.com>
@zhangt2333
zhangt2333 merged commit f4f1c5d into pascal-lab:master Feb 16, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants