1 /* src/vm/jit/code.h - codeinfo struct for representing compiled code
3 Copyright (C) 1996-2005, 2006, 2007 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
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., 51 Franklin Street, Fifth Floor, Boston, MA
31 /* forward typedefs ***********************************************************/
36 #include "toolbox/list.h"
38 #include "vm/global.h"
40 #include "vm/jit/replace.h"
42 #include "vmcore/method.h"
45 /* constants ******************************************************************/
47 #define CODE_FLAG_INVALID 0x0001
48 #define CODE_FLAG_LEAFMETHOD 0x0002
51 /* codeinfo *******************************************************************
53 A codeinfo represents a particular realization of a method in
56 ATTENTION: The methodinfo entry in the code-structure MUST have the
57 offset 0, otherwise we have a problem in our compiler stub. This is
58 checked with an assert in code_init().
60 *******************************************************************************/
63 methodinfo *m; /* method this is a realization of */
64 codeinfo *prev; /* previous codeinfo of this method */
66 u4 codeflags; /* or of CODE_FLAG_ constants */
68 u1 optlevel; /* optimization level of this code */
69 s4 basicblockcount; /* number of basic blocks */
72 u1 *mcode; /* pointer to machine code */
73 u1 *entrypoint; /* machine code entry point */
74 s4 mcodelength; /* length of generated machine code */
80 #if defined(ENABLE_REPLACEMENT)
81 rplpoint *rplpoints; /* replacement points */
82 rplalloc *regalloc; /* register allocation info */
83 s4 rplpointcount; /* number of replacement points */
84 s4 globalcount; /* number of global allocations */
85 s4 regalloccount; /* number of total allocations */
86 s4 memuse; /* number of arg + local slots */
87 s4 stackframesize; /* size of the stackframe in slots */
88 u1 savedintcount; /* number of callee saved int regs */
89 u1 savedfltcount; /* number of callee saved flt regs */
90 # if defined(HAS_ADDRESS_REGISTER_FILE)
91 u1 savedadrcount; /* number of callee saved adr regs */
93 u1 *savedmcode; /* saved code under patches */
96 #if defined(ENABLE_PROFILING)
97 u4 frequency; /* number of method invocations */
99 s8 cycles; /* number of cpu cycles */
104 /* macros *********************************************************************/
106 #define CODE_IS_VALID(code) (!((code)->codeflags & CODE_FLAG_INVALID))
107 #define CODE_IS_INVALID(code) ((code)->codeflags & CODE_FLAG_INVALID)
108 #define CODE_IS_LEAFMETHOD(code) ((code)->codeflags & CODE_FLAG_LEAFMETHOD)
110 #define CODE_SETFLAG_INVALID(code) \
111 ((code)->codeflags |= CODE_FLAG_INVALID)
112 #define CODE_SETFLAG_LEAFMETHOD(code) \
113 ((code)->codeflags |= CODE_FLAG_LEAFMETHOD)
116 /* function prototypes ********************************************************/
118 bool code_init(void);
120 codeinfo *code_codeinfo_new(methodinfo *m);
121 void code_codeinfo_free(codeinfo *code);
123 codeinfo *code_find_codeinfo_for_pc(u1 *pc);
125 methodinfo *code_get_methodinfo_for_pv(u1 *pv);
127 #if defined(ENABLE_REPLACEMENT)
128 int code_get_sync_slot_count(codeinfo *code);
129 #endif /* defined(ENABLE_REPLACEMENT) */
131 void code_free_code_of_method(methodinfo *m);
137 * These are local overrides for various environment variables in Emacs.
138 * Please do not remove this and leave it at the end of the file, where
139 * Emacs will automagically detect them.
140 * ---------------------------------------------------------------------
143 * indent-tabs-mode: t
147 * vim:noexpandtab:sw=4:ts=4: