* Removed all Id tags.
[cacao.git] / src / vm / jit / dseg.h
index 0b567704118b3ae9b9ace1911ea6e8a8186fb447..229f34d347d7aca264483d20dffeb993adea3e78 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/dseg.c - data segment handling stuff
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
-
-   Authors: Reinhard Grafl
-            Andreas  Krall
-
-   Changes: Christian Thalinger
-            Joseph Wenninger
-
-   $Id: dseg.h 4445 2006-02-05 15:26:34Z edwin $
-
 */
 
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct jumpref jumpref;
-typedef struct dataref dataref;
-typedef struct patchref patchref;
-typedef struct linenumberref linenumberref;
+typedef struct dsegentry             dsegentry;
+typedef struct linenumbertable_entry linenumbertable_entry;
+typedef struct dseg_exception_entry  dseg_exception_entry;
 
 
 #include "config.h"
-
 #include "vm/types.h"
 
+#include "toolbox/list.h"
+
 #include "vm/jit/jit.h"
 #include "vm/jit/codegen-common.h"
 
+#include "vmcore/references.h"
 
-/* global macros **************************************************************/
 
-#if SIZEOF_VOID_P == 8
-# define dseg_addaddress(cd,value)    dseg_adds8((cd), (s8) (value))
-#else
-# define dseg_addaddress(cd,value)    dseg_adds4((cd), (s4) (value))
-#endif
+/* convenience macros *********************************************************/
 
+#define dseg_add_functionptr(cd,value) \
+    dseg_add_address((cd), (void *) (ptrint) (value))
 
-/* jumpref ********************************************************************/
 
-struct jumpref {
-       s4          tablepos;       /* patching position in data segment          */
-       basicblock *target;         /* target basic block                         */
-       jumpref    *next;           /* next element in jumpref list               */
+/* dataentry ******************************************************************/
+
+#define DSEG_FLAG_UNIQUE      0x0001
+#define DSEG_FLAG_READONLY    0x0002
+
+struct dsegentry {
+       u2         type;
+       u2         flags;
+       s4         disp;
+       imm_union  val;
+       dsegentry *next;
 };
 
 
-/* dataref ********************************************************************/
+/* linenumbertable_entry ******************************************************/
 
-struct dataref {
-       s4       datapos;           /* patching position in generated code        */
-       dataref *next;              /* next element in dataref list               */
+/* Keep the type of line the same as the pointer type, otherwise we
+   run into alignment troubles (like on MIPS64). */
+
+struct linenumbertable_entry {
+       ptrint  line;               /* NOTE: see doc/inlining_stacktrace.txt for  */
+       u1     *pc;                 /*       special meanings of line and pc.     */
 };
 
 
-/* patchref *******************************************************************/
+/* dseg_exception_entry ********************************************************
 
-struct patchref {
-       s4           branchpos;
-       functionptr  patcher;
-       voidptr      ref;
-       patchref    *next;
-       s4           disp;
-};
+   Datastructure which represents an exception entry in the exception
+   table residing in the data segment.
 
+*******************************************************************************/
 
-/* 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         */
+struct dseg_exception_entry {
+       classref_or_classinfo  catchtype;
+       u1                    *handlerpc;
+       u1                    *endpc;
+       u1                    *startpc;
 };
 
 
 /* function prototypes ********************************************************/
 
-void dseg_increase(codegendata *cd);
+void dseg_finish(jitdata *jd);
 
-s4 dseg_adds4_increase(codegendata *cd, s4 value);
-s4 dseg_adds4(codegendata *cd, s4 value);
+s4 dseg_add_unique_s4(codegendata *cd, s4 value);
+s4 dseg_add_unique_s8(codegendata *cd, s8 value);
+s4 dseg_add_unique_float(codegendata *cd, float value);
+s4 dseg_add_unique_double(codegendata *cd, double value);
+s4 dseg_add_unique_address(codegendata *cd, void *value);
 
-s4 dseg_adds8_increase(codegendata *cd, s8 value);
-s4 dseg_adds8(codegendata *cd, s8 value);
+s4 dseg_add_s4(codegendata *cd, s4 value);
+s4 dseg_add_s8(codegendata *cd, s8 value);
+s4 dseg_add_float(codegendata *cd, float value);
+s4 dseg_add_double(codegendata *cd, double value);
+s4 dseg_add_address(codegendata *cd, void *value);
 
-s4 dseg_addfloat_increase(codegendata *cd, float value);
-s4 dseg_addfloat(codegendata *cd, float value);
-
-s4 dseg_adddouble_increase(codegendata *cd, double value);
-s4 dseg_adddouble(codegendata *cd, double value);
-
-void dseg_addtarget(codegendata *cd, basicblock *target);
+void dseg_add_unique_target(codegendata *cd, basicblock *target);
+void dseg_add_target(codegendata *cd, basicblock *target);
 
 void dseg_addlinenumbertablesize(codegendata *cd);
-void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *ptr);
-void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr, u1 *ptr);
+void dseg_addlinenumber(codegendata *cd, u2 linenumber);
+void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr);
 void dseg_addlinenumber_inline_end(codegendata *cd, instruction *iptr);
 
 void dseg_createlinenumbertable(codegendata *cd);
 
-#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP)
-void dseg_adddata(codegendata *cd, u1 *ptr);
-void dseg_resolve_datareferences(codegendata *cd, methodinfo *m);
+s4 dseg_get_linenumber_from_pc(methodinfo **pm, u1 *pv, u1 *pc);
+
+#if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(__M68K__) || defined(ENABLE_INTRP)
+void dseg_adddata(codegendata *cd);
+void dseg_resolve_datareferences(jitdata *jd);
 #endif
 
 #if !defined(NDEBUG)
-void dseg_display(methodinfo *m, codegendata *cd);
+void dseg_display(jitdata *jd);
 #endif
 
 #endif /* _DSEG_H */