* src/vm/jit/replace.c: Only recompile if necessary. Count
[cacao.git] / src / vm / method.h
index 1e16df96169443d799645a435fc8744ce3e2888e..ec57352af4ee9dbf5442075f55c255007a598b1e 100644 (file)
    Contact: cacao@cacaojvm.org
 
    Authors: Reinhard Grafl
+            Christian Thalinger
+            Edwin Steiner
 
-   Changes: Christian Thalinger
-
-   $Id: method.h 4381 2006-01-28 14:18:06Z twisti $
+   $Id: method.h 6012 2006-11-16 19:45:15Z twisti $
 */
 
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct methodinfo methodinfo; 
-typedef struct exceptiontable exceptiontable;
-typedef struct lineinfo lineinfo; 
+typedef struct methodinfo          methodinfo; 
+typedef struct raw_exception_entry raw_exception_entry;
+typedef struct lineinfo            lineinfo; 
+typedef struct method_assumption   method_assumption;
+typedef struct method_worklist     method_worklist;
 
 #include "config.h"
 #include "vm/types.h"
 
+#include "vm/descriptor.h"
 #include "vm/global.h"
-#include "vm/utf8.h"
+#include "vm/linker.h"
 #include "vm/references.h"
-#include "vm/descriptor.h"
+#include "vm/utf8.h"
+#include "vm/jit/code.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/inline/parseXTA.h"
 
 
 /* methodinfo *****************************************************************/
@@ -59,10 +62,9 @@ struct methodinfo {                 /* method structure                       */
        s4            flags;            /* ACC flags                              */
        utf          *name;             /* name of method                         */
        utf          *descriptor;       /* JavaVM descriptor string of method     */
+       utf          *signature;        /* Signature attribute string             */
        methoddesc   *parseddesc;       /* parsed descriptor                      */
                             
-       bool          isleafmethod;     /* does method call subroutines           */
-                            
        classinfo    *class;            /* class, the method belongs to           */
        s4            vftblindex;       /* index of method in virtual function    */
                                        /* table (if it is a virtual method)      */
@@ -70,22 +72,9 @@ struct methodinfo {                 /* method structure                       */
        s4            maxlocals;        /* maximum number of local variables      */
        s4            jcodelength;      /* length of JavaVM code                  */
        u1           *jcode;            /* pointer to JavaVM code                 */
-                            
-       s4            basicblockcount;  /* number of basic blocks                 */
-       basicblock   *basicblocks;      /* points to basic block array            */
-       s4           *basicblockindex;  /* a table which contains for every byte  */
-                                       /* of JavaVM code a basic block index if  */
-                                       /* at this byte is the start of a basic   */
-                                       /* block                                  */
-
-       s4            instructioncount; /* number of JavaVM instructions          */
-       instruction  *instructions;     /* points to intermediate code instr.     */
-
-       s4            stackcount;       /* number of stack elements               */
-       stackelement *stack;            /* points to intermediate code instr.     */
 
-       s4            exceptiontablelength; /* exceptiontable length              */
-       exceptiontable *exceptiontable; /* the exceptiontable                     */
+       s4            rawexceptiontablelength;  /* exceptiontable length          */
+       raw_exception_entry *rawexceptiontable; /* the exceptiontable             */
 
        u2            thrownexceptionscount; /* number of exceptions attribute    */
        classref_or_classinfo *thrownexceptions; /* except. a method may throw    */
@@ -93,36 +82,51 @@ struct methodinfo {                 /* method structure                       */
        u2            linenumbercount;  /* number of linenumber attributes        */
        lineinfo     *linenumbers;      /* array of lineinfo items                */
 
-       int       c_debug_nr;           /* a counter to number all BB with an     */
-                                       /* unique value                           */
-
        u1           *stubroutine;      /* stub for compiling or calling natives  */
-       s4            mcodelength;      /* length of generated machine code       */
-       u1           *mcode;            /* pointer to machine code                */
-       u1           *entrypoint;       /* entry point in machine code            */
+       codeinfo     *code;             /* current code of this method            */
 
 #if defined(ENABLE_LSRA)
        s4            maxlifetimes;     /* helper for lsra                        */
 #endif
+
+       methodinfo   *overwrites;       /* method that is directly overwritten    */
+       method_assumption *assumptions; /* list of assumptions about this method  */
 };
 
 
-/* exceptiontable *************************************************************/
+/* method_assumption ***********************************************************
 
-struct exceptiontable {         /* exceptiontable entry in a method           */
-       s4              startpc;    /* start pc of guarded area (inclusive)       */
-       basicblock     *start;
+   This struct is used for registering assumptions about methods.
 
-       s4              endpc;      /* end pc of guarded area (exklusive)         */
-       basicblock     *end;
+*******************************************************************************/
 
-       s4              handlerpc;  /* pc of exception handler                    */
-       basicblock     *handler;
+struct method_assumption {
+       method_assumption *next;
+       methodinfo        *context;
+};
 
-       classref_or_classinfo catchtype; /* catchtype of exc. (NULL == catchall)  */
-       exceptiontable *next;       /* used to build a list of exception when     */
-                                   /* loops are copied */
-       exceptiontable *down;       /* instead of the old array, a list is used   */
+
+/* method_worklist *************************************************************
+
+   List node used for method worklists.
+
+*******************************************************************************/
+
+struct method_worklist {
+       method_worklist *next;
+       methodinfo      *m;
+};
+
+
+/* raw_exception_entry ********************************************************/
+
+/* exception table entry read by the loader */
+
+struct raw_exception_entry {    /* exceptiontable entry in a method           */
+       classref_or_classinfo catchtype; /* catchtype of exc. (0 == catchall)     */
+       u2              startpc;    /* start pc of guarded area (inclusive)       */
+       u2              endpc;      /* end pc of guarded area (exklusive)         */
+       u2              handlerpc;  /* pc of exception handler                    */
 };
 
 
@@ -139,10 +143,17 @@ struct lineinfo {
 void method_free(methodinfo *m);
 bool method_canoverwrite(methodinfo *m, methodinfo *old);
 
+methodinfo *method_vftbl_lookup(vftbl_t *vftbl, methodinfo* m);
+
+void method_add_assumption_monomorphic(methodinfo *m, methodinfo *caller);
+void method_break_assumption_monomorphic(methodinfo *m, method_worklist **wl);
+
 #if !defined(NDEBUG)
 void method_printflags(methodinfo *m);
 void method_print(methodinfo *m);
 void method_println(methodinfo *m);
+void method_methodref_print(constant_FMIref *mr);
+void method_methodref_println(constant_FMIref *mr);
 #endif
 
 #endif /* _METHOD_H */
@@ -159,4 +170,5 @@ void method_println(methodinfo *m);
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */