From: bdemsky Date: Tue, 16 Jun 2009 22:08:00 +0000 (+0000) Subject: changes to analysis.. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=d55999cd59fecab09df184cc531f1d3c7ed23f8a changes to analysis.. --- diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index 5a8fe1ae..211f6659 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -15,12 +15,14 @@ public class DelayComputation { LocalityAnalysis locality; TypeAnalysis typeanalysis; GlobalFieldType gft; + DiscoverConflicts dcopts; - public DelayComputation(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis, GlobalFieldType gft) { + public DelayComputation(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis, GlobalFieldType gft, DiscoverConflicts dcopts) { this.locality=locality; this.state=state; this.typeanalysis=typeanalysis; this.gft=gft; + this.dcopts=dcopts; } public void doAnalysis() { @@ -33,6 +35,7 @@ public class DelayComputation { public void analyzeMethod(LocalityBinding lb) { MethodDescriptor md=lb.getMethod(); FlatMethod fm=state.getMethodFlat(md); + System.out.println("Analyzing "+md); HashSet cannotdelay=new HashSet(); Hashtable atomictable=locality.getAtomic(lb); if (lb.isAtomic()) { @@ -179,7 +182,31 @@ public class DelayComputation { /* Do we read from arrays */ if (fn.kind()==FKind.FlatElementNode) { //have to do expansion - nodelayarrayrdset.addAll(typeanalysis.expand(((FlatSetElementNode)fn).getSrc().getType())); + nodelayarrayrdset.addAll(typeanalysis.expand(((FlatElementNode)fn).getSrc().getType())); + } + } else { + //Need to know which objects to lock on + switch(fn.kind()) { + case FKind.FlatSetFieldNode: { + FlatSetFieldNode fsfn=(FlatSetFieldNode)fn; + nodelaytempset.add(fsfn.getDst()); + break; + } + case FKind.FlatSetElementNode: { + FlatSetElementNode fsen=(FlatSetElementNode)fn; + nodelaytempset.add(fsen.getDst()); + break; + } + case FKind.FlatFieldNode: { + FlatFieldNode ffn=(FlatFieldNode)fn; + nodelaytempset.add(ffn.getSrc()); + break; + } + case FKind.FlatElementNode: { + FlatElementNode fen=(FlatElementNode)fn; + nodelaytempset.add(fen.getSrc()); + break; + } } } @@ -222,7 +249,106 @@ public class DelayComputation { if (changed) for(int i=0;i notreadyset=computeNotReadySet(lb, cannotdelay); + HashSet atomicset=new HashSet(); + for(Iterator fnit=fm.getNodeSet().iterator();fnit.hasNext();) { + FlatNode fn=fnit.next(); + boolean isatomic=atomictable.get(fn).intValue()>0; + if (isatomic) + atomicset.add(fn); + } + atomicset.removeAll(notreadyset); + atomicset.removeAll(cannotdelay); + System.out.println("-----------------------------------------------------"); + System.out.println(md); + System.out.println("Cannot delay set:"+cannotdelay); + System.out.println("Not ready set:"+notreadyset); + System.out.println("Other:"+atomicset); + + //We now have: + //(1) Cannot delay set -- stuff that must be done before commit + //(2) Not ready set -- stuff that must wait until commit + //(3) everything else -- stuff that should be done before commit } //end of method + + public HashSet computeNotReadySet(LocalityBinding lb, HashSet cannotdelay) { + //You are in not ready set if: + //I. You read a not ready temp + + //II. You read a field or element and both (A) you are not in the + //cannot delay set and (B) you do a transactional access to object + MethodDescriptor md=lb.getMethod(); + FlatMethod fm=state.getMethodFlat(md); + Hashtable atomictable=locality.getAtomic(lb); + + HashSet notreadynodes=new HashSet(); + HashSet toanalyze=new HashSet(); + toanalyze.addAll(fm.getNodeSet()); + Hashtable> notreadymap=new Hashtable>(); + + while(!toanalyze.isEmpty()) { + FlatNode fn=toanalyze.iterator().next(); + toanalyze.remove(fn); + boolean isatomic=atomictable.get(fn).intValue()>0; + + if (!isatomic) + continue; + + //Compute initial notready set + HashSet notreadyset=new HashSet(); + for(int i=0;i