* Removed all Id tags.
[cacao.git] / src / vm / jit / code.c
index fb88d79a427b763431466aee1f84bbe9fbc0fa39..e02bdcadf1f796e5a805e2bcfe13fd3f19500660 100644 (file)
@@ -22,8 +22,6 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id$
-
 */
 
 
@@ -44,6 +42,7 @@
 #include "vm/jit/code.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/methodheader.h"
+#include "vm/jit/patcher-common.h"
 
 #include "vmcore/options.h"
 
@@ -75,8 +74,7 @@ bool code_init(void)
 
    The following fields are set in codeinfo:
        m
-          isleafmethod
-   all other fields are zeroed
+       patchers
 
    RETURN VALUE:
        a new, initialized codeinfo, or
@@ -92,9 +90,7 @@ codeinfo *code_codeinfo_new(methodinfo *m)
 
        code->m = m;
 
-#if defined(ENABLE_THREADS)
-       lock_init_object_lock(&code->header);
-#endif
+       patcher_list_create(code);
 
 #if defined(ENABLE_STATISTICS)
        if (opt_stat)
@@ -203,76 +199,6 @@ int code_get_sync_slot_count(codeinfo *code)
 #endif /* defined(ENABLE_REPLACEMENT) */
 
 
-/* code_get_stack_frame_size ***************************************************
-
-   Return the number of stack slots that the stack frame of the given code
-   comprises.
-
-   IMPORTANT: The return value does *not* include the saved return address 
-              slot, although it is part of non-leaf stack frames on RISC
-                         architectures. The rationale behind this is that the saved
-                         return address is never moved or changed by replacement, and
-                         this way CISC and RISC architectures can be treated the same.
-                         (See also doc/stack_frames.txt.)
-   
-   IN:
-       code.............the codeinfo of the code in question
-                           (must be != NULL)
-
-   RETURN VALUE:
-       the number of stack slots
-  
-*******************************************************************************/
-
-#if defined(ENABLE_REPLACEMENT)
-int code_get_stack_frame_size(codeinfo *code)
-{
-#if 0
-       int count;
-       
-       assert(code);
-
-       /* slots allocated by register allocator plus saved registers */
-
-#ifdef HAS_4BYTE_STACKSLOT
-       count = code->memuse + code->savedintcount + 2*code->savedfltcount;
-#else
-       count = code->memuse + code->savedintcount + code->savedfltcount;
-#endif
-
-       /* add slots needed in synchronized methods */
-
-       count += code_get_sync_slot_count(code);
-
-       /* keep stack aligned */
-
-#if defined(__X86_64__)
-       /* the x86_64 codegen only aligns the stack in non-leaf methods */
-       if (!code->isleafmethod || opt_verbosecall)
-               count |= 1; /* even when return address is added */
-#endif
-
-       /* XXX align stack on alpha */
-#if defined(__MIPS__)
-       if (code->isleafmethod)
-               count = (count + 1) & ~1;
-       else
-               count |= 1; /* even when return address is added */
-#endif
-
-#if defined(__POWERPC__)
-       /* keep stack 16-byte aligned */
-       count = (count + 3) & ~3;
-#endif
-
-       return count;
-#endif
-
-       return code->stackframesize;
-}
-#endif /* defined(ENABLE_REPLACEMENT) */
-
-
 /* code_codeinfo_free **********************************************************
 
    Free the memory used by a codeinfo.
@@ -290,6 +216,8 @@ void code_codeinfo_free(codeinfo *code)
        if (code->mcode != NULL)
                CFREE((void *) (ptrint) code->mcode, code->mcodelength);
 
+       patcher_list_free(code);
+
 #if defined(ENABLE_REPLACEMENT)
        replace_free_replacement_points(code);
 #endif