[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Side-effects
For my BTA, I will need a side-effects analysis for methods.
The requirements for the analysis is that it should output a set of
locations read and written foreach method, preferably as a function of
the points-to sets of it's arguments and staticly read "globals", but
less precision is also acceptable.
The analysis in SideEffectAnalysis.java seems to be (after some
code-reading and experimentation) unsuitable.
It does not return points-to sets as it's output, but rather RWSets,
which are basically Sets of SootFields, which I cannot (possibly because
of my limited knowledge of the points-to analysis and soot) relate to
points-to-sets.
It also seems to be monovariant in the call-site functions arguments,
"lub'ing" the side-effects of all invocations of the function.
For example, assigning it assigns the same RWSets to the readSet and
writeSet of the lines:
Object x1 = rwarg_rec(sft1);
Object x2 = rwarg_rec(sft2);
In the attached test-program.
Any input on what direction to go in is welcome. Ultimatly, I guess I
would have to implement a side-effect analysis myself, but this problem
must have happened to others?
If the SideEffectAnalysis does provide the information I'm requesting,
how would I get that information?
For example, from the information that calling warg(sft), an SFT.o field
is writted to, how would i go about extracting the information on
whether it was sft.o? would my only option be to regard all SFT.o fields
as one location?
--
Helge
class SFT {
private int x;
SFT o;
int getx() { return x; }
void setx(int x) { this.x = x; }
}
class SFT2 extends SFT {
private int y;
int getx() { return y; }
void setx(int x) { this.y = x; }
}
public class SideEffectTest {
static Object none(SFT sft) // R: {}, W: {}
{
return null;
};
static Object rarg(SFT sft) // R: { sft.o }, W: {}
{
if (sft.o == null)
sft = sft.o;
if ( sft.getx() > 0 )
sft = sft.o;
return null;
}
static Object warg(SFT sft) // R: {}, W: { sft.o }
{
sft.o = new SFT();
sft.setx(1);
return null;
}
static Object rwarg_rec(SFT sft) // R: { sft.o }, W: { sft.o }
{
rarg(sft);
warg(sft);
return null;
}
public static void main(String[] args) {
SFT sft1 = new SFT();
if ( args.length <= 0 )
sft1.o = null;
else
sft1.o = new SFT();
SFT sft2 = new SFT2();
Object x1 = rwarg_rec(sft1);
Object x2 = rwarg_rec(sft2);
}
}