Merge from subtype.
[cacao.git] / src / vm / jit / optimizing / recompiler.hpp
1 /* src/vm/jit/optimizing/recompiler.hpp - recompilation system
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
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.
12
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.
17
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
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _RECOMPILER_HPP
27 #define _RECOMPILER_HPP
28
29 #include "config.h"
30
31 #include <stdbool.h>
32 #include <stdint.h>
33
34 #ifdef __cplusplus
35 #include <queue>
36 #endif
37
38 #include "threads/condition.hpp"
39 #include "threads/mutex.hpp"
40
41 #include "vm/method.hpp"
42
43
44 #ifdef __cplusplus
45
46 /**
47  * Thread for JIT recompilations.
48  */
49 class Recompiler {
50 private:
51         Mutex                   _mutex;
52         Condition               _cond;
53         std::queue<methodinfo*> _methods;
54         bool                    _run;       ///< Flag to stop worker thread.
55
56         static void thread();               ///< Worker thread.
57
58 public:
59         Recompiler() : _run(true) {}
60         ~Recompiler();
61
62         bool start();                       ///< Start the worker thread.
63         void queue_method(methodinfo* m);   ///< Queue a method for recompilation.
64 };
65
66 #endif
67
68 /* list_method_entry **********************************************************/
69
70 typedef struct list_method_entry list_method_entry;
71
72 struct list_method_entry {
73         methodinfo *m;
74 /*      listnode_t  linkage; */
75 };
76
77
78 /* function prototypes ********************************************************/
79
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83
84 void Recompiler_queue_method(methodinfo *m);
85
86 #ifdef __cplusplus
87 } // extern "C"
88 #endif
89
90 #endif // _RECOMPILER_HPP
91
92
93 /*
94  * These are local overrides for various environment variables in Emacs.
95  * Please do not remove this and leave it at the end of the file, where
96  * Emacs will automagically detect them.
97  * ---------------------------------------------------------------------
98  * Local variables:
99  * mode: c++
100  * indent-tabs-mode: t
101  * c-basic-offset: 4
102  * tab-width: 4
103  * End:
104  * vim:noexpandtab:sw=4:ts=4:
105  */