use of soot.Unit in project soot by Sable.
the class TypeResolverBV method check_constraints.
private void check_constraints() throws TypeException {
ConstraintCheckerBV checker = new ConstraintCheckerBV(this, false);
StringBuffer s = null;
if (DEBUG) {
s = new StringBuffer("Checking:\n");
}
for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext(); ) {
final Stmt stmt = (Stmt) stmtIt.next();
if (DEBUG) {
s.append(" " + stmt + "\n");
}
try {
checker.check(stmt, stmtBody);
} catch (TypeException e) {
if (DEBUG) {
logger.debug("" + s);
}
throw e;
}
}
}
use of soot.Unit in project soot by Sable.
the class TypeResolverBV method collect_constraints_3.
private void collect_constraints_3() {
ConstraintCollectorBV collector = new ConstraintCollectorBV(this, false);
for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext(); ) {
final Stmt stmt = (Stmt) stmtIt.next();
if (DEBUG) {
logger.debug("stmt: ");
}
collector.collect(stmt, stmtBody);
if (DEBUG) {
logger.debug("" + stmt);
}
}
}
use of soot.Unit in project soot by Sable.
the class LockAllocationBodyTransformer method getLockFor.
public static Value getLockFor(EquivalentValue lockEqVal) {
Value lock = lockEqVal.getValue();
if (lock instanceof InstanceFieldRef)
return lock;
if (// it would be better to lock the array
lock instanceof ArrayRef)
// ref for each value of the index!
return ((ArrayRef) lock).getBase();
if (lock instanceof Local)
return lock;
if (lock instanceof StaticFieldRef || lock instanceof NewStaticLock) {
if (lockEqValToLock.containsKey(lockEqVal))
return lockEqValToLock.get(lockEqVal);
SootClass lockClass = null;
if (lock instanceof StaticFieldRef) {
StaticFieldRef sfrLock = (StaticFieldRef) lock;
lockClass = sfrLock.getField().getDeclaringClass();
} else if (lock instanceof NewStaticLock) {
DeadlockAvoidanceEdge dae = (DeadlockAvoidanceEdge) lock;
lockClass = dae.getLockClass();
}
SootMethod clinitMethod = null;
JimpleBody clinitBody = null;
Stmt firstStmt = null;
boolean addingNewClinit = !lockClass.declaresMethod("void <clinit>()");
if (addingNewClinit) {
clinitMethod = Scene.v().makeSootMethod("<clinit>", new ArrayList(), VoidType.v(), Modifier.PUBLIC | Modifier.STATIC);
clinitBody = Jimple.v().newBody(clinitMethod);
clinitMethod.setActiveBody(clinitBody);
lockClass.addMethod(clinitMethod);
} else {
clinitMethod = lockClass.getMethod("void <clinit>()");
clinitBody = (JimpleBody) clinitMethod.getActiveBody();
firstStmt = clinitBody.getFirstNonIdentityStmt();
}
PatchingChain<Unit> clinitUnits = clinitBody.getUnits();
Local lockLocal = Jimple.v().newLocal("objectLockLocal" + lockNumber, RefType.v("java.lang.Object"));
// lockNumber is increased below
// TODO: add name conflict
clinitBody.getLocals().add(lockLocal);
// avoidance code
// assign new object to lock obj
Stmt newStmt = Jimple.v().newAssignStmt(lockLocal, Jimple.v().newNewExpr(RefType.v("java.lang.Object")));
if (addingNewClinit)
clinitUnits.add(newStmt);
else
clinitUnits.insertBeforeNoRedirect(newStmt, firstStmt);
// initialize new object
SootClass objectClass = Scene.v().loadClassAndSupport("java.lang.Object");
RefType type = RefType.v(objectClass);
SootMethod initMethod = objectClass.getMethod("void <init>()");
Stmt initStmt = Jimple.v().newInvokeStmt(Jimple.v().newSpecialInvokeExpr(lockLocal, initMethod.makeRef(), Collections.EMPTY_LIST));
if (addingNewClinit)
clinitUnits.add(initStmt);
else
clinitUnits.insertBeforeNoRedirect(initStmt, firstStmt);
// copy new object to global static lock object (for use by other
// fns)
SootField actualLockObject = Scene.v().makeSootField("objectLockGlobal" + lockNumber, RefType.v("java.lang.Object"), Modifier.STATIC | Modifier.PUBLIC);
lockNumber++;
lockClass.addField(actualLockObject);
StaticFieldRef actualLockSfr = Jimple.v().newStaticFieldRef(actualLockObject.makeRef());
Stmt assignStmt = Jimple.v().newAssignStmt(actualLockSfr, lockLocal);
if (addingNewClinit)
clinitUnits.add(assignStmt);
else
clinitUnits.insertBeforeNoRedirect(assignStmt, firstStmt);
if (addingNewClinit)
clinitUnits.add(Jimple.v().newReturnVoidStmt());
lockEqValToLock.put(lockEqVal, actualLockSfr);
return actualLockSfr;
}
throw new RuntimeException("Unknown type of lock (" + lock + "): expected FieldRef, ArrayRef, or Local");
}
use of soot.Unit in project soot by Sable.
the class TypeResolver method collect_constraints_3.
private void collect_constraints_3() {
ConstraintCollector collector = new ConstraintCollector(this, false);
for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext(); ) {
final Stmt stmt = (Stmt) stmtIt.next();
if (DEBUG) {
logger.debug("stmt: ");
}
collector.collect(stmt, stmtBody);
if (DEBUG) {
logger.debug("" + stmt);
}
}
}
use of soot.Unit in project soot by Sable.
the class TypeResolver method collect_constraints_1_2.
private void collect_constraints_1_2() {
ConstraintCollector collector = new ConstraintCollector(this, true);
for (Iterator<Unit> stmtIt = stmtBody.getUnits().iterator(); stmtIt.hasNext(); ) {
final Stmt stmt = (Stmt) stmtIt.next();
if (DEBUG) {
logger.debug("stmt: ");
}
collector.collect(stmt, stmtBody);
if (DEBUG) {
logger.debug("" + stmt);
}
}
}
Aggregations