From 640066fefbf1612656494b5865c3ae778917e0b4 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 16 Aug 2007 23:02:13 +0000 Subject: [PATCH] code changes --- Robust/src/IR/Flat/BuildCode.java | 19 ++++++++++--------- Robust/src/Runtime/DSTM/interface/dstm.h | 2 +- Robust/src/Runtime/DSTM/interface/trans.c | 16 +++++++--------- Robust/src/Runtime/runtime.c | 8 ++++---- Robust/src/Runtime/runtime.h | 16 ++++++++-------- 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 387a327e..7a5ddc6f 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1785,21 +1785,22 @@ public class BuildCode { } private void generateFlatNew(FlatMethod fm, LocalityBinding lb, FlatNew fn, PrintWriter output) { - String isglobal=""; - if (fn.isGlobal()) - isglobal="global"; if (fn.getType().isArray()) { int arrayid=state.getArrayNumber(fn.getType())+state.numClasses(); - if (GENERATEPRECISEGC) { - output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray"+isglobal+"(&"+localsprefix+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");"); + if (fn.isGlobal()) { + output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarrayglobal(trans, "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");"); + } else if (GENERATEPRECISEGC) { + output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray(&"+localsprefix+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");"); } else { - output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray"+isglobal+"("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");"); + output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");"); } } else { - if (GENERATEPRECISEGC) { - output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new"+isglobal+"(&"+localsprefix+", "+fn.getType().getClassDesc().getId()+");"); + if (fn.isGlobal()) { + output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newglobal(trans, "+fn.getType().getClassDesc().getId()+");"); + } else if (GENERATEPRECISEGC) { + output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new(&"+localsprefix+", "+fn.getType().getClassDesc().getId()+");"); } else { - output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new"+isglobal+"("+fn.getType().getClassDesc().getId()+");"); + output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+fn.getType().getClassDesc().getId()+");"); } } } diff --git a/Robust/src/Runtime/DSTM/interface/dstm.h b/Robust/src/Runtime/DSTM/interface/dstm.h index 8fbc6edd..e3ccbc02 100644 --- a/Robust/src/Runtime/DSTM/interface/dstm.h +++ b/Robust/src/Runtime/DSTM/interface/dstm.h @@ -216,7 +216,7 @@ int transCommitProcess(trans_commit_data_t *, int); int dstmStartup(const char *); void transInit(); -void * dstmalloc(int size); +void * dstmalloc(transrecord_t *trans, int size); void randomdelay(void); transrecord_t *transStart(); diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 338c718e..963f324f 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -80,15 +80,13 @@ void prefetch(int ntuples, unsigned int *oids, short *endoffsets, short *arrayfi pthread_mutex_unlock(&pqueue.qlock); } -static int objid=1; -/* This function allocates an object */ -void * dstmalloc(int size) { - objheader_t * newobj=(objheader_t *)objstrAlloc(mainobjstore, size+sizeof(objheader_t)); - OID(newobj)=objid; - newobj->version=1; - newobj->rcount=0; - STATUS(newobj)=NEW; - objid+=2; +/* This function allocates an object on the local machine */ +//FIXME + +void * dstmalloc(transrecord_t *trans, int size) { + objheader_t * newobj=(objheader_t *)objstrAlloc(trans->cache, size+sizeof(objheader_t)); + //Need to assign OID + return newobj; } diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index 803f19db..f9f7e2a5 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -90,8 +90,8 @@ void CALL01(___System______printString____L___String___,struct ___String___ * __ /* Object allocation function */ #ifdef DSTM -void * allocate_newglobal(void * ptr, int type) { - struct ___Object___ * v=(struct ___Object___ *) dstmalloc(classsize[type]); +void * allocate_newglobal(transrecord_t *trans, int type) { + struct ___Object___ * v=(struct ___Object___ *) dstmalloc(trans, classsize[type]); v->type=type; #ifdef THREADS v->tid=0; @@ -103,8 +103,8 @@ void * allocate_newglobal(void * ptr, int type) { /* Array allocation function */ -struct ArrayObject * allocate_newarrayglobal(void * ptr, int type, int length) { - struct ArrayObject * v=(struct ArrayObject *)dstmalloc(classsize[type]); +struct ArrayObject * allocate_newarrayglobal(transrecord_t *trans, int type, int length) { + struct ArrayObject * v=(struct ArrayObject *)dstmalloc(trans, classsize[type]); v->type=type; if (length<0) { printf("ERROR: negative array\n"); diff --git a/Robust/src/Runtime/runtime.h b/Robust/src/Runtime/runtime.h index aa928154..a90508fb 100644 --- a/Robust/src/Runtime/runtime.h +++ b/Robust/src/Runtime/runtime.h @@ -4,6 +4,9 @@ extern jmp_buf error_handler; extern int instructioncount; extern int failurecount; +#ifdef DSTM +#include "dstm.h" +#endif #define TAGARRAYINTERVAL 10 #define OBJECTARRAYINTERVAL 10 @@ -14,21 +17,18 @@ extern int failurecount; #define ARRAYGET(array, type, index) \ ((type *)(&(& array->___length___)[1]))[index] -#ifdef PRECISE_GC -#include "garbage.h" #ifdef DSTM -void * allocate_newglobal(void *, int type); -struct ArrayObject * allocate_newarrayglobal(void *, int type, int length); +void * allocate_newglobal(transrecord_t *, int type); +struct ArrayObject * allocate_newarrayglobal(transrecord_t *, int type, int length); #endif + +#ifdef PRECISE_GC +#include "garbage.h" void * allocate_new(void *, int type); struct ArrayObject * allocate_newarray(void *, int type, int length); struct ___String___ * NewString(void *, const char *str,int length); struct ___TagDescriptor___ * allocate_tag(void *ptr, int index); #else -#ifdef DSTM -void * allocate_newglobal(int type); -struct ArrayObject * allocate_newarrayglobal(int type, int length); -#endif void * allocate_new(int type); struct ArrayObject * allocate_newarray(int type, int length); struct ___String___ * NewString(const char *str,int length); -- 2.34.1