* src/vm/method.h (vm/jit/code.h): Added.
[cacao.git] / src / vm / jit / dseg.h
1 /* src/vm/jit/dseg.c - data segment handling stuff
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28             Andreas  Krall
29
30    Changes: Christian Thalinger
31             Joseph Wenninger
32
33    $Id: dseg.h 4699 2006-03-28 14:52:32Z twisti $
34
35 */
36
37
38 #ifndef _DSEG_H
39 #define _DSEG_H
40
41 /* forward typedefs ***********************************************************/
42
43 typedef struct jumpref jumpref;
44 typedef struct dataref dataref;
45 typedef struct exceptionref exceptionref;
46 typedef struct patchref patchref;
47 typedef struct linenumberref linenumberref;
48
49
50 #include "config.h"
51
52 #include "vm/types.h"
53
54 #include "vm/jit/jit.h"
55 #include "vm/jit/codegen-common.h"
56
57
58 /* global macros **************************************************************/
59
60 #if SIZEOF_VOID_P == 8
61 # define dseg_addaddress(cd,value)    dseg_adds8((cd), (s8) (value))
62 #else
63 # define dseg_addaddress(cd,value)    dseg_adds4((cd), (s4) (value))
64 #endif
65
66
67 /* jumpref ********************************************************************/
68
69 struct jumpref {
70         s4          tablepos;       /* patching position in data segment          */
71         basicblock *target;         /* target basic block                         */
72         jumpref    *next;           /* next element in jumpref list               */
73 };
74
75
76 /* dataref ********************************************************************/
77
78 struct dataref {
79         s4       datapos;           /* patching position in generated code        */
80         dataref *next;              /* next element in dataref list               */
81 };
82
83
84 /* exceptionref ***************************************************************/
85
86 struct exceptionref {
87         s4            branchpos;    /* patching position in code segment          */
88         s4            reg;          /* used for ArrayIndexOutOfBounds index reg   */
89         functionptr   function;     /* function pointer to generate exception     */
90         exceptionref *next;         /* next element in exceptionref list          */
91 };
92
93
94 /* patchref *******************************************************************/
95
96 struct patchref {
97         s4           branchpos;
98         functionptr  patcher;
99         voidptr      ref;
100         patchref    *next;
101         s4           disp;
102 };
103
104
105 /* linenumberref **************************************************************/
106
107 struct linenumberref {
108         s4             tablepos;    /* patching position in data segment          */
109         s4             linenumber;  /* line number, used for inserting into the   */
110                                     /* table and for validity checking            */
111                                     /* -1......start of inlined body              */
112                                     /* -2......end of inlined body                */
113                                     /* <= -3...special entry with methodinfo *    */
114                                                                 /* (see doc/inlining_stacktrace.txt)          */
115         ptrint         targetmpc;   /* machine code program counter of first      */
116                                     /* instruction for given line                 */
117                                                                 /* NOTE: for linenumber <= -3 this is a the   */
118                                     /* (methodinfo *) of the inlined method       */
119         linenumberref *next;        /* next element in linenumberref list         */
120 };
121
122
123 /* function prototypes ********************************************************/
124
125 void dseg_increase(codegendata *cd);
126
127 s4 dseg_adds4_increase(codegendata *cd, s4 value);
128 s4 dseg_adds4(codegendata *cd, s4 value);
129
130 s4 dseg_adds8_increase(codegendata *cd, s8 value);
131 s4 dseg_adds8(codegendata *cd, s8 value);
132
133 s4 dseg_addfloat_increase(codegendata *cd, float value);
134 s4 dseg_addfloat(codegendata *cd, float value);
135
136 s4 dseg_adddouble_increase(codegendata *cd, double value);
137 s4 dseg_adddouble(codegendata *cd, double value);
138
139 void dseg_addtarget(codegendata *cd, basicblock *target);
140
141 void dseg_addlinenumbertablesize(codegendata *cd);
142 void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *ptr);
143 void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr, u1 *ptr);
144 void dseg_addlinenumber_inline_end(codegendata *cd, instruction *iptr);
145
146 void dseg_createlinenumbertable(codegendata *cd);
147
148 #if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP)
149 void dseg_adddata(codegendata *cd, u1 *ptr);
150 void dseg_resolve_datareferences(jitdata *jd);
151 #endif
152
153 #if !defined(NDEBUG)
154 void dseg_display(jitdata *jd);
155 #endif
156
157 #endif /* _DSEG_H */
158
159
160 /*
161  * These are local overrides for various environment variables in Emacs.
162  * Please do not remove this and leave it at the end of the file, where
163  * Emacs will automagically detect them.
164  * ---------------------------------------------------------------------
165  * Local variables:
166  * mode: c
167  * indent-tabs-mode: t
168  * c-basic-offset: 4
169  * tab-width: 4
170  * End:
171  * vim:noexpandtab:sw=4:ts=4:
172  */