From 98e346bc171fe24713b1647ccd41b47df3b1b1c1 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 24 Apr 2007 23:28:05 +0000 Subject: [PATCH] checking in code --- Robust/src/IR/Flat/BuildCode.java | 56 ++++++++++++++++++++++++++++++- Robust/src/IR/State.java | 13 +++++++ Robust/src/Makefile | 2 +- Robust/src/Util/Relation.java | 45 +++++++++++++++++++++++++ Robust/src/docs/tagimplementation | 26 ++++++++------ 5 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 Robust/src/Util/Relation.java diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index cd726b7e..86a47ac2 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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)+");"); + } + } } } diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 185b8590..c0862f54 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -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(); } diff --git a/Robust/src/Makefile b/Robust/src/Makefile index fdf5f80b..a925c0eb 100644 --- a/Robust/src/Makefile +++ b/Robust/src/Makefile @@ -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 index 00000000..eea6f68a --- /dev/null +++ b/Robust/src/Util/Relation.java @@ -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); + } +} diff --git a/Robust/src/docs/tagimplementation b/Robust/src/docs/tagimplementation index 56342063..3b15ab45 100644 --- a/Robust/src/docs/tagimplementation +++ b/Robust/src/docs/tagimplementation @@ -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... -- 2.34.1