From 1e60ab13ca480d3618776ff8c3de99303fed1b40 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 13 Oct 2009 23:58:58 +0000 Subject: [PATCH] make build system for benchmarks a little nicer working toward word-based STM for arrays --- Robust/src/Runtime/STM/tm.h | 4 ++++ Robust/src/Runtime/garbage.c | 8 ++++++++ Robust/src/Runtime/runtime.c | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index 2384b30c..faa297c5 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -189,7 +189,11 @@ void objstrReset(); void objstrDelete(objstr_t *store); objstr_t *objstrCreate(unsigned int size); void transStart(); +#ifdef STMARRAY +objheader_t *transCreateObj(void * ptr, unsigned int size, int bytelength); +#else objheader_t *transCreateObj(void * ptr, unsigned int size); +#endif unsigned int getNewOID(void); void *objstrAlloc(unsigned int size); __attribute__((pure)) void *transRead(void *, void *); diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index ddd77783..72ed9e02 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -859,10 +859,18 @@ int gc_createcopy(void * orig, void ** copy_ptr) { int elementsize=classsize[type]; int length=ao->___length___; #ifdef STM +#ifdef STAMARRAY + int versionspace=sizeof(int)*(length>>DBLINDEXSHIFT); + int size=sizeof(struct ArrayObject)+length*elementsize+sizeof(objheader_t)+versionspace; + void *newobj=tomalloc(size); + memcpy(newobj, ((char*)orig)-sizeof(objheader_t)-versionspace, size); + newobj=((char *)newobj)+sizeof(objheader_t)+versionspace; +#else int size=sizeof(struct ArrayObject)+length*elementsize+sizeof(objheader_t); void *newobj=tomalloc(size); memcpy(newobj, ((char*)orig)-sizeof(objheader_t), size); newobj=((char *)newobj)+sizeof(objheader_t); +#endif #else int size=sizeof(struct ArrayObject)+length*elementsize; void *newobj=tomalloc(size); diff --git a/Robust/src/Runtime/runtime.c b/Robust/src/Runtime/runtime.c index b8240d22..1fa8f0a3 100644 --- a/Robust/src/Runtime/runtime.c +++ b/Robust/src/Runtime/runtime.c @@ -461,7 +461,11 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, i /* Object allocation function */ __attribute__((malloc)) void * allocate_newtrans(void * ptr, int type) { +#ifdef STMARRAY + struct ___Object___ * v=(struct ___Object___ *) transCreateObj(ptr, classsize[type], 0); +#else struct ___Object___ * v=(struct ___Object___ *) transCreateObj(ptr, classsize[type]); +#endif v->type=type; v->___objlocation___=v; return v; -- 2.34.1