* src/vm/jit/stack.h (COPYCURSTACK): Do not create invars here.
[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 5186 2006-07-28 13:24:43Z twisti $
34
35 */
36
37
38 #ifndef _DSEG_H
39 #define _DSEG_H
40
41 /* forward typedefs ***********************************************************/
42
43 typedef struct dsegentry dsegentry;
44 typedef struct jumpref jumpref;
45 typedef struct dataref dataref;
46 typedef struct exceptionref exceptionref;
47 typedef struct patchref patchref;
48 typedef struct linenumberref linenumberref;
49
50
51 #include "config.h"
52
53 #include "vm/types.h"
54
55 #include "vm/jit/jit.h"
56 #include "vm/jit/codegen-common.h"
57
58
59 /* XXX don't-break-trunk macros ***********************************************/
60
61 #define dseg_adds4(cd,value)         dseg_add_unique_s4((cd), (value))
62 #define dseg_adds8(cd,value)         dseg_add_unique_s8((cd), (value))
63 #define dseg_addfloat(cd,value)      dseg_add_unique_float((cd), (value))
64 #define dseg_adddouble(cd,value)     dseg_add_unique_double((cd), (value))
65 #define dseg_addaddress(cd,value)    dseg_add_unique_address((cd), (void *) (ptrint) (value))
66 #define dseg_addtarget(cd,value)     dseg_add_target((cd), (value))
67
68
69 /* convenience macros *********************************************************/
70
71 #define dseg_add_functionptr(cd,value) \
72     dseg_add_address((cd), (void *) (ptrint) (value))
73
74
75 /* dataentry ******************************************************************/
76
77 #define DSEG_FLAG_UNIQUE      0x0001
78 #define DSEG_FLAG_READONLY    0x0002
79
80 struct dsegentry {
81         u2         type;
82         u2         flags;
83         s4         disp;
84         imm_union  val;
85         dsegentry *next;
86 };
87
88
89 /* jumpref ********************************************************************/
90
91 struct jumpref {
92         s4          tablepos;       /* patching position in data segment          */
93         basicblock *target;         /* target basic block                         */
94         jumpref    *next;           /* next element in jumpref list               */
95 };
96
97
98 /* dataref ********************************************************************/
99
100 struct dataref {
101         s4       datapos;           /* patching position in generated code        */
102         dataref *next;              /* next element in dataref list               */
103 };
104
105
106 /* exceptionref ***************************************************************/
107
108 struct exceptionref {
109         s4            branchpos;    /* patching position in code segment          */
110         s4            reg;          /* used for ArrayIndexOutOfBounds index reg   */
111         functionptr   function;     /* function pointer to generate exception     */
112         exceptionref *next;         /* next element in exceptionref list          */
113 };
114
115
116 /* patchref *******************************************************************/
117
118 struct patchref {
119         s4           branchpos;
120         functionptr  patcher;
121         voidptr      ref;
122         patchref    *next;
123         s4           disp;
124 };
125
126
127 /* linenumberref **************************************************************/
128
129 struct linenumberref {
130         s4             tablepos;    /* patching position in data segment          */
131         s4             linenumber;  /* line number, used for inserting into the   */
132                                     /* table and for validity checking            */
133                                     /* -1......start of inlined body              */
134                                     /* -2......end of inlined body                */
135                                     /* <= -3...special entry with methodinfo *    */
136                                                                 /* (see doc/inlining_stacktrace.txt)          */
137         ptrint         targetmpc;   /* machine code program counter of first      */
138                                     /* instruction for given line                 */
139                                                                 /* NOTE: for linenumber <= -3 this is a the   */
140                                     /* (methodinfo *) of the inlined method       */
141         linenumberref *next;        /* next element in linenumberref list         */
142 };
143
144
145 /* function prototypes ********************************************************/
146
147 void dseg_finish(jitdata *jd);
148
149 s4 dseg_add_unique_s4(codegendata *cd, s4 value);
150 s4 dseg_add_unique_s8(codegendata *cd, s8 value);
151 s4 dseg_add_unique_float(codegendata *cd, float value);
152 s4 dseg_add_unique_double(codegendata *cd, double value);
153 s4 dseg_add_unique_address(codegendata *cd, void *value);
154
155 s4 dseg_add_s4(codegendata *cd, s4 value);
156 s4 dseg_add_s8(codegendata *cd, s8 value);
157 s4 dseg_add_float(codegendata *cd, float value);
158 s4 dseg_add_double(codegendata *cd, double value);
159 s4 dseg_add_address(codegendata *cd, void *value);
160
161 void dseg_add_unique_target(codegendata *cd, basicblock *target);
162 void dseg_add_target(codegendata *cd, basicblock *target);
163
164 void dseg_addlinenumbertablesize(codegendata *cd);
165 void dseg_addlinenumber(codegendata *cd, u2 linenumber);
166 void dseg_addlinenumber_inline_start(codegendata *cd, instruction *iptr);
167 void dseg_addlinenumber_inline_end(codegendata *cd, instruction *iptr);
168
169 void dseg_createlinenumbertable(codegendata *cd);
170
171 #if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP)
172 void dseg_adddata(codegendata *cd);
173 void dseg_resolve_datareferences(jitdata *jd);
174 #endif
175
176 #if !defined(NDEBUG)
177 void dseg_display(jitdata *jd);
178 #endif
179
180 #endif /* _DSEG_H */
181
182
183 /*
184  * These are local overrides for various environment variables in Emacs.
185  * Please do not remove this and leave it at the end of the file, where
186  * Emacs will automagically detect them.
187  * ---------------------------------------------------------------------
188  * Local variables:
189  * mode: c
190  * indent-tabs-mode: t
191  * c-basic-offset: 4
192  * tab-width: 4
193  * End:
194  * vim:noexpandtab:sw=4:ts=4:
195  */