soot.jimple.toolkits.thread.synchronization.CriticalSection Maven / Gradle / Ivy
package soot.jimple.toolkits.thread.synchronization;
/*-
* #%L
* Soot - a J*va Optimization Framework
* %%
* Copyright (C) 1997 - 2018 Raja Vallée-Rai and others
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import soot.EquivalentValue;
import soot.MethodOrMethodContext;
import soot.SootMethod;
import soot.Unit;
import soot.Value;
import soot.jimple.toolkits.pointer.CodeBlockRWSet;
class CriticalSection extends SynchronizedRegion {
public static int nextIDNum = 1;
// Information about the transactional region
public int IDNum;
public int nestLevel;
public String name;
public Value origLock;
public CodeBlockRWSet read, write;
public HashSet invokes;
public HashSet units;
public HashMap unitToRWSet;
public HashMap unitToUses; // For lockset analysis
public boolean wholeMethod;
// Information for analyzing conflicts with other transactions
public SootMethod method;
public int setNumber; // used for breaking the list of transactions into sets
public CriticalSectionGroup group;
public HashSet edges;
public HashSet waits;
public HashSet notifys;
public HashSet transitiveTargets;
// Locking Information
public Value lockObject;
public Value lockObjectArrayIndex;
public List lockset;
CriticalSection(boolean wholeMethod, SootMethod method, int nestLevel) {
super();
this.IDNum = nextIDNum;
nextIDNum++;
this.nestLevel = nestLevel;
this.read = new CodeBlockRWSet();
this.write = new CodeBlockRWSet();
this.invokes = new HashSet();
this.units = new HashSet();
this.unitToRWSet = new HashMap();
this.unitToUses = new HashMap();
this.wholeMethod = wholeMethod;
this.method = method;
this.setNumber = 0; // 0 = no group, -1 = DELETE
this.group = null;
this.edges = new HashSet();
this.waits = new HashSet();
this.notifys = new HashSet();
this.transitiveTargets = null;
this.lockObject = null;
this.lockObjectArrayIndex = null;
this.lockset = null;
}
CriticalSection(CriticalSection tn) {
super(tn);
this.IDNum = tn.IDNum;
this.nestLevel = tn.nestLevel;
this.origLock = tn.origLock;
this.read = new CodeBlockRWSet();
this.read.union(tn.read);
this.write = new CodeBlockRWSet();
this.write.union(tn.write);
this.invokes = (HashSet) tn.invokes.clone();
this.units = (HashSet) tn.units.clone();
this.unitToRWSet = (HashMap) tn.unitToRWSet.clone();
this.unitToUses = (HashMap) tn.unitToUses.clone();
this.wholeMethod = tn.wholeMethod;
this.method = tn.method;
this.setNumber = tn.setNumber;
this.group = tn.group;
this.edges = (HashSet) tn.edges.clone();
this.waits = (HashSet) tn.waits.clone();
this.notifys = (HashSet) tn.notifys.clone();
this.transitiveTargets
= (HashSet) (tn.transitiveTargets == null ? null : tn.transitiveTargets.clone());
this.lockObject = tn.lockObject;
this.lockObjectArrayIndex = tn.lockObjectArrayIndex;
this.lockset = tn.lockset;
}
protected Object clone() {
return new CriticalSection(this);
}
public String toString() {
return name;
}
}