|
From: Thomas G. <Tho...@fz...> - 2003-03-27 08:37:06
|
Hi *, hmm, I don't know. Dead code analysis is either very conservative (i.e., the statically observable control flow is analysed and some very rough estimations are made) or very costly (in case you use abstract interpretation; it basically boils down to points-to analysis which is undecidable in general and can thus only yield approximations). Thus i don't really see what we would gain here. We either end up having the same functionality as the java compiler (in fact we already have this kind of stuff: "before exit" requires a control flow analysis as well as the check whether a fragment (the parameter to before/after operations) is valid, i.e., does not produce dead code). Or we need to integrate a sophisticated points-to analysis (in fact we have this analysis readily available: Holger Bär has built it for his PhD) which runs in the order of hours to produce decent results for a small-to-medium sized system. A general-purpose trafo does not really make sense for my point of view (see the aforementioned problems). We could however add a heuristic function to the, say, methods and classes like "boolean containsDeadCodeBlocks(...)" or even "markDeadCodeBlocks" to put comments around code which is proven to be "dead". Question is what the advantages are (or: do the advantages outweigh the disadvantages?) The disadvantages I see: - we need to be able to analyse dead code not only on the basis of static control flow (scf) approximations (i.e., the way of the java compiler). If we would only do scf analysis we either end up with no "hits" (given our pre-requisite -- the Java code is compilable before transformation -- still holds). Or (again with scf analysis) we drop this pre-requisite (i.e., if there is statically observable dead code in the program, it would never have made it through the compiler thus it is not correct) which I personally do not like either. - Analysing the "dynamic" control flow is *very* costly. We would need to restrict ourselves to heuristics which are easy (and fast) to compute and still accurate enough to be of any use. If the belowmentioned tool can do this -- fine! If not I'd say let's drop this by now. Cheers, Thomas P.S.: Don't drink to many B52's :-) Sven Luzar wrote: > Hello together, > > > > the following webside presents an analyse Tool to detect dead code an so on. > > > > http://pmd.sourceforge.net/ > > > > I think it’s a nice addition for Inject/J to use a tool like this. > > We can use it for our own code and / or we can > > support this information by Inject/J. > > My idea is a transformation like this: > > > > “Detect all dead code lines and add a comment for this lines.” or > > “Detect all dead code lines and remove this lines.” > > > > What do you think about it? > > > > Mit freundlichem Gruß > > > > Sven Luzar > > Wasserstraße 23 > > 48565 Steinfurt > > > > Tel: +49 (2551) 862250 > > Fax: +49 (89) 2443 68746 > > Email: Sve...@we... > > > -- Thomas Genssler (Tho...@fz...) Tel./Fax: +49-721-9654-602/-603 Forschungszentrum Informatik - Research Center for Information Technologies Programmstrukturen - Program Structures (http://www.fzi.de/prost) Haid-und-Neu-Strasse 10-14 76131 Karlsruhe GERMANY |