FlatMethod fm=state.getMethodFlat(md);
HashSet<FlatNode> delayedset=notreadymap.get(lb);
- HashSet<FlatNode> derefset=derefmap.get(lb);
+ HashSet<FlatNode> derefset=null;
+ if (state.STMARRAY)
+ derefset=derefmap.get(lb);
HashSet<FlatNode> otherset=othermap.get(lb);
HashSet<FlatNode> cannotdelayset=cannotdelaymap.get(lb);
Hashtable<FlatNode,Set<TempDescriptor>> livemap=Liveness.computeLiveTemps(fm);
//Delay branches if possible
if (fn.kind()==FKind.FlatCondBranch) {
- Set<FlatNode> branchset=revbranchmap.get(lb);
+ Set<FlatNode> branchset=revbranchmap.get((FlatCondBranch)fn);
for(Iterator<FlatNode> brit=branchset.iterator();brit.hasNext();) {
FlatNode branchnode=brit.next();
if (cannotdelay.contains(branchnode)||(state.STMARRAY&&derefset.contains(branchnode))) {
for(Iterator<FlatCondBranch> fcbit=fcbset.iterator();fcbit.hasNext();) {
FlatCondBranch fcb=fcbit.next();
//enqueue flatcondbranch node for reanalysis
- if (cannotdelay.contains(fcb)) {
+ if (!cannotdelay.contains(fcb)) {
cannotdelay.add(fcb);
toanalyze.add(fcb);
}
if (genset==null||genset.contains(current_node)||specialprimitive)
generateFlatNode(fm, lb, current_node, output);
- if (state.STMARRAY&&refset.contains(current_node)) {
+ if (state.STMARRAY&&refset!=null&&refset.contains(current_node)) {
//need to acquire lock
handleArrayDeref(fm, lb, current_node, output, firstpass);
}
else
type=elementtype.getSafeSymbol()+" ";
output.println("{");
- output.println(" struct ___ArrayObject___ *array;");
+ output.println(" struct ArrayObject *array;");
output.println(" int index;");
output.println(" RESTOREARRAY(array,index);");
- output.println(" (("+type+"*)((struct ___ArrayObject___*) (((char *)&array->___length___))+sizeof(int)))[index]="+fsen.getSrc()+";");
+ output.println(" (("+type+"*)(((char *)&array->___length___)+sizeof(int)))[index]="+fsen.getSrc()+";");
output.println("}");
}
} else if (fn.kind()==FKind.FlatElementNode) {
if (firstpass) {
output.println("STOREARRAY("+src+","+index+");");
} else {
- TypeDescriptor elementtype=fen.getDst().getType().dereference();
+ TypeDescriptor elementtype=fen.getSrc().getType().dereference();
String dst=generateTemp(fm, fen.getDst(), lb);
String type="";
if (elementtype.isArray()||elementtype.isClass())
else
type=elementtype.getSafeSymbol()+" ";
output.println("{");
- output.println(" struct ___ArrayObject___ *array;");
+ output.println(" struct ArrayObject *array;");
output.println(" int index;");
output.println(" RESTOREARRAY(array,index);");
- output.println(" "+dst+"=(("+type+"*)((struct ___ArrayObject___*) (((char *)&array->___length___))+sizeof(int)))[index];");
+ output.println(" "+dst+"=(("+type+"*)(((char *)&array->___length___)+sizeof(int)))[index];");
output.println("}");
}
}
#define RESTOREARRAY(x,z) {x=arraystack.array[arraystack.maxcount];z=arraystack.index[arraystack.maxcount++];}
-#define STOREARRAY(x,z) {void * y=COMPOID(x); arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; dc_t_chashInsertOnce(y,y,z);}
+#define STOREARRAY(x,z) {void * y=COMPOID(x); arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; dc_t_chashInsertOnceArray(y,y,z);}
#define STOREARRAYNOLOCK(x,z) {void * y=COMPOID(x); arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z;}
-#define STOREARRAYNOTRANS(x,z) {void * y=x; arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; dc_t_chashInsertOnce(y,y,z);}
+#define STOREARRAYNOTRANS(x,z) {void * y=x; arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; dc_t_chashInsertOnceArray(y,y,z);}
#define STOREARRAYNOLOCKNOTRANS(x,z) {void * y=x; arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; }
}
#endif
-#ifdef STMARRAY
-//Store objects and their pointers into hash
-void dc_t_chashInsertOnce(void * key, unsigned int indexkey, void *val) {
- chashlistnode_t *ptr;
-
- if (key==NULL)
- return;
-
- if(dc_c_numelements > (dc_c_threshold)) {
- //Resize
- unsigned int newsize = dc_c_size << 1;
- dc_t_chashResize(newsize);
- }
-
- ptr = &dc_c_table[(((unsigned INTPTR)key)&dc_c_mask)>>4];
-
- if(ptr->key==0) {
- ptr->key=key;
- ptr->val=val;
- ptr->lnext=dc_c_list;
- dc_c_list=ptr;
- dc_c_numelements++;
- } else { // Insert in the beginning of linked list
- chashlistnode_t * node;
- chashlistnode_t *search=ptr;
-
- //make sure it isn't here
- do {
- if(search->key == key) {
- return;
- }
- search=search->next;
- } while(search != NULL);
-
- dc_c_numelements++;
- if (dc_c_structs->num<NUMCLIST) {
- node=&dc_c_structs->array[dc_c_structs->num];
- dc_c_structs->num++;
- } else {
- //get new list
- cliststruct_t *tcl=calloc(1,sizeof(cliststruct_t));
- tcl->next=dc_c_structs;
- dc_c_structs=tcl;
- node=&tcl->array[0];
- tcl->num=1;
- }
- node->key = key;
- node->val = val;
- node->next = ptr->next;
- ptr->next=node;
- node->lnext=dc_c_list;
- dc_c_list=node;
- }
-}
-#endif
-
unsigned int dc_t_chashResize(unsigned int newsize) {
dchashlistnode_t *node, *ptr, *curr; // curr and next keep track of the current and the next chashlistnodes in a linked list
unsigned int oldsize;