* src/vm/jit/linenumbertable.c: Moved to .cpp.
[cacao.git] / src / vm / jit / linenumbertable.hpp
1 /* src/vm/jit/linenumbertable.hpp - linenumber table
2
3    Copyright (C) 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 _LINENUMBERTABLE_HPP
27 #define _LINENUMBERTABLE_HPP
28
29 #include "config.h"
30
31 #include <stdint.h>
32
33 #ifdef __cplusplus
34 #include <vector>
35 #endif
36
37 #include "toolbox/list.hpp"
38
39 #include "vm/method.h"
40
41 #include "vm/jit/jit.hpp"
42 #include "vm/jit/code.hpp"
43
44 #include "vm/jit/ir/instruction.hpp"
45
46
47 #ifdef __cplusplus
48
49 /**
50  * Represents a Java line number.
51  */
52 class Linenumber {
53 private:
54         // TODO Add constants.
55         /* -1......start of inlined body              */
56         /* -2......end of inlined body                */
57         /* <= -3...special entry with methodinfo *    */
58         /* (see doc/inlining_stacktrace.txt)          */
59
60         int32_t _linenumber;
61         void*   _pc;
62
63 public:
64         Linenumber(int32_t linenumber, void* pc) : _linenumber(linenumber), _pc(pc) {}
65
66         inline int32_t get_linenumber() const { return _linenumber; }
67         inline void*   get_pc        () const { return _pc; }
68
69         void resolve(codeinfo* code);
70 };
71
72
73 /**
74  * Linenumber table of a Java method.
75  */
76 class LinenumberTable {
77 private:
78         std::vector<Linenumber> _linenumbers;
79
80 public:
81         LinenumberTable(jitdata* jd);
82         ~LinenumberTable();
83
84         int32_t find(methodinfo **pm, void* pc);
85 };
86
87 #else
88
89 typedef struct LinenumberTable LinenumberTable;
90
91 #include "vm/jit/codegen-common.hpp"
92
93 int32_t linenumbertable_linenumber_for_pc(methodinfo** m, codeinfo* code, void* pc);
94
95 #endif
96
97 #include "vm/jit/codegen-common.hpp"
98
99 #ifdef __cplusplus
100 extern "C" {
101 #endif
102
103 void    linenumbertable_list_entry_add(codegendata *cd, int32_t linenumber);
104 void    linenumbertable_list_entry_add_inline_start(codegendata *cd, instruction *iptr);
105 void    linenumbertable_list_entry_add_inline_end(codegendata *cd, instruction *iptr);
106
107 #ifdef __cplusplus
108 } // extern "C"
109 #endif
110
111
112 #endif // _LINENUMBERTABLE_HPP
113
114
115 /*
116  * These are local overrides for various environment variables in Emacs.
117  * Please do not remove this and leave it at the end of the file, where
118  * Emacs will automagically detect them.
119  * ---------------------------------------------------------------------
120  * Local variables:
121  * mode: c++
122  * indent-tabs-mode: t
123  * c-basic-offset: 4
124  * tab-width: 4
125  * End:
126  * vim:noexpandtab:sw=4:ts=4:
127  */