Unified variables changes for common/i386.
[cacao.git] / src / vm / jit / codegen-common.h
index 019f8683743e0f740b00f4f601396a6f114ff1f8..81fb1d4477a3f989ccc36a1db65d0abcf973325d 100644 (file)
@@ -27,8 +27,9 @@
    Authors: Christian Thalinger
 
    Changes: Christian Ullrich
+            Edwin Steiner
 
-   $Id: codegen-common.h 4357 2006-01-22 23:33:38Z twisti $
+   $Id: codegen-common.h 5404 2006-09-07 13:29:05Z christian $
 
 */
 
@@ -39,8 +40,7 @@
 /* forward typedefs ***********************************************************/
 
 typedef struct codegendata codegendata;
-typedef struct branchref branchref;
-typedef struct threadcritnodetemp threadcritnodetemp;
+typedef struct codegen_critical_section_t codegen_critical_section_t;
 
 
 #include "config.h"
@@ -52,7 +52,7 @@ typedef struct threadcritnodetemp threadcritnodetemp;
 #include "vm/jit/dseg.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/reg.h"
-#include "vm/jit/inline/inline.h"
+#include "vm/jit/code.h"
 
 
 #define MCODEINITSIZE (1<<15)       /* 32 Kbyte code area initialization size */
@@ -64,7 +64,7 @@ typedef struct threadcritnodetemp threadcritnodetemp;
 /* Register Pack/Unpack Macros ************************************************/
 
 /* ATTENTION: Don't change the order where low and high bits are
-   stored! At least mips32 relys in one case on that order. */
+   stored! At least mips32 relies in one case on that order. */
 
 #define PACK_REGS(low,high) \
     ( (((high) & 0x0000ffff) << 16) | ((low) & 0x0000ffff) )
@@ -75,8 +75,8 @@ typedef struct threadcritnodetemp threadcritnodetemp;
 
 /************************* critical sections  *********************************/
 
-struct threadcritnodetemp {
-       threadcritnodetemp *next;
+struct codegen_critical_section_t {
+       codegen_critical_section_t *next;
        s4                  mcodebegin;
        s4                  mcodeend;
        s4                  mcoderestart;
@@ -85,13 +85,10 @@ struct threadcritnodetemp {
 
 struct codegendata {
        u1             *mcodebase;      /* base pointer of code area              */
-       s4             *mcodeend;       /* pointer to end of code area            */
+       u1             *mcodeend;       /* pointer to end of code area            */
        s4              mcodesize;      /* complete size of code area (bytes)     */
        u1             *mcodeptr;       /* code generation pointer                */
-
-#if defined(__I386__) || defined(__MIPS__) || defined(__X86_64__) || defined(ENABLE_INTRP)
        u1             *lastmcodeptr;   /* last patcher position of basic block   */
-#endif
 
 #if defined(ENABLE_INTRP)
        u1             *ncodebase;      /* base pointer of native code area       */
@@ -106,8 +103,7 @@ struct codegendata {
        struct superstart *superstarts; /* list of supers without patchers        */
 #endif
 
-       u1             *dsegtop;        /* pointer to top (end) of data area      */
-       s4              dsegsize;       /* complete size of data area (bytes)     */
+       dsegentry      *dseg;           /* chain of data segment entries          */
        s4              dseglen;        /* used size of data area (bytes)         */
                                     /* data area grows from top to bottom     */
 
@@ -117,12 +113,7 @@ struct codegendata {
        dataref        *datareferences; /* list of data segment references        */
 #endif
 
-       branchref      *xboundrefs;     /* list of bound check branches           */
-       branchref      *xnullrefs;      /* list of null check branches            */
-       branchref      *xcastrefs;      /* list of cast check branches            */
-       branchref      *xstorerefs;     /* list of array store check branches     */
-       branchref      *xdivrefs;       /* list of divide by zero branches        */
-       branchref      *xexceptionrefs; /* list of exception branches             */
+       exceptionref   *exceptionrefs;  /* list of exception branches             */
        patchref       *patchrefs;
 
        linenumberref  *linenumberreferences; /* list of line numbers and the     */
@@ -136,98 +127,97 @@ struct codegendata {
        s4              exceptiontablelength; /* exceptiontable length            */
        exceptiontable *exceptiontable; /* the exceptiontable                     */
 
-       threadcritnodetemp *threadcrit; /* List of critical code regions          */
-       threadcritnodetemp threadcritcurrent;
+       codegen_critical_section_t *threadcrit; /* List of critical code regions          */
+       codegen_critical_section_t threadcritcurrent;
        s4                 threadcritcount; /* Number of critical regions         */
 
        s4              maxstack;
        s4              maxlocals;
+       s4              stackframesize;    /* stackframe size of this method      */
 };
 
 
-/***************** forward references in branch instructions ******************/
-
-struct branchref {
-       s4         branchpos;       /* patching position in code segment          */
-       s4         reg;             /* used for ArrayIndexOutOfBounds index reg   */
-       branchref *next;            /* next element in branchref list             */
-};
-
+/* methodtree_element *********************************************************/
 
-#if defined(__I386__) || defined(__X86_64__) || defined(ENABLE_INTRP) || defined(DISABLE_GC)
-typedef struct _methodtree_element methodtree_element;
+typedef struct methodtree_element methodtree_element;
 
-struct _methodtree_element {
+struct methodtree_element {
        u1 *startpc;
        u1 *endpc;
 };
-#endif
 
 
 /* function prototypes ********************************************************/
 
 void codegen_init(void);
-void codegen_setup(methodinfo *m, codegendata *cd, t_inlining_globals *e);
+void codegen_setup(jitdata *jd);
 
-void codegen_free(methodinfo *m, codegendata *cd);
 void codegen_close(void);
 
-s4 *codegen_increase(codegendata *cd, u1 *mcodeptr);
+void codegen_increase(codegendata *cd);
 
 #if defined(ENABLE_INTRP)
 u1 *codegen_ncode_increase(codegendata *cd, u1 *ncodeptr);
 #endif
 
-void codegen_addreference(codegendata *cd, basicblock *target, void *branchptr);
+void codegen_addreference(codegendata *cd, basicblock *target);
+
+void codegen_add_arithmeticexception_ref(codegendata *cd);
+void codegen_add_arrayindexoutofboundsexception_ref(codegendata *cd, s4 reg);
+void codegen_add_arraystoreexception_ref(codegendata *cd);
+void codegen_add_classcastexception_ref(codegendata *cd, s4 reg);
+void codegen_add_nullpointerexception_ref(codegendata *cd);
+void codegen_add_fillinstacktrace_ref(codegendata *cd);
 
-void codegen_addxboundrefs(codegendata *cd, void *branchptr, s4 reg);
-void codegen_addxcastrefs(codegendata *cd, void *branchptr);
-void codegen_addxdivrefs(codegendata *cd, void *branchptr);
-void codegen_addxstorerefs(codegendata *cd, void *branchptr);
-void codegen_addxnullrefs(codegendata *cd, void *branchptr);
-void codegen_addxexceptionrefs(codegendata *cd, void *branchptr);
 
-void codegen_addpatchref(codegendata *cd, voidptr branchptr,
-                                                functionptr patcher, voidptr ref, s4 disp);
+void codegen_addpatchref(codegendata *cd, functionptr patcher, voidptr ref,
+                                                s4 disp);
 
 void codegen_insertmethod(u1 *startpc, u1 *endpc);
-u1 *codegen_findmethod(u1 *pc);
+u1 *codegen_get_pv_from_pc(u1 *pc);
+u1 *codegen_get_pv_from_pc_nocheck(u1 *pc);
 
-void codegen_finish(methodinfo *m, codegendata *cd, s4 mcodelen);
+void codegen_finish(jitdata *jd);
 
-u1 *codegen_createnativestub(functionptr f, methodinfo *m);
+codeinfo *codegen_createnativestub(functionptr f, methodinfo *m);
+#if defined(ENABLE_DISASSEMBLER)
 void codegen_disassemble_nativestub(methodinfo *m, u1 *start, u1 *end);
+#endif
 
 void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra);
-void codegen_finish_native_call(u1 *datasp);
+java_objectheader *codegen_finish_native_call(u1 *datasp);
 
 u1 *createcompilerstub(methodinfo *m);
-u1 *createnativestub(functionptr f, methodinfo *m, codegendata *cd,
-                                        registerdata *rd, methoddesc *md);
+u1 *createnativestub(functionptr f, jitdata *jd, methoddesc *nmd);
 
 #if defined(ENABLE_INTRP)
 u1 *intrp_createcompilerstub(methodinfo *m);
-u1 *intrp_createnativestub(functionptr f, methodinfo *m, codegendata *cd,
-                                                  registerdata *rd, methoddesc *md);
+u1 *intrp_createnativestub(functionptr f, jitdata *jd, methoddesc *md);
 #endif
 
 void removecompilerstub(u1 *stub);
 void removenativestub(u1 *stub);
 
-s4 reg_of_var(registerdata *rd, stackptr v, s4 tempregnum);
+#if defined(NEW_VAR)
+s4 codegen_reg_of_var(u2 opcode, varinfo *v, s4 tempregnum);
+#else
+s4 codegen_reg_of_var(registerdata *rd, u2 opcode, stackptr v, s4 tempregnum);
+#endif
+s4 codegen_reg_of_dst(jitdata *jd, instruction *iptr, s4 tempregnum);
 
-#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+#if defined(ENABLE_THREADS)
 void codegen_threadcritrestart(codegendata *cd, int offset);
 void codegen_threadcritstart(codegendata *cd, int offset);
 void codegen_threadcritstop(codegendata *cd, int offset);
 #endif
 
 /* machine dependent functions */
-u1 *md_codegen_findmethod(u1 *ra);
-bool codegen(methodinfo *m, codegendata *cd, registerdata *rd);
+u1 *md_codegen_get_pv_from_pc(u1 *ra);
+
+bool codegen(jitdata *jd);
 
 #if defined(ENABLE_INTRP)
-bool intrp_codegen(methodinfo *m, codegendata *cd, registerdata *rd);
+bool intrp_codegen(jitdata *jd);
 #endif
 
 #endif /* _CODEGEN_COMMON_H */
@@ -244,4 +234,5 @@ bool intrp_codegen(methodinfo *m, codegendata *cd, registerdata *rd);
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */