generalized invoke statement type declaration to SSAAbstractInvokeInstruction for use by multiple languages

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@600 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
dolby-oss 2007-01-24 04:18:24 +00:00
parent f2b8fb078f
commit fa236058e3
5 changed files with 58 additions and 58 deletions

View File

@ -12,7 +12,7 @@ package com.ibm.wala.ipa.slicer;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.propagation.PointerKey;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
public abstract class HeapStatement extends Statement {
@ -26,9 +26,9 @@ public abstract class HeapStatement extends Statement {
public final static class ParamCaller extends HeapStatement {
private final SSAInvokeInstruction call;
private final SSAAbstractInvokeInstruction call;
public ParamCaller(CGNode node, SSAInvokeInstruction call, PointerKey loc) {
public ParamCaller(CGNode node, SSAAbstractInvokeInstruction call, PointerKey loc) {
super(node, loc);
this.call = call;
}
@ -38,7 +38,7 @@ public abstract class HeapStatement extends Statement {
return Kind.HEAP_PARAM_CALLER;
}
public SSAInvokeInstruction getCall() {
public SSAAbstractInvokeInstruction getCall() {
return call;
}
@ -97,9 +97,9 @@ public abstract class HeapStatement extends Statement {
}
public final static class ReturnCaller extends HeapStatement {
private final SSAInvokeInstruction call;
private final SSAAbstractInvokeInstruction call;
public ReturnCaller(CGNode node, SSAInvokeInstruction call, PointerKey loc) {
public ReturnCaller(CGNode node, SSAAbstractInvokeInstruction call, PointerKey loc) {
super(node, loc);
this.call = call;
}
@ -109,7 +109,7 @@ public abstract class HeapStatement extends Statement {
return Kind.HEAP_RET_CALLER;
}
public SSAInvokeInstruction getCall() {
public SSAAbstractInvokeInstruction getCall() {
return call;
}

View File

@ -40,7 +40,7 @@ import com.ibm.wala.ssa.SSAFieldAccessInstruction;
import com.ibm.wala.ssa.SSAGetCaughtExceptionInstruction;
import com.ibm.wala.ssa.SSAInstanceofInstruction;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.ssa.SSANewInstruction;
import com.ibm.wala.ssa.SSAPhiInstruction;
import com.ibm.wala.ssa.SSAPiInstruction;
@ -78,9 +78,9 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
private Statement[] returnStatements;
private final Map<SSAInvokeInstruction, Set<Statement>> callerParamStatements = HashMapFactory.make();
private final Map<SSAAbstractInvokeInstruction, Set<Statement>> callerParamStatements = HashMapFactory.make();
private final Map<SSAInvokeInstruction, Set<Statement>> callerReturnStatements = HashMapFactory.make();
private final Map<SSAAbstractInvokeInstruction, Set<Statement>> callerReturnStatements = HashMapFactory.make();
private final HeapExclusions exclusions;
@ -122,11 +122,11 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
createControlDependenceEdges(cOptions);
}
public Set<Statement> getCallerParamStatements(SSAInvokeInstruction call) {
public Set<Statement> getCallerParamStatements(SSAAbstractInvokeInstruction call) {
return callerParamStatements.get(call);
}
public Set<Statement> getCallerReturnStatements(SSAInvokeInstruction call) {
public Set<Statement> getCallerReturnStatements(SSAAbstractInvokeInstruction call) {
return callerReturnStatements.get(call);
}
@ -161,7 +161,7 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
} else {
src = ssaInstruction2Statement(s);
// add edges from call statements to parameter passing and return
if (s instanceof SSAInvokeInstruction) {
if (s instanceof SSAAbstractInvokeInstruction) {
for (Statement st : callerParamStatements.get(s)) {
addEdge(src, st);
}
@ -237,7 +237,7 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
SSAInstruction statement = statement2SSAInstruction(instructions, s);
// note that data dependencies from invoke instructions will pass
// interprocedurally
if (!(statement instanceof SSAInvokeInstruction)) {
if (!(statement instanceof SSAAbstractInvokeInstruction)) {
if (dOptions.isTerminateAtCast() && (statement instanceof SSACheckCastInstruction)) {
break;
}
@ -325,8 +325,8 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
if (dOptions.isTerminateAtCast() && (pei.getInstruction() instanceof SSACheckCastInstruction)) {
continue;
}
if (pei.getInstruction() instanceof SSAInvokeInstruction) {
SSAInvokeInstruction call = (SSAInvokeInstruction) pei.getInstruction();
if (pei.getInstruction() instanceof SSAAbstractInvokeInstruction) {
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) pei.getInstruction();
Statement st = new ParamStatement.ExceptionalReturnCaller(node, call);
addEdge(st, s);
} else {
@ -349,8 +349,8 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
break;
}
if (d != null) {
if (d instanceof SSAInvokeInstruction) {
SSAInvokeInstruction call = (SSAInvokeInstruction) d;
if (d instanceof SSAAbstractInvokeInstruction) {
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) d;
if (vn == call.getException()) {
Statement st = new ParamStatement.ExceptionalReturnCaller(node, call);
addEdge(st, pac);
@ -784,8 +784,8 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
addNode(new NormalStatement(node, i));
visited.add(s);
}
if (s instanceof SSAInvokeInstruction) {
addParamPassingStatements((SSAInvokeInstruction) s, mod, ref, dOptions);
if (s instanceof SSAAbstractInvokeInstruction) {
addParamPassingStatements((SSAAbstractInvokeInstruction) s, mod, ref, dOptions);
}
}
return visited;
@ -797,7 +797,7 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
*
* @param dOptions
*/
private void addParamPassingStatements(SSAInvokeInstruction call, Map<CGNode, OrdinalSet<PointerKey>> mod,
private void addParamPassingStatements(SSAAbstractInvokeInstruction call, Map<CGNode, OrdinalSet<PointerKey>> mod,
Map<CGNode, OrdinalSet<PointerKey>> ref, DataDependenceOptions dOptions) {
Collection<Statement> params = MapUtil.findOrCreateSet(callerParamStatements, call);
@ -839,7 +839,7 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
/**
* @return the set of all locations read by any callee at a call site.
*/
private OrdinalSet<PointerKey> unionHeapLocations(CGNode n, SSAInvokeInstruction call, Map<CGNode, OrdinalSet<PointerKey>> loc) {
private OrdinalSet<PointerKey> unionHeapLocations(CGNode n, SSAAbstractInvokeInstruction call, Map<CGNode, OrdinalSet<PointerKey>> loc) {
BitVectorIntSet bv = new BitVectorIntSet();
for (CGNode t : n.getPossibleTargets(call.getCallSite())) {
bv.addAll(loc.get(t).getBackingSet());

View File

@ -11,7 +11,7 @@
package com.ibm.wala.ipa.slicer;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
/**
* Represents parameter-passing statement in the SDG
@ -30,15 +30,15 @@ public abstract class ParamStatement extends Statement {
}
public interface CallStatementCarrier {
public SSAInvokeInstruction getCall();
public SSAAbstractInvokeInstruction getCall();
}
public static class ParamCaller extends ParamStatement implements ValueNumberCarrier, CallStatementCarrier {
private final SSAInvokeInstruction call;
private final SSAAbstractInvokeInstruction call;
protected final int valueNumber;
public ParamCaller(CGNode node, SSAInvokeInstruction call, int valueNumber) {
public ParamCaller(CGNode node, SSAAbstractInvokeInstruction call, int valueNumber) {
super(node);
this.call = call;
this.valueNumber = valueNumber;
@ -49,7 +49,7 @@ public abstract class ParamStatement extends Statement {
return Kind.PARAM_CALLER;
}
public SSAInvokeInstruction getCall() {
public SSAAbstractInvokeInstruction getCall() {
return call;
}
@ -118,11 +118,11 @@ public abstract class ParamStatement extends Statement {
}
public static class NormalReturnCaller extends ParamStatement implements ValueNumberCarrier, CallStatementCarrier {
private final SSAInvokeInstruction call;
private final SSAAbstractInvokeInstruction call;
protected final int valueNumber;
public NormalReturnCaller(CGNode node, SSAInvokeInstruction call) {
public NormalReturnCaller(CGNode node, SSAAbstractInvokeInstruction call) {
super(node);
this.call = call;
this.valueNumber = call.getDef();
@ -133,7 +133,7 @@ public abstract class ParamStatement extends Statement {
return Kind.NORMAL_RET_CALLER;
}
public SSAInvokeInstruction getCall() {
public SSAAbstractInvokeInstruction getCall() {
return call;
}
@ -163,11 +163,11 @@ public abstract class ParamStatement extends Statement {
}
public static class ExceptionalReturnCaller extends ParamStatement implements ValueNumberCarrier, CallStatementCarrier {
private final SSAInvokeInstruction call;
private final SSAAbstractInvokeInstruction call;
protected final int valueNumber;
public ExceptionalReturnCaller(CGNode node, SSAInvokeInstruction call) {
public ExceptionalReturnCaller(CGNode node, SSAAbstractInvokeInstruction call) {
super(node);
this.call = call;
this.valueNumber = call.getException();
@ -178,7 +178,7 @@ public abstract class ParamStatement extends Statement {
return Kind.EXC_RET_CALLER;
}
public SSAInvokeInstruction getCall() {
public SSAAbstractInvokeInstruction getCall() {
return call;
}

View File

@ -25,7 +25,7 @@ import com.ibm.wala.ipa.slicer.Slicer.ControlDependenceOptions;
import com.ibm.wala.ipa.slicer.Slicer.DataDependenceOptions;
import com.ibm.wala.ipa.slicer.Statement.Kind;
import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.util.CompoundIterator;
import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.collections.HashSetFactory;
@ -207,7 +207,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
return getPDG(N.getNode()).getPredNodes(N);
case EXC_RET_CALLER: {
ParamStatement.ExceptionalReturnCaller nrc = (ParamStatement.ExceptionalReturnCaller) N;
SSAInvokeInstruction call = nrc.getCall();
SSAAbstractInvokeInstruction call = nrc.getCall();
Collection<Statement> result = new Iterator2Collection<Statement>(getPDG(N.getNode()).getPredNodes(N));
if (!dOptions.equals(DataDependenceOptions.NONE)) {
// data dependence predecessors
@ -221,7 +221,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
}
case NORMAL_RET_CALLER: {
ParamStatement.NormalReturnCaller nrc = (ParamStatement.NormalReturnCaller) N;
SSAInvokeInstruction call = nrc.getCall();
SSAAbstractInvokeInstruction call = nrc.getCall();
Collection<Statement> result = new Iterator2Collection<Statement>(getPDG(N.getNode()).getPredNodes(N));
if (!dOptions.equals(DataDependenceOptions.NONE)) {
// data dependence predecessors
@ -235,7 +235,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
}
case HEAP_RET_CALLER: {
HeapStatement.ReturnCaller r = (HeapStatement.ReturnCaller) N;
SSAInvokeInstruction call = r.getCall();
SSAAbstractInvokeInstruction call = r.getCall();
Collection<Statement> result = new Iterator2Collection<Statement>(getPDG(N.getNode()).getPredNodes(N));
if (!dOptions.equals(DataDependenceOptions.NONE)) {
// data dependence predecessors
@ -263,7 +263,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
IntSet indices = ir.getCallInstructionIndices(site);
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
int i = ii.next();
SSAInvokeInstruction call = (SSAInvokeInstruction) ir.getInstructions()[i];
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ir.getInstructions()[i];
int p = call.getUse(parameterIndex);
Statement s = new ParamStatement.ParamCaller(caller, call, p);
addNode(s);
@ -292,7 +292,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
IntSet indices = ir.getCallInstructionIndices(site);
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
int i = ii.next();
SSAInvokeInstruction call = (SSAInvokeInstruction) ir.getInstructions()[i];
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ir.getInstructions()[i];
Statement s = new HeapStatement.ParamCaller(caller, call, hpc.getLocation());
addNode(s);
result.add(s);
@ -319,7 +319,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
IntSet indices = ir.getCallInstructionIndices(site);
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
int i = ii.next();
SSAInvokeInstruction call = (SSAInvokeInstruction) ir.getInstructions()[i];
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ir.getInstructions()[i];
Statement s = pdg.ssaInstruction2Statement(call);
addNode(s);
result.add(s);
@ -345,9 +345,9 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
return getPDG(N.getNode()).getSuccNodes(N);
} else {
NormalStatement ns = (NormalStatement) N;
if (ns.getInstruction() instanceof SSAInvokeInstruction) {
if (ns.getInstruction() instanceof SSAAbstractInvokeInstruction) {
HashSet<Statement> result = HashSetFactory.make();
SSAInvokeInstruction call = (SSAInvokeInstruction) ns.getInstruction();
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ns.getInstruction();
for (CGNode t : N.getNode().getPossibleTargets(call.getCallSite())) {
Statement s = new MethodEntryStatement(t);
addNode(s);
@ -379,7 +379,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
IntSet indices = ir.getCallInstructionIndices(site);
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
int i = ii.next();
SSAInvokeInstruction call = (SSAInvokeInstruction) ir.getInstructions()[i];
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ir.getInstructions()[i];
Statement s = new ParamStatement.ExceptionalReturnCaller(caller, call);
addNode(s);
result.add(s);
@ -401,7 +401,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
IntSet indices = ir.getCallInstructionIndices(site);
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
int i = ii.next();
SSAInvokeInstruction call = (SSAInvokeInstruction) ir.getInstructions()[i];
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ir.getInstructions()[i];
Statement s = new ParamStatement.NormalReturnCaller(caller, call);
addNode(s);
result.add(s);
@ -424,7 +424,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
IntSet indices = ir.getCallInstructionIndices(site);
for (IntIterator ii = indices.intIterator(); ii.hasNext();) {
int i = ii.next();
SSAInvokeInstruction call = (SSAInvokeInstruction) ir.getInstructions()[i];
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ir.getInstructions()[i];
Statement s = new HeapStatement.ReturnCaller(caller, call, r.getLocation());
addNode(s);
result.add(s);
@ -436,7 +436,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
}
case PARAM_CALLER: {
ParamStatement.ParamCaller pac = (ParamStatement.ParamCaller) N;
SSAInvokeInstruction call = pac.getCall();
SSAAbstractInvokeInstruction call = pac.getCall();
Collection<Statement> result = HashSetFactory.make(5);
if (!dOptions.equals(DataDependenceOptions.NONE)) {
// data dependence successors
@ -454,7 +454,7 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
}
case HEAP_PARAM_CALLER:
HeapStatement.ParamCaller pc = (HeapStatement.ParamCaller) N;
SSAInvokeInstruction call = pc.getCall();
SSAAbstractInvokeInstruction call = pc.getCall();
Collection<Statement> result = HashSetFactory.make(5);
if (!dOptions.equals(DataDependenceOptions.NONE)) {
// data dependence successors
@ -481,8 +481,8 @@ public class SDG extends AbstractNumberedGraph<Statement> implements ISDG {
} else {
NormalStatement ns = (NormalStatement) src;
if (dst instanceof MethodEntryStatement) {
if (ns.getInstruction() instanceof SSAInvokeInstruction) {
SSAInvokeInstruction call = (SSAInvokeInstruction) ns.getInstruction();
if (ns.getInstruction() instanceof SSAAbstractInvokeInstruction) {
SSAAbstractInvokeInstruction call = (SSAAbstractInvokeInstruction) ns.getInstruction();
return src.getNode().getPossibleTargets(call.getCallSite()).contains(dst.getNode());
} else {
return false;

View File

@ -17,7 +17,7 @@ import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.slicer.ParamStatement.ExceptionalReturnCaller;
import com.ibm.wala.ipa.slicer.ParamStatement.NormalReturnCaller;
import com.ibm.wala.ipa.slicer.Slicer.ControlDependenceOptions;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.util.collections.EmptyIterator;
import com.ibm.wala.util.collections.Filter;
import com.ibm.wala.util.collections.FilterIterator;
@ -71,19 +71,19 @@ class SDGSupergraph implements ISupergraph<Statement, PDG> {
switch (r.getKind()) {
case EXC_RET_CALLER: {
ParamStatement.ExceptionalReturnCaller n = (ExceptionalReturnCaller) r;
SSAInvokeInstruction call = n.getCall();
SSAAbstractInvokeInstruction call = n.getCall();
PDG pdg = getProcOf(r);
return pdg.getCallerParamStatements(call).iterator();
}
case NORMAL_RET_CALLER: {
ParamStatement.NormalReturnCaller n = (NormalReturnCaller) r;
SSAInvokeInstruction call = n.getCall();
SSAAbstractInvokeInstruction call = n.getCall();
PDG pdg = getProcOf(r);
return pdg.getCallerParamStatements(call).iterator();
}
case HEAP_RET_CALLER: {
HeapStatement.ReturnCaller n = (HeapStatement.ReturnCaller) r;
SSAInvokeInstruction call = n.getCall();
SSAAbstractInvokeInstruction call = n.getCall();
PDG pdg = getProcOf(r);
return pdg.getCallerParamStatements(call).iterator();
}
@ -244,19 +244,19 @@ class SDGSupergraph implements ISupergraph<Statement, PDG> {
switch (call.getKind()) {
case PARAM_CALLER: {
ParamStatement.ParamCaller n = (ParamStatement.ParamCaller) call;
SSAInvokeInstruction st = n.getCall();
SSAAbstractInvokeInstruction st = n.getCall();
PDG pdg = getProcOf(call);
return pdg.getCallerReturnStatements(st).iterator();
}
case HEAP_PARAM_CALLER: {
HeapStatement.ParamCaller n = (HeapStatement.ParamCaller) call;
SSAInvokeInstruction st = n.getCall();
SSAAbstractInvokeInstruction st = n.getCall();
PDG pdg = getProcOf(call);
return pdg.getCallerReturnStatements(st).iterator();
}
case NORMAL: {
NormalStatement n = (NormalStatement) call;
SSAInvokeInstruction st = (SSAInvokeInstruction) n.getInstruction();
SSAAbstractInvokeInstruction st = (SSAAbstractInvokeInstruction) n.getInstruction();
PDG pdg = getProcOf(call);
return pdg.getCallerReturnStatements(st).iterator();
}
@ -291,7 +291,7 @@ class SDGSupergraph implements ISupergraph<Statement, PDG> {
return false;
} else {
NormalStatement s = (NormalStatement) n;
return s.getInstruction() instanceof SSAInvokeInstruction;
return s.getInstruction() instanceof SSAAbstractInvokeInstruction;
}
default:
Assertions.UNREACHABLE();
@ -501,4 +501,4 @@ class SDGSupergraph implements ISupergraph<Statement, PDG> {
}
}
}
}