From: bdemsky Date: Fri, 15 Apr 2011 21:50:06 +0000 (+0000) Subject: more bug fixes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=de3bffc9b168163cbce8834faccc435affb23d1b;p=IRC.git more bug fixes --- diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 7a2950b9..367d9a83 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1831,7 +1831,7 @@ public class BuildCode { ClassDescriptor cd=md.getClassDesc(); generateHeader(fm, md, outmethod); int startindex=0; - + outmethod.println("JNIPUSHFRAME();"); if (md.getModifiers().isStatic()) { outmethod.println("jobject rec=JNIWRAP(((void **)(((char *) &(global_defs_p->classobjs->___length___))+sizeof(int)))[" + cd.getId() + "]);"); } else { @@ -1874,10 +1874,10 @@ public class BuildCode { if (md.getReturnType()!=null) { if (md.getReturnType().isPtr()) { outmethod.println("struct ___Object___ * retobj=JNIUNWRAP(retval);"); - outmethod.println("JNIclearstack();"); + outmethod.println("JNIPOPFRAME();"); outmethod.println("return retobj;"); } else { - outmethod.println("JNIclearstack();"); + outmethod.println("JNIPOPFRAME();"); outmethod.println("return retval;"); } } diff --git a/Robust/src/Runtime/garbage.h b/Robust/src/Runtime/garbage.h index a5f7cd83..c504c65a 100644 --- a/Robust/src/Runtime/garbage.h +++ b/Robust/src/Runtime/garbage.h @@ -26,6 +26,9 @@ struct listitem { #ifdef THREADS struct lockvector * lvector; #endif +#ifdef JNI + struct jnireferences ** jnirefs; +#endif #ifdef STM unsigned int tc_size; cliststruct_t **tc_structs; diff --git a/Robust/src/Runtime/jni/jni-private.h b/Robust/src/Runtime/jni/jni-private.h index 9cc6a132..41645d8d 100644 --- a/Robust/src/Runtime/jni/jni-private.h +++ b/Robust/src/Runtime/jni/jni-private.h @@ -18,6 +18,29 @@ struct jfieldID { char *fieldname; }; +struct _jobject { + void * ref; +}; + +#define MAXJNIREFS 2048 +struct jnireferences { + struct jnireferences * next; + int index + struct _jobject array[MAXJNIREFS]; +}; + +#ifndef MAC +struct _jobject * getwrapped(void * objptr); +void jnipushframe(); +void jnipopframe(); + +extern __thread struct jnireferences * jnirefs; +#define JNIUNWRAP(x) ((x==NULL)?NULL:x->ref) +#define JNIWRAP(x) getwrapper(x); +#define JNIPUSHFRAME() jnipushframe(); +#define JNIPOPFRAME() jnipopframe(); +#endif + jint RC_GetVersion(JNIEnv *); jclass RC_DefineClass(JNIEnv * env, const char * c, jobject loader, const jbyte * buf, jsize bufLen); jclass RC_FindClass(JNIEnv * env, const char *classname); diff --git a/Robust/src/Runtime/jni/jni-stuff.c b/Robust/src/Runtime/jni/jni-stuff.c index 08584edf..f016b9e7 100644 --- a/Robust/src/Runtime/jni/jni-stuff.c +++ b/Robust/src/Runtime/jni/jni-stuff.c @@ -1,6 +1,28 @@ #include #include +#ifndef MAC +struct _jobject * getwrapped(void * objptr) { + if ((jnirefs->index)>=MAXJNIREFS) + printf("OVERFLOW IN JOBJECT\n"); + struct _jobject *ptr=&jnirefs->array[jnirefs->index++]; + ptr->ref=objptr; + return ptr; +} + +void jnipushframe() { + struct jnireferences *ptr=calloc(1, sizeof(struct jnireferences)); + ptr->next=jnirefs; + jnirefs=ptr; +} + +void jnipopframe() { + struct jnireferences *ptr=jnirefs; + jnirefs=ptr->next; + free(ptr); +} +#endif + jint RC_GetVersion(JNIEnv * env) { return JNI_VERSION_1_1; }