outmethod.println("#include \"psemaphore.h\"");
}
if (state.COREPROF) {
- outmethod.println("#include \"coreprof\\coreprof.h\"");
+ outmethod.println("#include \"coreprof.h\"");
}
//Store the sizes of classes & array elements
Iterator<TempDescriptor> dynSrcItr = callerSESEplaceholder.getDynamicVarSet().iterator();
while( dynSrcItr.hasNext() ) {
TempDescriptor dynSrcVar = dynSrcItr.next();
- output.println(" void* "+dynSrcVar+"_srcSESE;");
- output.println(" int "+dynSrcVar+"_srcOffset;");
+ output.println(" void* "+dynSrcVar+"_srcSESE;");
+ output.println(" INTPTR "+dynSrcVar+"_srcOffset;");
}
}
}
}
}
+ // used when generating the specific SESE record struct
+ // to remember the FIRST field name of sese records
+ // that the current SESE depends on--we need to know the
+ // offset to the first one for garbage collection
+ protected void addingDepRecField( FlatSESEEnterNode fsen,
+ String field ) {
+ if( fsen.getFirstDepRecField() == null ) {
+ fsen.setFirstDepRecField( field );
+ }
+ fsen.incNumDepRecs();
+ }
+
protected void generateMethodSESE(FlatSESEEnterNode fsen,
LocalityBinding lb,
PrintWriter outputStructs,
outputStructs.println("};\n");
- // generate the SESE record structure
- outputStructs.println(fsen.getSESErecordName()+" {");
-
- // data common to any SESE, and it must be placed first so
- // a module that doesn't know what kind of SESE record this
- // is can cast the pointer to a common struct
- outputStructs.println(" SESEcommon common;");
-
- // then garbage list stuff
- outputStructs.println(" int size;");
- outputStructs.println(" void * next;");
-
- // DYNAMIC stuff was here
-
- // invar source taking was here
-
- // space for all in and out set primitives
+ // divide in-set and out-set into objects and primitives to prep
+ // for the record generation just below
Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
inSetAndOutSet.addAll( fsen.getInVarSet() );
inSetAndOutSet.addAll( fsen.getOutVarSet() );
+ Set<TempDescriptor> inSetAndOutSetObjs = new HashSet<TempDescriptor>();
Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
while( itr.hasNext() ) {
TempDescriptor temp = itr.next();
TypeDescriptor type = temp.getType();
- if( !type.isPtr() ) {
+ if( type.isPtr() ) {
+ inSetAndOutSetObjs.add( temp );
+ } else {
inSetAndOutSetPrims.add( temp );
}
}
- Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
- while( itrPrims.hasNext() ) {
- TempDescriptor temp = itrPrims.next();
- TypeDescriptor type = temp.getType();
- if(!type.isPrimitive()){
- outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
- }
- }
+ // generate the SESE record structure
+ outputStructs.println(fsen.getSESErecordName()+" {");
+
+ // data common to any SESE, and it must be placed first so
+ // a module that doesn't know what kind of SESE record this
+ // is can cast the pointer to a common struct
+ outputStructs.println(" SESEcommon common;");
+
+ // then garbage list stuff
+ outputStructs.println(" /* next is in-set and out-set objects that look like a garbage list */");
+ outputStructs.println(" int size;");
+ outputStructs.println(" void * next;");
+
+ // I think that the set of TempDescriptors inSetAndOutSetObjs
+ // calculated above should match the pointer object params
+ // used in the following code, but let's just leave the working
+ // implementation unless there is actually a problem...
for(int i=0; i<objectparams.numPointers(); i++) {
TempDescriptor temp=objectparams.getPointer(i);
if (temp.getType().isNull())
- outputStructs.println(" void * "+temp.getSafeSymbol()+";");
+ outputStructs.println(" void * "+temp.getSafeSymbol()+
+ "; /* in-or-out-set obj in gl */");
else
- outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
+ outputStructs.println(" struct "+temp.getType().getSafeSymbol()+" * "+
+ temp.getSafeSymbol()+"; /* in-or-out-set obj in gl */");
}
- // DYNAMIC stuff needs a source SESE ptr and offset
- Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
- while( itrDynInVars.hasNext() ) {
- TempDescriptor dynInVar = itrDynInVars.next();
-// outputStructs.println(" void* "+dynInVar+"_srcSESE;");
- outputStructs.println(" int "+dynInVar+"_srcOffset;");
- }
-
- itrPrims = inSetAndOutSetPrims.iterator();
+ outputStructs.println(" /* next is primitives for in-set and out-set and dynamic tracking */");
+
+ Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
while( itrPrims.hasNext() ) {
TempDescriptor temp = itrPrims.next();
TypeDescriptor type = temp.getType();
if(type.isPrimitive()){
- outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";");
+ outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+"; /* in-set or out-set primitive */");
}
}
- outputStructs.println(" int prevSESECount;");
+ // note that the sese record pointer will be added below, just primitive part of tracking here
+ Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
+ while( itrDynInVars.hasNext() ) {
+ TempDescriptor dynInVar = itrDynInVars.next();
+ outputStructs.println(" INTPTR "+dynInVar+"_srcOffset; /* dynamic tracking primitive */");
+ }
+
- // DYNAMIC stuff needs a source SESE ptr and offset
+ outputStructs.println(" /* everything after this should be pointers to an SESE record */" );
+
+ // other half of info for dynamic tracking, the SESE record pointer
itrDynInVars = fsen.getDynamicInVarSet().iterator();
while( itrDynInVars.hasNext() ) {
TempDescriptor dynInVar = itrDynInVars.next();
- outputStructs.println(" void* "+dynInVar+"_srcSESE;");
-// outputStructs.println(" int "+dynInVar+"_srcOffset;");
+ String depRecField = dynInVar+"_srcSESE";
+ outputStructs.println(" void* "+depRecField+";");
+ addingDepRecField( fsen, depRecField );
}
- // in-set source tracking
- // in-vars that are READY come from parent, don't need anything
- // stuff STATIC needs a custom SESE pointer for each age pair
+ // statically known sese sources are record pointers, too
Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
while( itrStaticInVarSrcs.hasNext() ) {
SESEandAgePair srcPair = itrStaticInVarSrcs.next();
outputStructs.println(" "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";");
+ addingDepRecField( fsen, srcPair.toString() );
}
+ if( fsen.getFirstDepRecField() != null ) {
+ outputStructs.println(" /* compiler believes first dependent SESE record field above is: "+
+ fsen.getFirstDepRecField()+" */" );
+ }
+
outputStructs.println("};\n");
Iterator<TempDescriptor> dynSrcItr = fsen.getDynamicVarSet().iterator();
while( dynSrcItr.hasNext() ) {
TempDescriptor dynSrcVar = dynSrcItr.next();
- output.println(" void* "+dynSrcVar+"_srcSESE;");
- output.println(" int "+dynSrcVar+"_srcOffset;");
+ output.println(" void* "+dynSrcVar+"_srcSESE;");
+ output.println(" INTPTR "+dynSrcVar+"_srcOffset;");
}
// declare local temps for in-set primitives, and if it is
output.println(" atomic_inc(&parentCommon->numRunningChildren);");
}
- // just allocate the space for this record
- output.println(" "+fsen.getSESErecordName()+"* seseToIssue = ("+
- fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
- fsen.getSESErecordName()+" ) );");
- //eomgc need to set next, size
-// output.println(" struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
+ // allocate the space for this record
+ output.println(" "+
+ fsen.getSESErecordName()+"* seseToIssue = ("+
+ fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+
+ fsen.getSESErecordName()+" ) );");
+
+ // set up the SESE in-set and out-set objects, which look
+ // like a garbage list
output.println(" struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(seseToIssue))[1]);");
- // sizeof(int)*2 + sizeof(void*)*calculateSizeOfSESEParamList(fsen)
- //output.println(" // sizeof(int)*2+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen));
- //output.println(" // blah="+calculateSizeOfSESEParamSize(fsen));
- output.println(" (seseToIssue->common).offsetsize=sizeof(int)+sizeof(void*)+sizeof(void*)*"+calculateSizeOfSESEParamList(fsen)+calculateSizeOfSESEParamSize(fsen)+";");
output.println(" gl->size="+calculateSizeOfSESEParamList(fsen)+";");
-// output.println(" gl->next = (struct garbagelist *)&___locals___;");
- output.println(" seseToIssue->prevSESECount="+calculatePrevSESECount(fsen)+";");
-// output.println(" seseToIssue->prevSESECount=50;");
output.println(" gl->next = NULL;");
-// output.println(" seseToIssue->size = "+calculateSizeOfSESEParamList(fsen)+";");
-// output.println(" seseToIssue->next = &___locals___;");
+
+ // there are pointers to SESE records the newly-issued SESE
+ // will use to get values it depends on them for--how many
+ // are there, and what is the offset from the total SESE
+ // record to the first dependent record pointer?
+ output.println(" seseToIssue->common.numDependentSESErecords="+
+ fsen.getNumDepRecs()+";");
+
+ // we only need this (and it will only compile) when the number of dependent
+ // SESE records is non-zero
+ if( fsen.getFirstDepRecField() != null ) {
+ output.println(" seseToIssue->common.offsetToDepSESErecords=(INTPTR)sizeof("+
+ fsen.getSESErecordName()+") - (INTPTR)&((("+
+ fsen.getSESErecordName()+"*)0)->"+fsen.getFirstDepRecField()+");"
+ );
+ }
- // and keep the thread-local sese stack up to date
+ // and keep the thread-local sese stack up to date (jjenista--this still relevant??)
//output.println(" addNewItem( seseCallStack, (void*) seseToIssue);");
// fill in common data
// otherwise we track where it will come from
SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
output.println(" "+refVar+"_srcSESE = "+instance+";");
- output.println(" "+refVar+"_srcOffset = (int) &((("+
+ output.println(" "+refVar+"_srcOffset = (INTPTR) &((("+
vst.getSESE().getSESErecordName()+"*)0)->"+vst.getAddrVar()+");");
}
}
return tdSet.size();
}
-private String calculateSizeOfSESEParamSize(FlatSESEEnterNode fsen){
- HashMap <String,Integer> map=new HashMap();
- HashSet <TempDescriptor> processed=new HashSet<TempDescriptor>();
- String rtr="";
+ private String calculateSizeOfSESEParamSize(FlatSESEEnterNode fsen){
+ HashMap <String,Integer> map=new HashMap();
+ HashSet <TempDescriptor> processed=new HashSet<TempDescriptor>();
+ String rtr="";
- // space for all in and out set primitives
- Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
- inSetAndOutSet.addAll( fsen.getInVarSet() );
- inSetAndOutSet.addAll( fsen.getOutVarSet() );
+ // space for all in and out set primitives
+ Set<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
+ inSetAndOutSet.addAll( fsen.getInVarSet() );
+ inSetAndOutSet.addAll( fsen.getOutVarSet() );
- Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
-
- Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
- while( itr.hasNext() ) {
- TempDescriptor temp = itr.next();
- TypeDescriptor type = temp.getType();
- if( !type.isPtr() ) {
- inSetAndOutSetPrims.add( temp );
- }
- }
+ Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
+
+ Iterator<TempDescriptor> itr = inSetAndOutSet.iterator();
+ while( itr.hasNext() ) {
+ TempDescriptor temp = itr.next();
+ TypeDescriptor type = temp.getType();
+ if( !type.isPtr() ) {
+ inSetAndOutSetPrims.add( temp );
+ }
+ }
- Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
- while( itrPrims.hasNext() ) {
- TempDescriptor temp = itrPrims.next();
- TypeDescriptor type = temp.getType();
- if(type.isPrimitive()){
- Integer count=map.get(type.getSymbol());
- if(count==null){
- count=new Integer(1);
- map.put(type.getSymbol(), count);
- }else{
- map.put(type.getSymbol(), new Integer(count.intValue()+1));
- }
- }
- }
+ Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
+ while( itrPrims.hasNext() ) {
+ TempDescriptor temp = itrPrims.next();
+ TypeDescriptor type = temp.getType();
+ if(type.isPrimitive()){
+ Integer count=map.get(type.getSymbol());
+ if(count==null){
+ count=new Integer(1);
+ map.put(type.getSymbol(), count);
+ }else{
+ map.put(type.getSymbol(), new Integer(count.intValue()+1));
+ }
+ }
+ }
- Set<String> keySet=map.keySet();
- for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
- String key = (String) iterator.next();
- rtr+="+sizeof("+key+")*"+map.get(key);
- }
- return rtr;
-}
-
-private int calculatePrevSESECount(FlatSESEEnterNode fsen){
- int count=0;
-
- // dynamic stuff
- Iterator<TempDescriptor>itrDynInVars = fsen.getDynamicInVarSet().iterator();
- while( itrDynInVars.hasNext() ) {
- TempDescriptor dynInVar = itrDynInVars.next();
- count++;
- }
-
- // in-set source tracking
- Iterator<SESEandAgePair> itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator();
- while( itrStaticInVarSrcs.hasNext() ) {
- SESEandAgePair srcPair = itrStaticInVarSrcs.next();
- count++;
- }
-
- return count;
-}
-
+ Set<String> keySet=map.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ rtr+="+sizeof("+key+")*"+map.get(key);
+ }
+ return rtr;
+ }
}
qitem=qitem->next;
continue;
}
- struct garbagelist * gl=(struct garbagelist *)&(((SESEcommon*)(qitem->value))[1]);
+ SESEcommon* seseRec = (SESEcommon*)(qitem->value);
+ struct garbagelist * gl=(struct garbagelist *)&(seseRec[1]);
struct garbagelist * glroot=gl;
// update its ascendant SESEs
- updateAscendantSESE(gl);
+ updateAscendantSESE(seseRec);
while(gl!=NULL) {
int i;
struct QueueItem * fqItem=getHead(forwardList);
while(fqItem!=NULL){
- struct garbagelist * gl=(struct garbagelist *)&(((SESEcommon*)(fqItem->objectptr))[1]);
+ SESEcommon* seseRec = (SESEcommon*)(fqItem->objectptr);
+ struct garbagelist * gl=(struct garbagelist *)&(seseRec[1]);
if(prevUpdate==TRUE){
- updateAscendantSESE(gl);
+ updateAscendantSESE(seseRec);
}
// do something here
while(gl!=NULL) {
int i;
- for(i=0; i<gl->size; i++) {
- void * orig=gl->array[i];
- ENQUEUE(orig, gl->array[i]);
- }
- gl=gl->next;
+ for(i=0; i<gl->size; i++) {
+ void * orig=gl->array[i];
+ ENQUEUE(orig, gl->array[i]);
+ }
+ gl=gl->next;
}
- // iterate forwarding list of seseRec
- SESEcommon *common=(SESEcommon*)fqItem->objectptr;
- struct Queue* fList=common->forwardList;
+ // iterate forwarding list of seseRec
+ struct Queue* fList=seseRec->forwardList;
updateForwardList(fList,prevUpdate);
fqItem=getNextQueueItem(fqItem);
}
ReadBinItem* readBinItem=(ReadBinItem*)binItem;
int ridx;
for(ridx=0; ridx<readBinItem->index; ridx++){
- REntry *rentry=readBinItem->array[ridx];
- struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
- updateAscendantSESE(gl);
+ REntry *rentry=readBinItem->array[ridx];
+ SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+ struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+ updateAscendantSESE(seseRec);
while(gl!=NULL) {
int i;
for(i=0; i<gl->size; i++) {
}
}else{ //writebin
REntry *rentry=((WriteBinItem*)binItem)->val;
- struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
- updateAscendantSESE(gl);
+ SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+ struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+ updateAscendantSESE(seseRec);
while(gl!=NULL) {
int i;
for(i=0; i<gl->size; i++) {
for(idx=0; idx<vt->index; idx++){
REntry *rentry=vt->array[idx];
if(rentry!=NULL){
- struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
- updateAscendantSESE(gl);
+ SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+ struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+ updateAscendantSESE(seseRec);
while(gl!=NULL) {
int i;
for(i=0; i<gl->size; i++) {
SCC *scc=(SCC*)memoryItem;
REntry *rentry=scc->val;
if(rentry!=NULL){
- struct garbagelist * gl= (struct garbagelist *)&(((SESEcommon*)(rentry->seseRec))[1]);
- updateAscendantSESE(gl);
+ SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+ struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+ updateAscendantSESE(seseRec);
while(gl!=NULL) {
int i;
for(i=0; i<gl->size; i++) {
}
}
-updateAscendantSESE(struct garbagelist *gl){
- int offsetsize=*((int*)((void*)gl-sizeof(int)));
- int prevSESECount=*((int*)((void*)gl+offsetsize));
- INTPTR tailaddr=(INTPTR)((void*)gl+offsetsize+sizeof(int));
+ updateAscendantSESE(SESEcommon* seseRec){
int prevIdx;
- for(prevIdx=0; prevIdx<prevSESECount; prevIdx++){
- SESEcommon* prevSESE=(SESEcommon*)*((INTPTR*)(tailaddr+sizeof(void*)*prevIdx));
+ for(prevIdx=0; prevIdx<(seseRec->numDependentSESErecords); prevIdx++){
+ SESEcommon* prevSESE = (SESEcommon*)
+ (
+ ((INTPTR)seseRec) +
+ seseRec->offsetToDepSESErecords +
+ (sizeof(INTPTR)*prevIdx)
+ );
+
if(prevSESE!=NULL){
struct garbagelist * prevgl=(struct garbagelist *)&(((SESEcommon*)(prevSESE))[1]);
while(prevgl!=NULL) {
}
}
}
-}
+
+ }
#endif
int within(void *ptr){ //debug function