* src/vm/jit/i386/md.c (md_patch_replacement_point): Generalized to
[cacao.git] / src / vm / jit / replace.h
1 /* vm/jit/replace.h - on-stack replacement of methods
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: Edwin Steiner
28
29    Changes:
30
31    $Id$
32
33 */
34
35
36 #ifndef _REPLACE_H
37 #define _REPLACE_H
38
39 #include "config.h"
40 #include "vm/types.h"
41 #include "vm/method.h"
42
43 /* An `rplpoint` represents a replacement point in a compiled method  */
44
45 struct rplpoint {
46         u1       *pc;           /* machine code PC of this point  */
47         u1       *outcode;      /* pointer to replacement-out code*/
48         rplpoint *hashlink;     /* chain to next rplpoint in hash */ /* XXX needed? */
49         codeinfo *code;         /* codeinfo this point belongs to */
50         rplpoint *target;       /* target of the replacement      */
51         u8        mcode;        /* saved maching code for patching*/
52         s2       *regalloc;     /* pointer to register index table*/
53         s2        regalloccount;/* number of local allocations    */
54 };
55
56 /* An `executionsstate` represents the state of a thread as it reached */
57 /* an replacement point or is about to enter one.                      */
58
59 #define MD_EXCSTATE_NREGS  32
60 #define MD_EXCSTATE_NCALLEESAVED  8
61
62 struct executionstate {
63         u1           *pc;
64         u8            regs[MD_EXCSTATE_NREGS];
65         u8            savedregs[MD_EXCSTATE_NCALLEESAVED]; /* or read from frame */
66
67         u1           *frame;
68         
69     java_objectheader *locked; /* XXX maybe just leave it in frame? */
70 };
71
72 /* `sourcestate` will probably only be used for debugging              */
73
74 struct sourcestate {
75         u8           *javastack;
76         s4            javastackdepth;
77
78         u8            javalocals;
79         s4            javalocalscount;
80 };
81
82 /*** prototypes ********************************************************/
83
84 bool replace_create_replacement_points(codeinfo *code,registerdata *rd);
85 void replace_free_replacement_points(codeinfo *code);
86
87 void replace_activate_replacement_point(rplpoint *rp,rplpoint *target);
88 void replace_deactivate_replacement_point(rplpoint *rp);
89 void replace_activate(codeinfo *code,codeinfo *target);
90
91 void replace_me(rplpoint *rp,executionstate *es);
92
93 #ifndef NDEBUG
94 void replace_show_replacement_points(codeinfo *code);
95 void replace_replacement_point_println(rplpoint *rp);
96 void replace_executionstate_println(executionstate *es);
97 #endif
98
99 /* machine dependent functions (code in ARCH_DIR/md.c) */
100
101 #if defined(ENABLE_JIT)
102 void md_patch_replacement_point(rplpoint *rp);
103 #endif
104
105 #endif
106
107 /*
108  * These are local overrides for various environment variables in Emacs.
109  * Please do not remove this and leave it at the end of the file, where
110  * Emacs will automagically detect them.
111  * ---------------------------------------------------------------------
112  * Local variables:
113  * mode: c
114  * indent-tabs-mode: t
115  * c-basic-offset: 4
116  * tab-width: 4
117  * End:
118  * vim:noexpandtab:sw=4:ts=4:
119  */