Mercurial > hg > truffle
annotate src/share/vm/c1/c1_Compilation.hpp @ 1476:1f81c0d18c75
Build also release version of VM. Fix towards making SpecJVM2008 run.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 26 Nov 2010 12:12:35 +0100 |
parents | b4776199210f |
children | c18cbe5936b8 |
rev | line source |
---|---|
0 | 1 /* |
1397
b4776199210f
6943485: JVMTI always on capabilities change code generation too much
never
parents:
0
diff
changeset
|
2 * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 class BlockBegin; | |
26 class CompilationResourceObj; | |
27 class XHandlers; | |
28 class ExceptionInfo; | |
29 class DebugInformationRecorder; | |
30 class FrameMap; | |
31 class IR; | |
32 class IRScope; | |
33 class Instruction; | |
34 class LinearScan; | |
35 class OopMap; | |
36 class LIR_Emitter; | |
37 class LIR_Assembler; | |
38 class CodeEmitInfo; | |
39 class ciEnv; | |
40 class ciMethod; | |
41 class ValueStack; | |
42 class LIR_OprDesc; | |
43 class C1_MacroAssembler; | |
44 class CFGPrinter; | |
45 typedef LIR_OprDesc* LIR_Opr; | |
46 | |
47 | |
48 define_array(BasicTypeArray, BasicType) | |
49 define_stack(BasicTypeList, BasicTypeArray) | |
50 | |
51 define_array(ExceptionInfoArray, ExceptionInfo*) | |
52 define_stack(ExceptionInfoList, ExceptionInfoArray) | |
53 | |
54 class Compilation: public StackObj { | |
55 friend class CompilationResourceObj; | |
56 private: | |
57 | |
58 static Arena* _arena; | |
59 static Arena* arena() { return _arena; } | |
60 | |
61 static Compilation* _compilation; | |
62 | |
63 private: | |
64 // compilation specifics | |
65 AbstractCompiler* _compiler; | |
66 ciEnv* _env; | |
67 ciMethod* _method; | |
68 int _osr_bci; | |
69 IR* _hir; | |
70 int _max_spills; | |
71 FrameMap* _frame_map; | |
72 C1_MacroAssembler* _masm; | |
73 bool _has_exception_handlers; | |
74 bool _has_fpu_code; | |
75 bool _has_unsafe_access; | |
76 const char* _bailout_msg; | |
77 ExceptionInfoList* _exception_info_list; | |
78 ExceptionHandlerTable _exception_handler_table; | |
79 ImplicitExceptionTable _implicit_exception_table; | |
80 LinearScan* _allocator; | |
81 CodeOffsets _offsets; | |
82 CodeBuffer _code; | |
83 | |
84 // compilation helpers | |
85 void initialize(); | |
86 void build_hir(); | |
87 void emit_lir(); | |
88 | |
89 void emit_code_epilog(LIR_Assembler* assembler); | |
90 int emit_code_body(); | |
91 | |
92 int compile_java_method(); | |
93 void install_code(int frame_size); | |
94 void compile_method(); | |
95 | |
96 void generate_exception_handler_table(); | |
97 | |
98 ExceptionInfoList* exception_info_list() const { return _exception_info_list; } | |
99 ExceptionHandlerTable* exception_handler_table() { return &_exception_handler_table; } | |
100 | |
101 LinearScan* allocator() { return _allocator; } | |
102 void set_allocator(LinearScan* allocator) { _allocator = allocator; } | |
103 | |
104 Instruction* _current_instruction; // the instruction currently being processed | |
105 #ifndef PRODUCT | |
106 Instruction* _last_instruction_printed; // the last instruction printed during traversal | |
107 #endif // PRODUCT | |
108 | |
109 public: | |
110 // creation | |
111 Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, int osr_bci); | |
112 ~Compilation(); | |
113 | |
114 static Compilation* current_compilation() { return _compilation; } | |
115 | |
116 // accessors | |
117 ciEnv* env() const { return _env; } | |
118 AbstractCompiler* compiler() const { return _compiler; } | |
119 bool has_exception_handlers() const { return _has_exception_handlers; } | |
120 bool has_fpu_code() const { return _has_fpu_code; } | |
121 bool has_unsafe_access() const { return _has_unsafe_access; } | |
122 ciMethod* method() const { return _method; } | |
123 int osr_bci() const { return _osr_bci; } | |
124 bool is_osr_compile() const { return osr_bci() >= 0; } | |
125 IR* hir() const { return _hir; } | |
126 int max_spills() const { return _max_spills; } | |
127 FrameMap* frame_map() const { return _frame_map; } | |
128 CodeBuffer* code() { return &_code; } | |
129 C1_MacroAssembler* masm() const { return _masm; } | |
130 CodeOffsets* offsets() { return &_offsets; } | |
131 | |
132 // setters | |
133 void set_has_exception_handlers(bool f) { _has_exception_handlers = f; } | |
134 void set_has_fpu_code(bool f) { _has_fpu_code = f; } | |
135 void set_has_unsafe_access(bool f) { _has_unsafe_access = f; } | |
136 // Add a set of exception handlers covering the given PC offset | |
137 void add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers); | |
138 // Statistics gathering | |
139 void notice_inlined_method(ciMethod* method); | |
140 | |
141 DebugInformationRecorder* debug_info_recorder() const; // = _env->debug_info(); | |
142 Dependencies* dependency_recorder() const; // = _env->dependencies() | |
143 ImplicitExceptionTable* implicit_exception_table() { return &_implicit_exception_table; } | |
144 | |
145 Instruction* current_instruction() const { return _current_instruction; } | |
146 Instruction* set_current_instruction(Instruction* instr) { | |
147 Instruction* previous = _current_instruction; | |
148 _current_instruction = instr; | |
149 return previous; | |
150 } | |
151 | |
152 #ifndef PRODUCT | |
153 void maybe_print_current_instruction(); | |
154 #endif // PRODUCT | |
155 | |
156 // error handling | |
157 void bailout(const char* msg); | |
158 bool bailed_out() const { return _bailout_msg != NULL; } | |
159 const char* bailout_msg() const { return _bailout_msg; } | |
160 | |
161 // timers | |
162 static void print_timers(); | |
163 | |
164 #ifndef PRODUCT | |
165 // debugging support. | |
166 // produces a file named c1compileonly in the current directory with | |
167 // directives to compile only the current method and it's inlines. | |
168 // The file can be passed to the command line option -XX:Flags=<filename> | |
169 void compile_only_this_method(); | |
170 void compile_only_this_scope(outputStream* st, IRScope* scope); | |
171 void exclude_this_method(); | |
172 #endif // PRODUCT | |
173 }; | |
174 | |
175 | |
176 // Macro definitions for unified bailout-support | |
177 // The methods bailout() and bailed_out() are present in all classes | |
178 // that might bailout, but forward all calls to Compilation | |
179 #define BAILOUT(msg) { bailout(msg); return; } | |
180 #define BAILOUT_(msg, res) { bailout(msg); return res; } | |
181 | |
182 #define CHECK_BAILOUT() { if (bailed_out()) return; } | |
183 #define CHECK_BAILOUT_(res) { if (bailed_out()) return res; } | |
184 | |
185 | |
186 class InstructionMark: public StackObj { | |
187 private: | |
188 Compilation* _compilation; | |
189 Instruction* _previous; | |
190 | |
191 public: | |
192 InstructionMark(Compilation* compilation, Instruction* instr) { | |
193 _compilation = compilation; | |
194 _previous = _compilation->set_current_instruction(instr); | |
195 } | |
196 ~InstructionMark() { | |
197 _compilation->set_current_instruction(_previous); | |
198 } | |
199 }; | |
200 | |
201 | |
202 //---------------------------------------------------------------------- | |
203 // Base class for objects allocated by the compiler in the compilation arena | |
204 class CompilationResourceObj ALLOCATION_SUPER_CLASS_SPEC { | |
205 public: | |
206 void* operator new(size_t size) { return Compilation::arena()->Amalloc(size); } | |
207 void operator delete(void* p) {} // nothing to do | |
208 }; | |
209 | |
210 | |
211 //---------------------------------------------------------------------- | |
212 // Class for aggregating exception handler information. | |
213 | |
214 // Effectively extends XHandlers class with PC offset of | |
215 // potentially exception-throwing instruction. | |
216 // This class is used at the end of the compilation to build the | |
217 // ExceptionHandlerTable. | |
218 class ExceptionInfo: public CompilationResourceObj { | |
219 private: | |
220 int _pco; // PC of potentially exception-throwing instruction | |
221 XHandlers* _exception_handlers; // flat list of exception handlers covering this PC | |
222 | |
223 public: | |
224 ExceptionInfo(int pco, XHandlers* exception_handlers) | |
225 : _pco(pco) | |
226 , _exception_handlers(exception_handlers) | |
227 { } | |
228 | |
229 int pco() { return _pco; } | |
230 XHandlers* exception_handlers() { return _exception_handlers; } | |
231 }; |