From e89e247d75c2ffb354e9ac9a8adbf80b0ba8fe25 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 9 Oct 2009 07:27:37 +0000 Subject: [PATCH] changes --- Robust/src/IR/Flat/BuildCode.java | 27 ++++++++++++++++++++++-- Robust/src/Runtime/STM/stm.c | 35 +------------------------------ Robust/src/Runtime/STM/tm.h | 7 +------ 3 files changed, 27 insertions(+), 42 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 0cac7b65..223d6730 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -125,6 +125,7 @@ public class BuildCode { /** The buildCode method outputs C code for all the methods. The Flat * versions of the methods must already be generated and stored in * the State object. */ + PrintWriter outsandbox=null; public void buildCode() { /* Create output streams to write to */ @@ -140,6 +141,9 @@ public class BuildCode { PrintWriter optionalheaders=null; try { + if (state.SANDBOX) { + outsandbox=new PrintWriter(new FileOutputStream(PREFIX+"sandboxdefs.c"), true); + } outstructs=new PrintWriter(new FileOutputStream(PREFIX+"structdefs.h"), true); outmethodheader=new PrintWriter(new FileOutputStream(PREFIX+"methodheaders.h"), true); outclassdefs=new PrintWriter(new FileOutputStream(PREFIX+"classdefs.h"), true); @@ -170,6 +174,9 @@ public class BuildCode { outmethodheader.println("#include \"structdefs.h\""); if (state.DSM) outmethodheader.println("#include \"dstm.h\""); + if (state.SANDBOX) { + outmethodheader.println("#include \"sandbox.h\""); + } if (state.SINGLETM) { outmethodheader.println("#include \"tm.h\""); outmethodheader.println("#include \"delaycomp.h\""); @@ -441,6 +448,9 @@ public class BuildCode { outmethod.println("#include \"methodheaders.h\""); outmethod.println("#include \"virtualtable.h\""); outmethod.println("#include \"runtime.h\""); + if (state.SANDBOX) { + outmethod.println("#include \"sandboxdefs.c\""); + } if (state.DSM) { outmethod.println("#include \"addPrefetchEnhance.h\""); outmethod.println("#include \"localobjects.h\""); @@ -2565,13 +2575,16 @@ public class BuildCode { break; case FKind.FlatBackEdge: + if (state.SINGLETM&&state.SANDBOX&&locality.getAtomic(locality.getAtomic(lb).get(fn).intValue()>0)) { + output.println("if ((--transaction_check_counter)<=0) checkObjects();"); + } if (((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) { output.println("if (needtocollect) checkcollect2("+localsprefixaddr+");"); } else if(this.state.MULTICOREGC) { - output.println("if (gcflag) gc("+localsprefixaddr+");"); - } else + output.println("if (gcflag) gc("+localsprefixaddr+");"); + } else output.println("if (needtocollect) checkcollect("+localsprefixaddr+");"); } else output.println("/* nop */"); @@ -2821,6 +2834,7 @@ public class BuildCode { output.println(generateTemp(fm, fion.getDst(), lb)+"=instanceof("+generateTemp(fm,fion.getSrc(),lb)+","+type+");"); } + int sandboxcounter=0; public void generateFlatAtomicEnterNode(FlatMethod fm, LocalityBinding lb, FlatAtomicEnterNode faen, PrintWriter output) { /* Check to see if we need to generate code for this atomic */ if (locality==null) { @@ -2832,6 +2846,11 @@ public class BuildCode { return; + if (state.SANDBOX) { + outsandbox.println("int atomiccounter"+sandboxcounter+"=LOW_CHECK_FREQUENCY;"); + output.println("counter_reset_pointer=&atomiccounter"+sandboxcounter+";"); + } + if (state.DELAYCOMP) { AtomicRecord ar=atomicmethodmap.get(faen); //copy in @@ -2879,6 +2898,10 @@ public class BuildCode { /******* Tell the runtime to start the transaction *******/ output.println("transstart"+faen.getIdentifier()+":"); + if (state.SANDBOX) { + output.println("transaction_check_counter=*counter_reset_pointer;"); + sandboxcounter++; + } output.println("transStart();"); if (state.ABORTREADERS||state.SANDBOX) { diff --git a/Robust/src/Runtime/STM/stm.c b/Robust/src/Runtime/STM/stm.c index 6795af28..57c97d6b 100644 --- a/Robust/src/Runtime/STM/stm.c +++ b/Robust/src/Runtime/STM/stm.c @@ -20,8 +20,7 @@ __thread objstr_t *t_reserve; __thread struct objlist * newobjs; #ifdef SANDBOX -__thread jmp_buf aborttrans; -__thread int abortenabled; +#include "sandbox.h" #endif #ifdef DELAYCOMP @@ -300,38 +299,6 @@ void *objstrAlloc(unsigned int size) { } } -#ifdef SANDBOX -/* Do sandboxing */ -void errorhandler(int sig, struct sigcontext ctx) { - printf("Error\n"); - if (abortenabled&&checktrans()) - longjmp(aborttrans, 1); - threadhandler(sig, ctx); -} - -int checktrans() { - /* Create info to keep track of objects that can be locked */ - chashlistnode_t *curr = c_list; - - /* Inner loop to traverse the linked list of the cache lookupTable */ - while(likely(curr != NULL)) { - //if the first bin in hash table is empty - objheader_t * headeraddr=&((objheader_t *) curr->val)[-1]; - objheader_t *header=(objheader_t *)(((char *)curr->key)-sizeof(objheader_t)); - unsigned int version = headeraddr->version; - - if (header->lock==0) { - return 1; - } - CFENCE; - if (version!=header->version) { - return 1; - } - curr = curr->lnext; - } - return 0; -} -#endif /* ============================================================= * transRead diff --git a/Robust/src/Runtime/STM/tm.h b/Robust/src/Runtime/STM/tm.h index 9f7847ab..5f3a4f7b 100644 --- a/Robust/src/Runtime/STM/tm.h +++ b/Robust/src/Runtime/STM/tm.h @@ -217,11 +217,6 @@ int getReadAbortCount(int, int, void*, int*, int*, int, objheader_t*, int*); objheader_t * needLock(objheader_t *, void *); #endif #ifdef SANDBOX -#include -#include -extern __thread jmp_buf aborttrans; -extern __thread int abortenabled; -int checktrans(); -void errorhandler(int sig, struct sigcontext ctx); +#include "sandbox.h" #endif #endif -- 2.34.1