[Soot-list] JimpleBody vs BafBody

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Tue Apr 6 02:02:48 EDT 2010


Hi Fernando.

This was answered in a thread "Baf Bodies" on 17/11/2009. Back then,
Ondrej wrote:

> jtp is not wjtp.
>
> The order in Soot is that first the whole program packs run, and then
> for each method, all of the body packs run. So you will have some
> methods that have already run all the way through and are at the Baf
> stage, while other methods haven't run yet.

The following appears to be a solution. Put the following code into a
Scene Transformer and put that one into the wjtp pack.

for(SootClass c: Scene.v().getApplicationClasses()) {
 for(SootMethod m: c.getMethods()) {
   if(m.hasActiveBody()) {
     Body b = m.getActiveBody();
     //b is now a JimpleBody
   }
 }
}

Eric

--
Dr. Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt



On 6 April 2010 03:09, Fernando Calheiros <xfernando at gmail.com> wrote:
> Hi there, I'm developing a few soot transformations that require
> method inlining, so I'm extending the class BodyTransformer to perform
> the transformation. I'm using InlineSafetyManager.ensureInlinability()
> to check if it's safe to inline a method at its invocation site, and
> SiteInliner.inlineSite() to perform the actual inlining.
>
> I'm having some problems because some methods active bodies are being
> BafBody and not JimpleBody (SiteInliner only works with JimpleBody).
> I'm adding my transformations to the jtp pack, so I assumed that
> everything would be represented as Jimple, but some methods are being
> represented as BafBody, is there any explanation for this behavior?
>
> Or at least a way to convert from one to another?
>
> Some information: soot is recieving classfiles as input, with the
> following options: -allow-phantom-refs -app.
>
> I'm adding my optimizations like this:
>
>                PackManager.v().getPack("jtp").add(
>                                new Transform("jtp.fii", FieldinitInliner.v()), "jtp.uaor");
>                PackManager.v().getPack("jtp").insertAfter(
>                                new Transform("jtp.ii", InitInliner.v()), "jtp.fii");
>
> I read that the jtp pack is empty by default, so only my
> transformations should be there. Any ideas on why I'm getting BafBody
> instead of JimpleBody for some methods? Oh, and another thing, the
> methods that have BafBody are usually very small, normally containing
> only one return statement.
>
> Thanks in advance,
> Fernando Calheiros
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>


More information about the Soot-list mailing list