Control Flow Analysis for Languages with Exceptions (e.g. Java)

"Oliver Wong" <owong@castortech.com>
4 Nov 2006 18:44:15 -0500

          From comp.compilers

Related articles
Control Flow Analysis for Languages with Exceptions (e.g. Java) owong@castortech.com (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) ajonospam@andrew.cmu.edu (Arthur J. O'Dwyer) (2006-11-05)
Re: Control Flow Analysis for Languages with Exceptions (e.g. Java) int2k@gmx.net (Wolfram Fenske) (2006-11-05)
Re: Control Flow Analysis for Languages with Exceptions (e.g. Java) usenet@gmx.info (Michael Klemm) (2006-11-15)
| List of all articles for this month |
From: "Oliver Wong" <owong@castortech.com>
Newsgroups: comp.compilers
Date: 4 Nov 2006 18:44:15 -0500
Organization: GlobeTrotter
Keywords: analysis, question
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"
(http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ThreadDeath.html)


        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:


<quote>
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)
</quote>


        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.


        - Oliver



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.