* src/vm/jit/parse.c (ICMD_CHECKNULL): Use OP_CHECK_EXCEPTION.
[cacao.git] / src / vm / method.c
index 4aa0705850e8c9425e93c8b4c6a400b88e72906c..53ccb6dd141db0d28c285e6b4b735f3fb3321b63 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: method.c 5258 2006-08-22 09:02:25Z tbfg $
+   $Id: method.c 5992 2006-11-15 22:46:10Z edwin $
 
 */
 
 #include "vm/jit/methodheader.h"
 
 
+#if !defined(NDEBUG) && defined(ENABLE_INLINING)
+extern bool inline_debug_log;
+#define INLINELOG(code)  do { if (inline_debug_log) { code } } while (0)
+#else
+#define INLINELOG(code)
+#endif
+
+
 /* method_free *****************************************************************
 
    Frees all memory that was allocated for this method.
@@ -65,8 +73,8 @@ void method_free(methodinfo *m)
        if (m->jcode)
                MFREE(m->jcode, u1, m->jcodelength);
 
-       if (m->exceptiontable)
-               MFREE(m->exceptiontable, exceptiontable, m->exceptiontablelength);
+       if (m->rawexceptiontable)
+               MFREE(m->rawexceptiontable, raw_exception_entry, m->rawexceptiontablelength);
 
        code_free_code_of_method(m);
 
@@ -147,6 +155,92 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
 }
 
 
+/* method_add_to_worklist ******************************************************
+
+   Add the method to the given worklist. If the method already occurs in
+   the worklist, the worklist remains unchanged.
+
+*******************************************************************************/
+
+static void method_add_to_worklist(methodinfo *m, method_worklist **wl)
+{
+       method_worklist *wi;
+
+       for (wi = *wl; wi != NULL; wi = wi->next)
+               if (wi->m == m)
+                       return;
+
+       wi = NEW(method_worklist);
+       wi->next = *wl;
+       wi->m = m;
+
+       *wl = wi;
+}
+
+
+/* method_add_assumption_monomorphic *******************************************
+
+   Record the assumption that the method is monomorphic.
+
+   IN:
+      m.................the method
+         caller............the caller making the assumption
+
+*******************************************************************************/
+
+void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller)
+{
+       method_assumption *as;
+
+       /* XXX LOCKING FOR THIS FUNCTION? */
+
+       /* check if we already have registered this assumption */
+
+       for (as = m->assumptions; as != NULL; as = as->next) {
+               if (as->context == caller)
+                       return;
+       }
+
+       /* register the assumption */
+
+       as = NEW(method_assumption);
+       as->next = m->assumptions;
+       as->context = caller;
+
+       m->assumptions = as;
+}
+
+
+/* method_break_assumption_monomorphic *****************************************
+
+   Break the assumption that this method is monomorphic. All callers that
+   have registered this assumption are added to the worklist.
+
+   IN:
+      m.................the method
+         wl................worklist where to add invalidated callers
+
+*******************************************************************************/
+
+void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl)
+{
+       method_assumption *as;
+
+       /* XXX LOCKING FOR THIS FUNCTION? */
+
+       for (as = m->assumptions; as != NULL; as = as->next) {
+               INLINELOG(
+                       printf("ASSUMPTION BROKEN (monomorphism): ");
+                       method_print(m);
+                       printf(" in ");
+                       method_println(as->context);
+               );
+
+               method_add_to_worklist(as->context, wl);
+       }
+}
+
+
 /* method_printflags ***********************************************************
 
    Prints the flags of a method to stdout like.
@@ -172,6 +266,8 @@ void method_printflags(methodinfo *m)
        if (m->flags & ACC_NATIVE)       printf(" NATIVE");
        if (m->flags & ACC_INTERFACE)    printf(" INTERFACE");
        if (m->flags & ACC_ABSTRACT)     printf(" ABSTRACT");
+       if (m->flags & ACC_METHOD_MONOMORPHIC) printf(" (mono)");
+       if (m->flags & ACC_METHOD_IMPLEMENTED) printf(" (impl)");
 }
 #endif /* !defined(NDEBUG) */