CompL-Research / stava

Stava is a static program analysis for identifying stack allocable objects of code written in Java 8
7 stars 6 forks source link

Can new arrays be allcoated on stack? #5

Open 42niks opened 4 years ago

42niks commented 4 years ago

Should new array statements be tracked for their escape status or shall we just discard them as objects that escape?

42niks commented 4 years ago

getSootClass is not available for the object received from doing ((JNewArrayExpr)rhs).getBaseType(). Cannot check if it is runnable. @manasthakur

manasthakur commented 4 years ago

If an array object does not escape the current method, my guess is that we can allocate it on the stack -- the array object is just a single reference and destroying it doesn't remove the contained objects (if they escape, they will still be accessible from the reference that made them escape).

For the second question, will the following work?

if (t instanceof RefType) {
    SootClass c = ((RefType) t).getSootClass();