From: bdemsky Date: Tue, 13 Oct 2009 20:53:48 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cba3858851db43f0a93c6805b00590ee4450030e;p=IRC.git *** empty log message *** --- diff --git a/Robust/src/Analysis/MLP/MemoryStall.java b/Robust/src/Analysis/MLP/MemoryStall.java new file mode 100644 index 00000000..3e27e918 --- /dev/null +++ b/Robust/src/Analysis/MLP/MemoryStall.java @@ -0,0 +1,162 @@ +package Analysis.MLP; + +public class MemoryStall { + JavaCallGraph callgraph; + State state; + TypeUtil typeutil; + SESETree sesetree; + + public MemoryStall(State state, TypeUtil typeutil, JavaCallGraph callgraph, SESETree sesetree) { + this.state=state; + this.typeutil=typeutil; + this.callgraph=callgraph; + this.sesetree=sesetree; + } + + private boolean isOnlyLeaf(MethodDescriptor md) { + Set seseset=sesetree.getSESE(md); + for(Iterator seseit=seseset.iterator();seseit.hasNext();) { + SESENode sese=seseit.next(); + if (!sese.isLeaf()) + return false + } + return true; + } + + HashSet toanalyze=new HashSet(); + + public void doAnalysis() { + MethodDescriptor main=typeutil.getMain(); + toanalyze.addAll(callGraph.getAllMethods(main)); + + while(!toanalyze.isEmpty()) { + MethodDescriptor md=(MethodDescriptor)toanalyze.iterator().next(); + toanalyze.remove(md); + if (isOnlyLeaf(md)) + continue; + analyzeMethod(md); + } + } + + private void analyzeMethod(MethodDescriptor md) { + FlatMethod fm=state.getMethodFlat(md); + Hashtable> nodetosese=sesetree.analyzeMethod(md); + HashSet tovisit=new HashSet(); + tovisit.add(fm); + Hashtable> dirtytemps=new Hashtable>(); + + while(!tovisit.isEmpty()) { + FlatNode fn=tovisit.iterator().next(); + tovisit.remove(fn); + HashSet newset=new HashSet(); + for(int i=0;i(); + break; + } + case FKind.FlatElementNode: { + FlatElementNode fen=(FlatElementNode) fn; + newset.remove(fen.getSrc()); + newset.remove(fen.getDst()); + break; + } + case FKind.FlatFieldNode: { + FlatFieldNode ffn=(FlatFieldNode) fn; + newset.remove(ffn.getSrc()); + newset.remove(ffn.getDst()); + break; + } + case FKind.FlatSetFieldNode: { + FlatSetFieldNode fsfn=(FlatSetFieldNode) fn; + newset.remove(fsfn.getSrc()); + newset.remove(fsfn.getDst()); + break; + } + case FKind.FlatSetElementNode: { + FlatSetElementNode fsen=(FlatSetElementNode) fn; + newset.remove(fsen.getSrc()); + newset.remove(fsen.getDst()); + break; + } + case FKind.FlatLiteralNode: { + FlatLiteralNode fln=(FlatLiteralNode) fn; + newset.remove(fln.getDst()); + break; + } + case FKind.FlatMethodNode: { + + break; + } + case FKind.FlatOpNode: { + FlatOpNode fon=(FlatOpNode)fn; + if (fon.getOp().getOp()==Operation.ASSIGN) { + if (newset.contains(getLeft())) + newset.add(getDest()); + else if (!newset.contains(getLeft())) + newset.remove(getDest()); + break; + } + } + case FKind.FlatCastNode: { + FlatCastNode fcn=(FlatOpNode)fn; + if (newset.contains(getSrc())) + newset.add(getDst()); + else if (!newset.contains(getSrc())) + newset.remove(getDst()); + break; + } + case FKind.FlatNew: { + FlatNew fnew=(FlatNew) fn; + newset.remove(fnew.getDst()); + break; + } + case FKind.FlatReturnNode: { + FlatReturnNode frn=(FlatReturnNode) fn; + + break; + } + case FKind.FlatCall: { + FlatCall fc=(FlatCall)fn; + + break; + } + } + + } + + + + } + + private MethodDescriptor getBase(MethodDescriptor md) { + ClassDescriptor cd=md.getClassDesc(); + while (cd.getSuperDesc()!=null) { + cd=cd.getSuperDesc(); + Set methodset=cd.getMethodTable().getSet(md.getSymbol()); + MethodDescriptor mdtemp=null; + for(Iterator mdit=methodset.iterator();mdit.hasNext();) { + MethodDescriptor mdsuper=(MethodDescriptor) mdit.next(); + if (mdsuper.matches(md)) { + mdtemp=mdsuper; + break; + } + } + if (mdtemp!=null) + md=mdtemp; + else + return md; + } + return md; + } + + class MethodContext { + boolean[] parameters; + boolean dirtytemp; + } + +} \ No newline at end of file