From: bdemsky Date: Tue, 20 Feb 2007 08:50:50 +0000 (+0000) Subject: add object files X-Git-Tag: preEdgeChange~713 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bfa7228f257255c44b89509708b5202b7b3bba01;p=IRC.git add object files --- diff --git a/Robust/src/Runtime/object.c b/Robust/src/Runtime/object.c new file mode 100644 index 00000000..352637d1 --- /dev/null +++ b/Robust/src/Runtime/object.c @@ -0,0 +1,64 @@ +#include "object.h" +#include "stdio.h" +#include "stdlib.h" + +#ifdef THREADS +#include "thread.h" +#endif + +int CALL01(___Object______hashCode____, struct ___Object___ * ___this___) { + return (int) VAR(___this___); +} + +int CALL01(___Object______getType____, struct ___Object___ * ___this___) { + return ((int *)VAR(___this___))[0]; +} + +#ifdef THREADS +int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___) { + pthread_t self=pthread_self(); + if (self==VAR(___this___)->tid) { + VAR(___this___)->lockcount++; + } else { +#ifdef PRECISEGC + struct listitem *tmp=stopforgc(stackptr); +#endif + pthread_mutex_lock(&objlock); +#ifdef PRECISEGC + restartaftergc(tmp); +#endif + while(1) { + if (VAR(___this___)->tid==0) { + VAR(___this___)->lockcount=1; + VAR(___this___)->tid=self; + pthread_mutex_unlock(&objlock); + break; + } + { +#ifdef PRECISEGC + struct listitem *tmp=stopforgc(stackptr); +#endif + pthread_cond_wait(&objcond, &objlock); +#ifdef PRECISEGC + restartaftergc(tmp); +#endif + } + } + } +} + +int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___) { + pthread_t self=pthread_self(); + if (self==VAR(___this___)->tid) { + VAR(___this___)->lockcount--; + if (VAR(___this___)->lockcount==0) + VAR(___this___)->tid=0; + pthread_mutex_lock(&objlock); + pthread_cond_broadcast(&objcond); + pthread_mutex_unlock(&objlock); + } else { + printf("ERROR...UNLOCKING LOCK WE DON'T HAVE\n"); + exit(-1); + } +} +#endif diff --git a/Robust/src/Runtime/object.h b/Robust/src/Runtime/object.h new file mode 100644 index 00000000..73e201d8 --- /dev/null +++ b/Robust/src/Runtime/object.h @@ -0,0 +1,12 @@ +#ifndef OBJECT_H +#define OBJECT_H +#include "runtime.h" +#include "structdefs.h" + +int CALL01(___Object______hashCode____, struct ___Object___ * ___this___); +int CALL01(___Object______getType____, struct ___Object___ * ___this___); +#ifdef THREADS +int CALL01(___Object______MonitorEnter____, struct ___Object___ * ___this___); +int CALL01(___Object______MonitorExit____, struct ___Object___ * ___this___); +#endif +#endif