* src/vm/jit/codegen-common.cpp, src/vm/jit/x86_64/codegen.c: Generate
[cacao.git] / src / vm / jit / codegen-common.hpp
index 813c5278fcaebb2951ba2a658020662eba565b3e..ead70b880c053c91f3f0a73de8c17ed730d29bc2 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/codegen-common.hpp - architecture independent code generator stuff
 
-   Copyright (C) 1996-2005, 2006, 2007, 2008
+   Copyright (C) 1996-2005, 2006, 2007, 2008, 2009
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
@@ -33,9 +33,8 @@ typedef struct branchref              branchref;
 typedef struct branch_label_ref_t     branch_label_ref_t;
 typedef struct jumpref                jumpref;
 typedef struct dataref                dataref;
-typedef struct exceptionref           exceptionref;
-typedef struct linenumberref          linenumberref;
 
+struct patchref_t;
 
 #include "config.h"
 #include "vm/types.h"
@@ -43,16 +42,16 @@ typedef struct linenumberref          linenumberref;
 #include "toolbox/list.hpp"
 
 #include "vm/jit/builtin.hpp"
-#include "vm/descriptor.h"
+#include "vm/descriptor.hpp"
 #include "vm/global.h"
-#include "vm/method.h"
+#include "vm/method.hpp"
 #include "vm/references.h"
 
 #include "vm/jit/dseg.h"
 #include "vm/jit/jit.hpp"
 #include "vm/jit/reg.h"
 #include "vm/jit/code.hpp"
-#include "vm/jit/linenumbertable.h"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/replace.hpp"
 
 
@@ -73,6 +72,19 @@ typedef struct linenumberref          linenumberref;
 #define GET_LOW_REG(a)      ((a) & 0x0000ffff)
 #define GET_HIGH_REG(a)    (((a) & 0xffff0000) >> 16)
 
+/* All 32-bit machines we support use packed registers to store
+   return values and temporary values. */
+
+#if SIZEOF_VOID_P == 8
+# define REG_LRESULT         REG_RESULT
+# define REG_LTMP12          REG_ITMP1
+# define REG_LTMP23          REG_ITMP2
+#else
+# define REG_LRESULT         REG_RESULT_PACKED
+# define REG_LTMP12          REG_ITMP12_PACKED
+# define REG_LTMP23          REG_ITMP23_PACKED
+#endif
+
 
 /* branch conditions **********************************************************/
 
@@ -133,7 +145,7 @@ struct codegendata {
 
 #ifdef __cplusplus
        DumpList<branch_label_ref_t*>* brancheslabel;
-       DumpList<linenumbertable_list_entry_t*>* linenumbers; ///< List of line numbers.
+       DumpList<Linenumber>* linenumbers; ///< List of line numbers.
 #else
        // REMOVEME
        DumpList* brancheslabel;
@@ -201,24 +213,6 @@ struct dataref {
 };
 
 
-/* linenumberref **************************************************************/
-
-struct linenumberref {
-       s4             tablepos;    /* patching position in data segment          */
-       s4             linenumber;  /* line number, used for inserting into the   */
-                                   /* table and for validity checking            */
-                                   /* -1......start of inlined body              */
-                                   /* -2......end of inlined body                */
-                                   /* <= -3...special entry with methodinfo *    */
-                                                               /* (see doc/inlining_stacktrace.txt)          */
-       ptrint         targetmpc;   /* machine code program counter of first      */
-                                   /* instruction for given line                 */
-                                                               /* NOTE: for linenumber <= -3 this is a the   */
-                                   /* (methodinfo *) of the inlined method       */
-       linenumberref *next;        /* next element in linenumberref list         */
-};
-
-
 /* function prototypes ********************************************************/
 
 #ifdef __cplusplus
@@ -231,6 +225,14 @@ void codegen_setup(jitdata *jd);
 bool codegen_generate(jitdata *jd);
 bool codegen_emit(jitdata *jd);
 
+void codegen_emit_prolog(jitdata* jd);
+void codegen_emit_epilog(jitdata* jd);
+void codegen_emit_instruction(jitdata* jd, instruction* iptr);
+
+#if defined(USES_PATCHABLE_MEMORY_BARRIER)
+void codegen_emit_patchable_barrier(instruction *iptr, codegendata *cd, struct patchref_t *pr, fieldinfo *fi);
+#endif
+
 #if defined(ENABLE_INTRP)
 bool intrp_codegen(jitdata *jd);
 #endif