merged volatile memory barriers
[cacao.git] / src / vm / jit / codegen-common.hpp
index 51d45696483a53cb8f5e468f9b6dc87403325487..ead70b880c053c91f3f0a73de8c17ed730d29bc2 100644 (file)
@@ -1,6 +1,6 @@
-/* src/vm/jit/codegen-common.h - architecture independent code generator stuff
+/* 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,23 +33,25 @@ 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"
 
+#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.h"
+#include "vm/jit/code.hpp"
+#include "vm/jit/linenumbertable.hpp"
 #include "vm/jit/replace.hpp"
 
 
@@ -70,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 **********************************************************/
 
@@ -128,8 +143,14 @@ struct codegendata {
        dataref        *datareferences; /* list of data segment references        */
 #endif
 
-       list_t         *brancheslabel;
-       list_t         *linenumbers;    /* list of line numbers                   */
+#ifdef __cplusplus
+       DumpList<branch_label_ref_t*>* brancheslabel;
+       DumpList<Linenumber>* linenumbers; ///< List of line numbers.
+#else
+       // REMOVEME
+       DumpList* brancheslabel;
+       DumpList* linenumbers;
+#endif
 
        methodinfo     *method;
 
@@ -171,7 +192,7 @@ struct branch_label_ref_t {
        s4         condition;       /* conditional branch condition               */
        s4         reg;             /* register number to check                   */
        u4         options;         /* branch options                             */
-       listnode_t linkage;
+/*     listnode_t linkage; */
 };
 
 
@@ -192,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
@@ -222,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