Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: jni.c 8390 2007-08-21 19:22:16Z michi $
+ $Id: jni.c 8391 2007-08-21 20:34:27Z michi $
*/
void _Jv_JNI_DeleteLocalRef(JNIEnv *env, jobject localRef)
{
java_handle_t *o;
- localref_table *lrt;
- s4 i;
STATISTICS(jniinvokation());
o = (java_handle_t *) localRef;
- /* get local reference table (thread specific) */
-
- lrt = LOCALREFTABLE;
-
- /* go through all local frames */
-
- for (; lrt != NULL; lrt = lrt->prev) {
-
- /* and try to remove the reference */
-
- for (i = 0; i < lrt->capacity; i++) {
- if (lrt->refs[i] == o) {
- lrt->refs[i] = NULL;
- lrt->used--;
-
- return;
- }
- }
- }
-
- /* this should not happen */
+ /* delete the reference */
-/* if (opt_checkjni) */
-/* FatalError(env, "Bad global or local ref passed to JNI"); */
- log_text("JNI-DeleteLocalRef: Local ref passed to JNI not found");
+ localref_del(o);
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: localref.c 8365 2007-08-20 19:57:08Z michi $
+ $Id: localref.c 8391 2007-08-21 20:34:27Z michi $
*/
/* insert the reference into the local reference table */
- h = NULL;
-
for (i = 0; i < lrt->capacity; i++) {
if (lrt->refs[i] == NULL) {
lrt->refs[i] = o;
h = (java_handle_t *) o;
#endif
- break;
+#if 0
+ {
+ int count = 0;
+ for (lrt = LOCALREFTABLE; lrt != NULL; lrt = lrt->prev)
+ count += lrt->used;
+ log_println("added localref %p for %p (total count %d)", h, o, count);
+ /*localref_dump();*/
+ }
+#endif
+
+ return h;
}
}
/* this should not happen */
- if (h == NULL)
- assert(0);
+ log_println("localref_add: WARNING: unable to add localref for %p", o);
-#if 0
- {
- int count = 0;
- for (lrt = LOCALREFTABLE; lrt != NULL; lrt = lrt->prev)
- count += lrt->used;
- log_println("added localref %p for %p (total count %d)", h, o, count);
- /*localref_dump();*/
- }
+ return NULL;
+}
+
+
+/* localref_del ****************************************************************
+
+ Deletes an entry from the local reference table.
+
+*******************************************************************************/
+
+void localref_del(java_handle_t *localref)
+{
+ localref_table *lrt;
+ java_handle_t *h;
+ int32_t i;
+
+ /* get local reference table from thread */
+
+ lrt = LOCALREFTABLE;
+
+ assert(lrt != NULL);
+
+ /* go through all local frames */
+
+ /* XXX: this is definitely not what the spec wants! */
+ /*for (; lrt != NULL; lrt = lrt->prev) {*/
+
+ /* and try to remove the reference */
+
+ for (i = 0; i < lrt->capacity; i++) {
+#if defined(ENABLE_HANDLES)
+ h = (java_handle_t *) &(lrt->refs[i]);
+#else
+ h = (java_handle_t *) lrt->refs[i];
#endif
- return h;
+ if (h == localref) {
+ lrt->refs[i] = NULL;
+ lrt->used--;
+
+ return;
+ }
+ }
+ /*}*/
+
+ /* this should not happen */
+
+ log_println("localref_del: WARNING: unable to find localref %p", localref);
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: localref.h 8364 2007-08-20 19:52:00Z michi $
+ $Id: localref.h 8391 2007-08-21 20:34:27Z michi $
*/
void localref_frame_pop_all(void);
java_handle_t *localref_add(java_object_t *o);
-void localref_del(java_handle_t *h);
+void localref_del(java_handle_t *localref);
#if !defined(NDEBUG)
void localref_dump(void);