1 /* jit/codegen.inc.h - code generation header
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
5 M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
6 P. Tomsich, J. Wenninger
8 This file is part of CACAO.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
29 $Id: codegen.inc.h 1605 2004-11-29 10:06:02Z twisti $
34 #ifndef _CODEGEN_INC_H
35 #define _CODEGEN_INC_H
37 /* We typedef these structures before #includes to resolve circular */
40 typedef struct codegendata codegendata;
41 typedef struct branchref branchref;
42 typedef struct jumpref jumpref;
43 typedef struct dataref dataref;
44 typedef struct clinitref clinitref;
45 typedef struct linenumberref linenumberref;
46 typedef struct threadcritnodetemp threadcritnodetemp;
51 #include "jit/inline.h"
55 #define MCODEINITSIZE (1<<15) /* 32 Kbyte code area initialization size */
56 #define DSEGINITSIZE (1<<12) /* 4 Kbyte data area initialization size */
59 #define dseg_addaddress(cd,value) dseg_adds8((cd), (s8) (value))
61 #define dseg_addaddress(cd,value) dseg_adds4((cd), (s4) (value))
65 /************************* critical sections *********************************/
67 struct threadcritnodetemp {
68 threadcritnodetemp *next;
76 u1 *mcodebase; /* base pointer of code area */
77 s4 *mcodeend; /* pointer to end of code area */
78 s4 mcodesize; /* complete size of code area (bytes) */
80 #if defined(__I386__) || defined(__X86_64__)
81 u1 *mcodeptr; /* code generation pointer */
84 u1 *dsegtop; /* pointer to top (end) of data area */
85 s4 dsegsize; /* complete size of data area (bytes) */
86 s4 dseglen; /* used size of data area (bytes) */
87 /* data area grows from top to bottom */
89 jumpref *jumpreferences; /* list of jumptable target addresses */
90 dataref *datareferences; /* list of data segment references */
91 branchref *xboundrefs; /* list of bound check branches */
92 branchref *xcheckarefs; /* list of array size check branches */
93 branchref *xnullrefs; /* list of null check branches */
94 branchref *xcastrefs; /* list of cast check branches */
95 branchref *xdivrefs; /* list of divide by zero branches */
96 branchref *xexceptionrefs; /* list of exception branches */
97 clinitref *clinitrefs;
99 linenumberref *linenumberreferences; /* list of line numbers and the */
100 /* program counters of their first */
102 s4 linenumbertablesizepos;
103 s4 linenumbertablestartpos;
107 s4 exceptiontablelength; /* exceptiontable length */
108 exceptiontable *exceptiontable; /* the exceptiontable */
110 threadcritnodetemp *threadcrit; /* List of critical code regions */
111 threadcritnodetemp threadcritcurrent;
112 s4 threadcritcount; /* Number of critical regions */
119 /***************** forward references in branch instructions ******************/
122 s4 branchpos; /* patching position in code segment */
123 s4 reg; /* used for ArrayIndexOutOfBounds index reg */
124 branchref *next; /* next element in branchref list */
128 /******************** forward references in tables ***************************/
131 s4 tablepos; /* patching position in data segment */
132 basicblock *target; /* target basic block */
133 jumpref *next; /* next element in jumpref list */
138 u1 *pos; /* patching position in generated code */
139 dataref *next; /* next element in dataref list */
150 struct linenumberref {
151 s4 tablepos; /* patching position in data segment */
152 s4 targetmpc; /* machine code program counter of first */
153 /* instruction for given line */
154 u2 linenumber; /* line number, used for inserting into the */
155 /* table and for validty checking */
156 linenumberref *next; /* next element in linenumberref list */
160 #if defined(__I386__) || defined(__X86_64__)
161 typedef struct _methodtree_element methodtree_element;
163 struct _methodtree_element {
170 /* function prototypes ********************************************************/
173 void codegen_setup(methodinfo *m, codegendata *cd, t_inlining_globals *e);
174 void codegen(methodinfo *m, codegendata *cd, registerdata *rd);
175 void codegen_free(methodinfo *m, codegendata *cd);
176 void codegen_close();
177 void codegen_insertmethod(functionptr startpc, functionptr endpc);
179 #if defined(__I386__) || defined(__X86_64__)
180 void codegen_addreference(codegendata *cd, struct basicblock *target, void *branchptr);
183 void dseg_display(methodinfo *m, codegendata *cd);
185 void init_exceptions();
187 #endif /* _CODEGEN_INC_H */
191 * These are local overrides for various environment variables in Emacs.
192 * Please do not remove this and leave it at the end of the file, where
193 * Emacs will automagically detect them.
194 * ---------------------------------------------------------------------
197 * indent-tabs-mode: t