checkin to only generate C for callable methods...
authorbdemsky <bdemsky>
Sat, 9 Apr 2011 10:27:07 +0000 (10:27 +0000)
committerbdemsky <bdemsky>
Sat, 9 Apr 2011 10:27:07 +0000 (10:27 +0000)
use javacallgraph when appropriate
get rid of some annoying warnings

18 files changed:
Robust/src/Analysis/CallGraph/CallGraph.java
Robust/src/Analysis/CallGraph/JavaCallGraph.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildCodeMGC.java
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/IR/Flat/BuildCodeTran.java
Robust/src/IR/Flat/BuildOoOJavaCode.java
Robust/src/IR/State.java
Robust/src/IR/TypeUtil.java
Robust/src/IR/Virtual.java
Robust/src/Main/Main.java
Robust/src/Runtime/file.c
Robust/src/Runtime/math.c
Robust/src/Runtime/object.c
Robust/src/Runtime/object.h
Robust/src/Runtime/runtime.c
Robust/src/Runtime/socket.c
Robust/src/Runtime/thread.c

index 1d0b6987f40549dd49f9186c5487f0237509d6cd..5ed43132aaa5cd744fbb19eaf9c4f28ccb67b2e7 100644 (file)
@@ -9,6 +9,7 @@ import IR.ClassDescriptor;
 import IR.MethodDescriptor;
 import IR.TaskDescriptor;
 import IR.TypeDescriptor;
+import IR.TypeUtil;
 import java.util.*;
 import java.io.*;
 
@@ -26,8 +27,12 @@ public class CallGraph {
 
   protected CallGraph() {}
 
-  public CallGraph(State state) {
+  protected TypeUtil typeUtil;
+
+  public CallGraph(State state, TypeUtil typeUtil) {
     this.state=state;
+    this.typeUtil=typeUtil;
+
     mapVirtual2ImplementationSet = new Hashtable();
     mapCaller2CalleeSet          = new Hashtable();
     mapCallee2CallerSet          = new Hashtable();
@@ -74,6 +79,33 @@ public class CallGraph {
        MethodDescriptor md=(MethodDescriptor)methodit.next();
        if (md.isStatic()||md.getReturnType()==null)
          continue;
+       Stack<ClassDescriptor> possInterfaces=new Stack<ClassDescriptor>();
+       ClassDescriptor tmpcd=cn;
+       while(tmpcd!=null) {
+         for(Iterator supit=tmpcd.getSuperInterfaces();supit.hasNext();) {
+           possInterfaces.add((ClassDescriptor)supit.next());
+         }
+         tmpcd=tmpcd.getSuperDesc();
+       }
+       while(!possInterfaces.isEmpty()) {
+         ClassDescriptor IFdesc=possInterfaces.pop();
+         for(Iterator supit=IFdesc.getSuperInterfaces();supit.hasNext();) {
+           possInterfaces.add((ClassDescriptor)supit.next());
+         }
+         Set possiblematches=IFdesc.getMethodTable().getSet(md.getSymbol());
+         boolean foundmatch=false;
+         for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
+           MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+           if (md.matches(matchmd)) {
+             if (!mapVirtual2ImplementationSet.containsKey(matchmd))
+               mapVirtual2ImplementationSet.put(matchmd,new HashSet());
+             ((HashSet)mapVirtual2ImplementationSet.get(matchmd)).add(md);
+             break;
+           }
+         }
+       }
+       
+
        ClassDescriptor superdesc=cn.getSuperDesc();
        if (superdesc!=null) {
          Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
@@ -144,6 +176,10 @@ public class CallGraph {
     return ns;
   }
 
+  public boolean isCallable(MethodDescriptor md) {
+    return true;
+  }
+
   /** Returns all methods transitively callable from d */
 
   public Set getAllMethods(Descriptor d) {
@@ -154,6 +190,7 @@ public class CallGraph {
       Descriptor md=(Descriptor)tovisit.iterator().next();
       tovisit.remove(md);
       Set s=(Set)mapCaller2CalleeSet.get(md);
+
       if (s!=null) {
        for(Iterator it=s.iterator(); it.hasNext();) {
          MethodDescriptor md2=(MethodDescriptor)it.next();
@@ -234,7 +271,7 @@ public class CallGraph {
        MethodDescriptor calledmethod=fc.getMethod();
        Set methodsthatcouldbecalled=fc.getThis()==null ? getMethods(calledmethod) :
                                      getMethods(calledmethod, fc.getThis().getType());
-
+       
        // add caller -> callee maps
        if( !mapCaller2CalleeSet.containsKey(caller) ) {
          mapCaller2CalleeSet.put(caller, new HashSet() );
index 3b6ba97cfdd8cd1910cc54e7b1e5789789afaf42..14e9a759eb4f83911919c0643c5e26a10c539fbe 100644 (file)
@@ -15,33 +15,71 @@ import java.io.*;
 
 public class JavaCallGraph extends CallGraph {
   TypeUtil tu;
+  HashSet discovered;
+
   public JavaCallGraph(State state, TypeUtil tu) {
     this.state=state;
     mapVirtual2ImplementationSet = new Hashtable();
     mapCaller2CalleeSet          = new Hashtable();
     mapCallee2CallerSet          = new Hashtable();
+    discovered=new HashSet();
     this.tu=tu;
     buildVirtualMap();
     buildGraph();
   }
 
+  public boolean isCallable(MethodDescriptor md) {
+    return discovered.contains(md);
+  }
+
   //Work our way down from main
   private void buildGraph() {
     MethodDescriptor main=tu.getMain();
     HashSet tovisit=new HashSet();
-    HashSet discovered=new HashSet();
     tovisit.add(main);
     discovered.add(main);
+    Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
+
+    while(it.hasNext()) {
+      ClassDescriptor cn=(ClassDescriptor)it.next();
+      Iterator methodit=cn.getMethods();
+      //Iterator through methods
+      while(methodit.hasNext()) {
+       MethodDescriptor md=(MethodDescriptor)methodit.next();
+       if (md.isStaticBlock()) {
+         tovisit.add(md);
+         discovered.add(md);
+       }
+      }
+    }
+
+
     while(!tovisit.isEmpty()) {
       MethodDescriptor md=(MethodDescriptor)tovisit.iterator().next();
       tovisit.remove(md);
       FlatMethod fm=state.getMethodFlat(md);
+      if (fm==null)
+       continue;
       analyzeMethod(md, fm);
       for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator();fnit.hasNext();) {
        FlatNode fn=fnit.next();
        if (fn.kind()==FKind.FlatCall) {
          FlatCall fcall=(FlatCall)fn;
          Set callees=fcall.getThis()==null?getMethods(fcall.getMethod()):getMethods(fcall.getMethod(),fcall.getThis().getType());
+
+         if (fcall.getThis()!=null) {
+           MethodDescriptor methodd=fcall.getMethod();
+
+           if (methodd.getClassDesc()==tu.getClass(TypeUtil.ThreadClass)&&
+               methodd.getSymbol().equals("start")&&methodd.numParameters()==0&&!methodd.getModifiers().isStatic()) {
+             //Have call to start
+             HashSet ns=new HashSet();
+             ns.addAll(callees);
+             ns.addAll(getMethods(tu.getRun(), fcall.getThis().getType()));
+             callees=ns;
+           }
+         }
+
          for(Iterator mdit=callees.iterator();mdit.hasNext();) {
            MethodDescriptor callee=(MethodDescriptor)mdit.next();
            if (!discovered.contains(callee)) {
index 43b3513583043cf56b4bb976db1346b76185324d..ed6e796826d9dacbbedcc1fdec7bb4927a9f731f 100644 (file)
@@ -55,26 +55,22 @@ public class BuildCode {
   
   int boundschknum = 0;
 
-  public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil) {
-    this(st, temptovar, typeutil, null);
+  public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, CallGraph callgraph) {
+    this(st, temptovar, typeutil, null, callgraph);
   }
 
-  public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa) {
+  public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, CallGraph callgraph) {
     this.sa=sa;
     state=st;
-    State.logEvent("Start CallGraph");    
-    callgraph=new CallGraph(state);
-    State.logEvent("Finish CallGraph");    
+    this.callgraph=callgraph;
     this.temptovar=temptovar;
     paramstable=new Hashtable();
     tempstable=new Hashtable();
     fieldorder=new Hashtable();
     flagorder=new Hashtable();
     this.typeutil=typeutil;
-    State.logEvent("CheckMethods");    
-    checkMethods2Gen();
     State.logEvent("Virtual");    
-    virtualcalls=new Virtual(state, null);
+    virtualcalls=new Virtual(state, null, callgraph);
     printedfieldstbl = new Hashtable<String, ClassDescriptor>();
   }
 
@@ -258,36 +254,6 @@ public class BuildCode {
     State.logEvent("End of buildCode");
   }
 
-  /* This method goes though the call graph and check which methods are really
-   * invoked and should be generated
-   */
-  protected void checkMethods2Gen() {
-    MethodDescriptor md=(state.main==null)?null:typeutil.getMain();
-    
-    if(md != null) {
-      // check the methods to be generated
-      state.setGenAllMethods(false);
-    } else {
-      // generate all methods
-      return;
-    }
-    this.state.addMethod2gen(md);
-    
-    Iterator it_classes = this.state.getClassSymbolTable().getDescriptorsIterator();
-    while(it_classes.hasNext()) {
-      ClassDescriptor cd = (ClassDescriptor)it_classes.next();
-      Iterator it_methods = cd.getMethodTable().getDescriptorsIterator();
-      while(it_methods.hasNext()) {
-        md = (MethodDescriptor)it_methods.next();
-        if(md.isStaticBlock() || md.getModifiers().isNative() || this.callgraph.getCallerSet(md).size() > 0
-            || (cd.getSymbol().equals("Thread") && md.getSymbol().equals("staticStart"))) {
-          this.state.addMethod2gen(md);
-        }
-      }
-    }
-  }
-
-
   /* This method goes though the call graph and tag those methods that are
    * invoked inside static blocks
    */
@@ -450,6 +416,7 @@ public class BuildCode {
     while(taskit.hasNext()) {
       TaskDescriptor td=(TaskDescriptor)taskit.next();
       FlatMethod fm=state.getMethodFlat(td);
+
       generateFlatMethod(fm, outmethod);
       generateTaskDescriptor(outtaskdefs, fm, td);
     }
@@ -539,20 +506,10 @@ public class BuildCode {
       while(methodit.hasNext()) {
        /* Classify parameters */
        MethodDescriptor md=(MethodDescriptor)methodit.next();
-    if(!this.state.genAllMethods) {
-      boolean foundmatch = false;
-      Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
-      for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-        MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-        if (md.matches(matchmd)) {
-          foundmatch=true;
-          break;
-        }
-      }
-      if(!foundmatch) {
-        continue;
-      }
-    }
+       if (!callgraph.isCallable(md)) {
+         continue;
+       }
+
        FlatMethod fm=state.getMethodFlat(md);
        if (!md.getModifiers().isNative()) {
          generateFlatMethod(fm, outmethod);
@@ -930,22 +887,11 @@ public class BuildCode {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
        continue;
-      boolean foundmatch = false;
-      if(this.state.genAllMethods) {
-        foundmatch = true;
-      } else {
-        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
-        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-          if (md.matches(matchmd)) {
-            foundmatch=true;
-            break;
-          }
-        }
-      }
-      if(!foundmatch) {
-        continue;
+
+      if (!callgraph.isCallable(md)) {
+       continue;
       }
+
       int methodnum = virtualcalls.getMethodNumber(md);
       virtualtable[rownum][methodnum]=md;
     }
@@ -1643,22 +1589,12 @@ public class BuildCode {
   protected void generateCallStructsMethods(ClassDescriptor cn, PrintWriter output, PrintWriter headersout) {
     for(Iterator methodit=cn.getMethods(); methodit.hasNext(); ) {
       MethodDescriptor md=(MethodDescriptor)methodit.next();
-      boolean foundmatch = false;
-      if(this.state.genAllMethods) {
-        foundmatch = true;
-      } else {
-        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
-        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-          if (md.matches(matchmd)) {
-            foundmatch=true;
-            break;
-          }
-        }
-      }
-      if(foundmatch) {
-        generateMethod(cn, md, headersout, output);
+
+      if (!callgraph.isCallable(md)) {
+       continue;
       }
+
+      generateMethod(cn, md, headersout, output);
     }
   }
 
@@ -2830,10 +2766,17 @@ public class BuildCode {
        else
          output.println(generateTemp(fm, fon.getDest())+" = ((unsigned int)"+generateTemp(fm, fon.getLeft())+")>>"+generateTemp(fm,fon.getRight())+";");
 
-      } else
-       output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+fon.getOp().toString()+generateTemp(fm,fon.getRight())+";");
+      } else {
+       if (fon.getLeft().getType().isPtr()&&fon.getLeft().getType()!=fon.getRight().getType()&&!fon.getRight().getType().isNull())
+         output.println(generateTemp(fm, fon.getDest())+" = (struct "+fon.getRight().getType().getSafeSymbol()+"*)"+generateTemp(fm, fon.getLeft())+fon.getOp().toString()+generateTemp(fm,fon.getRight())+";");
+       else
+         output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+fon.getOp().toString()+generateTemp(fm,fon.getRight())+";");
+      }
     } else if (fon.getOp().getOp()==Operation.ASSIGN)
-      output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+";");
+      if (fon.getDest().getType().isPtr()&&fon.getDest().getType()!=fon.getLeft().getType())
+       output.println(generateTemp(fm, fon.getDest())+" = (struct "+fon.getDest().getType().getSafeSymbol()+"*)"+generateTemp(fm, fon.getLeft())+";");
+      else
+       output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+";");
     else if (fon.getOp().getOp()==Operation.UNARYPLUS)
       output.println(generateTemp(fm, fon.getDest())+" = "+generateTemp(fm, fon.getLeft())+";");
     else if (fon.getOp().getOp()==Operation.UNARYMINUS)
index e01fe00825636b11150b3b59df23054c5bc3b7ae..86e7db56cc4db6ae04f642328f0fd079b9def0b3 100644 (file)
@@ -6,6 +6,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 
 import Analysis.TaskStateAnalysis.SafetyAnalysis;
+import Analysis.CallGraph.CallGraph;
 import IR.ClassDescriptor;
 import IR.MethodDescriptor;
 import IR.State;
@@ -25,8 +26,8 @@ public class BuildCodeMGC extends BuildCode {
                       SafetyAnalysis sa,
                       int coreNum, 
                       int tcoreNum,
-                      int gcoreNum) {
-    super(st, temptovar, typeutil, sa);
+                      int gcoreNum, CallGraph callgraph) {
+    super(st, temptovar, typeutil, sa, callgraph);
     this.coreNum = coreNum; // # of the active cores
     this.tcoreNum = tcoreNum; // # of the total number of cores
     this.gcoreNum = gcoreNum; // # of the cores for gc if any
index 454432b4a413d3bd234a9e7d3dfb41dc72f9a14c..edbe54b0a21073989d434b6db3443a380962064e 100644 (file)
@@ -18,6 +18,7 @@ import Analysis.OwnershipAnalysis.AllocationSite;
 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
 import Analysis.OwnershipAnalysis.HeapRegionNode;
 import Analysis.Prefetch.*;
+import Analysis.CallGraph.CallGraph;
 import IR.ClassDescriptor;
 import IR.Descriptor;
 import IR.FlagDescriptor;
@@ -61,8 +62,8 @@ public class BuildCodeMultiCore extends BuildCode {
                            SafetyAnalysis sa, 
                            Vector<Schedule> scheduling, 
                            int coreNum, 
-                           int gcoreNum) {
-    super(st, temptovar, typeutil, sa);
+                           int gcoreNum, CallGraph callgraph) {
+    super(st, temptovar, typeutil, sa, callgraph);
     this.scheduling = scheduling;
     this.coreNum = coreNum; // # of the active cores
     this.tcoreNum = coreNum;  // # of the cores setup by users
index 7966193f2e24c5d3a235ea54329b4b02bbb6ef18..3f979b4640c631482308acf92293fe43895ecd78 100644 (file)
@@ -43,17 +43,18 @@ public class BuildCodeTran extends BuildCode {
   LocalityBinding currlb;
 
 
-  public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa) {
-    this(st, temptovar, typeutil, null, sa, pa);
+  public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa, CallGraph callgraph) {
+    this(st, temptovar, typeutil, null, sa, pa, callgraph);
   }
 
-  public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa) {
-    this(st, temptovar, typeutil, locality, null, pa);
+  public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa, CallGraph callgraph) {
+    this(st, temptovar, typeutil, locality, null, pa, callgraph);
   }
 
-  public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa) {
-    super(st, temptovar, typeutil, sa);
+  public BuildCodeTran(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa, CallGraph callgraph) {
+    super(st, temptovar, typeutil, sa, callgraph);
     this.sa=sa;
+    this.virtualcalls=new Virtual(state, locality, callgraph);
     if (state.SINGLETM)
       oidstr="___objlocation___";
     if (locality!=null) {
index 99494f450c35c7101e087d7d646759012f442c69..ef30c32a3993cfe6afddf8f92ccc6fc79aac9051 100644 (file)
@@ -32,9 +32,9 @@ public class BuildOoOJavaCode extends BuildCode {
                            Hashtable        temptovar, 
                            TypeUtil         typeutil, 
                            SafetyAnalysis   sa, 
-                           OoOJavaAnalysis  oooa
+                           OoOJavaAnalysis  oooa, CallGraph callgraph
                            ) {
-    super( st, temptovar, typeutil, sa);
+    super( st, temptovar, typeutil, sa, callgraph);
 
     this.oooa = oooa;
   }
index d340669bbc7748c8c616aba71bc463bc3946f65c..dc488eab0a2f7aaee30c7b1afb917b794b00c133 100644 (file)
@@ -6,6 +6,7 @@ import Util.Lattice;
 
 import java.util.*;
 import Analysis.TaskStateAnalysis.*;
+import Analysis.CallGraph.CallGraph;
 
 public class State {
   public static long startTime;
@@ -31,8 +32,6 @@ public class State {
     this.sclasses=new SymbolTable();
     this.treemethodmap=new Hashtable();
     this.flatmethodmap=new Hashtable();
-    this.genAllMethods = true;
-    this.methods2gen = new SymbolTable();
     this.parsetrees=new HashSet();
     this.arraytypes=new HashSet();
     this.arraytonumber=new Hashtable();
@@ -199,7 +198,6 @@ public class State {
   public Hashtable treemethodmap;
   public Hashtable flatmethodmap;
   SymbolTable methods2gen;
-  public boolean genAllMethods;
   private HashSet arraytypes;
   public Hashtable arraytonumber;
   private int numclasses=1; // start from 1 instead of 0 for multicore gc
@@ -271,21 +269,6 @@ public class State {
     }
   }
   
-  public void setGenAllMethods(boolean flag) {
-    this.genAllMethods = flag;
-  }
-  
-  public void addMethod2gen(MethodDescriptor md) {
-    if(this.genAllMethods) {
-      throw new Error("The state.genAllMethods is TRUE, do not need to check methods to genenrate");
-    }
-    this.methods2gen.add(md);
-  }
-  
-  public SymbolTable getMethod2gen() {
-    return this.methods2gen;
-  }
-  
   public int numClasses() {
     return numclasses;
   }
index 0d7efcba7cec11caab51ba260b25b3c5e24cb305..61faa673f8b89bde904f7f5612499d5204ea309c 100644 (file)
@@ -19,7 +19,7 @@ public class TypeUtil {
   BuildIR bir;
   
   // for interfaces
-  Hashtable superIFtbl;
+  Hashtable<ClassDescriptor, Set<ClassDescriptor>> superIFtbl;
 
   public TypeUtil(State state, BuildIR bir) {
     this.state=state;
@@ -69,7 +69,7 @@ public class TypeUtil {
        supertable.put(cd,cd_super);
       }
     }
-    if (!this.superIFtbl.containsKey(cd)) {
+    if (!superIFtbl.containsKey(cd)) {
       // add inherited interfaces
       superIFtbl.put(cd,new HashSet());
       HashSet hs=(HashSet)superIFtbl.get(cd);
@@ -85,7 +85,7 @@ public class TypeUtil {
 
   private void createTables() {
     supertable=new Hashtable();
-    superIFtbl = new Hashtable();
+    superIFtbl = new Hashtable<ClassDescriptor,Set<ClassDescriptor>>();
   }
 
   public ClassDescriptor getMainClass() {
@@ -276,8 +276,8 @@ NextMethod:
     return (ClassDescriptor)supertable.get(cd);
   }
   
-  public Set getSuperIFs(ClassDescriptor cd) {
-    return (Set)this.superIFtbl.get(cd);
+  public Set<ClassDescriptor> getSuperIFs(ClassDescriptor cd) {
+    return superIFtbl.get(cd);
   }
 
   public boolean isCastable(TypeDescriptor original, TypeDescriptor casttype) {
@@ -411,9 +411,9 @@ NextMethod:
     
     {
       // check cd2's interface ancestors
-      Iterator it_sifs = getSuperIFs(cd2).iterator();
+      Iterator<ClassDescriptor> it_sifs = getSuperIFs(cd2).iterator();
       while(it_sifs.hasNext()) {
-       ClassDescriptor cd = (ClassDescriptor)it_sifs.next();
+       ClassDescriptor cd = it_sifs.next();
        if(cd == possiblesuper) {
          return true;
        } else if(!tovisit.contains(cd)){
index 456fb45ed2ed29472d15f800f1c384948f0f6eb9..b5cee9781d80228d51b3fba072d35e228178cb48 100644 (file)
@@ -3,7 +3,7 @@ import java.util.*;
 
 import Analysis.Locality.LocalityBinding;
 import Analysis.Locality.LocalityAnalysis;
-
+import Analysis.CallGraph.CallGraph;
 
 public class Virtual {
   State state;
@@ -11,7 +11,8 @@ public class Virtual {
   Hashtable<MethodDescriptor, Integer> methodnumber;
   Hashtable<ClassDescriptor, Integer> classmethodcount;
   Hashtable<LocalityBinding, Integer> localitynumber;
-  
+  CallGraph callgraph;
+
   // for interfaces
   int if_starts;
   SymbolTable if_methods;
@@ -28,11 +29,12 @@ public class Virtual {
     return localitynumber.get(lb).intValue();
   }
 
-  public Virtual(State state, LocalityAnalysis locality) {
+  public Virtual(State state, LocalityAnalysis locality, CallGraph callgraph) {
     this.state=state;
     this.locality=locality;
     this.if_starts = 0;
     this.if_methods = new SymbolTable();
+    this.callgraph=callgraph;
     classmethodcount=new Hashtable<ClassDescriptor, Integer>();
     if (state.DSM||state.SINGLETM)
       localitynumber=new Hashtable<LocalityBinding, Integer>();
@@ -127,23 +129,10 @@ public class Virtual {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
         continue;
-      boolean foundmatch = false;
-      if(this.state.genAllMethods) {
-        foundmatch = true;
-      } else {
-        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
-        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-          if (md.matches(matchmd)) {
-            foundmatch=true;
-            break;
-          }
-        }
-      }
-      if(!foundmatch) {
-        continue;
-      }
-      foundmatch=false;
+
+      if (!callgraph.isCallable(md))
+       continue;
+      boolean foundmatch=false;
       // check if there is a matched method that has been assigned method num
       Set possiblematches_if = if_methods.getSet(md.getSymbol());
       for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext();) {
@@ -155,10 +144,10 @@ public class Virtual {
           break;
         }
       }
-      if(!foundmatch) {
-        methodnumber.put(md, new Integer(if_starts++));
-        if_methods.add(md);
-        mnum++;
+      if (!foundmatch) {
+       methodnumber.put(md, new Integer(if_starts++));
+       if_methods.add(md);
+       mnum++;
       }
     }
     classmethodcount.put(cd, new Integer(mnum));
@@ -175,54 +164,49 @@ public class Virtual {
       mnum = numberMethods(superdesc);
       start += mnum;
     }
+    methodit:
     for(Iterator it=cd.getMethods(); it.hasNext();) {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
         continue;
-      boolean foundmatch = false;
-      if(this.state.genAllMethods) {
-        foundmatch = true;
-      } else {
-        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
-        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-          if (md.matches(matchmd)) {
-            foundmatch=true;
-            break;
-          }
-        }
-      }
-      if(!foundmatch) {
-        continue;
-      }
-      foundmatch=false;
+      if (!callgraph.isCallable(md))
+       continue;
       // check if there is a matched method in methods defined in interfaces
       Set possiblematches_if=if_methods.getSet(md.getSymbol());
       for(Iterator matchit=possiblematches_if.iterator(); matchit.hasNext();) {
         MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
         if (md.matches(matchmd)) {
-          int num = methodnumber.get(matchmd);
+         int num;
+         if (!methodnumber.containsKey(matchmd)) {
+           num=start++;
+           mnum++;
+           methodnumber.put(matchmd,num);
+         } else
+           num = methodnumber.get(matchmd);
           methodnumber.put(md, new Integer(num));
-          foundmatch=true;
-          break;
+         continue methodit;
         }
       }
-      if (!foundmatch && superdesc!=null) {
+      if (superdesc!=null) {
         Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
         for(Iterator matchit=possiblematches.iterator(); matchit.hasNext();) {
           MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
           if (md.matches(matchmd)) {
-            int num = methodnumber.get(matchmd);
+           int num;
+           if (!methodnumber.containsKey(matchmd)) {
+             num=start++;
+             mnum++;
+             methodnumber.put(matchmd,num);
+           } else
+             num = methodnumber.get(matchmd);
             methodnumber.put(md, new Integer(num));
-            foundmatch=true;
-            break;
+           continue methodit;
           }
         }
       }
-      if (!foundmatch) {
-        methodnumber.put(md, new Integer(start++));
-        mnum++;
-      }
+
+      methodnumber.put(md, new Integer(start++));
+      mnum++;
     }
     classmethodcount.put(cd, new Integer(mnum));
     return mnum;
index 29e6a5b212bc44227150906d6906bcf7ca622adb..57581a9c5d6bb59f2030360bfe4925855fb41838 100644 (file)
@@ -34,6 +34,7 @@ import Analysis.TaskStateAnalysis.TaskAnalysis;
 import Analysis.TaskStateAnalysis.TaskTagAnalysis;
 import Analysis.TaskStateAnalysis.TaskGraph;
 import Analysis.CallGraph.CallGraph;
+import Analysis.CallGraph.JavaCallGraph;
 import Analysis.TaskStateAnalysis.FEdge;
 import Analysis.TaskStateAnalysis.FlagState;
 import Analysis.TaskStateAnalysis.TagAnalysis;
@@ -299,16 +300,16 @@ public class Main {
         startnum = Integer.parseInt(args[++i]);
       else if (option.equals("-useprofile")) {
        state.USEPROFILE=true;
-    state.profilename = args[++i];
+       state.profilename = args[++i];
       }
       else if (option.equals("-thread"))
        state.THREAD=true;
       else if (option.equals("-dsm"))
        state.DSM=true;
       else if (option.equals("-recoverystats"))
-  state.DSMRECOVERYSTATS=true;
+       state.DSMRECOVERYSTATS=true;
       else if (option.equals("-dsmtask"))
-  state.DSMTASK=true;
+       state.DSMTASK=true;
       else if (option.equals("-singleTM"))
        state.SINGLETM=true;
       else if (option.equals("-readset"))
@@ -341,14 +342,14 @@ public class Main {
        state.RCR_DEBUG = true;
        state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
       } else if (option.equals("-rcr_debug_verbose")){
-  state.RCR_DEBUG_VERBOSE = true;
-  state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
+       state.RCR_DEBUG_VERBOSE = true;
+       state.KEEP_RG_FOR_ALL_PROGRAM_POINTS=true;
       } else if (option.equals("-nostalltr")){
        state.NOSTALLTR = true;     
       } else if (option.equals("-ssjava")){
-  state.SSJAVA = true;     
+       state.SSJAVA = true;     
       } else if (option.equals("-printlinenum")){
-  state.LINENUM=true;
+       state.LINENUM=true;
       }else if (option.equals("-help")) {      
        System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
        System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
@@ -444,6 +445,7 @@ public class Main {
     }
     
 
+
     BuildFlat bf=new BuildFlat(state,tu);
     bf.buildFlat();
     State.logEvent("Done Building Flat");
@@ -465,8 +467,9 @@ public class Main {
       }
     }
 
+    CallGraph callgraph=state.TASK?new CallGraph(state, tu):new JavaCallGraph(state, tu);
+
     if (state.OPTIMIZE) {
-      CallGraph callgraph=new CallGraph(state);
       CopyPropagation cp=new CopyPropagation();
       DeadCode dc=new DeadCode();
       GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
@@ -508,12 +511,11 @@ public class Main {
     }
     
     if (state.OWNERSHIP) {
-      CallGraph callGraph = new CallGraph(state);
       Liveness liveness = new Liveness();
       ArrayReferencees ar = new ArrayReferencees(state);
       OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                    tu,
-                                                   callGraph,
+                                                   callgraph,
                                                   liveness,
                                                    ar,
                                                    state.OWNERSHIPALLOCDEPTH,
@@ -524,28 +526,24 @@ public class Main {
     }
 
     if (state.DISJOINT && !state.OOOJAVA) {
-      CallGraph        cg = new CallGraph(state);
       Liveness         l  = new Liveness();
       ArrayReferencees ar = new ArrayReferencees(state);
-      DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null);
+      DisjointAnalysis da = new DisjointAnalysis(state, tu, callgraph, l, ar, null, null);
     }
 
     if (state.OOOJAVA) {
-      CallGraph        cg  = new CallGraph(state);
       Liveness         l   = new Liveness();
       ArrayReferencees ar  = new ArrayReferencees(state);
-      oooa = new OoOJavaAnalysis(state, tu, cg, l, ar);
+      oooa = new OoOJavaAnalysis(state, tu, callgraph, l, ar);
     }
 
 
     if (state.TAGSTATE) {
-      CallGraph callgraph=new CallGraph(state);
       TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
       TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis, tu);
     }
 
     if (state.TASKSTATE) {
-      CallGraph callgraph=new CallGraph(state);
       TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
       TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
       ta.taskAnalysis();
@@ -570,7 +568,6 @@ public class Main {
 
       if (state.SCHEDULING) {
        // Use ownership analysis to get alias information
-       CallGraph callGraph = new CallGraph(state);
        Liveness liveness = new Liveness();
         ArrayReferencees ar = new ArrayReferencees(state);
        OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
@@ -603,20 +600,20 @@ public class Main {
           System.exit(0);
         }
 
-           // generate multicore codes
-           if(state.MULTICORE) {
-               BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
-                                                             bf.getMap(),
-                                                             tu,
-                                                             sa,
-                                                             scheduling,
-                                                             mcImplSynthesis.getCoreNum(),
-                                                             state.CORENUM4GC);
-               bcm.setOwnershipAnalysis(oa);
-               bcm.buildCode();
-           }
-           scheduling.clear();
-           scheduling = null;
+       // generate multicore codes
+       if(state.MULTICORE) {
+         BuildCodeMultiCore bcm=new BuildCodeMultiCore(state,
+                                                       bf.getMap(),
+                                                       tu,
+                                                       sa,
+                                                       scheduling,
+                                                       mcImplSynthesis.getCoreNum(),
+                                                       state.CORENUM4GC, callgraph);
+         bcm.setOwnershipAnalysis(oa);
+         bcm.buildCode();
+       }
+       scheduling.clear();
+       scheduling = null;
        }
       }
     }
@@ -630,7 +627,7 @@ public class Main {
                                             sa,
                                             state.CORENUM,
                                             state.CORENUM,
-                                            state.CORENUM4GC);
+                                            state.CORENUM4GC, callgraph);
         bcmgc.buildCode();
       }
     }
@@ -639,7 +636,6 @@ public class Main {
       BuildCode bc;
 
       if (state.DSM||state.SINGLETM) {
-       CallGraph callgraph=new CallGraph(state);
        if (state.PREFETCH) {
          //speed up prefetch generation using locality analysis results
          LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
@@ -647,12 +643,12 @@ public class Main {
        }
        LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
        GenerateConversions gc=new GenerateConversions(la, state);
-       bc=new BuildCodeTran(state, bf.getMap(), tu, la, pa);
+       bc=new BuildCodeTran(state, bf.getMap(), tu, la, pa, callgraph);
       } else {
         if( state.OOOJAVA ) {
-          bc=new BuildOoOJavaCode(state, bf.getMap(), tu, sa, oooa);
+          bc=new BuildOoOJavaCode(state, bf.getMap(), tu, sa, oooa, callgraph);
         } else {
-          bc=new BuildCode(state, bf.getMap(), tu, sa);
+          bc=new BuildCode(state, bf.getMap(), tu, sa, callgraph);
         }
       }
 
index bf6c2d3d3aaacd1789883f80ce1bb4d310b77d6d..7dbd8de9fcb293104315a819b88d01be9f10542a 100644 (file)
@@ -7,7 +7,9 @@
 #include "structdefs.h"
 #include "mem.h"
 #include "runtime.h"
+#include "methodheaders.h"
 
+#ifdef D___FileOutputStream______nativeWrite____I__AR_B_I_I
 void CALL34(___FileOutputStream______nativeWrite____I__AR_B_I_I, int fd, int off, int len, int fd, struct ArrayObject * ___array___, int off, int len) {
 #ifdef MULTICORE
 #else
@@ -15,14 +17,18 @@ void CALL34(___FileOutputStream______nativeWrite____I__AR_B_I_I, int fd, int off
   int status=write(fd, &string[off], len);
 #endif
 }
+#endif
 
+#ifdef D___FileOutputStream______nativeClose____I
 void CALL11(___FileOutputStream______nativeClose____I, int fd, int fd) {
 #ifdef MULTICORE
 #else
   close(fd);
 #endif
 }
+#endif
 
+#ifdef D___FileOutputStream______nativeFlush____I
 void CALL11(___FileOutputStream______nativeFlush____I, int fd, int fd) {
   // not supported in RAW version
 #ifdef MULTICORE
@@ -30,7 +36,9 @@ void CALL11(___FileOutputStream______nativeFlush____I, int fd, int fd) {
   fsync(fd);
 #endif
 }
+#endif
 
+#ifdef D___FileOutputStream______nativeOpen_____AR_B
 int CALL01(___FileOutputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
 #ifdef MULTICORE
   return 0;
@@ -41,7 +49,9 @@ int CALL01(___FileOutputStream______nativeOpen_____AR_B, struct ArrayObject * __
   return fd;
 #endif
 }
+#endif
 
+#ifdef D___FileOutputStream______nativeAppend_____AR_B
 int CALL01(___FileOutputStream______nativeAppend_____AR_B, struct ArrayObject * ___filename___) {
 #ifdef MULTICORE
   return 0;
@@ -52,7 +62,9 @@ int CALL01(___FileOutputStream______nativeAppend_____AR_B, struct ArrayObject *
   return fd;
 #endif
 }
+#endif
 
+#ifdef D___FileInputStream______nativeOpen_____AR_B
 int CALL01(___FileInputStream______nativeOpen_____AR_B, struct ArrayObject * ___filename___) {
 #ifdef MULTICORE
   return 0;
@@ -63,14 +75,18 @@ int CALL01(___FileInputStream______nativeOpen_____AR_B, struct ArrayObject * ___
   return fd;
 #endif
 }
+#endif
 
+#ifdef D___FileInputStream______nativeClose____I
 void CALL11(___FileInputStream______nativeClose____I, int fd, int fd) {
 #ifdef MULTICORE
 #else
   close(fd);
 #endif
 }
+#endif
 
+#ifdef D___FileInputStream______nativeRead____I__AR_B_I
 int CALL23(___FileInputStream______nativeRead____I__AR_B_I, int fd, int numBytes, int fd, struct ArrayObject * ___array___, int numBytes) {
 #ifdef MULTICORE
   return -1;
@@ -86,7 +102,9 @@ int CALL23(___FileInputStream______nativeRead____I__AR_B_I, int fd, int numBytes
   return status;
 #endif
 }
+#endif
 
+#ifdef D___FileInputStream______nativePeek____I
 int CALL11(___FileInputStream______nativePeek____I, int fd, int fd) {
 #ifdef MULTICORE
   return 0;
@@ -102,7 +120,9 @@ int CALL11(___FileInputStream______nativePeek____I, int fd, int fd) {
   return string[0];
 #endif
 }
+#endif
 
+#ifdef D___File______nativeLength_____AR_B
 long long CALL01(___File______nativeLength_____AR_B, struct ArrayObject * ___pathname___) {
 #ifdef MULTICORE
   return 0;
@@ -114,3 +134,4 @@ long long CALL01(___File______nativeLength_____AR_B, struct ArrayObject * ___pat
   return st.st_size;
 #endif
 }
+#endif
index ed4fd0e3117c54b2025fae03bc2026472a34a5d4..e352244627ac23136403aaee705e38fdc0722e70 100644 (file)
 #include "math.h"
 #include "structdefs.h"
 
+#ifdef D___Math______cos____D
 double CALL11(___Math______cos____D, double ___a___, double ___a___) {
   return cos(___a___);
 }
+#endif
 
+#ifdef D___Math______sin____D
 double CALL11(___Math______sin____D, double ___a___, double ___a___) {
   return sin(___a___);
 }
+#endif
 
+#ifdef D___Math______tan____D
 double CALL11(___Math______tan____D, double ___a___, double ___a___) {
   return tan(___a___);
 }
+#endif
 
+#ifdef D___Math______acos____D
 double CALL11(___Math______acos____D, double ___a___, double ___a___) {
   return acos(___a___);
 }
+#endif
 
+#ifdef D___Math______asin____D
 double CALL11(___Math______asin____D, double ___a___, double ___a___) {
   return asin(___a___);
 }
+#endif
 
+#ifdef D___Math______atan____D
 double CALL11(___Math______atan____D, double ___a___, double ___a___) {
   return atan(___a___);
 }
+#endif
 
+#ifdef D___Math______atan2____D_D
 double CALL22(___Math______atan2____D_D, double ___a___, double ___b___, double ___a___, double ___b___) {
   return atan2(___a___,___b___);
 }
+#endif
 
+#ifdef D___Math______log____D
 double CALL11(___Math______log____D, double ___a___, double ___a___) {
   return log(___a___);
 }
+#endif
 
+#ifdef D___Math______exp____D
 double CALL11(___Math______exp____D, double ___a___, double ___a___) {
   return exp(___a___);
 }
+#endif
 
+#ifdef D___Math______sqrt____D
 double CALL11(___Math______sqrt____D, double ___a___, double ___a___) {
   return sqrt(___a___);
 }
+#endif
 
+#ifdef D___Math______pow____D_D
 double CALL22(___Math______pow____D_D, double ___a___, double ___b___, double ___a___, double ___b___) {
   return pow(___a___,___b___);
 }
+#endif
 
+#ifdef D___Math______ceil____D
 double CALL11(___Math______ceil____D, double ___a___, double ___a___) {
   return ceil(___a___);
 }
+#endif
 
+#ifdef D___Math______floor____D
 double CALL11(___Math______floor____D, double ___a___, double ___a___) {
   return floor(___a___);
 }
+#endif
 
+#ifdef D___Math______cosf____F
 float CALL11(___Math______cosf____F, float ___a___, float ___a___) {
   return cosf(___a___);
 }
+#endif
 
+#ifdef D___Math______sinf____F
 float CALL11(___Math______sinf____F, float ___a___, float ___a___) {
   return sinf(___a___);
 }
+#endif
 
+#ifdef D___Math______expf____F
 float CALL11(___Math______expf____F, float ___a___, float ___a___) {
   return expf(___a___);
 }
+#endif
 
+#ifdef D___Math______sqrtf____F
 float CALL11(___Math______sqrtf____F, float ___a___, float ___a___) {
   return sqrtf(___a___);
 }
+#endif
 
+#ifdef D___Math______logf____F
 float CALL11(___Math______logf____F, float ___a___, float ___a___) {
   return logf(___a___);
 }
+#endif
 
+#ifdef D___Math______powf____F_F
 float CALL22(___Math______powf____F_F, float ___a___, float ___b___, float ___a___, float ___b___) {
   return powf(___a___,___b___);
 }
+#endif
 
+#ifdef D___Math______ceilf____F
 float CALL11(___Math______ceilf____F, float ___a___, float ___a___) {
   return ceilf(___a___);
 }
+#endif
 
+#ifdef D___Math______IEEEremainder____F_F
 float CALL22(___Math______IEEEremainder____F_F, float ___a___, float ___b___,  float ___a___, float ___b___) {
   return fmod(___a___, ___b___);
 }
-
+#endif
index 17f296c96ec056bc37a6b33a0c7eb805d7c95a34..a7e1062ac0fe2073ba804910bba50d46142d88df 100644 (file)
@@ -29,11 +29,14 @@ int CALL01(___Object______hashCode____, struct ___Object___ * ___this___) {
 }
 #endif
 
+#ifdef D___Object______getType____
 int CALL01(___Object______getType____, struct ___Object___ * ___this___) {
   return ((int *)VAR(___this___))[0];
 }
+#endif
 
 #ifdef THREADS
+#ifdef D___Object______MonitorEnter____
 int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
 #ifndef NOLOCK
   pthread_t self=pthread_self();
@@ -64,15 +67,19 @@ int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) {
   }
 #endif
 }
+#endif
+
 
 #ifdef D___Object______notify____
 void CALL01(___Object______notify____, struct ___Object___ * ___this___) {
 }
 #endif
+
 #ifdef D___Object______notifyAll____
 void CALL01(___Object______notifyAll____, struct ___Object___ * ___this___) {
 }
 #endif
+
 #ifdef D___Object______wait____
 void CALL01(___Object______wait____, struct ___Object___ * ___this___) {
   pthread_t self=pthread_self();
@@ -125,6 +132,7 @@ void CALL01(___Object______wait____, struct ___Object___ * ___this___) {
 }
 #endif
 
+#ifdef D___Object______MonitorExit____
 int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) {
 #ifndef NOLOCK
   pthread_t self=pthread_self();
@@ -155,3 +163,4 @@ int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) {
 #endif
 }
 #endif
+#endif
index 1c430450fe8db74090cfb023d31b8d6d8d6146cb..b9484e1b64278c7e2bf5f21acb2285865a5e38da 100644 (file)
@@ -9,7 +9,6 @@ int CALL01(___Object______nativehashCode____, struct ___Object___ * ___this___);
 #ifdef D___Object______hashCode____
 int CALL01(___Object______hashCode____, struct ___Object___ * ___this___); 
 #endif
-int CALL01(___Object______getType____, struct ___Object___ * ___this___);
 #ifdef THREADS
 int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___);
 int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___);
index cffd1c375ebe2d377ea290f98008b4a692971db3..245cda9354f4a2f7efecf4defed831f85edd92d9 100644 (file)
@@ -360,7 +360,7 @@ long long CALL01(___Runtime______maxMemory____, struct ___Runtime___ * ___this__
   return 1024*1024*1024;
 }
 #endif
-
+#ifdef D___System______exit____I
 void CALL11(___System______exit____I,int ___status___, int ___status___) {
 #ifdef TRANSSTATS
 #ifndef RECOVERY
@@ -384,7 +384,9 @@ void CALL11(___System______exit____I,int ___status___, int ___status___) {
 #endif
   exit(___status___);
 }
+#endif
 
+#ifdef D___System______logevent____I
 void CALL11(___System______logevent____I,int ___event___, int ___event___) {
 #ifdef STMLOG
   event[counter] = ___event___;
@@ -393,14 +395,18 @@ void CALL11(___System______logevent____I,int ___event___, int ___event___) {
 #endif
   return;
 }
+#endif
 
+#ifdef ___System______logevent____
 void CALL00(___System______logevent____) {
 #ifdef STMLOG
   beginClock= rdtsc();
 #endif
   return;
 }
+#endif
 
+#ifdef ___System______flushToFile____I
 void CALL11(___System______flushToFile____I, int ___threadid___, int ___threadid___) {
 #ifdef STMLOG
   FILE *fp;
@@ -422,7 +428,9 @@ void CALL11(___System______flushToFile____I, int ___threadid___, int ___threadid
 #endif
   return;
 }
+#endif
 
+#ifdef D___System______initLog____
 void CALL00(___System______initLog____) {
 #ifdef STMLOG
   counter=0;
@@ -435,6 +443,7 @@ void CALL00(___System______initLog____) {
 #endif
   return;
 }
+#endif
 
 #ifdef D___Vector______removeElement_____AR_L___Object____I_I
 void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index___, int ___size___, struct ArrayObject * ___array___, int ___index___, int ___size___) {
@@ -443,10 +452,13 @@ void CALL23(___Vector______removeElement_____AR_L___Object____I_I, int ___index_
 }
 #endif
 
+#ifdef D___System______printI____I
 void CALL11(___System______printI____I,int ___status___, int ___status___) {
   printf("%d\n",___status___);
 }
+#endif
 
+#ifdef D___System______currentTimeMillis____
 long long CALL00(___System______currentTimeMillis____) {
   struct timeval tv; long long retval;
   gettimeofday(&tv, NULL);
@@ -455,6 +467,7 @@ long long CALL00(___System______currentTimeMillis____) {
   retval+= (tv.tv_usec/1000); /* adjust milliseconds & add them in */
   return retval;
 }
+#endif
 
 #ifdef D___System______gc____
 void CALL00(___System______gc____) {
@@ -508,6 +521,7 @@ void CALL00(___System______gc____) {
 }
 #endif
 
+#ifdef D___System______microTimes____
 long long CALL00(___System______microTimes____) {
   struct timeval tv; 
   long long retval;
@@ -517,14 +531,18 @@ long long CALL00(___System______microTimes____) {
   retval+= (tv.tv_usec); /* adjust microseconds & add them in */
   return retval;
 }
+#endif
 
+#ifdef D___System______getticks____
 long long CALL00(___System______getticks____) {
   unsigned a, d;
   asm("cpuid");
   asm volatile("rdtsc" : "=a" (a), "=d" (d));
   return (((ticks)a) | (((ticks)d) << 32));
 }
+#endif
 
+#ifdef D___System______printString____L___String___
 void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
   struct ArrayObject * chararray=VAR(___s___)->___value___;
   int i;
@@ -538,6 +556,7 @@ void CALL01(___System______printString____L___String___,struct ___String___ * __
   fflush(stdout);
 #endif
 }
+#endif
 
 #ifdef D___RecoveryStat______printRecoveryStat____ 
 #ifdef RECOVERYSTATS
@@ -553,11 +572,14 @@ void CALL00(___RecoveryStat______printRecoveryStat____) {
 #endif
 
 #ifdef DSTM
+#ifdef D___System______clearPrefetchCache____
 void CALL00(___System______clearPrefetchCache____) {
   prehashClear();
 }
+#endif
 
 #ifdef RANGEPREFETCH
+#ifdef D___System______rangePrefetch____L___Object_____AR_S
 void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Object___ * ___o___, struct ArrayObject * ___offsets___) {
   /* Manual Prefetches to be inserted */
   //printf("DEBUG-> %s() ___Object___ * ___o___ = %x\n", __func__, VAR(___o___));
@@ -584,6 +606,7 @@ void CALL02(___System______rangePrefetch____L___Object_____AR_S, struct ___Objec
   return;
 }
 #endif
+#endif
 
 #ifdef D___Task______execution____ 
 extern void* virtualtable[];
index e9e73d45ec9efdfdd85611d15602356962af091a..bc46887031465c43e518aadef43b46a71e4992db 100644 (file)
@@ -14,6 +14,7 @@
 
 struct RuntimeHash *fdtoobject;
 
+#ifdef D___Socket______nativeConnect____I__AR_B_I
 int CALL24(___Socket______nativeConnect____I__AR_B_I, int ___fd___, int ___port___, struct ___Socket___ * ___this___, int ___fd___, struct ArrayObject * ___address___,int ___port___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -61,8 +62,10 @@ error:
   return -1;
 #endif
 }
+#endif
 
 #ifdef TASK
+#ifdef D___Socket______nativeBindFD____I
 int CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ * ___this___, int ___fd___) {
 #ifdef MULTICORE
 #else
@@ -74,8 +77,9 @@ int CALL12(___Socket______nativeBindFD____I, int ___fd___, struct ___Socket___ *
   return 0;
 }
 #endif
+#endif
 
-
+#ifdef D___Socket______nativeBind_____AR_B_I
 int CALL12(___Socket______nativeBind_____AR_B_I, int ___port___,  struct ArrayObject * ___address___, int ___port___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -133,7 +137,9 @@ error:
 #endif
 #endif
 }
+#endif
 
+#ifdef D___InetAddress______getHostByName_____AR_B
 struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct ArrayObject * ___hostname___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -185,8 +191,9 @@ struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct A
        }
 #endif
 }
+#endif
 
-
+#ifdef D___ServerSocket______createSocket____I
 int CALL12(___ServerSocket______createSocket____I, int port, struct ___ServerSocket___ * ___this___, int port) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -291,7 +298,9 @@ int CALL12(___ServerSocket______createSocket____I, int port, struct ___ServerSoc
   return fd;
 #endif
 }
+#endif
 
+#ifdef D___ServerSocket______nativeaccept____L___Socket___
 int CALL02(___ServerSocket______nativeaccept____L___Socket___,struct ___ServerSocket___ * ___this___, struct ___Socket___ * ___s___) {
 #ifdef MULTICORE
   // not supported in MULTICORE version
@@ -344,7 +353,9 @@ int CALL02(___ServerSocket______nativeaccept____L___Socket___,struct ___ServerSo
   return newfd;
 #endif
 }
+#endif
 
+#ifdef D___Socket______nativeWrite_____AR_B_I_I
 void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, struct ___Socket___ * ___this___, struct ArrayObject * ___b___, int offset, int length) {
 #ifdef MULTICORE
 #else
@@ -369,7 +380,10 @@ void CALL24(___Socket______nativeWrite_____AR_B_I_I, int offset, int length, str
   }
 #endif
 }
+#endif
 
+
+#ifdef D___Socket______nativeRead_____AR_B
 int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___, struct ArrayObject * ___b___) {
 #ifdef MULTICORE
   return -1;
@@ -422,7 +436,9 @@ int CALL02(___Socket______nativeRead_____AR_B, struct ___Socket___ * ___this___,
   return byteread;
 #endif
 }
+#endif
 
+#ifdef D___Socket______nativeClose____
 void CALL01(___Socket______nativeClose____, struct ___Socket___ * ___this___) {
 #ifdef MULTICORE
 #else
@@ -438,3 +454,4 @@ void CALL01(___Socket______nativeClose____, struct ___Socket___ * ___this___) {
   close(fd);
 #endif
 }
+#endif
index 6f78c414215ea1b1f4895f7263ada396d02deacb..857f89c81462e5562e8f52ae91d8337fd6ce8a44 100644 (file)
@@ -7,6 +7,7 @@
 #include "thread.h"
 #include "option.h"
 #include <signal.h>
+#include "methodheaders.h"
 
 #ifdef DSTM
 #ifdef RECOVERY
@@ -369,6 +370,7 @@ void initthread(struct ___Thread___ * ___this___) {
 }
 #endif
 
+#ifdef D___Thread______sleep____J
 void CALL11(___Thread______sleep____J, long long ___millis___, long long ___millis___) {
 #if defined(THREADS)||defined(STM)
 #ifdef PRECISE_GC
@@ -382,8 +384,9 @@ void CALL11(___Thread______sleep____J, long long ___millis___, long long ___mill
 #endif
 #endif
 }
+#endif
 
-#if defined(DSTM)|| defined(THREADS)||defined(STM)
+#ifdef D___Thread______yield____
 void CALL00(___Thread______yield____) {
   pthread_yield();
 }
@@ -400,17 +403,22 @@ void CALL00(___Thread______abort____) {
 #ifdef DSTM
 #ifdef RECOVERY
 // return if the machine is dead
+#ifdef D___Thread______nativeGetStatus____I
 int CALL12(___Thread______nativeGetStatus____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
   return getStatus(___mid___);
 }
+#endif
 #else 
+#ifdef D___Thread______nativeGetStatus____I
 int CALL12(___Thread______nativeGetStatus____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
   return 0;
 }
 #endif
 #endif
+#endif
 #ifdef DSTM
 /* Add thread join capability */
+#ifdef D___Thread______join____
 void CALL01(___Thread______join____, struct ___Thread___ * ___this___) {
   unsigned int *oidarray;
   unsigned short *versionarray, version;
@@ -473,8 +481,10 @@ transstart:
   return;
 }
 #endif
+#endif
 
 #if defined(THREADS)||defined(STM)
+#ifdef D___Thread______nativeJoin____
 void CALL01(___Thread______nativeJoin____, struct ___Thread___ * ___this___) {
   pthread_mutex_lock(&joinlock);
   while(!VAR(___this___)->___finished___) {
@@ -488,7 +498,9 @@ void CALL01(___Thread______nativeJoin____, struct ___Thread___ * ___this___) {
   }
   pthread_mutex_unlock(&joinlock);
 }
+#endif
 
+#ifdef D___Thread______nativeCreate____
 void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
   pthread_t thread;
   int retval;
@@ -501,7 +513,6 @@ void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
   pthread_attr_setdetachstate(&nattr, PTHREAD_CREATE_DETACHED);
   INTPTR stacksize;
   pthread_attr_getstacksize(&nattr, &stacksize);
-  printf("STACKSIZE=%u\n",stacksize);
   do {
     retval=pthread_create(&thread, &nattr, (void * (*)(void *)) &initthread, VAR(___this___));
     if (retval!=0)
@@ -512,12 +523,15 @@ void CALL01(___Thread______nativeCreate____, struct ___Thread___ * ___this___) {
   pthread_attr_destroy(&nattr);
 }
 #endif
+#endif
 
 #ifdef DSTM
+#ifdef D___Thread______start____I
 void CALL12(___Thread______start____I, int ___mid___, struct ___Thread___ * ___this___, int ___mid___) {
   startRemoteThread((unsigned int)VAR(___this___), ___mid___);
 }
 #endif
+#endif
 
 #ifdef DSTM
 void globalDestructor(void *value) {