* src/vm/options.h, src/vm/method.c, src/vm/jit/inline/inline.c,
[cacao.git] / src / vm / method.c
index ae58d8fcf5822d195b3ba6f7f9938ebf655fd2b6..58e0da3b84a8ce68a4a88ab5b12650ee9dc80604 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: method.c 5974 2006-11-12 15:14:19Z edwin $
+   $Id: method.c 7228 2007-01-19 01:13:48Z edwin $
 
 */
 
@@ -54,9 +54,8 @@
 #include "vm/jit/methodheader.h"
 
 
-#if !defined(NDEBUG)
-extern bool inline_debug_log;
-#define INLINELOG(code)  do { if (inline_debug_log) { code } } while (0)
+#if !defined(NDEBUG) && defined(ENABLE_INLINING)
+#define INLINELOG(code)  do { if (opt_inline_debug_log) { code } } while (0)
 #else
 #define INLINELOG(code)
 #endif
@@ -155,13 +154,60 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
 }
 
 
+/* method_count_implementations ************************************************
+
+   Count the implementations of a method in a class cone (a class and all its
+   subclasses.)
+
+   IN:
+       m................the method to count
+          c................class at which to start the counting (this class and
+                           all its subclasses will be searched)
+
+   OUT:
+       *found...........if found != NULL, *found receives the method
+                           implementation that was found. This value is only
+                                               meaningful if the return value is 1.
+
+   RETURN VALUE:
+       the number of implementations found
+
+*******************************************************************************/
+
+s4 method_count_implementations(methodinfo *m, classinfo *c, methodinfo **found)
+{
+       s4          count;
+       methodinfo *mp;
+       methodinfo *mend;
+       classinfo  *child;
+
+       count = 0;
+
+       mp = c->methods;
+       mend = mp + c->methodscount;
+
+       for (; mp < mend; ++mp) {
+               if (method_canoverwrite(mp, m)) {
+                       if (found)
+                               *found = mp;
+                       count++;
+                       break;
+               }
+       }
+
+       for (child = c->sub; child != NULL; child = child->nextsub) {
+               count += method_count_implementations(m, child, found);
+       }
+
+       return count;
+}
+
+
 /* method_add_to_worklist ******************************************************
 
    Add the method to the given worklist. If the method already occurs in
    the worklist, the worklist remains unchanged.
 
-   Worklist items are allocated in dump memory.
-
 *******************************************************************************/
 
 static void method_add_to_worklist(methodinfo *m, method_worklist **wl)
@@ -172,7 +218,7 @@ static void method_add_to_worklist(methodinfo *m, method_worklist **wl)
                if (wi->m == m)
                        return;
 
-       wi = DNEW(method_worklist);
+       wi = NEW(method_worklist);
        wi->next = *wl;
        wi->m = m;
 
@@ -268,6 +314,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) */