From bae799f54777dbf7bf3f222c61aeeb72b4b11c85 Mon Sep 17 00:00:00 2001 From: adash Date: Fri, 29 Feb 2008 00:50:49 +0000 Subject: [PATCH] bug fixes --- Robust/src/IR/Flat/BuildCode.java | 51 ++++++++++++++----- .../src/Runtime/DSTM/interface/dstmserver.c | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 11 +++- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 8b24c523..5518e0a0 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -34,6 +34,7 @@ public class BuildCode { public static String PREFIX=""; public static String arraytype="ArrayObject"; public static int count = 0; + public static int flagcount = 0; Virtual virtualcalls; TypeUtil typeutil; private int maxtaskparams=0; @@ -1427,7 +1428,7 @@ public class BuildCode { Vector endoffset = new Vector(); Vector oids = new Vector(); short offsetcount = 0; - int tuplecount = 0; + int tuplecount = 0; //Keeps track of number of prefetch tuples that need to be generated int i,j; if (state.PREFETCH) { @@ -1522,18 +1523,29 @@ public class BuildCode { tstlbl += generateTemp(fm, id.getTempDescAt(i), lb) + "+"; } tstlbl += id.offset.toString(); + output.println(" int flag_" + flagcount + "= 0;"); output.println("if ("+tstlbl+"< 0 || "+tstlbl+" >= "+ generateTemp(fm, pp.base, lb) + "->___length___) {"); - output.println(" failedboundschk();"); + output.println(" flag_" + flagcount+" = 1;"); output.println("}"); - String oid = new String("(unsigned int) (" + - generateTemp(fm, pp.base, lb) + " != NULL ? " + - generateTemp(fm, pp.base, lb) + "[" + tstlbl + "] : NULL)"); + + output.println("if (flag_"+flagcount+") {"); + output.println("}"); + + TypeDescriptor elementtype = pp.base.getType().dereference(); + String type=""; + if (elementtype.isArray()||elementtype.isClass()) + type="void *"; + else + type=elementtype.getSafeSymbol()+" "; + + String oid = new String("(unsigned int) (" + generateTemp(fm, pp.base, lb) + " != NULL ? " + "((" + type + "*)(((char *) &("+ generateTemp(fm, pp.base, lb)+ "->___length___))+sizeof(int)))["+tstlbl+"] : 0)"); oids.add(oid); } for(i = 1; i < pp.desc.size(); i++) { TypeDescriptor newtd; + ClassDescriptor cd; String newfieldoffset; Object desc = pp.getDescAt(i); offsetcount++; @@ -1542,15 +1554,19 @@ public class BuildCode { if(prevdesc instanceof IndexDescriptor){ if((i-1) == 0) { newtd = pp.base.getType(); + cd = newtd.getClassDesc(); } else { //FIXME currently handles one dimensional arrays newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType(); + cd = newtd.getClassDesc(); } + newfieldoffset = new String("(unsigned int)(&(((struct "+ cd.getSafeSymbol() +" *)0)->"+ + ((FieldDescriptor)desc).getSafeSymbol()+ "))"); } else { newtd = ((FieldDescriptor)pp.getDescAt(i-1)).getType(); - } - newfieldoffset = new String("(short)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ + newfieldoffset = new String("(unsigned int)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ ((FieldDescriptor)desc).getSafeSymbol()+ "))"); + } fieldoffset.add(newfieldoffset); } else { String tstlbl = new String(); @@ -1558,7 +1574,7 @@ public class BuildCode { tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(j), lb) + "+"; } tstlbl += ((IndexDescriptor)desc).offset.toString(); - newfieldoffset = new String("(short)("+tstlbl+")"); + newfieldoffset = new String(tstlbl); fieldoffset.add(newfieldoffset); } } @@ -1569,6 +1585,7 @@ public class BuildCode { }else { endoffset.add(offsetcount); } + flagcount++; } public void generateOutsideTransCode(FlatMethod fm, LocalityBinding lb,PrefetchPair pp, Vector oids, Vector fieldoffset, Vector endoffset, int tuplecount) { @@ -1579,34 +1596,41 @@ public class BuildCode { oids.add(oid); for(i = 0; i < pp.desc.size(); i++) { TypeDescriptor newtd; + ClassDescriptor cd; String newfieldoffset; Object desc = pp.getDescAt(i); offsetcount++; if(desc instanceof FieldDescriptor) { if(i == 0){ newtd = pp.base.getType(); + newfieldoffset = new String("(unsigned int)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ + ((FieldDescriptor)desc).getSafeSymbol()+ "))"); } else { Object prevdesc = pp.getDescAt(i-1); if(prevdesc instanceof IndexDescriptor){ if((i-1) == 0) { newtd = pp.base.getType(); + cd = newtd.getClassDesc(); } else { //FIXME currently handles one dimensional arrays newtd = ((FieldDescriptor)pp.getDescAt(i-2)).getType(); + cd = newtd.getClassDesc(); } + newfieldoffset = new String("(unsigned int)(&(((struct "+ cd.getSafeSymbol() +" *)0)->"+ + ((FieldDescriptor)desc).getSafeSymbol()+ "))"); } else { newtd = ((FieldDescriptor)pp.getDescAt(i-1)).getType(); + newfieldoffset = new String("(unsigned int)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ + ((FieldDescriptor)desc).getSafeSymbol()+ "))"); } } - newfieldoffset = new String("(short)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ - ((FieldDescriptor)desc).getSafeSymbol()+ "))"); } else { String tstlbl = new String(); for(j = 0; j < ((IndexDescriptor)desc).tddesc.size(); j++) { tstlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(j), lb) + "+"; } tstlbl += ((IndexDescriptor)desc).offset.toString(); - newfieldoffset = new String("(short)("+tstlbl+")"); + newfieldoffset = new String(tstlbl); } fieldoffset.add(newfieldoffset); } @@ -1617,7 +1641,6 @@ public class BuildCode { }else { endoffset.add(offsetcount); } - tuplecount++; } public void generateLocalTransCode(FlatMethod fm, LocalityBinding lb,PrefetchPair pp,Vector oids, Vector fieldoffset,Vector endoffset, int tuplecount) { @@ -1654,7 +1677,7 @@ public class BuildCode { } else { newtd = ((FieldDescriptor) pp.getDescAt(j-1)).getType(); } - newfieldoffset = new String("(short)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ + newfieldoffset = new String("(unsigned int)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ ((FieldDescriptor)desc).getSafeSymbol()+ "))"); } else { String indexlbl = new String(); @@ -1662,7 +1685,7 @@ public class BuildCode { indexlbl += generateTemp(fm, ((IndexDescriptor)desc).getTempDescAt(k), lb) + "+"; } indexlbl += ((IndexDescriptor)desc).offset.toString(); - newfieldoffset = new String("(short)("+indexlbl+")"); + newfieldoffset = new String(indexlbl); } fieldoffset.add(newfieldoffset); } diff --git a/Robust/src/Runtime/DSTM/interface/dstmserver.c b/Robust/src/Runtime/DSTM/interface/dstmserver.c index 0c96b83f..99f48f07 100644 --- a/Robust/src/Runtime/DSTM/interface/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface/dstmserver.c @@ -448,7 +448,7 @@ int processClientReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, /* This function increments counters while running a voting decision on all objects involved * in TRANS_REQUEST and If a TRANS_DISAGREE sends the response immediately back to the coordinator */ char handleTransReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, unsigned int *listmid, char *objread, void *modptr, int acceptfd) { - int val, i = 0; + int val, i = 0, j; unsigned short version; char control = 0, *ptr; unsigned int oid; diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index c82ab104..d6782934 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -1574,7 +1574,8 @@ void sendPrefetchReq(prefetchpile_t *mcpilenode) { void getPrefetchResponse(int count, int sd) { int i = 0, val, n, N, sum, index, objsize; unsigned int bufsize,oid; - char buffer[RECEIVE_BUFFER_SIZE], control; + char *buffer; + char control; char *ptr; void *modptr, *oldptr; @@ -1587,7 +1588,10 @@ void getPrefetchResponse(int count, int sd) { if(control == TRANS_PREFETCH_RESPONSE) { /*For each oid and offset tuple sent as prefetch request to remote machine*/ while(N = recv((int)sd, &bufsize, sizeof(unsigned int), 0) != 0) { - bzero(&buffer, RECEIVE_BUFFER_SIZE); + if((buffer = calloc(1, bufsize)) == NULL) { + printf("Calloc Error in %s() at %s, %d\n", __func__, __FILE__, __LINE__); + return; + } sum = 0; index = 0; ptr = buffer; @@ -1611,6 +1615,7 @@ void getPrefetchResponse(int count, int sd) { if ((modptr = objstrAlloc(prefetchcache, objsize)) == NULL) { printf("Error: objstrAlloc error for copying into prefetch cache %s, %d\n", __FILE__, __LINE__); pthread_mutex_unlock(&prefetchcache_mutex); + free(buffer); return; } pthread_mutex_unlock(&prefetchcache_mutex); @@ -1650,9 +1655,11 @@ void getPrefetchResponse(int count, int sd) { exit(-1); } else { printf("Error in decoding the index value %d, %s, %d\n",index, __FILE__, __LINE__); + free(buffer); return; } } + free(buffer); } } else printf("Error in receving response for prefetch request %s, %d\n",__FILE__, __LINE__); -- 2.34.1