Remove a redundant PTS updating#176
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #176 +/- ##
============================================
+ Coverage 71.91% 75.19% +3.28%
- Complexity 4354 4584 +230
============================================
Files 479 480 +1
Lines 15856 15927 +71
Branches 2175 2181 +6
============================================
+ Hits 11403 11977 +574
+ Misses 3571 3078 -493
+ Partials 882 872 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Just passing by, but I noticed that the assigned context for reflective objects is also suspicious. It bypasses the standard method This makes reflective objects directly inherit the context of the method containing its allocation-site (limited by the parameter This might not be a huge concern for soundness, but it might introduce excessive reflective objects and therefore affect the efficiency of a pointer analysis. |
|
This redundancy should not be a concern since As for safety, the model of |
Thanks for pointing this out, I think it is an interesting issue, maybe this needs @zhangt2333 to make a further assessment.
For this part, the 2 calls to |
|
Thank you for @Michael1015198808's PR. I reviewed the three usages of I'm not sure if line 259 is meant to maintain consistency with this usage pattern (needs further confirmation from @silverbullettt). If this line is removed, the left-hand side assignment on line 258 could also be deleted. Regarding the heap selection mentioned by @jjppp, I'm not the author of the reflection analysis related code, but I noticed there's a comment at , so I suspect this design might be intentional. |
|
I agree with @Michael1015198808 that L259 is indeed redundant and can be removed. Although this redundancy should not cause performance or correctness issues, it would still be good to eliminate it. As @zhangt2333 mentioned, if we remove it, As for the heap context issue raised by @jjppp , when Selecting k-1 as the heap context should be a detail within the Additionally, to ensure correctness before merging this change, perhaps @Michael1015198808 could run pointer analyses on some reflection-intensive programs and then compare whether the results are exactly the same after deleting L259? |
Sure! But I am only an API guy 😢 and not very familiar with different benchmark features. Therefore, I wrote scripts to test on ALL benchmarks provided by
For an easier reproductivity, I provide 2 scripts, Update at July 25th
I've finished testing on the latest commit 359eb63 and no difference was detected. But I have to say that I simply run the |
|
Thank @Michael1015198808! Once |



In
ReflectiveActionModel'sarrayNewInstance, the code first callsnewReflectiveObj(context, invoke, arrayType)to create a reflective object for the array, and then callssolver.addVarPointsTo(context, result, csNewArray)to make theresultpoints to this newly allocated object:Tai-e/src/main/java/pascal/taie/analysis/pta/plugin/reflection/ReflectiveActionModel.java
Lines 258 to 259 in 21118b5
However,
newReflectiveObjhas already done the updation of the points-to set ofresult(Line 156), and it also performs a null-check onresultto ensure that invocation does contain a left-value.Tai-e/src/main/java/pascal/taie/analysis/pta/plugin/reflection/ReflectiveActionModel.java
Lines 149 to 159 in 21118b5
Therefore, I think
Tai-e/src/main/java/pascal/taie/analysis/pta/plugin/reflection/ReflectiveActionModel.java
Line 259 in 21118b5
newReflectiveObjwill add the points-to relation ifresultis not null) and dangerous (if theresultis null due to some rare corner cases).Is simply removing it safe? I am not sure if there is any special case that I ignore.