Static Points-to Analysis Query

Jonathan Byrne <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Hi, I've used ASM to implement a very, very simple intra-procedural
points-to analysis that is based on an iterative forward-seeking,
fixed-point, data-flow analysis. For the moment I'm just interested in
detecting relationships (or points-to sets) for objects, so I'm
tracking for the moment: ALOAD for the right-hand side of an
assignment; and ASTORE for the left-hand side of an expression. My
analysis is very simple because it detects cases like:

if (someBoolean) {
    // Exoression 1
    // ALOAD 1
    // ASTORE 0
    o = a;
} else {
    // Exoression 2
    // ALOAD 2
    // ASTORE 0
    o = b;
}

My question is (and I must say, I'm very new to this area): how do I
-- in a general way -- detect an expression like 1 and 2 above where
the bytecode for the left and right-hand side of an expression can be
become very complicated:

// ALOAD A
// ALOAD B
// GETFIELD B.f
// GETFIELD B.f.f'
// PUTFIELD A.f
A.f = B.f.f'

Do I need to define a Deterministic Finite State Automata (DFA) for
all possible as a bunch switch, cases, which I think can get rather
large. Or is there a smarter way to do this, like modelling the
execution of the bytecode like in Analyzer.java, but I think this is
only useful for checking for type safety on opcode usage.

The problem becomes more apparent when I want to see which objects are escaping:

// ILOAD 0
// ALOAD 1
// INVOKESTATIC methodDispatch....
z = methodDispatch(int, Object);

This is a rather simple case, and I could right a simple set of
switch, cases to detect this pattern in the bytecode, but integer
parameter might come from an object's field (ALOAD X, GETFIELD I) and
the same for the Object parameter; furthermore the number of
parameters could be N, and a method's signature can vary a lot: int,
double or double, float, Object, and so on...

I fear the solution is going to be rather painful :-) and lengthly;
I'm kinda of thinking I'll need to define a DFA like:

(s0) --ALOAD--> (s1) --GETFIELD--> (s2)  --ASTORE--> (s3)

With a loop back from s2 to s1 and if I reach state s3 where s2 has
been visited twice then the bytecode sequence is:

ALOAD
GETFIELD
GETFIELD
ASTORE

And so on, but this can very easily get complex and out-of-hand with cases like:

x = methodA(int, double, Object) + methodB(float, Array, Object.f.f')

Any comments, suggestions would be GREATLY appreciate!!

Many thanks,
Jon.
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.