|
From: Stephen F. <sj...@us...> - 2008-10-28 15:50:35
|
You are using a context-sensitivity policy that uses one abstract object
to represent all java.lang.Integer objects. Probably, you're using one of
the "standard" WALA ZeroOne -type pointer analysis, which sets the policy
ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS by default.
/**
* A policy variant where if a type T has only primitive instance
fields, then
* instances of type T are NOT disambiguated by allocation site.
*/
public static final int SMUSH_PRIMITIVE_HOLDERS = 8;
To disable this behavior, you'll need to use a pointer analysis where
SMUSH_PRIMITIVE_HOLDERS is not set. For example, see
com.ibm.wala.ipa.callgraph.impl.Util.makeVanillaZeroOneCFABuilder(), which
sets up a 0-1-CFA policy without the SMUSH optimizations.
SJF
------------------------------------------------------------------------
Stephen Fink
IBM T.J. Watson Research Center
sj...@us...
(914)784-7776
"Yao Qi" <qiy...@gm...>
10/28/2008 04:40 AM
Please respond to
WALA discussion and Q&A <wal...@li...>
To
"WALA discussion and Q&A" <wal...@li...>
cc
Subject
[Wala-wala] Point to analysis on static field access
We want to know what objects these static fields may point to, by this
code snip,
final class Visitor extends SSAInstruction.Visitor
{
@Override
public void visitGet(SSAGetInstruction instruction)
{
if (instruction.isStatic())
{
IField f =
ai.getClassHierarchy().resolveField(instruction.getDeclaredField());
PointerKey refPointer =
pt.getHeapModel().getPointerKeyForStaticField(f);
OrdinalSet<InstanceKey> instances =
pt.getPointsToSet(refPointer);
for (Iterator<InstanceKey> it =
instances.iterator(); it.hasNext();)
{
InstanceKey ik =
it.next();
ConcreteTypeKey ctk =
(ConcreteTypeKey) ik;
System.out.println
(ctk.getConcreteType()); //
}
}
}
Visitor v = new Visitor();
int first = bb.getFirstInstructionIndex();
int last = bb.getLastInstructionIndex();
for (int i = first; i <= last; i++)
{
SSAInstruction s = statements[i];
if (s != null)
{
s.visit(v);
}
}
What we got is shown below,
<Primordial,Ljava/lang/Integer>
<Primordial,Ljava/lang/Integer>
What we expecte is that different static field may point to different
objects. However, these static fields are represend by
ConcreteTypekey, and all of them is the same. we could not know
wether two static fields point to the same object or not. I guess
that InstanceKeyWithNode should be got, because these static field is
initialized in <clinit>.
Please let me know if I made some mistakes or misunderstand APIs in
WALA. Thanks.
Test Case.
-----------------------
public class PointTo
{
static Integer lock = new Integer(0);
static Integer lock1 = new Integer(1);
Object o;
public PointTo()
{
o = null;
}
public void m()
{}
/**
* @param args
*/
public static void main(String[] args)
{
PointTo pt = new PointTo();
synchronized (lock)
{
pt.o = new Object();
}
synchronized (lock1)
{
Object o = pt.o;
}
}
}
--
Yao
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Wala-wala mailing list
Wal...@li...
https://lists.sourceforge.net/lists/listinfo/wala-wala
|