* Removed all Id tags.
[cacao.git] / src / vm / jit / codegen-common.c
index 999c5c0e4dc14f0d269d77ca285a3ee5e684307c..aa7a158fea7f967b7691fe73183e8e0bee8017fd 100644 (file)
@@ -39,8 +39,6 @@
    memory. All functions writing values into the data area return the offset
    relative the begin of the code area (start of procedure).   
 
-   $Id: codegen-common.c 8215 2007-07-18 20:31:21Z michi $
-
 */
 
 
@@ -63,6 +61,7 @@
 #include "toolbox/logging.h"
 
 #include "native/jni.h"
+#include "native/localref.h"
 #include "native/native.h"
 
 #include "threads/threads-common.h"
@@ -264,6 +263,11 @@ static void codegen_reset(jitdata *jd)
                bptr->branchrefs = NULL;
        }
 
+       /* We need to clear all the patcher references from the codeinfo
+          since they all will be regenerated */
+
+       patcher_list_reset(code);
+
 #if defined(ENABLE_REPLACEMENT)
        code->rplpoints     = NULL;
        code->rplpointcount = 0;
@@ -546,14 +550,6 @@ void codegen_add_patch_ref(codegendata *cd, functionptr patcher, voidptr ref,
        if (opt_shownops)
                PATCHER_NOPS;
 
-       /* If the codegen provides a PACHER_LONGBRANCHES_NOPS macro, honour it. */
-
-#if defined(PATCHER_LONGBRANCHES_NOPS)
-       if (CODEGENDATA_HAS_FLAG_LONGBRANCHES(cd)) {
-               PATCHER_LONGBRANCHES_NOPS;
-       }
-#endif
-
 #if defined(ENABLE_JIT) && (defined(__I386__) || defined(__M68K__) || defined(__MIPS__) \
  || defined(__SPARC_64__) || defined(__X86_64__))
 
@@ -1398,16 +1394,7 @@ void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra)
 #if defined(ENABLE_JNI)
        /* add current JNI local references table to this thread */
 
-       lrt->capacity    = LOCALREFTABLE_CAPACITY;
-       lrt->used        = 0;
-       lrt->localframes = 1;
-       lrt->prev        = LOCALREFTABLE;
-
-       /* clear the references array (memset is faster the a for-loop) */
-
-       MSET(lrt->refs, 0, java_objectheader*, LOCALREFTABLE_CAPACITY);
-
-       LOCALREFTABLE = lrt;
+       localref_table_add(lrt);
 #endif
 }
 
@@ -1420,16 +1407,11 @@ void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra)
 
 *******************************************************************************/
 
-java_objectheader *codegen_finish_native_call(u1 *datasp)
+java_object_t *codegen_finish_native_call(u1 *datasp)
 {
-       stackframeinfo     *sfi;
-       stackframeinfo    **psfi;
-#if defined(ENABLE_JNI)
-       localref_table     *lrt;
-       localref_table     *plrt;
-       s4                  localframes;
-#endif
-       java_objectheader  *e;
+       stackframeinfo  *sfi;
+       stackframeinfo **psfi;
+       java_handle_t   *e;
 
        /* get data structures from stack */
 
@@ -1442,33 +1424,10 @@ java_objectheader *codegen_finish_native_call(u1 *datasp)
        *psfi = sfi->prev;
 
 #if defined(ENABLE_JNI)
-       /* release JNI local references tables for this thread */
-
-       lrt = LOCALREFTABLE;
-
-       /* release all current local frames */
-
-       for (localframes = lrt->localframes; localframes >= 1; localframes--) {
-               /* get previous frame */
-
-               plrt = lrt->prev;
-
-               /* Clear all reference entries (only for tables allocated on
-                  the Java heap). */
-
-               if (localframes > 1)
-                       MSET(&lrt->refs[0], 0, java_objectheader*, lrt->capacity);
-
-               lrt->prev = NULL;
-
-               /* set new local references table */
-
-               lrt = plrt;
-       }
-
-       /* now store the previous local frames in the thread structure */
+       /* release JNI local references table for this thread */
 
-       LOCALREFTABLE = lrt;
+       localref_frame_pop_all();
+       localref_table_remove();
 #endif
 
        /* get the exception and return it */