From 0ae570181655201d90847bb65c94a0275e1d64df Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 10 Aug 2007 02:52:03 +0000 Subject: [PATCH] more code for support DSM --- .../Analysis/Locality/LocalityAnalysis.java | 34 +++- .../Analysis/Locality/LocalityBinding.java | 3 + Robust/src/IR/Flat/BuildCode.java | 175 +++++++++++------- 3 files changed, 140 insertions(+), 72 deletions(-) diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index 23a6c90b..766f910c 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -7,6 +7,7 @@ import IR.State; import IR.TypeUtil; import IR.MethodDescriptor; import IR.Flat.*; +import IR.ClassDescriptor; public class LocalityAnalysis { State state; @@ -16,6 +17,7 @@ public class LocalityAnalysis { Hashtable>> temptab; Hashtable> atomictab; Hashtable>> tempstosave; + Hashtable> classtolb; CallGraph callgraph; TypeUtil typeutil; @@ -34,10 +36,16 @@ public class LocalityAnalysis { this.lbtovisit=new Stack(); this.callgraph=callgraph; this.tempstosave=new Hashtable>>(); - + this.classtolb=new Hashtable>(); doAnalysis(); } + /** This method returns a set of LocalityBindings for the parameter class. */ + + public Set getClassBindings(ClassDescriptor cd) { + return classtolb.get(cd); + } + /** This method returns a set of LocalityBindings. A * LocalityBinding specifies a context a method can be invoked in. * It specifies whether the method is in a transaction and whether @@ -94,7 +102,10 @@ public class LocalityAnalysis { lbmain.setGlobal(0, LOCAL); lbtovisit.add(lbmain); discovered.put(lbmain, lbmain); - + if (!classtolb.containsKey(lbmain.getMethod().getClassDesc())) + classtolb.put(lbmain.getMethod().getClassDesc(), new HashSet()); + classtolb.get(lbmain.getMethod().getClassDesc()).add(lbmain); + while(!lbtovisit.empty()) { LocalityBinding lb=(LocalityBinding) lbtovisit.pop(); Integer returnglobal=lb.getGlobalReturn(); @@ -241,9 +252,17 @@ public class LocalityAnalysis { Integer currreturnval=EITHER; //Start off with the either value for(Iterator methodit=methodset.iterator();methodit.hasNext();) { MethodDescriptor md=(MethodDescriptor) methodit.next(); + boolean isnative=md.getModifiers().isNative(); + LocalityBinding lb=new LocalityBinding(md, isatomic); + if (isnative&&isatomic) { + System.out.println("Don't call native methods in atomic blocks!"); + } for(int i=0;i()); + classtolb.get(lb.getMethod().getClassDesc()).add(lb); } else lb=discovered.get(lb); Integer returnval=lb.getGlobalReturn(); diff --git a/Robust/src/Analysis/Locality/LocalityBinding.java b/Robust/src/Analysis/Locality/LocalityBinding.java index a679c60c..cfd9c5d4 100644 --- a/Robust/src/Analysis/Locality/LocalityBinding.java +++ b/Robust/src/Analysis/Locality/LocalityBinding.java @@ -37,6 +37,9 @@ public class LocalityBinding { } public String getSignature() { + if (md.getModifiers().isNative()) + return ""; + String st="_"; if (isatomic) { st+="A"; diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index df52097a..c807d16f 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -279,8 +279,6 @@ public class BuildCode { generateFlatMethod(fm, lb, outmethod); } } - - } else { Iterator classit=state.getClassSymbolTable().getDescriptorsIterator(); while(classit.hasNext()) { @@ -355,7 +353,8 @@ public class BuildCode { if (state.TASK) { outclassdefs.println(" int flag;"); outclassdefs.println(" void * flagptr;"); - if(state.OPTIONAL) outclassdefs.println(" int failedstatus;"); + if(state.OPTIONAL) + outclassdefs.println(" int failedstatus;"); } printClassStruct(typeutil.getClass(TypeUtil.ObjectClass), outclassdefs); @@ -880,74 +879,100 @@ public class BuildCode { printClassStruct(cn, classdefout); classdefout.println("};\n"); - /* Cycle through methods */ - Iterator methodit=cn.getMethods(); - while(methodit.hasNext()) { - /* Classify parameters */ - MethodDescriptor md=(MethodDescriptor)methodit.next(); - FlatMethod fm=state.getMethodFlat(md); - generateTempStructs(fm, null); - - ParamsObject objectparams=(ParamsObject) paramstable.get(md); - TempObject objecttemps=(TempObject) tempstable.get(md); - - /* Output parameter structure */ - if (GENERATEPRECISEGC) { - output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {"); - output.println(" int size;"); - output.println(" void * next;"); - for(int i=0;i lbit=locality.getClassBindings(cn).iterator();lbit.hasNext();) { + LocalityBinding lb=lbit.next(); + MethodDescriptor md=lb.getMethod(); + generateMethod(cn, md, lb, headersout, output); } + } else { + /* Cycle through methods */ + for(Iterator methodit=cn.getMethods();methodit.hasNext();) { + /* Classify parameters */ + MethodDescriptor md=(MethodDescriptor)methodit.next(); + generateMethod(cn, md, null, headersout, output); + } + } + } - /* Output temp structure */ - if (GENERATEPRECISEGC) { - output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {"); - output.println(" int size;"); - output.println(" void * next;"); - for(int i=0;i