__thread jmp_buf aborttrans;
__thread int abortenabled;
__thread int * counter_reset_pointer;
+#ifdef DELAYCOMP
+#include "delaycomp.h"
+#endif
void checkObjects() {
if (abortenabled&&checktrans()) {
- printf("Abort\n");
+ printf("Loop Abort\n");
transaction_check_counter=(*counter_reset_pointer=HIGH_CHECK_FREQUENCY);
- longjmp(aborttrans, 1);
+#ifdef TRANSSTATS
+ numTransAbort++;
+#endif
+ freenewobjs();
+ objstrReset();
+ t_chashreset();
+#ifdef READSET
+ rd_t_chashreset();
+#endif
+#ifdef DELAYCOMP
+ dc_t_chashreset();
+ ptrstack.count=0;
+ primstack.count=0;
+ branchstack.count=0;
+#endif
+ _longjmp(aborttrans, 1);
}
transaction_check_counter=*counter_reset_pointer;
}
/* Do sandboxing */
void errorhandler(int sig, struct sigcontext ctx) {
- printf("Error\n");
+ // printf("Error\n");
if (abortenabled&&checktrans()) {
sigset_t toclear;
sigemptyset(&toclear);
sigaddset(&toclear, sig);
sigprocmask(SIG_UNBLOCK, &toclear,NULL);
- longjmp(aborttrans, 1);
+#ifdef TRANSSTATS
+ numTransAbort++;
+#endif
+ freenewobjs();
+ objstrReset();
+ t_chashreset();
+#ifdef READSET
+ rd_t_chashreset();
+#endif
+#ifdef DELAYCOMP
+ dc_t_chashreset();
+ ptrstack.count=0;
+ primstack.count=0;
+ branchstack.count=0;
+#endif
+ _longjmp(aborttrans, 1);
}
threadhandler(sig, ctx);
}
* -copies the object into the transaction cache
* =============================================================
*/
+
+//void *TR(void *x, void * y, void *z) {
+// void * inputvalue;
+// if ((inputvalue=y)==NULL) x=NULL;
+// else {
+// chashlistnode_t * cnodetmp=&c_table[(((unsigned INTPTR)inputvalue)&c_mask)>>4];
+// do {
+// if (cnodetmp->key==inputvalue) {x=cnodetmp->val; break;}
+// cnodetmp=cnodetmp->next;
+// if (cnodetmp==NULL) {if (((struct ___Object___*)inputvalue)->___objstatus___&NEW) {x=inputvalue; break;} else
+// {x=transRead(inputvalue,z); asm volatile ("" : "=m" (c_table),"\=m" (c_mask)); break;}}
+// } while(1);
+// }
+// return x;
+//}
+
//__attribute__ ((pure))
void *transRead(void * oid, void *gl) {
objheader_t *tmp, *objheader;
#include "runtime.h"
#include <sys/types.h>
+#include <sys/mman.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
threadexit();
}
-struct primitivelist *pl;
+#define downpage(x) ((void *)(((INTPTR)x)&~((INTPTR)4095)))
void initializethreads() {
struct sigaction sig;
//deprecated use of sighandler, but apparently still works
#ifdef SANDBOX
sig.sa_handler=(void *)errorhandler;
+ abortenabled=0;
#else
sig.sa_handler=(void *)threadhandler;
#endif
dc_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
ptrstack.count=0;
primstack.count=0;
- pl=&primstack;
+ branchstack.count=0;
+ int a=mprotect((downpage(&ptrstack.array[MAXPOINTERS])), 4096, PROT_NONE);
+ if (a==-1)
+ perror("ptrstack");
+ a=mprotect(downpage(&primstack.array[MAXVALUES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("primstack");
+ a=mprotect(downpage(&branchstack.array[MAXBRANCHES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("branchstack");
#endif
#ifdef STMSTATS
trec=calloc(1, sizeof(threadrec_t));
{
int i;
for(i=0; i<TOTALNUMCLASSANDARRAY; i++) {
- typesCausingAbort[i] = 0;
+ typesCausingAbort[i].numaccess = 0;
+ typesCausingAbort[i].numabort = 0;
+ typesCausingAbort[i].numtrans = 0;
}
}
#endif
#if defined(THREADS)||defined(STM)
void initthread(struct ___Thread___ * ___this___) {
+#ifdef SANDBOX
+ struct sigaction sig;
+ abortenabled=0;
+ sig.sa_handler=(void *)errorhandler;
+ sig.sa_flags=SA_RESTART;
+ sigemptyset(&sig.sa_mask);
+
+ /* Catch bus errors, segmentation faults, and floating point exceptions*/
+ sigaction(SIGBUS,&sig,0);
+ sigaction(SIGSEGV,&sig,0);
+ sigaction(SIGFPE,&sig,0);
+#endif
#ifdef PRECISE_GC
INTPTR p[]={1, (INTPTR) NULL, (INTPTR) ___this___};
//Add our litem to list of threads
dc_t_chashCreate(CHASH_SIZE, CLOADFACTOR);
ptrstack.count=0;
primstack.count=0;
+ branchstack.count=0;
+ int a=mprotect(downpage(&ptrstack.array[MAXPOINTERS]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("ptrstack");
+ a=mprotect(downpage(&primstack.array[MAXVALUES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("primstack");
+ a=mprotect(downpage(&branchstack.array[MAXBRANCHES]), 4096, PROT_NONE);
+ if (a==-1)
+ perror("branchstack");
#endif
___Thread____NNR____staticStart____L___Thread___((struct ___Thread____NNR____staticStart____L___Thread____params *)p);
objstrDelete(t_cache);