1 /* src/vm/jit/jitcache.h - jit compiler output caching
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 #include "vm/jit/patcher-common.hpp"
34 #if defined(ENABLE_JITCACHE)
41 #include "vm/method.h"
43 typedef enum cachedreftype {
47 CRT_CODEGEN_FINISH_NATIVE_CALL,
48 CRT_ASM_HANDLE_EXCEPTION, /* 4 */
49 CRT_ASM_HANDLE_NAT_EXCEPTION,
54 CRT_CLASSINFO, /* 10 */
56 CRT_CLASSINFO_INTERFACETABLE,
58 CRT_METHODINFO_STUBROUTINE, /* 14 */
60 CRT_METHODINFO_INTERFACETABLE,
61 CRT_METHODINFO_METHODOFFSET,
62 CRT_FIELDINFO_VALUE, /* 18 */
64 CRT_FIELDINFO_OFFSET_HIGH,
65 CRT_JUMPREFERENCE /* 21 */
68 /* cachedref_t *****************************************************************
70 A cached reference contains information about a code or data position
71 which needs patching after restoring the it from disk.
73 *******************************************************************************/
76 cachedreftype type; /* type of the cached reference */
77 s4 md_patch; /* machine dependent back patching */
78 s4 disp; /* displacement of ref in the data segment */
79 void* ref; /* reference passed */
83 typedef struct mru_entry_t {
89 /* typedefs *******************************************************************/
91 typedef void (*serializerfptr) (int, patchref_t *, methodinfo *);
92 typedef void (*deserializerfptr) (patchref_t *, int, methodinfo *);
94 /* jitcache_patcher_function_list_t typedef ***********************************/
96 struct jitcache_patcher_function_list_t {
98 serializerfptr serializer;
99 deserializerfptr deserializer;
102 /* function prototypes ********************************************************/
104 void jitcache_list_create(codeinfo *code);
106 void jitcache_list_reset(codeinfo *code);
108 void jitcache_list_free(codeinfo *code);
110 void jitcache_add_cached_ref_jd(jitdata *jd, cachedreftype type, void* ref);
112 void jitcache_add_cached_ref_md_jd(jitdata *jd, cachedreftype type, s4 md_patch, void* ref);
114 void jitcache_add_cached_ref(codeinfo *code, cachedreftype type, void* ref, s4 disp);
116 void jitcache_store(methodinfo *m);
118 u1 jitcache_load(methodinfo *m);
120 void jitcache_handle_cached_ref(cachedref_t *cr, codeinfo *code);
122 void jitcache_quit();
124 void jitcache_freeclass(classinfo *);
126 #define JITCACHE_ADD_CACHED_REF_JD(jd, type, ref) \
127 (jitcache_add_cached_ref_jd(jd, type, (void*) ref))
129 #define JITCACHE_ADD_CACHED_REF_JD_COND(jd, type, ref, COND) \
131 (jitcache_add_cached_ref_jd(jd, type, (void*) ref))
133 #define JITCACHE_ADD_CACHED_REF_MD_JD(jd, type, md_patch, ref) \
134 (jitcache_add_cached_ref_md_jd(jd, type, md_patch, (void*) ref))
136 #define JITCACHE_ADD_CACHED_REF(code, type, ref, disp) \
137 (jitcache_add_cached_ref(code, type, (void*) ref, disp))
139 #define JITCACHE_ADD_CACHED_REF_COND(code, type, ref, disp, COND) \
141 jitcache_add_cached_ref(code, type, (void*) ref, disp)
145 #define JITCACHE_ADD_CACHED_REF_JD(jd, type, ref) \
148 #define JITCACHE_ADD_CACHED_REF_JD_COND(jd, type, ref, COND) \
151 #define JITCACHE_ADD_CACHED_REF_MD_JD(jd, type, md_patch, ref) \
154 #define JITCACHE_ADD_CACHED_REF(code, type, ref, disp) \
157 #define JITCACHE_ADD_CACHED_REF_COND(code, type, ref, disp, COND) \
160 #endif /* ENABLE_JITCACHE */
167 #endif /* _JITCACHE_HPP */
171 * These are local overrides for various environment variables in Emacs.
172 * Please do not remove this and leave it at the end of the file, where
173 * Emacs will automagically detect them.
174 * ---------------------------------------------------------------------
177 * indent-tabs-mode: t
181 * vim:noexpandtab:sw=4:ts=4: