* src/vm/jit/parse.c, src/vm/jit/parse.h (Changes): Merged with
[cacao.git] / src / vm / method.c
index cd5bc7e4342a05d7938c6413931392f9c8d1a0e7..845ed7236b20394d02e4937d235b1e01c7f78ef1 100644 (file)
@@ -32,7 +32,7 @@
             Edwin Steiner
             Christian Thalinger
 
-   $Id: method.c 4501 2006-02-13 18:55:55Z twisti $
+   $Id: method.c 5785 2006-10-15 22:25:54Z edwin $
 
 */
 
@@ -50,6 +50,7 @@
 #include "vm/linker.h"
 #include "vm/loader.h"
 #include "vm/method.h"
+#include "vm/options.h"
 #include "vm/jit/methodheader.h"
 
 
@@ -64,11 +65,10 @@ 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);
 
-       if (m->mcode)
-               CFREE((void *) (ptrint) m->mcode, m->mcodelength);
+       code_free_code_of_method(m);
 
        if (m->stubroutine) {
                if (m->flags & ACC_NATIVE) {
@@ -117,6 +117,7 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
        methodptr   mptr;
        methodptr  *pmptr;
        methodinfo *resm;                   /* pointer to new resolved method     */
+       codeinfo   *code;
 
        /* If the method is not an instance method, just return it. */
 
@@ -128,17 +129,19 @@ methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m)
        /* Get the method from the virtual function table.  Is this an
           interface method? */
 
-       if (m->flags & (ACC_INTERFACE | ACC_ABSTRACT)) {
+       if (m->class->flags & ACC_INTERFACE) {
                pmptr = vftbl->interfacetable[-(m->class->index)];
                mptr  = pmptr[(m - m->class->methods)];
-
-       else {
+       }
+       else {
                mptr = vftbl->table[m->vftblindex];
        }
 
-       /* and now get the methodinfo* from the first data segment slot */
+       /* and now get the codeinfo pointer from the first data segment slot */
 
-       resm = *((methodinfo **) (mptr + MethodPointer));
+       code = *((codeinfo **) (mptr + CodeinfoPointer));
+
+       resm = code->m;
 
        return resm;
 }
@@ -189,10 +192,10 @@ void method_print(methodinfo *m)
                return;
        }
 
-       utf_display_classname(m->class->name);
+       utf_display_printable_ascii_classname(m->class->name);
        printf(".");
-       utf_display(m->name);
-       utf_display(m->descriptor);
+       utf_display_printable_ascii(m->name);
+       utf_display_printable_ascii(m->descriptor);
 
        method_printflags(m);
 }
@@ -210,7 +213,53 @@ void method_print(methodinfo *m)
 #if !defined(NDEBUG)
 void method_println(methodinfo *m)
 {
+       if (opt_debugcolor) printf("\033[31m"); /* red */
        method_print(m);
+       if (opt_debugcolor) printf("\033[m");   
+       printf("\n");
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* method_methodref_print ******************************************************
+
+   Prints a method reference to stdout.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void method_methodref_print(constant_FMIref *mr)
+{
+       if (!mr) {
+               printf("(constant_FMIref *)NULL");
+               return;
+       }
+
+       if (IS_FMIREF_RESOLVED(mr)) {
+               printf("<method> ");
+               method_print(mr->p.method);
+       }
+       else {
+               printf("<methodref> ");
+               utf_display_printable_ascii_classname(mr->p.classref->name);
+               printf(".");
+               utf_display_printable_ascii(mr->name);
+               utf_display_printable_ascii(mr->descriptor);
+       }
+}
+#endif /* !defined(NDEBUG) */
+
+
+/* method_methodref_println ****************************************************
+
+   Prints a method reference to stdout, followed by a newline.
+
+*******************************************************************************/
+
+#if !defined(NDEBUG)
+void method_methodref_println(constant_FMIref *mr)
+{
+       method_methodref_print(mr);
        printf("\n");
 }
 #endif /* !defined(NDEBUG) */
@@ -227,4 +276,5 @@ void method_println(methodinfo *m)
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */