checking in code
authorbdemsky <bdemsky>
Tue, 24 Apr 2007 23:28:05 +0000 (23:28 +0000)
committerbdemsky <bdemsky>
Tue, 24 Apr 2007 23:28:05 +0000 (23:28 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/State.java
Robust/src/Makefile
Robust/src/Util/Relation.java [new file with mode: 0644]
Robust/src/docs/tagimplementation

index cd726b7e83326611ca6b729ce9cb67c442fba852..86a47ac2ac02e245f4f4d0c2614e22c153bcd0f7 100644 (file)
@@ -5,6 +5,7 @@ import IR.Tree.DNFFlagAtom;
 import IR.*;
 import java.util.*;
 import java.io.*;
+import Util.Relation;
 
 public class BuildCode {
     State state;
@@ -1025,6 +1026,9 @@ public class BuildCode {
 
     private void generateFlatNode(FlatMethod fm, FlatNode fn, PrintWriter output) {
        switch(fn.kind()) {
+       case FKind.FlatTagDeclaration:
+           generateFlatTagDeclaration(fm, (FlatTagDeclaration) fn,output);
+           return;
        case FKind.FlatCall:
            generateFlatCall(fm, (FlatCall) fn,output);
            return;
@@ -1279,6 +1283,15 @@ public class BuildCode {
        }
     }
 
+
+    private void generateFlatTagDeclaration(FlatMethod fm, FlatTagDeclaration fn, PrintWriter output) {
+       if (GENERATEPRECISEGC) {
+           output.println(generateTemp(fm,fn.getDst())+"=allocate_tag(&"+localsprefix+", "+state.getTagId(fn.getType())+");");
+       } else {
+           output.println(generateTemp(fm,fn.getDst())+"=allocate_tag("+state.getTagId(fn.getType())+");");
+       }
+    }
+
     private void generateFlatOpNode(FlatMethod fm, FlatOpNode fon, PrintWriter output) {
 
        if (fon.getRight()!=null)
@@ -1400,7 +1413,7 @@ public class BuildCode {
        Hashtable flagandtable=new Hashtable();
        Hashtable flagortable=new Hashtable();
 
-
+       /* Process flag changes */
        Iterator flagsit=ffan.getTempFlagPairs();
        while(flagsit.hasNext()) {
            TempFlagPair tfp=(TempFlagPair)flagsit.next();
@@ -1434,6 +1447,7 @@ public class BuildCode {
                }
            }
        }
+
        Iterator orit=flagortable.keySet().iterator();
        while(orit.hasNext()) {
            TempDescriptor temp=(TempDescriptor)orit.next();
@@ -1458,5 +1472,45 @@ public class BuildCode {
                    output.println("flagorand("+generateTemp(fm, temp)+", 0, 0x"+Integer.toHexString(andmask)+");");
            }
        }
+
+       /* Process tag changes */
+       Relation tagsettable=new Relation();
+       Relation tagcleartable=new Relation();
+
+       Iterator tagsit=ffan.getTempTagPairs(); 
+       while (tagsit.hasNext()) {
+           TempTagPair ttp=(TempTagPair) tagsit.next();
+           TempDescriptor objtmp=ttp.getTemp();
+           TagDescriptor tag=ttp.getTag();
+           TempDescriptor tagtmp=ttp.getTagTemp();
+           boolean tagstatus=ffan.getTagChange(ttp);
+           if (tagstatus) {
+               tagsettable.put(objtmp, tagtmp);
+           } else {
+               tagcleartable.put(objtmp, tagtmp);
+           }
+       }
+
+       Iterator clearit=tagcleartable.keySet().iterator();
+       while(clearit.hasNext()) {
+           TempDescriptor objtmp=(TempDescriptor)clearit.next();
+           Set tagtmps=tagcleartable.get(objtmp);
+           Iterator tagit=tagtmps.iterator();
+           while(tagit.hasNext()) {
+               TempDescriptor tagtmp=(TempDescriptor)tagit.next();
+               output.println("tagclear("+generateTemp(fm, objtmp)+", "+generateTemp(fm,tagtmp)+");");
+           }
+       }
+
+       Iterator setit=tagsettable.keySet().iterator();
+       while(setit.hasNext()) {
+           TempDescriptor objtmp=(TempDescriptor)setit.next();
+           Set tagtmps=tagcleartable.get(objtmp);
+           Iterator tagit=tagtmps.iterator();
+           while(tagit.hasNext()) {
+               TempDescriptor tagtmp=(TempDescriptor)tagit.next();
+               output.println("tagset("+generateTemp(fm, objtmp)+", "+generateTemp(fm,tagtmp)+");");
+           }
+       }
     }
 }
index 185b859035274082a2d9c765292f4433b6f4170e..c0862f54e93cf77e0b9c325efb941b35a90c446d 100644 (file)
@@ -13,6 +13,7 @@ public class State {
        this.parsetrees=new HashSet();
        this.arraytypes=new HashSet();
        this.arraytonumber=new Hashtable();
+       this.tagmap=new Hashtable();
     }
 
     public void addParseNode(ParseNode parsetree) {
@@ -39,6 +40,9 @@ public class State {
     private int numtasks=0;
     private int arraycount=0;
 
+    private Hashtable tagmap;
+    private int numtags=0;
+
     public void addArrayType(TypeDescriptor td) {
        if (!arraytypes.contains(td)) {
            arraytypes.add(td);
@@ -50,6 +54,15 @@ public class State {
        return arraytypes.iterator();
     }
 
+    public int getTagId(TagDescriptor tag) {
+       if (tagmap.containsKey(tag)) {
+           return ((Integer) tagmap.get(tag)).intValue();
+       } else {
+           tagmap.put(tag, new Integer(numtags));
+           return numtags++;
+       }
+    }
+
     public int getArrayNumber(TypeDescriptor td) {
        return ((Integer)arraytonumber.get(td)).intValue();
     }
index fdf5f80b6276b28328ae41d8929b3dab79dcfc05..a925c0eb253ebed56e170528b259a2776551b0ed 100644 (file)
@@ -41,7 +41,7 @@ IR/Flat/FlatOpNode.class IR/Flat/FlatReturnNode.class                 \
 IR/Flat/FlatSetElementNode.class IR/Flat/FlatSetFieldNode.class                \
 IR/Flat/NodePair.class IR/Flat/ParamsObject.class                      \
 IR/Flat/TempDescriptor.class IR/Flat/TempFlagPair.class                        \
-IR/Flat/TempObject.class
+IR/Flat/TempObject.class Util/Relation.class
 
 all: Parse/Sym.class Parse/Parser.class $(CLASSFILES) javadoc
 
diff --git a/Robust/src/Util/Relation.java b/Robust/src/Util/Relation.java
new file mode 100644 (file)
index 0000000..eea6f68
--- /dev/null
@@ -0,0 +1,45 @@
+package Util;
+import java.util.*;
+
+
+public class Relation {
+    private Hashtable table;
+    int size;
+
+    public Relation() {
+       table=new Hashtable();
+       size=0;
+    }
+
+    public int size() {
+       return size;
+    }
+
+    public boolean containsKey(Object o) {
+       return table.containsKey(o);
+    }
+
+    public Set keySet() {
+       return table.keySet();
+    }
+
+    public synchronized boolean put(Object key, Object value) {
+       HashSet s;
+       if (table.containsKey(key)) {
+           s=(HashSet) table.get(key);
+       } else {
+           s=new HashSet();
+           table.put(key,s);
+       }
+       if (!s.contains(value)) {
+           size++;
+           s.add(value);
+           return true;
+       } else
+           return false;
+    }
+    
+    public Set get(Object key) {
+       return (Set)table.get(key);
+    }
+}
index 563420632d8d6162bc853017454f04ec457023c8..3b15ab45ba668a88321da93207a2970606fb6b01 100644 (file)
@@ -1,14 +1,20 @@
-Baz a {}{Tag Foo x}, Bar b {}{Tag Foo x, Tag Far y}
+Example:
+task test(Baz a {}{tag Foo x}, Bar b {}{tag Foo x, Tag Far y}) {
+}
 
+Idea: Each parameter with a tag has its own queue and a hashtable that
+is indexed by the tag
 
-Idea: Each parameter has its own queue and a hashtable that is indexed by 
-the tag
+When adding the object to the queue, the runtime: 
 
-When adding the object to the queue, the system:
-cycles through each tag of the appropriate type in that object and indexes 
-into the other queues for that tag...if multiple objects have that tag, 
-have to search each possible one...if the parameter is specified to have a 
-second tag, search through each possible second tag
+1) cycles through each tag of the appropriate type in that object and
+index into the other queues for that tag
 
-Each flag object has tag pointer - it can either point to a tag object or 
-a list of tags...
+2) if multiple objects have that tag, have to search each possible
+one...
+
+3) if the parameter is specified to have a second tag, search through
+each possible second tag
+
+Each flag object has tag pointer - it can either point to a tag object
+or a list of tags...