Massive commit...
authorbdemsky <bdemsky>
Wed, 18 Feb 2009 08:54:42 +0000 (08:54 +0000)
committerbdemsky <bdemsky>
Wed, 18 Feb 2009 08:54:42 +0000 (08:54 +0000)
Changes:
1) Put Class Library files in directories by when we use them
2) Change class paths in buildscript
3) Only load/compile classes that we actually use

39 files changed:
Robust/src/Analysis/TaskStateAnalysis/TaskAnalysis.java
Robust/src/Analysis/TaskStateAnalysis/TaskTagAnalysis.java
Robust/src/ClassLibrary/Barrier.java [deleted file]
Robust/src/ClassLibrary/Bristlecone/Object.java [new file with mode: 0644]
Robust/src/ClassLibrary/Bristlecone/ServerSocket.java [new file with mode: 0644]
Robust/src/ClassLibrary/Bristlecone/Socket.java [new file with mode: 0644]
Robust/src/ClassLibrary/Bristlecone/StartupObject.java [new file with mode: 0644]
Robust/src/ClassLibrary/Bristlecone/TagDescriptor.java [new file with mode: 0644]
Robust/src/ClassLibrary/DistributedHashMap.java [deleted file]
Robust/src/ClassLibrary/Java/Object.java [new file with mode: 0644]
Robust/src/ClassLibrary/Java/ServerSocket.java [new file with mode: 0644]
Robust/src/ClassLibrary/Java/Socket.java [new file with mode: 0644]
Robust/src/ClassLibrary/JavaDSM/Barrier.java [new file with mode: 0644]
Robust/src/ClassLibrary/JavaDSM/BarrierClient.java [new file with mode: 0644]
Robust/src/ClassLibrary/JavaDSM/DistributedHashMap.java [new file with mode: 0644]
Robust/src/ClassLibrary/JavaDSM/Object.java [new file with mode: 0644]
Robust/src/ClassLibrary/JavaDSM/Thread.java [new file with mode: 0644]
Robust/src/ClassLibrary/JavaThread/Object.java [new file with mode: 0644]
Robust/src/ClassLibrary/JavaThread/Thread.java [new file with mode: 0644]
Robust/src/ClassLibrary/Object.java [deleted file]
Robust/src/ClassLibrary/ObjectFC.java [deleted file]
Robust/src/ClassLibrary/ObjectJava.java [deleted file]
Robust/src/ClassLibrary/ObjectJavaDSM.java [deleted file]
Robust/src/ClassLibrary/ObjectJavaNT.java [deleted file]
Robust/src/ClassLibrary/ServerSocket.java [deleted file]
Robust/src/ClassLibrary/ServerSocketJava.java [deleted file]
Robust/src/ClassLibrary/Socket.java [deleted file]
Robust/src/ClassLibrary/SocketJava.java [deleted file]
Robust/src/ClassLibrary/StartupObject.java [deleted file]
Robust/src/ClassLibrary/TagDescriptor.java [deleted file]
Robust/src/ClassLibrary/Thread.java [deleted file]
Robust/src/ClassLibrary/ThreadDSM.java [deleted file]
Robust/src/IR/State.java
Robust/src/IR/TagVarDescriptor.java
Robust/src/IR/Tree/BuildIR.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/IR/TypeUtil.java
Robust/src/Main/Main.java
Robust/src/buildscript

index be82555b629c461cecaadd8a33146aa5293d1d82..6081ae0f5ad28887c6302ef2606060ae62fdca9d 100644 (file)
@@ -25,9 +25,9 @@ public class TaskAnalysis {
    * @param state a flattened State object
    * @see State
    */
-  public TaskAnalysis(State state, TagAnalysis taganalysis) {
+  public TaskAnalysis(State state, TagAnalysis taganalysis, TypeUtil typeutil) {
     this.state=state;
-    this.typeutil=new TypeUtil(state);
+    this.typeutil=typeutil;
     this.taganalysis=taganalysis;
   }
 
index 6a2d3aab4701cff8f9a095e1b30f989e558343b1..602cd7ea778cbd335f4bb340c61ae0ad909f055b 100644 (file)
@@ -23,9 +23,9 @@ public class TaskTagAnalysis {
    * Class Constructor
    *
    */
-  public TaskTagAnalysis(State state, TagAnalysis taganalysis) {
+  public TaskTagAnalysis(State state, TagAnalysis taganalysis, TypeUtil typeutil) {
     this.state=state;
-    this.typeutil=new TypeUtil(state);
+    this.typeutil=typeutil;
     this.taganalysis=taganalysis;
     this.flaginfo=new FlagInfo(state);
     this.toprocess=new HashSet<TagState>();
diff --git a/Robust/src/ClassLibrary/Barrier.java b/Robust/src/ClassLibrary/Barrier.java
deleted file mode 100644 (file)
index f8389c4..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-public class BarrierServer extends Thread {
-  int numthreads;
-  boolean done;
-
-  public BarrierServer(int n) {
-    numthreads=n;
-    done=false;
-  }
-
-  public void run() {
-    int n;
-    ServerSocket ss=new ServerSocket(2000);
-    atomic {
-      n=numthreads;
-      done=true;
-    }
-    Socket ar[]=new Socket[n];
-    for(int i=0; i<n; i++) {
-      ar[i]=ss.accept();
-    }
-
-    while(true) {
-      for(int j=0; j<n; j++) {
-       Socket s=ar[j];
-       byte b[]=new byte[1];
-       while(s.read(b)!=1) {
-         ;
-       }
-      }
-      byte b[]=new byte[1];
-      b[0]= (byte) 'A';
-      for(int j=0; j<n; j++)
-       ar[j].write(b);
-    }
-  }
-}
-
-public class Barrier {
-  Socket s;
-  public Barrier(String name) {
-    s=new Socket(name, 2000);
-  }
-
-  public static void enterBarrier(Barrier barr) {
-    byte b[]=new byte[1];
-    b[0]=(byte)'A';
-    barr.s.write(b);
-    while(barr.s.read(b)!=1) {
-      ;
-    }
-  }
-}
diff --git a/Robust/src/ClassLibrary/Bristlecone/Object.java b/Robust/src/ClassLibrary/Bristlecone/Object.java
new file mode 100644 (file)
index 0000000..f2d05d2
--- /dev/null
@@ -0,0 +1,30 @@
+public class Object {
+  public native int nativehashCode();
+  private int cachedCode;  //first field has to be a primitive
+  private boolean cachedHash;
+
+  /* DO NOT USE ANY OF THESE - THEY ARE FOR IMPLEMENTING TAGS */
+  private Object tags;
+
+  public int hashCode() {
+    if (!cachedHash) {
+      cachedCode=nativehashCode();
+      cachedHash=true;
+    }
+    return cachedCode;
+  }
+
+  /* DON'T USE THIS METHOD UNLESS NECESSARY */
+  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
+  public native int getType();
+
+  public String toString() {
+    return "Object"+hashCode();
+  }
+
+  public boolean equals(Object o) {
+    if (o==this)
+      return true;
+    return false;
+  }
+}
diff --git a/Robust/src/ClassLibrary/Bristlecone/ServerSocket.java b/Robust/src/ClassLibrary/Bristlecone/ServerSocket.java
new file mode 100644 (file)
index 0000000..723e886
--- /dev/null
@@ -0,0 +1,38 @@
+public class ServerSocket {
+  /* Socket pending flag */
+  external flag SocketPending;
+  /* File Descriptor */
+  int fd;
+
+  private native int createSocket(int port);
+
+  public ServerSocket(int port) {
+    this.fd=createSocket(port);
+  }
+
+  public Socket accept() {
+    Socket s=new Socket();
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+    return s;
+  }
+
+  public Socket accept(tag td) {
+    Socket s=new Socket() {
+    } {td};
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+    return s;
+  }
+
+  /* Lets caller pass in their own Socket object. */
+  public void accept(Socket s) {
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+  }
+
+  private native int nativeaccept(Socket s);
+
+  public void close();
+
+}
diff --git a/Robust/src/ClassLibrary/Bristlecone/Socket.java b/Robust/src/ClassLibrary/Bristlecone/Socket.java
new file mode 100644 (file)
index 0000000..506c327
--- /dev/null
@@ -0,0 +1,71 @@
+public class Socket {
+  /* Data pending flag */
+  external flag IOPending;
+  /* File Descriptor */
+  int fd;
+  private SocketInputStream sin;
+  private SocketOutputStream sout;
+
+  public Socket() {
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+  public InputStream getInputStream() {
+    return sin;
+  }
+
+  public OutputStream getOutputStream() {
+    return sout;
+  }
+
+  public Socket(String host, int port) {
+    InetAddress address=InetAddress.getByName(host);
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public Socket(InetAddress address, int port) {
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public void connect(String host, int port) {
+    InetAddress address=InetAddress.getByName(host);
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public void connect(InetAddress address, int port) {
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+  }
+
+  public static native int nativeBind(byte[] address, int port);
+
+  public native int nativeConnect(int fd, byte[] address, int port);
+
+  int setFD(int filed) {
+    fd=filed;
+  }
+
+  public int read(byte[] b) {
+    return nativeRead(b);
+  }
+  public void write(byte[] b) {
+    nativeWrite(b, 0, b.length);
+  }
+
+  public void write(byte[] b, int offset, int len) {
+    nativeWrite(b, offset, len);
+  }
+
+  private native void nativeBindFD(int fd);
+  private native int nativeRead(byte[] b);
+  private native void nativeWrite(byte[] b, int offset, int len);
+  private native void nativeClose();
+
+  public void close() {
+    nativeClose();
+  }
+}
diff --git a/Robust/src/ClassLibrary/Bristlecone/StartupObject.java b/Robust/src/ClassLibrary/Bristlecone/StartupObject.java
new file mode 100644 (file)
index 0000000..541c26f
--- /dev/null
@@ -0,0 +1,5 @@
+public class StartupObject {
+  flag initialstate;
+
+  String [] parameters;
+}
diff --git a/Robust/src/ClassLibrary/Bristlecone/TagDescriptor.java b/Robust/src/ClassLibrary/Bristlecone/TagDescriptor.java
new file mode 100644 (file)
index 0000000..be067fa
--- /dev/null
@@ -0,0 +1,5 @@
+/** This class is not to be used by the end user.  It's intended for
+ * internal use to keep track of tags. */
+
+private class TagDescriptor {
+}
diff --git a/Robust/src/ClassLibrary/DistributedHashMap.java b/Robust/src/ClassLibrary/DistributedHashMap.java
deleted file mode 100644 (file)
index 76d16fb..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-public class DistributedHashMap {
-  DistributedHashEntry[] table;
-  float loadFactor;
-  int secondcapacity;
-
-  public DistributedHashMap(int initialCapacity, int secondcapacity, float loadFactor) {
-    init(initialCapacity, secondcapacity, loadFactor);
-  }
-
-  private void init(int initialCapacity, int secondcapacity, float loadFactor) {
-    table=global new DistributedHashEntry[initialCapacity];
-    this.loadFactor=loadFactor;
-    this.secondcapacity=secondcapacity;
-  }
-
-  private static int hash1(int hashcode, int length) {
-    int value=hashcode%length;
-    if (value<0)
-      return -value;
-    else
-      return value;
-  }
-
-  private static int hash2(int hashcode, int length1, int length2) {
-    int value=(hashcode*31)%length2;
-    if (value<0)
-      return -value;
-    else
-      return value;
-  }
-
-  void resize(int index) {
-    DHashEntry[] oldtable=table[index].array;
-    int newCapacity=oldtable.length*2+1;
-    DHashEntry [] newtable=global new DHashEntry[newCapacity];
-    table[index].array=newtable;
-
-    for(int i=0; i<oldtable.length; i++) {
-      DHashEntry e=oldtable[i];
-      while(e!=null) {
-       DHashEntry next=e.next;
-       int bin=hash2(e.hashval, table.length, newCapacity);
-       e.next=newtable[bin];
-       newtable[bin]=e;
-       e=next;
-      }
-    }
-  }
-
-  Object remove(Object key) {
-    int hashcode=key.hashCode();
-    int index1=hash1(hashcode, table.length);
-    DistributedHashEntry dhe=table[index1];
-    if (dhe==null)
-      return null;
-    int index2=hash2(hashcode, table.length, dhe.array.length);
-    DHashEntry ptr=dhe.array[index2];
-
-    if (ptr!=null) {
-      if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
-       dhe.array[index2]=ptr.next;
-       dhe.count--;
-       return ptr.value;
-      }
-      while(ptr.next!=null) {
-       if (ptr.hashval==hashcode&&ptr.next.key.equals(key)) {
-         Object oldvalue=ptr.value;
-         ptr.next=ptr.next.next;
-         dhe.count--;
-         return oldvalue;
-       }
-       ptr=ptr.next;
-      }
-    }
-    return null;
-  }
-
-  Object get(Object key) {
-    int hashcode=key.hashCode();
-    int index1=hash1(hashcode, table.length);
-    DistributedHashEntry dhe=table[index1];
-    if (dhe==null)
-      return null;
-
-    int index2=hash2(hashcode, table.length, dhe.array.length);
-    DHashEntry ptr=dhe.array[index2];
-
-    while(ptr!=null) {
-      if (ptr.hashval==hashcode
-          &&ptr.key.equals(key)) {
-       return ptr.value;
-      }
-      ptr=ptr.next;
-    }
-    return null;
-  }
-
-  boolean containsKey(Object key) {
-    int hashcode=key.hashCode();
-    int index1=hash1(hashcode, table.length);
-    DistributedHashEntry dhe=table[index1];
-    if (dhe==null)
-      return false;
-    int index2=hash2(hashcode, table.length, dhe.array.length);
-    DHashEntry ptr=dhe.array[index2];
-
-    while(ptr!=null) {
-      if (ptr.hashval==hashcode
-          &&ptr.key.equals(key)) {
-       return true;
-      }
-      ptr=ptr.next;
-    }
-    return false;
-  }
-
-  Object put(Object key, Object value) {
-    int hashcode=key.hashCode();
-    int index1=hash1(hashcode, table.length);
-    DistributedHashEntry dhe=table[index1];
-    if (dhe==null) {
-      dhe=global new DistributedHashEntry(secondcapacity);
-      table[index1]=dhe;
-    }
-    int index2=hash2(hashcode, table.length, dhe.array.length);
-    DHashEntry ptr=dhe.array[index2];
-
-    while(ptr!=null) {
-      if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
-       Object oldvalue=ptr.value;
-       ptr.value=value;
-       return oldvalue;
-      }
-      ptr=ptr.next;
-    }
-
-    DHashEntry he=global new DHashEntry();
-    he.value=value;
-    he.key=key;
-    he.hashval=hashcode;
-    he.next=dhe.array[index2];
-    dhe.array[index2]=he;
-
-    dhe.count++;
-    if (dhe.count>(loadFactor*dhe.array.length)) {
-      //Resize the table
-      resize(index1);
-    }
-    return null;
-  }
-}
-
-
-class DistributedHashEntry {
-  public DistributedHashEntry(int capacity) {
-    array=global new DHashEntry[capacity];
-  }
-  int count;
-  DHashEntry[] array;
-}
-
-
-class DHashEntry {
-  public DHashEntry() {
-  }
-  int hashval;
-  Object key;
-  Object value;
-  DHashEntry next;
-}
diff --git a/Robust/src/ClassLibrary/Java/Object.java b/Robust/src/ClassLibrary/Java/Object.java
new file mode 100644 (file)
index 0000000..4968cfa
--- /dev/null
@@ -0,0 +1,28 @@
+public class Object {
+  public int cachedCode;   //first field has to be a primitive
+  public boolean cachedHash;
+
+  public native int nativehashCode();
+
+  public int hashCode() {
+    if (!cachedHash) {
+      cachedCode=nativehashCode();
+      cachedHash=true;
+    }
+    return cachedCode;
+  }
+
+  /* DON'T USE THIS METHOD UNLESS NECESSARY */
+  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
+  public native int getType();
+
+  public String toString() {
+    return "Object"+hashCode();
+  }
+
+  public boolean equals(Object o) {
+    if (o==this)
+      return true;
+    return false;
+  }
+}
diff --git a/Robust/src/ClassLibrary/Java/ServerSocket.java b/Robust/src/ClassLibrary/Java/ServerSocket.java
new file mode 100644 (file)
index 0000000..1cf07f2
--- /dev/null
@@ -0,0 +1,28 @@
+public class ServerSocket {
+  /* File Descriptor */
+  int fd;
+
+  private native int createSocket(int port);
+
+  public ServerSocket(int port) {
+    this.fd=createSocket(port);
+  }
+
+  public Socket accept() {
+    Socket s=new Socket();
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+    return s;
+  }
+
+  /* Lets caller pass in their own Socket object. */
+  public void accept(Socket s) {
+    int newfd=nativeaccept(s);
+    s.setFD(newfd);
+  }
+
+  private native int nativeaccept(Socket s);
+
+  public void close();
+
+}
diff --git a/Robust/src/ClassLibrary/Java/Socket.java b/Robust/src/ClassLibrary/Java/Socket.java
new file mode 100644 (file)
index 0000000..297fe3d
--- /dev/null
@@ -0,0 +1,61 @@
+public class Socket {
+  /* File Descriptor */
+  int fd;
+  SocketInputStream sin;
+  SocketOutputStream sout;
+
+  public Socket() {
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+  public InputStream getInputStream() {
+    return sin;
+  }
+
+  public OutputStream getOutputStream() {
+    return sout;
+  }
+
+  public Socket(String host, int port) {
+    InetAddress address=InetAddress.getByName(host);
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+  public Socket(InetAddress address, int port) {
+    fd=nativeBind(address.getAddress(), port);
+    nativeConnect(fd, address.getAddress(), port);
+    sin=new SocketInputStream(this);
+    sout=new SocketOutputStream(this);
+  }
+
+  public static native int nativeBind(byte[] address, int port);
+
+  public static native int nativeConnect(int fd, byte[] address, int port);
+
+  int setFD(int filed) {
+    fd=filed;
+  }
+
+  public int read(byte[] b) {
+    return nativeRead(b);
+  }
+  public void write(byte[] b) {
+    nativeWrite(b, 0, b.length);
+  }
+
+  public void write(byte[] b, int offset, int len) {
+    nativeWrite(b, offset, len);
+  }
+
+  private native int nativeRead(byte[] b);
+  private native void nativeWrite(byte[] b, int offset, int len);
+  private native void nativeClose();
+
+  public void close() {
+    nativeClose();
+  }
+}
diff --git a/Robust/src/ClassLibrary/JavaDSM/Barrier.java b/Robust/src/ClassLibrary/JavaDSM/Barrier.java
new file mode 100644 (file)
index 0000000..f8389c4
--- /dev/null
@@ -0,0 +1,52 @@
+public class BarrierServer extends Thread {
+  int numthreads;
+  boolean done;
+
+  public BarrierServer(int n) {
+    numthreads=n;
+    done=false;
+  }
+
+  public void run() {
+    int n;
+    ServerSocket ss=new ServerSocket(2000);
+    atomic {
+      n=numthreads;
+      done=true;
+    }
+    Socket ar[]=new Socket[n];
+    for(int i=0; i<n; i++) {
+      ar[i]=ss.accept();
+    }
+
+    while(true) {
+      for(int j=0; j<n; j++) {
+       Socket s=ar[j];
+       byte b[]=new byte[1];
+       while(s.read(b)!=1) {
+         ;
+       }
+      }
+      byte b[]=new byte[1];
+      b[0]= (byte) 'A';
+      for(int j=0; j<n; j++)
+       ar[j].write(b);
+    }
+  }
+}
+
+public class Barrier {
+  Socket s;
+  public Barrier(String name) {
+    s=new Socket(name, 2000);
+  }
+
+  public static void enterBarrier(Barrier barr) {
+    byte b[]=new byte[1];
+    b[0]=(byte)'A';
+    barr.s.write(b);
+    while(barr.s.read(b)!=1) {
+      ;
+    }
+  }
+}
diff --git a/Robust/src/ClassLibrary/JavaDSM/BarrierClient.java b/Robust/src/ClassLibrary/JavaDSM/BarrierClient.java
new file mode 100644 (file)
index 0000000..145391f
--- /dev/null
@@ -0,0 +1,54 @@
+public class Barrier {
+  int numthreads;
+  int entercount;
+  boolean cleared;
+
+  public Barrier(int n) {
+    numthreads=n;
+    cleared = false;
+    entercount = 0;
+  }
+
+  public Barrier() {
+  }
+
+  public void reset() {
+    cleared = false;
+    entercount = 0;
+  }
+
+  public static void enterBarrier(Barrier b) {
+    int tmp;
+    boolean retry=true, ret1=false, ret2=true;;
+
+    do {
+      atomic {
+       if (!b.cleared) {
+         b.entercount++;
+         tmp = b.entercount;
+         if (tmp==b.numthreads) {
+           if(b.numthreads > 1)
+             b.cleared=true;
+           b.entercount--;
+           ret1 = true;
+         }
+         retry=false;
+       }
+      }
+    } while(retry);
+    if (ret1) {
+      return;
+    }
+    while(ret2) {
+      atomic {
+       if (b.cleared) {
+         b.entercount--;
+         int count = b.entercount;
+         if (count==0)
+           b.cleared=false;
+         ret2=false;
+       }
+      }
+    }
+  }
+}
diff --git a/Robust/src/ClassLibrary/JavaDSM/DistributedHashMap.java b/Robust/src/ClassLibrary/JavaDSM/DistributedHashMap.java
new file mode 100644 (file)
index 0000000..76d16fb
--- /dev/null
@@ -0,0 +1,170 @@
+public class DistributedHashMap {
+  DistributedHashEntry[] table;
+  float loadFactor;
+  int secondcapacity;
+
+  public DistributedHashMap(int initialCapacity, int secondcapacity, float loadFactor) {
+    init(initialCapacity, secondcapacity, loadFactor);
+  }
+
+  private void init(int initialCapacity, int secondcapacity, float loadFactor) {
+    table=global new DistributedHashEntry[initialCapacity];
+    this.loadFactor=loadFactor;
+    this.secondcapacity=secondcapacity;
+  }
+
+  private static int hash1(int hashcode, int length) {
+    int value=hashcode%length;
+    if (value<0)
+      return -value;
+    else
+      return value;
+  }
+
+  private static int hash2(int hashcode, int length1, int length2) {
+    int value=(hashcode*31)%length2;
+    if (value<0)
+      return -value;
+    else
+      return value;
+  }
+
+  void resize(int index) {
+    DHashEntry[] oldtable=table[index].array;
+    int newCapacity=oldtable.length*2+1;
+    DHashEntry [] newtable=global new DHashEntry[newCapacity];
+    table[index].array=newtable;
+
+    for(int i=0; i<oldtable.length; i++) {
+      DHashEntry e=oldtable[i];
+      while(e!=null) {
+       DHashEntry next=e.next;
+       int bin=hash2(e.hashval, table.length, newCapacity);
+       e.next=newtable[bin];
+       newtable[bin]=e;
+       e=next;
+      }
+    }
+  }
+
+  Object remove(Object key) {
+    int hashcode=key.hashCode();
+    int index1=hash1(hashcode, table.length);
+    DistributedHashEntry dhe=table[index1];
+    if (dhe==null)
+      return null;
+    int index2=hash2(hashcode, table.length, dhe.array.length);
+    DHashEntry ptr=dhe.array[index2];
+
+    if (ptr!=null) {
+      if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
+       dhe.array[index2]=ptr.next;
+       dhe.count--;
+       return ptr.value;
+      }
+      while(ptr.next!=null) {
+       if (ptr.hashval==hashcode&&ptr.next.key.equals(key)) {
+         Object oldvalue=ptr.value;
+         ptr.next=ptr.next.next;
+         dhe.count--;
+         return oldvalue;
+       }
+       ptr=ptr.next;
+      }
+    }
+    return null;
+  }
+
+  Object get(Object key) {
+    int hashcode=key.hashCode();
+    int index1=hash1(hashcode, table.length);
+    DistributedHashEntry dhe=table[index1];
+    if (dhe==null)
+      return null;
+
+    int index2=hash2(hashcode, table.length, dhe.array.length);
+    DHashEntry ptr=dhe.array[index2];
+
+    while(ptr!=null) {
+      if (ptr.hashval==hashcode
+          &&ptr.key.equals(key)) {
+       return ptr.value;
+      }
+      ptr=ptr.next;
+    }
+    return null;
+  }
+
+  boolean containsKey(Object key) {
+    int hashcode=key.hashCode();
+    int index1=hash1(hashcode, table.length);
+    DistributedHashEntry dhe=table[index1];
+    if (dhe==null)
+      return false;
+    int index2=hash2(hashcode, table.length, dhe.array.length);
+    DHashEntry ptr=dhe.array[index2];
+
+    while(ptr!=null) {
+      if (ptr.hashval==hashcode
+          &&ptr.key.equals(key)) {
+       return true;
+      }
+      ptr=ptr.next;
+    }
+    return false;
+  }
+
+  Object put(Object key, Object value) {
+    int hashcode=key.hashCode();
+    int index1=hash1(hashcode, table.length);
+    DistributedHashEntry dhe=table[index1];
+    if (dhe==null) {
+      dhe=global new DistributedHashEntry(secondcapacity);
+      table[index1]=dhe;
+    }
+    int index2=hash2(hashcode, table.length, dhe.array.length);
+    DHashEntry ptr=dhe.array[index2];
+
+    while(ptr!=null) {
+      if (ptr.hashval==hashcode&&ptr.key.equals(key)) {
+       Object oldvalue=ptr.value;
+       ptr.value=value;
+       return oldvalue;
+      }
+      ptr=ptr.next;
+    }
+
+    DHashEntry he=global new DHashEntry();
+    he.value=value;
+    he.key=key;
+    he.hashval=hashcode;
+    he.next=dhe.array[index2];
+    dhe.array[index2]=he;
+
+    dhe.count++;
+    if (dhe.count>(loadFactor*dhe.array.length)) {
+      //Resize the table
+      resize(index1);
+    }
+    return null;
+  }
+}
+
+
+class DistributedHashEntry {
+  public DistributedHashEntry(int capacity) {
+    array=global new DHashEntry[capacity];
+  }
+  int count;
+  DHashEntry[] array;
+}
+
+
+class DHashEntry {
+  public DHashEntry() {
+  }
+  int hashval;
+  Object key;
+  Object value;
+  DHashEntry next;
+}
diff --git a/Robust/src/ClassLibrary/JavaDSM/Object.java b/Robust/src/ClassLibrary/JavaDSM/Object.java
new file mode 100644 (file)
index 0000000..308e81f
--- /dev/null
@@ -0,0 +1,30 @@
+public class Object {
+  public int cachedCode;   //first field has to be a primitive
+  public boolean cachedHash;
+  public Object nextobject;   /* Oid */
+  public Object localcopy;
+
+  public native int nativehashCode();
+
+  public int hashCode() {
+    if (!cachedHash) {
+      cachedCode=nativehashCode();
+      cachedHash=true;
+    }
+    return cachedCode;
+  }
+
+  /* DON'T USE THIS METHOD UNLESS NECESSARY */
+  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
+  public native int getType();
+
+  public String toString() {
+    return "Object"+hashCode();
+  }
+
+  public boolean equals(Object o) {
+    if (o==this)
+      return true;
+    return false;
+  }
+}
diff --git a/Robust/src/ClassLibrary/JavaDSM/Thread.java b/Robust/src/ClassLibrary/JavaDSM/Thread.java
new file mode 100644 (file)
index 0000000..4fb2c7b
--- /dev/null
@@ -0,0 +1,20 @@
+public class Thread {
+  /* Don't allow overriding this method.  If you do, it will break dispatch
+   * because we don't have the type information necessary. */
+  public boolean threadDone;
+
+  public Thread() {
+    threadDone = false;
+  }
+
+  public static native void yield();
+
+  public final native void join();
+
+  public final native void start(int mid);
+
+  public native static void sleep(long millis);
+
+  public void run() {
+  }
+}
diff --git a/Robust/src/ClassLibrary/JavaThread/Object.java b/Robust/src/ClassLibrary/JavaThread/Object.java
new file mode 100644 (file)
index 0000000..a9bf6f4
--- /dev/null
@@ -0,0 +1,33 @@
+public class Object {
+  public int cachedCode;   //first field has to be a primitive
+  public boolean cachedHash;
+
+  public native int nativehashCode();
+  private Object nextlockobject;
+  private Object prevlockobject;
+
+  public int hashCode() {
+    if (!cachedHash) {
+      cachedCode=nativehashCode();
+      cachedHash=true;
+    }
+    return cachedCode;
+  }
+
+  /* DON'T USE THIS METHOD UNLESS NECESSARY */
+  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
+  public native int getType();
+
+  public native int MonitorEnter();
+  public native int MonitorExit();
+
+  public String toString() {
+    return "Object"+hashCode();
+  }
+
+  public boolean equals(Object o) {
+    if (o==this)
+      return true;
+    return false;
+  }
+}
diff --git a/Robust/src/ClassLibrary/JavaThread/Thread.java b/Robust/src/ClassLibrary/JavaThread/Thread.java
new file mode 100644 (file)
index 0000000..50c5580
--- /dev/null
@@ -0,0 +1,27 @@
+public class Thread {
+  private boolean finished;
+
+  public void start() {
+    nativeCreate();
+  }
+
+  private static void staticStart(Thread t) {
+    t.run();
+  }
+
+  public static native void yield();
+
+  public void join() {
+    nativeJoin();
+  }
+
+  private native void nativeJoin();
+
+  public native static void sleep(long millis);
+
+  public void run() {
+  }
+
+  private native void nativeCreate();
+
+}
diff --git a/Robust/src/ClassLibrary/Object.java b/Robust/src/ClassLibrary/Object.java
deleted file mode 100644 (file)
index f2d05d2..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-public class Object {
-  public native int nativehashCode();
-  private int cachedCode;  //first field has to be a primitive
-  private boolean cachedHash;
-
-  /* DO NOT USE ANY OF THESE - THEY ARE FOR IMPLEMENTING TAGS */
-  private Object tags;
-
-  public int hashCode() {
-    if (!cachedHash) {
-      cachedCode=nativehashCode();
-      cachedHash=true;
-    }
-    return cachedCode;
-  }
-
-  /* DON'T USE THIS METHOD UNLESS NECESSARY */
-  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
-  public native int getType();
-
-  public String toString() {
-    return "Object"+hashCode();
-  }
-
-  public boolean equals(Object o) {
-    if (o==this)
-      return true;
-    return false;
-  }
-}
diff --git a/Robust/src/ClassLibrary/ObjectFC.java b/Robust/src/ClassLibrary/ObjectFC.java
deleted file mode 100644 (file)
index ae2c437..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-public class Object {
-  public int cachedCode;   //first field has to be a primitive
-  public boolean cachedHash;
-  public Object nextobject;   /* Oid */
-  public Object localcopy;
-  private Object tags;
-
-  public native int nativehashCode();
-
-  public int hashCode() {
-    if (!cachedHash) {
-      cachedCode=nativehashCode();
-      cachedHash=true;
-    }
-    return cachedCode;
-  }
-
-  /* DON'T USE THIS METHOD UNLESS NECESSARY */
-  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
-  public native int getType();
-
-  public String toString() {
-    return "Object"+hashCode();
-  }
-
-  public boolean equals(Object o) {
-    if (o==this)
-      return true;
-    return false;
-  }
-}
diff --git a/Robust/src/ClassLibrary/ObjectJava.java b/Robust/src/ClassLibrary/ObjectJava.java
deleted file mode 100644 (file)
index a9bf6f4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-public class Object {
-  public int cachedCode;   //first field has to be a primitive
-  public boolean cachedHash;
-
-  public native int nativehashCode();
-  private Object nextlockobject;
-  private Object prevlockobject;
-
-  public int hashCode() {
-    if (!cachedHash) {
-      cachedCode=nativehashCode();
-      cachedHash=true;
-    }
-    return cachedCode;
-  }
-
-  /* DON'T USE THIS METHOD UNLESS NECESSARY */
-  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
-  public native int getType();
-
-  public native int MonitorEnter();
-  public native int MonitorExit();
-
-  public String toString() {
-    return "Object"+hashCode();
-  }
-
-  public boolean equals(Object o) {
-    if (o==this)
-      return true;
-    return false;
-  }
-}
diff --git a/Robust/src/ClassLibrary/ObjectJavaDSM.java b/Robust/src/ClassLibrary/ObjectJavaDSM.java
deleted file mode 100644 (file)
index 308e81f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-public class Object {
-  public int cachedCode;   //first field has to be a primitive
-  public boolean cachedHash;
-  public Object nextobject;   /* Oid */
-  public Object localcopy;
-
-  public native int nativehashCode();
-
-  public int hashCode() {
-    if (!cachedHash) {
-      cachedCode=nativehashCode();
-      cachedHash=true;
-    }
-    return cachedCode;
-  }
-
-  /* DON'T USE THIS METHOD UNLESS NECESSARY */
-  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
-  public native int getType();
-
-  public String toString() {
-    return "Object"+hashCode();
-  }
-
-  public boolean equals(Object o) {
-    if (o==this)
-      return true;
-    return false;
-  }
-}
diff --git a/Robust/src/ClassLibrary/ObjectJavaNT.java b/Robust/src/ClassLibrary/ObjectJavaNT.java
deleted file mode 100644 (file)
index 4968cfa..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-public class Object {
-  public int cachedCode;   //first field has to be a primitive
-  public boolean cachedHash;
-
-  public native int nativehashCode();
-
-  public int hashCode() {
-    if (!cachedHash) {
-      cachedCode=nativehashCode();
-      cachedHash=true;
-    }
-    return cachedCode;
-  }
-
-  /* DON'T USE THIS METHOD UNLESS NECESSARY */
-  /* WE WILL DEPRECATE IT AS SOON AS INSTANCEOF WORKS */
-  public native int getType();
-
-  public String toString() {
-    return "Object"+hashCode();
-  }
-
-  public boolean equals(Object o) {
-    if (o==this)
-      return true;
-    return false;
-  }
-}
diff --git a/Robust/src/ClassLibrary/ServerSocket.java b/Robust/src/ClassLibrary/ServerSocket.java
deleted file mode 100644 (file)
index 723e886..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-public class ServerSocket {
-  /* Socket pending flag */
-  external flag SocketPending;
-  /* File Descriptor */
-  int fd;
-
-  private native int createSocket(int port);
-
-  public ServerSocket(int port) {
-    this.fd=createSocket(port);
-  }
-
-  public Socket accept() {
-    Socket s=new Socket();
-    int newfd=nativeaccept(s);
-    s.setFD(newfd);
-    return s;
-  }
-
-  public Socket accept(tag td) {
-    Socket s=new Socket() {
-    } {td};
-    int newfd=nativeaccept(s);
-    s.setFD(newfd);
-    return s;
-  }
-
-  /* Lets caller pass in their own Socket object. */
-  public void accept(Socket s) {
-    int newfd=nativeaccept(s);
-    s.setFD(newfd);
-  }
-
-  private native int nativeaccept(Socket s);
-
-  public void close();
-
-}
diff --git a/Robust/src/ClassLibrary/ServerSocketJava.java b/Robust/src/ClassLibrary/ServerSocketJava.java
deleted file mode 100644 (file)
index 1cf07f2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-public class ServerSocket {
-  /* File Descriptor */
-  int fd;
-
-  private native int createSocket(int port);
-
-  public ServerSocket(int port) {
-    this.fd=createSocket(port);
-  }
-
-  public Socket accept() {
-    Socket s=new Socket();
-    int newfd=nativeaccept(s);
-    s.setFD(newfd);
-    return s;
-  }
-
-  /* Lets caller pass in their own Socket object. */
-  public void accept(Socket s) {
-    int newfd=nativeaccept(s);
-    s.setFD(newfd);
-  }
-
-  private native int nativeaccept(Socket s);
-
-  public void close();
-
-}
diff --git a/Robust/src/ClassLibrary/Socket.java b/Robust/src/ClassLibrary/Socket.java
deleted file mode 100644 (file)
index 506c327..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-public class Socket {
-  /* Data pending flag */
-  external flag IOPending;
-  /* File Descriptor */
-  int fd;
-  private SocketInputStream sin;
-  private SocketOutputStream sout;
-
-  public Socket() {
-    sin=new SocketInputStream(this);
-    sout=new SocketOutputStream(this);
-  }
-
-  public InputStream getInputStream() {
-    return sin;
-  }
-
-  public OutputStream getOutputStream() {
-    return sout;
-  }
-
-  public Socket(String host, int port) {
-    InetAddress address=InetAddress.getByName(host);
-    fd=nativeBind(address.getAddress(), port);
-    nativeConnect(fd, address.getAddress(), port);
-  }
-
-  public Socket(InetAddress address, int port) {
-    fd=nativeBind(address.getAddress(), port);
-    nativeConnect(fd, address.getAddress(), port);
-  }
-
-  public void connect(String host, int port) {
-    InetAddress address=InetAddress.getByName(host);
-    fd=nativeBind(address.getAddress(), port);
-    nativeConnect(fd, address.getAddress(), port);
-  }
-
-  public void connect(InetAddress address, int port) {
-    fd=nativeBind(address.getAddress(), port);
-    nativeConnect(fd, address.getAddress(), port);
-  }
-
-  public static native int nativeBind(byte[] address, int port);
-
-  public native int nativeConnect(int fd, byte[] address, int port);
-
-  int setFD(int filed) {
-    fd=filed;
-  }
-
-  public int read(byte[] b) {
-    return nativeRead(b);
-  }
-  public void write(byte[] b) {
-    nativeWrite(b, 0, b.length);
-  }
-
-  public void write(byte[] b, int offset, int len) {
-    nativeWrite(b, offset, len);
-  }
-
-  private native void nativeBindFD(int fd);
-  private native int nativeRead(byte[] b);
-  private native void nativeWrite(byte[] b, int offset, int len);
-  private native void nativeClose();
-
-  public void close() {
-    nativeClose();
-  }
-}
diff --git a/Robust/src/ClassLibrary/SocketJava.java b/Robust/src/ClassLibrary/SocketJava.java
deleted file mode 100644 (file)
index 297fe3d..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-public class Socket {
-  /* File Descriptor */
-  int fd;
-  SocketInputStream sin;
-  SocketOutputStream sout;
-
-  public Socket() {
-    sin=new SocketInputStream(this);
-    sout=new SocketOutputStream(this);
-  }
-
-  public InputStream getInputStream() {
-    return sin;
-  }
-
-  public OutputStream getOutputStream() {
-    return sout;
-  }
-
-  public Socket(String host, int port) {
-    InetAddress address=InetAddress.getByName(host);
-    fd=nativeBind(address.getAddress(), port);
-    nativeConnect(fd, address.getAddress(), port);
-    sin=new SocketInputStream(this);
-    sout=new SocketOutputStream(this);
-  }
-
-  public Socket(InetAddress address, int port) {
-    fd=nativeBind(address.getAddress(), port);
-    nativeConnect(fd, address.getAddress(), port);
-    sin=new SocketInputStream(this);
-    sout=new SocketOutputStream(this);
-  }
-
-  public static native int nativeBind(byte[] address, int port);
-
-  public static native int nativeConnect(int fd, byte[] address, int port);
-
-  int setFD(int filed) {
-    fd=filed;
-  }
-
-  public int read(byte[] b) {
-    return nativeRead(b);
-  }
-  public void write(byte[] b) {
-    nativeWrite(b, 0, b.length);
-  }
-
-  public void write(byte[] b, int offset, int len) {
-    nativeWrite(b, offset, len);
-  }
-
-  private native int nativeRead(byte[] b);
-  private native void nativeWrite(byte[] b, int offset, int len);
-  private native void nativeClose();
-
-  public void close() {
-    nativeClose();
-  }
-}
diff --git a/Robust/src/ClassLibrary/StartupObject.java b/Robust/src/ClassLibrary/StartupObject.java
deleted file mode 100644 (file)
index 541c26f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-public class StartupObject {
-  flag initialstate;
-
-  String [] parameters;
-}
diff --git a/Robust/src/ClassLibrary/TagDescriptor.java b/Robust/src/ClassLibrary/TagDescriptor.java
deleted file mode 100644 (file)
index be067fa..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/** This class is not to be used by the end user.  It's intended for
- * internal use to keep track of tags. */
-
-private class TagDescriptor {
-}
diff --git a/Robust/src/ClassLibrary/Thread.java b/Robust/src/ClassLibrary/Thread.java
deleted file mode 100644 (file)
index 50c5580..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-public class Thread {
-  private boolean finished;
-
-  public void start() {
-    nativeCreate();
-  }
-
-  private static void staticStart(Thread t) {
-    t.run();
-  }
-
-  public static native void yield();
-
-  public void join() {
-    nativeJoin();
-  }
-
-  private native void nativeJoin();
-
-  public native static void sleep(long millis);
-
-  public void run() {
-  }
-
-  private native void nativeCreate();
-
-}
diff --git a/Robust/src/ClassLibrary/ThreadDSM.java b/Robust/src/ClassLibrary/ThreadDSM.java
deleted file mode 100644 (file)
index 4fb2c7b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-public class Thread {
-  /* Don't allow overriding this method.  If you do, it will break dispatch
-   * because we don't have the type information necessary. */
-  public boolean threadDone;
-
-  public Thread() {
-    threadDone = false;
-  }
-
-  public static native void yield();
-
-  public final native void join();
-
-  public final native void start(int mid);
-
-  public native static void sleep(long millis);
-
-  public void run() {
-  }
-}
index e02d09d9ee8953e17c219319cdbcf8c894b2a67f..ef5aa45d59ac13b2b17ca51e42da47f2c3bee446 100644 (file)
@@ -8,6 +8,7 @@ import Analysis.TaskStateAnalysis.*;
 public class State {
   public State() {
     this.classes=new SymbolTable();
+    this.discclass=new HashSet();
     this.tasks=new SymbolTable();
     this.treemethodmap=new Hashtable();
     this.flatmethodmap=new Hashtable();
@@ -17,6 +18,7 @@ public class State {
     this.tagmap=new Hashtable();
     this.selfloops=new HashSet();
     this.excprefetch=new HashSet();
+    this.classpath=new Vector();
   }
 
   public void addParseNode(ParseNode parsetree) {
@@ -79,6 +81,8 @@ public class State {
 
   public HashSet selfloops;
   public HashSet excprefetch;
+  public Vector classpath;
+  public HashSet discclass;
   public SymbolTable classes;
   public SymbolTable tasks;
   public Set parsetrees;
index 4cca52da4d7048b8c3c816a3b4eb587032dffc4a..f076b3c1509c4b002edc243b9808dafcbfc8be71 100644 (file)
@@ -17,6 +17,7 @@ public class TagVarDescriptor extends Descriptor {
     this.identifier=identifier;
     this.safename = "___" + name + "___";
     this.uniqueid=count++;
+    throw new Error();
   }
 
   public String getName() {
index 12149c3e3ff47c7e9815533a163ca47f5d459e3e..2e61224fed4eceeec380cf20a1e8a5bb54e276d1 100644 (file)
@@ -13,18 +13,18 @@ public class BuildIR {
     this.m_taskexitnum = 0;
   }
 
-  public void buildtree() {
-    for(Iterator it=state.parsetrees.iterator(); it.hasNext();) {
-      ParseNode pn=(ParseNode)it.next();
+  public void buildtree(ParseNode pn) {
       parseFile(pn);
-    }
   }
 
+  Vector singleimports;
+  Vector multiimports;
+  NameDescriptor packages;
+
   /** Parse the classes in this file */
   public void parseFile(ParseNode pn) {
-    NameDescriptor packages;
-    Vector singleimports=new Vector();
-    Vector multiimports=new Vector();
+    singleimports=new Vector();
+    multiimports=new Vector();
 
     ParseNode ipn=pn.getChild("imports").getChild("import_decls_list");
     if (ipn!=null) {
@@ -396,6 +396,7 @@ public class BuildIR {
       return new LiteralNode(literaltype, literal_obj);
     } else if (isNode(pn,"createobject")) {
       TypeDescriptor td=parseTypeDescriptor(pn);
+      
       Vector args=parseArgumentList(pn);
       boolean isglobal=pn.getChild("global")!=null;
       String disjointId=null;
index d2fc664cd33f383c5dc91460bf8e0db171ebf770..59bc63aca9a4adff07c780584fb3e26964b7513b 100644 (file)
@@ -6,60 +6,70 @@ import IR.*;
 public class SemanticCheck {
   State state;
   TypeUtil typeutil;
-    Stack loopstack;
+  Stack loopstack;
+  HashSet toanalyze;
+  HashSet completed;
 
 
   public SemanticCheck(State state, TypeUtil tu) {
     this.state=state;
     this.typeutil=tu;
     this.loopstack=new Stack();
+    this.toanalyze=new HashSet();
+    this.completed=new HashSet();
   }
 
-  public void semanticCheck() {
-    SymbolTable classtable=state.getClassSymbolTable();
-    Iterator it=classtable.getDescriptorsIterator();
-    // Do descriptors first
-    while(it.hasNext()) {
-      ClassDescriptor cd=(ClassDescriptor)it.next();
+  public ClassDescriptor getClass(String classname) {
+    ClassDescriptor cd=typeutil.getClass(classname, toanalyze);
+    if (!completed.contains(cd)) {
+      completed.add(cd);
       //System.out.println("Checking class: "+cd);
       //Set superclass link up
       if (cd.getSuper()!=null) {
-       cd.setSuper(typeutil.getClass(cd.getSuper()));
+       cd.setSuper(getClass(cd.getSuper()));
        // Link together Field, Method, and Flag tables so classes
        // inherit these from their superclasses
        cd.getFieldTable().setParent(cd.getSuperDesc().getFieldTable());
        cd.getMethodTable().setParent(cd.getSuperDesc().getMethodTable());
        cd.getFlagTable().setParent(cd.getSuperDesc().getFlagTable());
       }
-
+      
       /* Check to see that fields are well typed */
       for(Iterator field_it=cd.getFields(); field_it.hasNext();) {
        FieldDescriptor fd=(FieldDescriptor)field_it.next();
        //System.out.println("Checking field: "+fd);
        checkField(cd,fd);
       }
-
+      
       for(Iterator method_it=cd.getMethods(); method_it.hasNext();) {
        MethodDescriptor md=(MethodDescriptor)method_it.next();
        checkMethod(cd,md);
       }
     }
+    return cd;
+  }
 
-    it=classtable.getDescriptorsIterator();
-    // Do descriptors first
-    while(it.hasNext()) {
-      ClassDescriptor cd=(ClassDescriptor)it.next();
-      for(Iterator method_it=cd.getMethods(); method_it.hasNext();) {
-       MethodDescriptor md=(MethodDescriptor)method_it.next();
-       checkMethodBody(cd,md);
-      }
-    }
+  public void semanticCheck() {
+    SymbolTable classtable=state.getClassSymbolTable();
+    toanalyze.addAll(classtable.getValueSet());
 
+    //Start with any tasks
     for(Iterator task_it=state.getTaskSymbolTable().getDescriptorsIterator(); task_it.hasNext();) {
       TaskDescriptor td=(TaskDescriptor)task_it.next();
       checkTask(td);
 
     }
+    
+    // Do methods next
+    while(!toanalyze.isEmpty()) {
+      ClassDescriptor cd=(ClassDescriptor)toanalyze.iterator().next();
+      toanalyze.remove(cd);
+      for(Iterator method_it=cd.getMethods(); method_it.hasNext();) {
+       MethodDescriptor md=(MethodDescriptor)method_it.next();
+       checkMethodBody(cd,md);
+      }
+    }
+
   }
 
   public void checkTypeDescriptor(TypeDescriptor td) {
@@ -67,7 +77,7 @@ public class SemanticCheck {
       return;       /* Done */
     else if (td.isClass()) {
       String name=td.toString();
-      ClassDescriptor field_cd=(ClassDescriptor)state.getClassSymbolTable().get(name);
+      ClassDescriptor field_cd=getClass(name);
       if (field_cd==null)
        throw new Error("Undefined class "+name);
       td.setClassDescriptor(field_cd);
@@ -412,7 +422,7 @@ public class SemanticCheck {
     if (cn.getType()==null) {
       NameDescriptor typenamed=cn.getTypeName().getName();
       String typename=typenamed.toString();
-      TypeDescriptor ntd=new TypeDescriptor(typeutil.getClass(typename));
+      TypeDescriptor ntd=new TypeDescriptor(getClass(typename));
       cn.setType(ntd);
     }
 
@@ -491,7 +501,7 @@ public class SemanticCheck {
     } else if (o instanceof Character) {
       ln.setType(new TypeDescriptor(TypeDescriptor.CHAR));
     } else if (o instanceof String) {
-      ln.setType(new TypeDescriptor(typeutil.getClass(TypeUtil.StringClass)));
+      ln.setType(new TypeDescriptor(getClass(TypeUtil.StringClass)));
     }
 
     if (td!=null)
@@ -599,7 +609,7 @@ public class SemanticCheck {
 
     if (an.getDest().getType().isString()&&an.getOperation().getOp()==AssignOperation.PLUSEQ) {
       //String add
-      ClassDescriptor stringcl=typeutil.getClass(TypeUtil.StringClass);
+      ClassDescriptor stringcl=getClass(TypeUtil.StringClass);
       TypeDescriptor stringtd=new TypeDescriptor(stringcl);
       NameDescriptor nd=new NameDescriptor("String");
       NameDescriptor valuend=new NameDescriptor(nd, "valueOf");
@@ -788,7 +798,7 @@ NextMethod:
        typetolookin=min.getExpression().getType();
       } else {
        //we have a type
-       ClassDescriptor cd=typeutil.getClass(min.getBaseName().getSymbol());
+       ClassDescriptor cd=getClass(min.getBaseName().getSymbol());
        if (cd==null)
          throw new Error("md = "+ md.toString()+ "  "+min.getBaseName()+" undefined");
        typetolookin=new TypeDescriptor(cd);
@@ -976,7 +986,7 @@ NextMethod:
 
     case Operation.ADD:
       if (ltd.isString()||rtd.isString()) {
-       ClassDescriptor stringcl=typeutil.getClass(TypeUtil.StringClass);
+       ClassDescriptor stringcl=getClass(TypeUtil.StringClass);
        TypeDescriptor stringtd=new TypeDescriptor(stringcl);
        NameDescriptor nd=new NameDescriptor("String");
        NameDescriptor valuend=new NameDescriptor(nd, "valueOf");
index 91fd0fdc1f9b75d4def48806ab8de22f773b875f..0bda49cb92c4b68b92d1bcce2f7ff914fb30bb55 100644 (file)
@@ -1,5 +1,8 @@
 package IR;
 import java.util.*;
+import IR.Tree.*;
+import java.io.File;
+import Main.Main;
 
 public class TypeUtil {
   public static final String StringClass="String";
@@ -10,32 +13,62 @@ public class TypeUtil {
   State state;
   Hashtable supertable;
   Hashtable subclasstable;
+  BuildIR bir;
 
-  public TypeUtil(State state) {
+  public TypeUtil(State state, BuildIR bir) {
     this.state=state;
+    this.bir=bir;
     createTables();
   }
 
+  public void addNewClass(String cl) {
+    if (state.discclass.contains(cl))
+      return;
+    for(int i=0;i<state.classpath.size();i++) {
+      String path=(String)state.classpath.get(i);
+      File f=new File(path, cl+".java");
+      if (f.exists()) {
+       try {
+         ParseNode pn=Main.readSourceFile(state, f.getCanonicalPath());
+         bir.buildtree(pn);
+         state.discclass.add(cl);
+         return;
+       } catch (Exception e) {
+         throw new Error(e);
+       }
+      }
+    }
+    throw new Error("Couldn't find class "+cl);
+  }
+
+
+
   public ClassDescriptor getClass(String classname) {
     ClassDescriptor cd=(ClassDescriptor)state.getClassSymbolTable().get(classname);
     return cd;
   }
 
-  private void createTables() {
-    supertable=new Hashtable();
-
-    Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
-    while(classit.hasNext()) {
-      ClassDescriptor cd=(ClassDescriptor)classit.next();
+  public ClassDescriptor getClass(String classname, HashSet todo) {
+    ClassDescriptor cd=(ClassDescriptor)state.getClassSymbolTable().get(classname);
+    if (cd==null) {
+      //have to find class
+      addNewClass(classname);
+      cd=(ClassDescriptor)state.getClassSymbolTable().get(classname);
+      System.out.println("Build class:"+cd);
+      todo.add(cd);
+    }
+    if (!supertable.containsKey(cd)) {
       String superc=cd.getSuper();
       if (superc!=null) {
-       ClassDescriptor cd_super=getClass(superc);
-       if (cd_super==null) {
-         throw new Error("Couldn't find class:"+superc);
-       }
+       ClassDescriptor cd_super=getClass(superc, todo);
        supertable.put(cd,cd_super);
       }
     }
+    return cd;
+  }
+
+  private void createTables() {
+    supertable=new Hashtable();
   }
 
   public ClassDescriptor getMainClass() {
index 5bcfe4353d834fd4ab1bd2d8b8095149d7f0564e..ff46a2380a656846faf91b0e5c94d323bb1398bb 100644 (file)
@@ -51,6 +51,8 @@ public class Main {
   public static void main(String args[]) throws Exception {
     String ClassLibraryPrefix="./ClassLibrary/";
     State state=new State();
+    Vector sourcefiles=new Vector();
+    state.classpath.add(".");
 
     for(int i=0; i<args.length; i++) {
       String option=args[i];
@@ -67,7 +69,7 @@ public class Main {
       else if (option.equals("-excprefetch"))
        state.excprefetch.add(args[++i]);
       else if (option.equals("-classlibrary"))
-       ClassLibraryPrefix=args[++i]+"/";
+       state.classpath.add(args[++i]);
       else if(option.equals("-numcore")) {
        ++i;
        state.CORENUM = Integer.parseInt(args[i]);
@@ -176,76 +178,36 @@ public class Main {
        System.out.println("-help -- print out help");
        System.exit(0);
       } else {
-       readSourceFile(state, args[i]);
+       if (args[i].indexOf(".java")!=-1)
+         sourcefiles.add(args[i].substring(0,args[i].indexOf(".java")));
+       else
+         sourcefiles.add(args[i]);
       }
     }
 
-
-    readSourceFile(state, ClassLibraryPrefix+"System.java");
-    readSourceFile(state, ClassLibraryPrefix+"String.java");
-    readSourceFile(state, ClassLibraryPrefix+"HashSet.java");
-    readSourceFile(state, ClassLibraryPrefix+"HashMap.java");
-    readSourceFile(state, ClassLibraryPrefix+"HashMapIterator.java");
-    readSourceFile(state, ClassLibraryPrefix+"HashEntry.java");
-    readSourceFile(state, ClassLibraryPrefix+"Integer.java");
-    readSourceFile(state, ClassLibraryPrefix+"StringBuffer.java");
-    //if(!state.RAW) {
-    readSourceFile(state, ClassLibraryPrefix+"FileInputStream.java");
-    readSourceFile(state, ClassLibraryPrefix+"PushbackInputStream.java");
-    readSourceFile(state, ClassLibraryPrefix+"InputStream.java");
-    readSourceFile(state, ClassLibraryPrefix+"OutputStream.java");
-    readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java");
-    readSourceFile(state, ClassLibraryPrefix+"File.java");
-    readSourceFile(state, ClassLibraryPrefix+"InetAddress.java");
-    readSourceFile(state, ClassLibraryPrefix+"SocketInputStream.java");
-    readSourceFile(state, ClassLibraryPrefix+"SocketOutputStream.java");
-    readSourceFile(state, ClassLibraryPrefix+"gnu/StringTokenizer.java");
-    //}
-    readSourceFile(state, ClassLibraryPrefix+"Math.java");
-    readSourceFile(state, ClassLibraryPrefix+"gnu/Random.java");
-    readSourceFile(state, ClassLibraryPrefix+"Vector.java");
-    readSourceFile(state, ClassLibraryPrefix+"Enumeration.java");
-    readSourceFile(state, ClassLibraryPrefix+"Dictionary.java");
-    readSourceFile(state, ClassLibraryPrefix+"Writer.java");
-    readSourceFile(state, ClassLibraryPrefix+"BufferedWriter.java");
-    readSourceFile(state, ClassLibraryPrefix+"OutputStreamWriter.java");
-    readSourceFile(state, ClassLibraryPrefix+"FileWriter.java");
-    readSourceFile(state, ClassLibraryPrefix+"Date.java");
-
-    if (state.TASK) {
-      if (state.FASTCHECK)
-       readSourceFile(state, ClassLibraryPrefix+"ObjectFC.java");
-      else
-       readSourceFile(state, ClassLibraryPrefix+"Object.java");
-      readSourceFile(state, ClassLibraryPrefix+"TagDescriptor.java");
-    } else if (state.DSM) {
-      readSourceFile(state, ClassLibraryPrefix+"ThreadDSM.java");
-      readSourceFile(state, ClassLibraryPrefix+"ObjectJavaDSM.java");
-      readSourceFile(state, ClassLibraryPrefix+"Barrier.java");
-    } else {
-      if (state.THREAD) {
-       readSourceFile(state, ClassLibraryPrefix+"Thread.java");
-       readSourceFile(state, ClassLibraryPrefix+"ObjectJava.java");
-      } else
-       readSourceFile(state, ClassLibraryPrefix+"ObjectJavaNT.java");
-    }
-
-    if (state.TASK) {
-      readSourceFile(state, ClassLibraryPrefix+"StartupObject.java");
-      readSourceFile(state, ClassLibraryPrefix+"Socket.java");
-      readSourceFile(state, ClassLibraryPrefix+"ServerSocket.java");
-    } else {
-      readSourceFile(state, ClassLibraryPrefix+"SocketJava.java");
-      readSourceFile(state, ClassLibraryPrefix+"ServerSocketJava.java");
-    }
+    //add default classpath
+    if (state.classpath.size()==1)
+      state.classpath.add(ClassLibraryPrefix);
 
     BuildIR bir=new BuildIR(state);
-    bir.buildtree();
-
-    TypeUtil tu=new TypeUtil(state);
+    TypeUtil tu=new TypeUtil(state, bir);
+    
 
     SemanticCheck sc=new SemanticCheck(state,tu);
+    for(int i=0;i<sourcefiles.size();i++)
+      sc.getClass((String)sourcefiles.get(i));
+
+    //Stuff the runtime wants to see
+    sc.getClass("String");
+    sc.getClass("Math");
+    sc.getClass("File");
+    sc.getClass("Socket");
+    sc.getClass("ServerSocket");
+    sc.getClass("FileInputStream");
+    sc.getClass("FileOutputStream");
+
     sc.semanticCheck();
+
     tu.createFullTable();
 
     BuildFlat bf=new BuildFlat(state,tu);
@@ -256,13 +218,13 @@ public class Main {
     if (state.TAGSTATE) {
       CallGraph callgraph=new CallGraph(state);
       TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
-      TaskTagAnalysis tta=new TaskTagAnalysis(state, taganalysis);
+      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);
+      TaskAnalysis ta=new TaskAnalysis(state, taganalysis, tu);
       ta.taskAnalysis();
       TaskGraph tg=new TaskGraph(state, ta);
       tg.createDOTfiles();
@@ -373,23 +335,29 @@ public class Main {
 
   /** Reads in a source file and adds the parse tree to the state object. */
 
-  private static void readSourceFile(State state, String sourcefile) throws Exception {
-    Reader fr = new BufferedReader(new FileReader(sourcefile));
-    Lex.Lexer l = new Lex.Lexer(fr);
-    java_cup.runtime.lr_parser g;
-    g = new Parse.Parser(l);
-    ParseNode p=null;
+  public static ParseNode readSourceFile(State state, String sourcefile) {
     try {
-      p=(ParseNode) g./*debug_*/ parse().value;
+      Reader fr= new BufferedReader(new FileReader(sourcefile));
+      Lex.Lexer l = new Lex.Lexer(fr);
+      java_cup.runtime.lr_parser g;
+      g = new Parse.Parser(l);
+      ParseNode p=null;
+      try {
+       p=(ParseNode) g./*debug_*/ parse().value;
+      } catch (Exception e) {
+       System.err.println("Error parsing file:"+sourcefile);
+       e.printStackTrace();
+       System.exit(-1);
+      }
+      state.addParseNode(p);
+      if (l.numErrors()!=0) {
+       System.out.println("Error parsing "+sourcefile);
+       System.exit(l.numErrors());
+      }
+      return p;
+
     } catch (Exception e) {
-      System.err.println("Error parsing file:"+sourcefile);
-      e.printStackTrace();
-      System.exit(-1);
-    }
-    state.addParseNode(p);
-    if (l.numErrors()!=0) {
-      System.out.println("Error parsing "+sourcefile);
-      System.exit(l.numErrors());
+      throw new Error(e);
     }
   }
 }
index 516a1b7ea6ff5cb7337372e321cf034096ca72a8..524824ff44ddc0e722817dae8767367f93e57f85 100755 (executable)
@@ -274,13 +274,38 @@ then
 JAVAOPTS="$JAVAOPTS -struct structfile"
 fi
 
+# Setup class path
+
+if $RECOVERFLAG
+then
+if $FASTCHECK
+then
+#fast transactions
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/FastCheck"
+fi
+#base bristlecone files
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/Bristlecone"
+else
+if $DSMFLAG
+then
+#dsm stuff
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/JavaDSM"
+elif $THREADFLAG
+then
+#threading java stuff
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/JavaThread"
+fi
+#base java stuff
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/Java"
+fi
+
 # Build bristlecone/java sources
 
 if $MULTICOREFLAG
 then
 if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx800m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
-$ROBUSTROOT/ClassLibrary/ -dir $BUILDDIR \
-$JAVAOPTS $SRCFILES
+$ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/ \
+-dir $BUILDDIR $JAVAOPTS $SRCFILES
 then exit $?
 fi
 else
@@ -288,7 +313,7 @@ else
 if ! $NOJAVA
 then
 if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx600m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
-$ROBUSTROOT/ClassLibrary/ -dir $BUILDDIR -precise \
+$ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/ -dir $BUILDDIR -precise \
 $JAVAOPTS $SRCFILES
 then exit $?
 fi