1 /******************************** -*- C -*- ****************************
2  *
3  *	Translator to native code declarations.
4  *
5  *
6  ***********************************************************************/
7 
8 /***********************************************************************
9  *
10  * Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
11  * Written by Paolo Bonzini.
12  *
13  * This file is part of GNU Smalltalk.
14  *
15  * GNU Smalltalk is free software; you can redistribute it and/or modify it
16  * under the terms of the GNU General Public License as published by the Free
17  * Software Foundation; either version 2, or (at your option) any later
18  * version.
19  *
20  * Linking GNU Smalltalk statically or dynamically with other modules is
21  * making a combined work based on GNU Smalltalk.  Thus, the terms and
22  * conditions of the GNU General Public License cover the whole
23  * combination.
24  *
25  * In addition, as a special exception, the Free Software Foundation
26  * give you permission to combine GNU Smalltalk with free software
27  * programs or libraries that are released under the GNU LGPL and with
28  * independent programs running under the GNU Smalltalk virtual machine.
29  *
30  * You may copy and distribute such a system following the terms of the
31  * GNU GPL for GNU Smalltalk and the licenses of the other code
32  * concerned, provided that you include the source code of that other
33  * code when and as the GNU GPL requires distribution of source code.
34  *
35  * Note that people who make modified versions of GNU Smalltalk are not
36  * obligated to grant this special exception for their modified
37  * versions; it is their choice whether to do so.  The GNU General
38  * Public License gives permission to release a modified version without
39  * this exception; this exception also makes it possible to release a
40  * modified version which carries forward this exception.
41  *
42  * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
43  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
45  * more details.
46  *
47  * You should have received a copy of the GNU General Public License along with
48  * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
49  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
50  *
51  ***********************************************************************/
52 
53 #ifndef GST_XLAT_H
54 #define GST_XLAT_H
55 
56 
57 #ifdef ENABLE_JIT_TRANSLATION
58 
59 struct inline_cache;
60 struct ip_map;
61 typedef struct method_entry
62 {
63   struct method_entry *next;
64   OOP methodOOP;
65   OOP receiverClass;
66   struct inline_cache *inlineCaches;
67   struct ip_map *ipMap;
68   int nativeCode[1];		/* type chosen randomly */
69 }
70 method_entry;
71 
72 extern void _gst_reset_inline_caches ()
73   ATTRIBUTE_HIDDEN;
74 
75 extern PTR _gst_get_native_code (OOP methodOOP,
76 				 OOP receiverClass)
77   ATTRIBUTE_HIDDEN;
78 
79 extern PTR _gst_map_virtual_ip (OOP methodOOP,
80 				OOP receiverClass,
81 				int ip)
82   ATTRIBUTE_HIDDEN;
83 
84 extern void _gst_free_released_native_code (void)
85   ATTRIBUTE_HIDDEN;
86 extern void _gst_release_native_code (OOP methodOOP)
87   ATTRIBUTE_HIDDEN;
88 extern void _gst_discard_native_code (OOP methodOOP)
89   ATTRIBUTE_HIDDEN;
90 extern void _gst_init_translator (void)
91   ATTRIBUTE_HIDDEN;
92 
93 extern PTR (*_gst_run_native_code) ()
94   ATTRIBUTE_HIDDEN;
95 
96 extern PTR (*_gst_return_from_native_code) ()
97   ATTRIBUTE_HIDDEN;
98 
99 #define GET_METHOD_ENTRY(nativeCodeStart) ((method_entry *) (		\
100   ((char *) nativeCodeStart) - (sizeof(method_entry) - sizeof(int))  ))
101 
102 #define IS_VALID_IP(nativeCodeStart) 					\
103   ((nativeCodeStart) && GET_METHOD_ENTRY((nativeCodeStart))->receiverClass)
104 
105 #endif /* ENABLE_JIT_TRANSLATION */
106 
107 #endif /* GST_XLAT_H */
108