|Control Flow Analysis for Languages with Exceptions (e.g. Java) firstname.lastname@example.org (Oliver Wong) (2006-11-04)|
|Re: Control Flow Analysis for Languages with Exceptions (e.g. Java) DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-11-05)|
|Re: Control Flow Analysis for Languages with Exceptions (e.g. Java) email@example.com (Arthur J. O'Dwyer) (2006-11-05)|
|Re: Control Flow Analysis for Languages with Exceptions (e.g. Java) firstname.lastname@example.org (Wolfram Fenske) (2006-11-05)|
|Re: Control Flow Analysis for Languages with Exceptions (e.g. Java) email@example.com (Michael Klemm) (2006-11-15)|
|From:||"Oliver Wong" <firstname.lastname@example.org>|
|Date:||4 Nov 2006 18:44:15 -0500|
|Posted-Date:||04 Nov 2006 18:44:15 EST|
I'm a novice to compiler theory, and I've been doing some reading on
control flow analysis.
It looks like the literature all agrees that the first step to
CFA, once you have the AST, is to determine what the basic blocks are
for your code. From what I understand a basic block is a sequence of
instructions such that if any one of those instructions are executed,
then all the instructions in that sequence are executed.
In the case of Java (and probably other languages with exception,
though I don't have experience with any of them), every instruction
would be its own basic block, because an exception could potentially
be thrown at any point, thus guaranteeing that there does not exist
any pair of points such that you could be certain that the second
instruction would execute, given that the first was executed.
In particular, Java has an Throwable java.lang.ThreadDeath which
is "thrown in the victim thread when the stop method with zero
arguments in class Thread is called"
It seems pretty pointless to have every instruction be in its own
basic block, so I was wondering how can the basic-block system be
reconciled with languages which support Exceptions?
As a bonus question: A lot of my interest in this is due to my
trying to understand how the control flow analysis for the FindBugs
software works (http://sourceforge.net/projects/findbugs). FindBugs
defines a class called Location, and puts in the documentation:
Because of JSR subroutines, the same instruction may actually
be part of multiple basic blocks (with different facts
true in each, due to calling context)
This surprised me quite a bit. In all of the literature I've seen
thus far, instructions should only belong to a single basic block at
one time, so I'm trying to understand what deviations from the
literature FindBugs did to implement CFA in Java.
So concretely, I'm more interested in this second "bonus"
question, but if you are unfamiliar with FindBugs, I suspected my more
abstract first question might be easier to answer, and would probably
lead me in the right direction.
Thanks for reading this far.
Return to the
Search the comp.compilers archives again.