Mercurial > hg > truffle
annotate src/share/vm/c1/c1_Compilation.hpp @ 1681:126ea7725993
6953477: Increase portability and flexibility of building Hotspot
Summary: A collection of portability improvements including shared code support for PPC, ARM platforms, software floating point, cross compilation support and improvements in error crash detail.
Reviewed-by: phh, never, coleenp, dholmes
author | bobv |
---|---|
date | Tue, 03 Aug 2010 08:13:38 -0400 |
parents | b812ff5abc73 |
children | 4a665be40fd3 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1397
diff
changeset
|
21 * questions. |
0 | 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 // compilation specifics | |
1584 | 58 Arena* _arena; |
59 int _next_id; | |
60 int _next_block_id; | |
0 | 61 AbstractCompiler* _compiler; |
62 ciEnv* _env; | |
63 ciMethod* _method; | |
64 int _osr_bci; | |
65 IR* _hir; | |
66 int _max_spills; | |
67 FrameMap* _frame_map; | |
68 C1_MacroAssembler* _masm; | |
69 bool _has_exception_handlers; | |
70 bool _has_fpu_code; | |
71 bool _has_unsafe_access; | |
72 const char* _bailout_msg; | |
73 ExceptionInfoList* _exception_info_list; | |
74 ExceptionHandlerTable _exception_handler_table; | |
75 ImplicitExceptionTable _implicit_exception_table; | |
76 LinearScan* _allocator; | |
77 CodeOffsets _offsets; | |
78 CodeBuffer _code; | |
79 | |
80 // compilation helpers | |
81 void initialize(); | |
82 void build_hir(); | |
83 void emit_lir(); | |
84 | |
85 void emit_code_epilog(LIR_Assembler* assembler); | |
86 int emit_code_body(); | |
87 | |
88 int compile_java_method(); | |
89 void install_code(int frame_size); | |
90 void compile_method(); | |
91 | |
92 void generate_exception_handler_table(); | |
93 | |
94 ExceptionInfoList* exception_info_list() const { return _exception_info_list; } | |
95 ExceptionHandlerTable* exception_handler_table() { return &_exception_handler_table; } | |
96 | |
97 LinearScan* allocator() { return _allocator; } | |
98 void set_allocator(LinearScan* allocator) { _allocator = allocator; } | |
99 | |
100 Instruction* _current_instruction; // the instruction currently being processed | |
101 #ifndef PRODUCT | |
102 Instruction* _last_instruction_printed; // the last instruction printed during traversal | |
103 #endif // PRODUCT | |
104 | |
105 public: | |
106 // creation | |
1584 | 107 Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, |
108 int osr_bci, BufferBlob* buffer_blob); | |
0 | 109 ~Compilation(); |
110 | |
1584 | 111 |
112 static Compilation* current() { | |
113 return (Compilation*) ciEnv::current()->compiler_data(); | |
114 } | |
0 | 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; } | |
1584 | 131 Arena* arena() { return _arena; } |
132 | |
133 // Instruction ids | |
134 int get_next_id() { return _next_id++; } | |
135 int number_of_instructions() const { return _next_id; } | |
136 | |
137 // BlockBegin ids | |
138 int get_next_block_id() { return _next_block_id++; } | |
139 int number_of_blocks() const { return _next_block_id; } | |
0 | 140 |
141 // setters | |
142 void set_has_exception_handlers(bool f) { _has_exception_handlers = f; } | |
143 void set_has_fpu_code(bool f) { _has_fpu_code = f; } | |
144 void set_has_unsafe_access(bool f) { _has_unsafe_access = f; } | |
145 // Add a set of exception handlers covering the given PC offset | |
146 void add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers); | |
147 // Statistics gathering | |
148 void notice_inlined_method(ciMethod* method); | |
149 | |
150 DebugInformationRecorder* debug_info_recorder() const; // = _env->debug_info(); | |
151 Dependencies* dependency_recorder() const; // = _env->dependencies() | |
152 ImplicitExceptionTable* implicit_exception_table() { return &_implicit_exception_table; } | |
153 | |
154 Instruction* current_instruction() const { return _current_instruction; } | |
155 Instruction* set_current_instruction(Instruction* instr) { | |
156 Instruction* previous = _current_instruction; | |
157 _current_instruction = instr; | |
158 return previous; | |
159 } | |
160 | |
161 #ifndef PRODUCT | |
162 void maybe_print_current_instruction(); | |
163 #endif // PRODUCT | |
164 | |
165 // error handling | |
166 void bailout(const char* msg); | |
167 bool bailed_out() const { return _bailout_msg != NULL; } | |
168 const char* bailout_msg() const { return _bailout_msg; } | |
169 | |
1584 | 170 static int desired_max_code_buffer_size() { |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
171 #ifndef PPC |
1584 | 172 return (int) NMethodSizeLimit; // default 256K or 512K |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
173 #else |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
174 // conditional branches on PPC are restricted to 16 bit signed |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
175 return MAX2((unsigned int)NMethodSizeLimit,32*K); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
176 #endif |
1584 | 177 } |
178 static int desired_max_constant_size() { | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
179 #ifndef PPC |
1584 | 180 return (int) NMethodSizeLimit / 10; // about 25K |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
181 #else |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
182 return (MAX2((unsigned int)NMethodSizeLimit, 32*K)) / 10; |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1584
diff
changeset
|
183 #endif |
1584 | 184 } |
185 | |
186 static void setup_code_buffer(CodeBuffer* cb, int call_stub_estimate); | |
187 | |
0 | 188 // timers |
189 static void print_timers(); | |
190 | |
191 #ifndef PRODUCT | |
192 // debugging support. | |
193 // produces a file named c1compileonly in the current directory with | |
194 // directives to compile only the current method and it's inlines. | |
195 // The file can be passed to the command line option -XX:Flags=<filename> | |
196 void compile_only_this_method(); | |
197 void compile_only_this_scope(outputStream* st, IRScope* scope); | |
198 void exclude_this_method(); | |
199 #endif // PRODUCT | |
200 }; | |
201 | |
202 | |
203 // Macro definitions for unified bailout-support | |
204 // The methods bailout() and bailed_out() are present in all classes | |
205 // that might bailout, but forward all calls to Compilation | |
206 #define BAILOUT(msg) { bailout(msg); return; } | |
207 #define BAILOUT_(msg, res) { bailout(msg); return res; } | |
208 | |
209 #define CHECK_BAILOUT() { if (bailed_out()) return; } | |
210 #define CHECK_BAILOUT_(res) { if (bailed_out()) return res; } | |
211 | |
212 | |
213 class InstructionMark: public StackObj { | |
214 private: | |
215 Compilation* _compilation; | |
216 Instruction* _previous; | |
217 | |
218 public: | |
219 InstructionMark(Compilation* compilation, Instruction* instr) { | |
220 _compilation = compilation; | |
221 _previous = _compilation->set_current_instruction(instr); | |
222 } | |
223 ~InstructionMark() { | |
224 _compilation->set_current_instruction(_previous); | |
225 } | |
226 }; | |
227 | |
228 | |
229 //---------------------------------------------------------------------- | |
230 // Base class for objects allocated by the compiler in the compilation arena | |
231 class CompilationResourceObj ALLOCATION_SUPER_CLASS_SPEC { | |
232 public: | |
1584 | 233 void* operator new(size_t size) { return Compilation::current()->arena()->Amalloc(size); } |
234 void* operator new(size_t size, Arena* arena) { | |
235 return arena->Amalloc(size); | |
236 } | |
0 | 237 void operator delete(void* p) {} // nothing to do |
238 }; | |
239 | |
240 | |
241 //---------------------------------------------------------------------- | |
242 // Class for aggregating exception handler information. | |
243 | |
244 // Effectively extends XHandlers class with PC offset of | |
245 // potentially exception-throwing instruction. | |
246 // This class is used at the end of the compilation to build the | |
247 // ExceptionHandlerTable. | |
248 class ExceptionInfo: public CompilationResourceObj { | |
249 private: | |
250 int _pco; // PC of potentially exception-throwing instruction | |
251 XHandlers* _exception_handlers; // flat list of exception handlers covering this PC | |
252 | |
253 public: | |
254 ExceptionInfo(int pco, XHandlers* exception_handlers) | |
255 : _pco(pco) | |
256 , _exception_handlers(exception_handlers) | |
257 { } | |
258 | |
259 int pco() { return _pco; } | |
260 XHandlers* exception_handlers() { return _exception_handlers; } | |
261 }; |