-#cp = lib/soot.jar:/Users/megacz/ibex.org/jar/org.ibex.core.jar:/Users/megacz/ibex.org/jar/org.ibex.util.jar:/Users/megacz/ibex.org/jar/org.ibex.js.jar:/Users/megacz/ibex.org/jar/org.ibex.net.jar:/Users/megacz/ibex.org/jar/org.ibex.io.jar:bin
-sootcp = lib/soot.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar
+sootjars := jar/sootclasses-2.2.1.jar jar/jasminclasses-2.2.1.jar jar/polyglotclasses-1.3.jar
+java := java -Djava.ext.dirs=jar
+arenaj := ${java} -jar jar/org.ibex.arenaj.jar
-# IVME Paper
-doc/charts/%.pdf: doc/charts/%.dat doc/charts/%.gnuplot
- cd doc/charts; gnuplot $*.gnuplot
- cd doc/charts; chmod +x boxfill.pl; ./boxfill.pl -g -o unfilled.eps $*.eps
- cd doc/charts; ps2pdf $*.eps
+jar: ; mkdir -p jar
+jar/sootclasses-2.2.1.jar: jar; cd jar; curl -C - -O http://www.sable.mcgill.ca/software/sootclasses-2.2.1.jar
+jar/jasminclasses-2.2.1.jar: jar; cd jar; curl -C - -O http://www.sable.mcgill.ca/software/jasminclasses-2.2.1.jar
+jar/polyglotclasses-1.3.jar: jar; cd jar; curl -C - -O http://www.sable.mcgill.ca/software/polyglotclasses-1.3.jar
-#mainclass = edu.berkeley.cs.megacz.Test
-#mainclass = org.ibex.graphics.Mesh
+jar/org.ibex.arenaj.jar: jar/org.ibex.tool.jar
+ ${java} -jar jar/org.ibex.tool.jar -v -w -j jar/org.ibex.arenaj.jar -m org.ibex.arenaj.Main src
-go:
- javac -classpath lib/soot.jar:bin -d bin `find src/ -name \*.java`
- mkdir -p in
-# cd in; for A in /Users/megacz/ibex.org.arenaj/jar/*.jar; do jar xf $$A; done
-# mkdir -p out
-# java -cp bin:lib/soot.jar edu.berkeley.cs.megacz.Transformer -keep-line-number -app -i org.ibex.graphics -d out -cp ${sootcp}:in org.ibex.graphics.Mesh
- java -cp bin:lib/soot.jar edu.berkeley.cs.megacz.Transformer \
- -keep-line-number \
+demo: jar/org.ibex.arenaj.jar
+ ${arenaj} \
-app -i org.ibex.graphics \
- -w \
-d out \
- -cp ${sootcp}:bin \
- -p cg enabled:false \
- -p cg.cha enabled:false \
- -p cg.spark enabled:false \
- -p cg.paddle enabled:false \
- -p wjap.ra enabled:false \
- -p wjap.umt enabled:false \
- -p wjap.uft enabled:false \
- -p wjap.tqt enabled:false \
- -p wjap.cgg enabled:false \
- edu.berkeley.cs.megacz.GCBench
-
-
-# java -jar lib/soot.jar -app -i org.ibex.graphics -f d -d outsrc -cp ${sootcp}:out ${mainclass}
-# cd out; find . -name \*.class -exec jad {} \;
-# cat out/Test.jad
+ org.ibex.arenaj.Test
+++ /dev/null
-package edu.berkeley.cs.megacz;
-
-import soot.*;
-import soot.util.*;
-import java.util.*;
-import soot.toolkits.scalar.*;
-import soot.jimple.*;
-import soot.toolkits.graph.*;
-import soot.*;
-import soot.jimple.*;
-import soot.toolkits.scalar.*;
-import soot.toolkits.graph.*;
-import soot.util.*;
-import java.util.*;
-
-/** Tracks which locals are definitely non-null.
- * Author: Patrick Lam (plam@sable.mcgill.ca)
- * Based on BranchedRefVarsAnalysis by Janus Godard (janus@place.org). */
-class JArena extends ForwardBranchedFlowAnalysis {
-
- protected Object newInitialFlow() { return fullSet.clone(); }
- protected Object entryInitialFlow() { return emptySet.clone(); }
- private void addGen(Unit u, Value v) { ArraySparseSet l = (ArraySparseSet)unitToGenerateSet.get(u); l.add(v); }
- private void addGensFor(DefinitionStmt u) {
- Value lo = u.getLeftOp();
- Value ro = u.getRightOp();
- if (ro instanceof NewExpr ||
- ro instanceof NewArrayExpr ||
- ro instanceof NewMultiArrayExpr ||
- ro instanceof ThisRef ||
- ro instanceof CaughtExceptionRef)
- addGen(u, lo);
- }
-
- protected void copy(Object src, Object dest) {
- FlowSet sourceSet = (FlowSet)src, destSet = (FlowSet) dest;
- sourceSet.copy(destSet);
- }
-
- protected void merge(Object src1, Object src2, Object dest) {
- FlowSet srcSet1 = (FlowSet) src1;
- FlowSet srcSet2 = (FlowSet) src2;
- FlowSet destSet = (FlowSet) dest;
- srcSet1.intersection(srcSet2, destSet);
- }
-
- FlowSet fullSet, emptySet;
- FlowUniverse allRefLocals;
- Map unitToGenerateSet;
-
- protected void flowThrough(Object srcValue, Unit unit, List fallOut, List branchOuts) {
- FlowSet dest;
- FlowSet src = (FlowSet) srcValue;
- Unit s = (Unit) unit;
-
- // Create working set.
- dest = (FlowSet)src.clone();
-
- // Take out kill set.
- Iterator boxIt = s.getDefBoxes().iterator();
- while (boxIt.hasNext()) {
- ValueBox box = (ValueBox) boxIt.next();
- Value value = box.getValue();
- if (value instanceof Local && value.getType() instanceof RefLikeType)
- dest.remove(value);
- }
-
- // Perform gen.
- dest.union((FlowSet)unitToGenerateSet.get(unit), dest);
-
- // Handle copy statements:
- // x = y && 'y' in src => add 'x' to dest
- if (s instanceof DefinitionStmt)
- {
- DefinitionStmt as = (DefinitionStmt) s;
-
- Value ro = as.getRightOp();
-
- // extract cast argument
- if (ro instanceof CastExpr) ro = ((CastExpr) ro).getOp();
-
- if (src.contains(ro) && as.getLeftOp() instanceof Local)
- dest.add(as.getLeftOp());
- }
-
- // Copy the out value to the fallthrough box (don't need iterator)
- {
- Iterator it = fallOut.iterator();
- while (it.hasNext()) {
- FlowSet fs = (FlowSet) (it.next());
- copy(dest, fs);
- }
- }
-
- // Copy the out value to all branch boxes.
- {
- Iterator it = branchOuts.iterator();
- while (it.hasNext()) {
- FlowSet fs = (FlowSet) (it.next());
- copy(dest, fs);
- }
- }
-
- // Handle if statements by patching dest sets.
- if (unit instanceof IfStmt)
- {
- Value cond = ((IfStmt)unit).getCondition();
- Value op1 = ((BinopExpr) cond).getOp1();
- Value op2 = ((BinopExpr) cond).getOp2();
- boolean isNeg = cond instanceof NeExpr;
- Value toGen = null;
-
- // case 1: opN is a local and opM is NullConstant
- // => opN nonnull on ne branch.
- if (op1 instanceof Local && op2 instanceof NullConstant)
- toGen = op1;
-
- if (op2 instanceof Local && op1 instanceof NullConstant)
- toGen = op2;
-
- if (toGen != null)
- {
- Iterator it = null;
-
- // if (toGen != null) goto l1: on branch, toGen nonnull.
- if (isNeg)
- it = branchOuts.iterator();
- else
- it = fallOut.iterator();
-
- while(it.hasNext()) {
- FlowSet fs = (FlowSet) (it.next());
- fs.add(toGen);
- }
- }
-
- // case 2: both ops are local and one op is non-null and testing equality
- if (op1 instanceof Local && op2 instanceof Local &&
- cond instanceof EqExpr)
- {
- toGen = null;
-
- if (src.contains(op1))
- toGen = op2;
- if (src.contains(op2))
- toGen = op1;
-
- if (toGen != null)
- {
- Iterator branchIt = branchOuts.iterator();
- while (branchIt.hasNext()) {
- FlowSet fs = (FlowSet) (branchIt.next());
- fs.add(toGen);
- }
- }
- }
- }
- }
-
- public JArena(UnitGraph g) {
- super(g);
-
- unitToGenerateSet = new HashMap();
-
- Body b = g.getBody();
-
- List refLocals = new LinkedList();
-
- // set up universe, empty, full sets.
-
- emptySet = new ArraySparseSet();
- fullSet = new ArraySparseSet();
-
- // Find all locals in body.
- Iterator localIt = b.getLocals().iterator();
- while (localIt.hasNext()) {
- Local l = (Local)localIt.next();
- if (l.getType() instanceof RefLikeType) fullSet.add(l);
- }
-
- // Create gen sets.
- Iterator unitIt = b.getUnits().iterator();
- while (unitIt.hasNext()) {
- Unit u = (Unit)unitIt.next();
- unitToGenerateSet.put(u, new ArraySparseSet());
-
- if (u instanceof DefinitionStmt) {
- Value lo = ((DefinitionStmt)u).getLeftOp();
- if (lo instanceof Local && lo.getType() instanceof RefLikeType)
- addGensFor((DefinitionStmt)u);
- }
-
- Iterator boxIt = u.getUseAndDefBoxes().iterator();
- while (boxIt.hasNext()) {
- Value boxValue = ((ValueBox) boxIt.next()).getValue();
- Value base = null;
-
- if(boxValue instanceof InstanceFieldRef) {
- base = ((InstanceFieldRef) (boxValue)).getBase();
- } else if (boxValue instanceof ArrayRef) {
- base = ((ArrayRef) (boxValue)).getBase();
- } else if (boxValue instanceof InstanceInvokeExpr) {
- base = ((InstanceInvokeExpr) boxValue).getBase();
- } else if (boxValue instanceof LengthExpr) {
- base = ((LengthExpr) boxValue).getOp();
- } else if (u instanceof ThrowStmt) {
- base = ((ThrowStmt)u).getOp();
- } else if (u instanceof MonitorStmt) {
- base = ((MonitorStmt)u).getOp();
- }
-
- if (base != null &&
- base instanceof Local &&
- base.getType() instanceof RefLikeType)
- addGen(u, base);
- }
- }
-
- // Call superclass method to do work.
- doAnalysis();
- }
-}
-
--- /dev/null
+package org.ibex.arenaj;
+// This is adapted from a benchmark written by John Ellis and Pete Kovac
+// of Post Communications.
+// It was modified by Hans Boehm of Silicon Graphics.
+//
+// This is no substitute for real applications. No actual application
+// is likely to behave in exactly this way. However, this benchmark was
+// designed to be more representative of real applications than other
+// Java GC benchmarks of which we are aware.
+// It attempts to model those properties of allocation requests that
+// are important to current GC techniques.
+// It is designed to be used either to obtain a single overall performance
+// number, or to give a more detailed estimate of how collector
+// performance varies with object lifetimes. It prints the time
+// required to allocate and collect balanced binary trees of various
+// sizes. Smaller trees result in shorter object lifetimes. Each cycle
+// allocates roughly the same amount of memory.
+// Two data structures are kept around during the entire process, so
+// that the measured performance is representative of applications
+// that maintain some live in-memory data. One of these is a tree
+// containing many pointers. The other is a large array containing
+// double precision floating point numbers. Both should be of comparable
+// size.
+//
+// The results are only really meaningful together with a specification
+// of how much memory was used. It is possible to trade memory for
+// better time performance. This benchmark should be run in a 32 MB
+// heap, though we don't currently know how to enforce that uniformly.
+//
+// Unlike the original Ellis and Kovac benchmark, we do not attempt
+// measure pause times. This facility should eventually be added back
+// in. There are several reasons for omitting it for now. The original
+// implementation depended on assumptions about the thread scheduler
+// that don't hold uniformly. The results really measure both the
+// scheduler and GC. Pause time measurements tend to not fit well with
+// current benchmark suites. As far as we know, none of the current
+// commercial Java implementations seriously attempt to minimize GC pause
+// times.
+//
+// Known deficiencies:
+// - No way to check on memory use
+// - No cyclic data structures
+// - No attempt to measure variation with object size
+// - Results are sensitive to locking cost, but we dont
+// check for proper locking
+
+public class GCBench {
+
+ public static final int kStretchTreeDepth = 18; // about 16Mb
+ public static final int kLongLivedTreeDepth = 16; // about 4Mb
+ public static final int kArraySize = 500000; // about 4Mb
+ public static final int kMinTreeDepth = 4;
+ public static final int kMaxTreeDepth = 16;
+
+ public static int zap(Object o) { return o==null ? -1 : ((Integer)o).intValue(); }
+
+ // Nodes used by a tree of a given size
+ static int TreeSize(int i) {
+ return ((1 << (i + 1)) - 1);
+ }
+
+ // Number of iterations to use for a given tree depth
+ static int NumIters(int i) {
+ return 2 * TreeSize(kStretchTreeDepth) / TreeSize(i);
+ }
+
+ // Build tree top down, assigning to older objects.
+ void Populate(int iDepth) { Populate(iDepth, new Node()); }
+ void Populate(int iDepth, Node thisNode) {
+ if (iDepth<=0) {
+ return;
+ } else {
+ iDepth--;
+ thisNode.left = new Node();
+ thisNode.right = new Node();
+ Populate (iDepth, thisNode.left);
+ Populate (iDepth, thisNode.right);
+ }
+ }
+
+ // Build tree bottom-up
+ void doMakeTree(int iDepth) { MakeTree(iDepth); }
+ Node MakeTree(int iDepth) {
+ if (iDepth<=0) {
+ return new Node();
+ } else {
+ Node l = MakeTree(iDepth-1);
+ Node r = MakeTree(iDepth-1);
+ Node ret = new Node();
+ ret.left = l;
+ ret.right = r;
+ return ret;
+ }
+ }
+
+ static void PrintDiagnostics() {
+ long lFreeMemory = Runtime.getRuntime().freeMemory();
+ long lTotalMemory = Runtime.getRuntime().totalMemory();
+
+ System.out.print(" Total memory available="
+ + lTotalMemory + " bytes");
+ System.out.println(" Free memory=" + lFreeMemory + " bytes");
+ }
+
+ void TimeConstruction(int depth) {
+ Node root;
+ long tStart, tFinish;
+ int iNumIters = NumIters(depth);
+ GCBench tempTree;
+
+ System.out.println("Creating " + iNumIters +
+ " trees of depth " + depth);
+ tStart = System.currentTimeMillis();
+ for (int i = 0; i < iNumIters; ++i) {
+ tempTree = new GCBench();
+ tempTree.Populate(depth);
+ tempTree = null;
+ }
+ tFinish = System.currentTimeMillis();
+ System.out.println("\tTop down construction took "
+ + (tFinish - tStart) + "msecs");
+ tStart = System.currentTimeMillis();
+ for (int i = 0; i < iNumIters; ++i) {
+ tempTree = new GCBench();
+ tempTree.doMakeTree(depth);
+ tempTree = null;
+ }
+ tFinish = System.currentTimeMillis();
+ System.out.println("\tBottom up construction took "
+ + (tFinish - tStart) + "msecs");
+
+ }
+
+ public static void main(String args[]) {
+ Node root;
+ Node longLivedTree;
+ Node tempTree;
+ long tStart, tFinish;
+ long tElapsed;
+
+
+ System.out.println("Garbage Collector Test");
+ System.out.println(
+ " Stretching memory with a binary tree of depth "
+ + kStretchTreeDepth);
+ PrintDiagnostics();
+ tStart = System.currentTimeMillis();
+
+ // Stretch the memory space quickly
+ GCBench gcb = new GCBench();
+ gcb.doMakeTree(kStretchTreeDepth);
+ gcb = null;
+
+ // Create a long lived object
+ System.out.println(
+ " Creating a long-lived binary tree of depth " +
+ kLongLivedTreeDepth);
+ GCBench ll = new GCBench();
+ ll.Populate(kLongLivedTreeDepth);
+
+ /*
+ // Create long-lived array, filling half of it
+ System.out.println(
+ " Creating a long-lived array of "
+ + kArraySize + " doubles");
+ double array[] = new double[kArraySize];
+ for (int i = 0; i < kArraySize/2; ++i) {
+ array[i] = 1.0/i;
+ }
+ */
+ PrintDiagnostics();
+
+ for (int d = kMinTreeDepth; d <= kMaxTreeDepth; d += 2) {
+ ll.TimeConstruction(d);
+ }
+ /*
+ if (longLivedTree == null || array[1000] != 1.0/1000)
+ System.out.println("Failed");
+ */
+ // fake reference to LongLivedTree
+ // and array
+ // to keep them from being optimized away
+
+ tFinish = System.currentTimeMillis();
+ tElapsed = tFinish-tStart;
+ PrintDiagnostics();
+ System.out.println("Completed in " + tElapsed + "ms.");
+ }
+
+ private class Node implements Gladiator {
+ Node left, right;
+ int i, j;
+ //Node(Node l, Node r) { left = l; right = r; }
+ Node() { }
+ }
+
+} // class JavaGC
--- /dev/null
+package org.ibex.arenaj;
+
+public interface Gladiator {
+}
-package edu.berkeley.cs.megacz;
+package org.ibex.arenaj;
import soot.*;
import soot.jimple.*;
import soot.util.*;
import java.io.*;
import java.util.*;
-public class Transformer extends SceneTransformer {
+public class Main extends SceneTransformer {
public static final int initialSize = 100;
- private static Transformer instance = new Transformer();
- private Transformer() {
- }
- public static Transformer v() { return instance; }
+ private static Main instance = new Main();
+ private Main() { }
+ public static Main v() { return instance; }
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception {
if(args.length == 0) {
System.out.println("Syntax: java " + v().getClass().getName() + " [soot options]");
System.exit(0);
}
- //PackManager.v().allPacks().add(v());
- PackManager.v().getPack("wjtp").add(new Transform("wjtp.tx", Transformer.v()));
- // Just in case, resolve the PrintStream SootClass.
- Scene.v().addBasicClass("java.io.PrintStream",SootClass.SIGNATURES);
- soot.Main.main(args);
+ PackManager.v().getPack("wjtp").add(new Transform("wjtp.tx", Main.v()));
+ String[] args2 = new String[args.length + 11];
+ System.arraycopy(args, 0, args2, 0, args.length-1);
+ String sootcp =
+ System.getProperty("java.class.path") +
+ File.pathSeparator +
+ System.getProperty("sun.boot.class.path");
+ if (System.getProperty("java.ext.dirs") != null) {
+ StringTokenizer st = new StringTokenizer(File.pathSeparatorChar+"", System.getProperty("java.ext.dirs"));
+ while(st.hasMoreTokens()) {
+ File f = new File(st.nextToken());
+ if (!f.exists() || !f.isDirectory()) continue;
+ String[] jars = f.list();
+ for(int i=0; i<jars.length; i++)
+ sootcp += File.pathSeparator + jars[i];
+ }
+ }
+ args2[args.length - 1] = "-w";
+ args2[args.length + 0] = "-p";
+ args2[args.length + 1] = "cg";
+ args2[args.length + 2] = "enabled:false";
+ args2[args.length + 3] = "-p";
+ args2[args.length + 4] = "wjap";
+ args2[args.length + 5] = "enabled:false";
+ args2[args.length + 6] = "-keep-line-number";
+ args2[args.length + 7] = "-keep-line-number";
+ args2[args.length + 8] = "-cp";
+ args2[args.length + 9] = sootcp;
+ args2[args.length + 10] = args[args.length-1];
+ soot.Main.main(args2);
}
static int tfr = 0;
HashMap map = new HashMap();
HashSet size_added = new HashSet();
- public boolean isGladiator(SootClass c) { return c.implementsInterface("edu.berkeley.cs.megacz.Gladiator"); }
+ public boolean isGladiator(SootClass c) { return c.implementsInterface("org.ibex.arenaj.Gladiator"); }
public boolean isGladiatorField(SootField f)
{ return isGladiator(f.getDeclaringClass()) && !f.getName().equals("this") && f.getName().indexOf('$')==-1; }
public boolean isGladiatorFieldRef(SootFieldRef f) {
private Body body;
public SootFieldRef getGladiatorFieldSizeRef(SootClass c) {
- SootClass mc = Scene.v().getMainClass();
+ SootClass mc = getParent(c);
String name = c.getShortName().substring(c.getShortName().lastIndexOf('$')+1) + "$$size";
if (map.get(name) == null) {
SootField f = new SootField(name, IntType.v());
return Scene.v().makeFieldRef(mc, name, IntType.v(), false);
}
public SootFieldRef getGladiatorFieldMaxRef(SootClass c) {
- SootClass mc = Scene.v().getMainClass();
+ SootClass mc = getParent(c);
String name = c.getShortName().substring(c.getShortName().lastIndexOf('$')+1) + "$$max";
if (map.get(name) == null) {
SootField f = new SootField(name, IntType.v());
boolean done = false;
public void internalTransform(String phaseName, Map options) {
- System.out.println("=============");
- if (done) return;
- done = true;
- //nuke(Scene.v().getSootClass("edu.berkeley.cs.megacz.Test$Inner"));
- //nuke(Scene.v().getSootClass("edu.berkeley.cs.megacz.Test"));
- //nuke(Scene.v().getSootClass("org.ibex.graphics.Mesh"));
- //nuke(Scene.v().getSootClass("org.ibex.graphics.Mesh$Triangle"));
- fixClass(Scene.v().getSootClass("edu.berkeley.cs.megacz.GCBench$Node"));
- nuke(Scene.v().getSootClass("edu.berkeley.cs.megacz.GCBench$Node"));
- nuke(Scene.v().getSootClass("edu.berkeley.cs.megacz.GCBench"));
+ for(Iterator it = Scene.v().getApplicationClasses().iterator(); it.hasNext();) {
+ SootClass sc = (SootClass)it.next();
+ if (!isGladiator(sc)) continue;
+ System.out.println("fixing Gladiator class: " + sc);
+ fixClass(sc);
+ }
+ for(Iterator it = Scene.v().getApplicationClasses().iterator(); it.hasNext();) {
+ SootClass sc = (SootClass)it.next();
+ System.out.println(" updating class: " + sc);
+ nuke(sc);
+ }
+ }
+
+ public SootClass getParent(SootClass sc) {
+ return Scene.v().getSootClass(sc.getName().substring(0, sc.getName().lastIndexOf('$')));
}
public void fixClass(SootClass sc) {
- SootClass mc = Scene.v().getMainClass();
+ SootClass mc = getParent(sc);
String incFuncName = sc.getShortName().substring(sc.getShortName().lastIndexOf('$')+1) + "$$inc";
SootMethod method = new SootMethod(incFuncName, new LinkedList(),
IntType.v(), Modifier.PRIVATE,
}
}
- //if (isGladiator(c)) fixClass(c);
-
List list = new LinkedList(); list.addAll(c.getMethods());
for(Iterator it = list.iterator(); it.hasNext();) {
SootMethod m = (SootMethod)it.next();
if (m.hasActiveBody() && !m.isStatic()) m.setActiveBody(fixBody(m.getActiveBody()));
if (m.getName().equals("<init>")) continue;
if (m.getName().equals("<clinit>")) continue;
- //if (map.get(m) != null) continue;
- //map.put(m, Boolean.TRUE);
- System.out.println(m.getName() + " -- " + m.getActiveBody());
List l2 = new LinkedList();
List l = m.getParameterTypes();
for(Iterator it2 = l.iterator(); it2.hasNext();) {
Type t = (Type)it2.next();
- //l2.add(t);
l2.add(isGladiatorType(t) ? IntType.v() : t);
- //if (isGladiatorType(t)) System.out.println("ought to swap " + t);
}
Type t = m.getReturnType();
c.removeMethod(m);
if (s instanceof DefinitionStmt) {
DefinitionStmt ds = (DefinitionStmt)s;
if (ds.getLeftOp().getType() instanceof PrimType && ds.getRightOp().getType() instanceof NullType) {
- System.out.println("*************************");
ds.getRightOpBox().setValue(IntConstant.v(-1));
}
}
if (v instanceof BinopExpr) {
BinopExpr boe = (BinopExpr)v;
if (boe.getOp1().getType() instanceof PrimType && boe.getOp2().getType() instanceof NullType) {
- System.out.println("*************************");
boe.setOp2(IntConstant.v(-1));
}
if (boe.getOp2().getType() instanceof PrimType && boe.getOp1().getType() instanceof NullType) {
- System.out.println("*************************");
boe.setOp1(IntConstant.v(-1));
}
}
} else if (v instanceof NewExpr) {
NewExpr ne = (NewExpr)v;
if (isGladiatorType(ne.getBaseType())) {
- System.out.println("******");
- SootClass mc = Scene.v().getMainClass();
SootClass sc = ((RefType)ne.getBaseType()).getSootClass();
- System.out.println(sc);
+ SootClass mc = getParent(sc);
String incFuncName = sc.getShortName().substring(sc.getShortName().lastIndexOf('$')+1) + "$$inc";
SootMethodRef smr = Scene.v().makeMethodRef(mc, incFuncName, new LinkedList(), IntType.v(), false);
Expr invokeExpr = Jimple.v().newSpecialInvokeExpr(body.getThisLocal(), smr);
} else if (v instanceof CastExpr) {
CastExpr ce = (CastExpr)v;
if (isGladiatorType(ce.getCastType())) {
- //SootClass intClass = Scene.v().getSootClass("java.lang.Integer");
- //SootClass intClass = Scene.v().getSootClass("java.lang.Integer");
- SootClass mc = Scene.v().getMainClass();
+ SootClass mc = getParent(((RefType)ce.getCastType()).getSootClass());
LinkedList list = new LinkedList();
list.add(Scene.v().getSootClass("java.lang.Object").getType());
SootMethodRef mr = Scene.v().makeMethodRef(mc, "zap", list, IntType.v(), true);
SootFieldRef fr = ifr.getFieldRef();
Type t = fr.type();
if (isGladiatorFieldRef(fr)) {
- SootClass mc = Scene.v().getMainClass();
+ SootClass mc = getParent(fr.declaringClass());
SootFieldRef sf = getGladiatorField(fr).makeRef();
InstanceFieldRef sfr = Jimple.v().newInstanceFieldRef(body.getThisLocal(), sf);
ArrayRef ar = Jimple.v().newArrayRef(viaLocal(sfr, body, s), ifr.getBase());
}
if ((t instanceof RefType) && isGladiator(((RefType)t).getSootClass())) {
SootClass tc = ((RefType)t).getSootClass();
- SootClass mc = Scene.v().getMainClass();
+ SootClass mc = getParent(tc);
ifr.setFieldRef(Scene.v().makeFieldRef(mc, fr.name(), IntType.v(), false));
}
}
-package edu.berkeley.cs.megacz;
+package org.ibex.arenaj;
public class Test {
public static void main(String[] s) {