Mercurial > hg > graal-compiler
annotate src/share/vm/c1/c1_LIRGenerator.hpp @ 1783:d5d065957597
6953144: Tiered compilation
Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation.
Reviewed-by: kvn, never, phh, twisti
author | iveresov |
---|---|
date | Fri, 03 Sep 2010 17:51:07 -0700 |
parents | 126ea7725993 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1783 | 2 * Copyright (c) 2005, 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:
342
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
342
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:
342
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // The classes responsible for code emission and register allocation | |
26 | |
27 | |
28 class LIRGenerator; | |
29 class LIREmitter; | |
30 class Invoke; | |
31 class SwitchRange; | |
32 class LIRItem; | |
33 | |
34 define_array(LIRItemArray, LIRItem*) | |
35 define_stack(LIRItemList, LIRItemArray) | |
36 | |
37 class SwitchRange: public CompilationResourceObj { | |
38 private: | |
39 int _low_key; | |
40 int _high_key; | |
41 BlockBegin* _sux; | |
42 public: | |
43 SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {} | |
44 void set_high_key(int key) { _high_key = key; } | |
45 | |
46 int high_key() const { return _high_key; } | |
47 int low_key() const { return _low_key; } | |
48 BlockBegin* sux() const { return _sux; } | |
49 }; | |
50 | |
51 define_array(SwitchRangeArray, SwitchRange*) | |
52 define_stack(SwitchRangeList, SwitchRangeArray) | |
53 | |
54 | |
55 class ResolveNode; | |
56 | |
57 define_array(NodeArray, ResolveNode*); | |
58 define_stack(NodeList, NodeArray); | |
59 | |
60 | |
61 // Node objects form a directed graph of LIR_Opr | |
62 // Edges between Nodes represent moves from one Node to its destinations | |
63 class ResolveNode: public CompilationResourceObj { | |
64 private: | |
65 LIR_Opr _operand; // the source or destinaton | |
66 NodeList _destinations; // for the operand | |
67 bool _assigned; // Value assigned to this Node? | |
68 bool _visited; // Node already visited? | |
69 bool _start_node; // Start node already visited? | |
70 | |
71 public: | |
72 ResolveNode(LIR_Opr operand) | |
73 : _operand(operand) | |
74 , _assigned(false) | |
75 , _visited(false) | |
76 , _start_node(false) {}; | |
77 | |
78 // accessors | |
79 LIR_Opr operand() const { return _operand; } | |
80 int no_of_destinations() const { return _destinations.length(); } | |
81 ResolveNode* destination_at(int i) { return _destinations[i]; } | |
82 bool assigned() const { return _assigned; } | |
83 bool visited() const { return _visited; } | |
84 bool start_node() const { return _start_node; } | |
85 | |
86 // modifiers | |
87 void append(ResolveNode* dest) { _destinations.append(dest); } | |
88 void set_assigned() { _assigned = true; } | |
89 void set_visited() { _visited = true; } | |
90 void set_start_node() { _start_node = true; } | |
91 }; | |
92 | |
93 | |
94 // This is shared state to be used by the PhiResolver so the operand | |
95 // arrays don't have to be reallocated for reach resolution. | |
96 class PhiResolverState: public CompilationResourceObj { | |
97 friend class PhiResolver; | |
98 | |
99 private: | |
100 NodeList _virtual_operands; // Nodes where the operand is a virtual register | |
101 NodeList _other_operands; // Nodes where the operand is not a virtual register | |
102 NodeList _vreg_table; // Mapping from virtual register to Node | |
103 | |
104 public: | |
105 PhiResolverState() {} | |
106 | |
107 void reset(int max_vregs); | |
108 }; | |
109 | |
110 | |
111 // class used to move value of phi operand to phi function | |
112 class PhiResolver: public CompilationResourceObj { | |
113 private: | |
114 LIRGenerator* _gen; | |
115 PhiResolverState& _state; // temporary state cached by LIRGenerator | |
116 | |
117 ResolveNode* _loop; | |
118 LIR_Opr _temp; | |
119 | |
120 // access to shared state arrays | |
121 NodeList& virtual_operands() { return _state._virtual_operands; } | |
122 NodeList& other_operands() { return _state._other_operands; } | |
123 NodeList& vreg_table() { return _state._vreg_table; } | |
124 | |
125 ResolveNode* create_node(LIR_Opr opr, bool source); | |
126 ResolveNode* source_node(LIR_Opr opr) { return create_node(opr, true); } | |
127 ResolveNode* destination_node(LIR_Opr opr) { return create_node(opr, false); } | |
128 | |
129 void emit_move(LIR_Opr src, LIR_Opr dest); | |
130 void move_to_temp(LIR_Opr src); | |
131 void move_temp_to(LIR_Opr dest); | |
132 void move(ResolveNode* src, ResolveNode* dest); | |
133 | |
134 LIRGenerator* gen() { | |
135 return _gen; | |
136 } | |
137 | |
138 public: | |
139 PhiResolver(LIRGenerator* _lir_gen, int max_vregs); | |
140 ~PhiResolver(); | |
141 | |
142 void move(LIR_Opr src, LIR_Opr dest); | |
143 }; | |
144 | |
145 | |
146 // only the classes below belong in the same file | |
147 class LIRGenerator: public InstructionVisitor, public BlockClosure { | |
342 | 148 |
0 | 149 private: |
150 Compilation* _compilation; | |
151 ciMethod* _method; // method that we are compiling | |
152 PhiResolverState _resolver_state; | |
153 BlockBegin* _block; | |
154 int _virtual_register_number; | |
155 Values _instruction_for_operand; | |
156 BitMap2D _vreg_flags; // flags which can be set on a per-vreg basis | |
157 LIR_List* _lir; | |
342 | 158 BarrierSet* _bs; |
0 | 159 |
160 LIRGenerator* gen() { | |
161 return this; | |
162 } | |
163 | |
164 #ifdef ASSERT | |
165 LIR_List* lir(const char * file, int line) const { | |
166 _lir->set_file_and_line(file, line); | |
167 return _lir; | |
168 } | |
169 #endif | |
170 LIR_List* lir() const { | |
171 return _lir; | |
172 } | |
173 | |
174 // a simple cache of constants used within a block | |
175 GrowableArray<LIR_Const*> _constants; | |
176 LIR_OprList _reg_for_constants; | |
177 Values _unpinned_constants; | |
178 | |
179 friend class PhiResolver; | |
180 | |
181 // unified bailout support | |
182 void bailout(const char* msg) const { compilation()->bailout(msg); } | |
183 bool bailed_out() const { return compilation()->bailed_out(); } | |
184 | |
185 void block_do_prolog(BlockBegin* block); | |
186 void block_do_epilog(BlockBegin* block); | |
187 | |
188 // register allocation | |
189 LIR_Opr rlock(Value instr); // lock a free register | |
190 LIR_Opr rlock_result(Value instr); | |
191 LIR_Opr rlock_result(Value instr, BasicType type); | |
192 LIR_Opr rlock_byte(BasicType type); | |
193 LIR_Opr rlock_callee_saved(BasicType type); | |
194 | |
195 // get a constant into a register and get track of what register was used | |
196 LIR_Opr load_constant(Constant* x); | |
197 LIR_Opr load_constant(LIR_Const* constant); | |
198 | |
1783 | 199 // Given an immediate value, return an operand usable in logical ops. |
200 LIR_Opr load_immediate(int x, BasicType type); | |
201 | |
0 | 202 void set_result(Value x, LIR_Opr opr) { |
203 assert(opr->is_valid(), "must set to valid value"); | |
204 assert(x->operand()->is_illegal(), "operand should never change"); | |
205 assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register"); | |
206 x->set_operand(opr); | |
207 assert(opr == x->operand(), "must be"); | |
208 if (opr->is_virtual()) { | |
209 _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL); | |
210 } | |
211 } | |
212 void set_no_result(Value x) { assert(!x->has_uses(), "can't have use"); x->clear_operand(); } | |
213 | |
214 friend class LIRItem; | |
215 | |
216 LIR_Opr round_item(LIR_Opr opr); | |
217 LIR_Opr force_to_spill(LIR_Opr value, BasicType t); | |
218 | |
219 PhiResolverState& resolver_state() { return _resolver_state; } | |
220 | |
221 void move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val); | |
222 void move_to_phi(ValueStack* cur_state); | |
223 | |
224 // code emission | |
225 void do_ArithmeticOp_Long (ArithmeticOp* x); | |
226 void do_ArithmeticOp_Int (ArithmeticOp* x); | |
227 void do_ArithmeticOp_FPU (ArithmeticOp* x); | |
228 | |
229 // platform dependent | |
230 LIR_Opr getThreadPointer(); | |
231 | |
232 void do_RegisterFinalizer(Intrinsic* x); | |
233 void do_getClass(Intrinsic* x); | |
234 void do_currentThread(Intrinsic* x); | |
235 void do_MathIntrinsic(Intrinsic* x); | |
236 void do_ArrayCopy(Intrinsic* x); | |
237 void do_CompareAndSwap(Intrinsic* x, ValueType* type); | |
238 void do_AttemptUpdate(Intrinsic* x); | |
239 void do_NIOCheckIndex(Intrinsic* x); | |
240 void do_FPIntrinsics(Intrinsic* x); | |
241 | |
242 void do_UnsafePrefetch(UnsafePrefetch* x, bool is_store); | |
243 | |
244 LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info); | |
245 LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info); | |
246 | |
247 // convenience functions | |
248 LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info); | |
249 LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info); | |
250 | |
251 // GC Barriers | |
252 | |
253 // generic interface | |
254 | |
342 | 255 void pre_barrier(LIR_Opr addr_opr, bool patch, CodeEmitInfo* info); |
0 | 256 void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); |
257 | |
258 // specific implementations | |
342 | 259 // pre barriers |
260 | |
261 void G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, bool patch, CodeEmitInfo* info); | |
0 | 262 |
263 // post barriers | |
264 | |
342 | 265 void G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); |
0 | 266 void CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); |
267 | |
268 | |
269 static LIR_Opr result_register_for(ValueType* type, bool callee = false); | |
270 | |
271 ciObject* get_jobject_constant(Value value); | |
272 | |
273 LIRItemList* invoke_visit_arguments(Invoke* x); | |
274 void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list); | |
275 | |
276 void trace_block_entry(BlockBegin* block); | |
277 | |
278 // volatile field operations are never patchable because a klass | |
279 // must be loaded to know it's volatile which means that the offset | |
280 // it always known as well. | |
281 void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info); | |
282 void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info); | |
283 | |
284 void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile); | |
285 void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile); | |
286 | |
287 void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args); | |
288 | |
1783 | 289 void increment_counter(address counter, BasicType type, int step = 1); |
0 | 290 void increment_counter(LIR_Address* addr, int step = 1); |
291 | |
292 // is_strictfp is only needed for mul and div (and only generates different code on i486) | |
293 void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL); | |
294 // machine dependent. returns true if it emitted code for the multiply | |
295 bool strength_reduce_multiply(LIR_Opr left, int constant, LIR_Opr result, LIR_Opr tmp); | |
296 | |
297 void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes); | |
298 | |
299 void jobject2reg_with_patching(LIR_Opr r, ciObject* obj, CodeEmitInfo* info); | |
300 | |
301 // this loads the length and compares against the index | |
302 void array_range_check (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info); | |
303 // For java.nio.Buffer.checkIndex | |
304 void nio_range_check (LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info); | |
305 | |
306 void arithmetic_op_int (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp); | |
307 void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL); | |
308 void arithmetic_op_fpu (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp = LIR_OprFact::illegalOpr); | |
309 | |
310 void shift_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp); | |
311 | |
312 void logic_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right); | |
313 | |
314 void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
315 void monitor_exit (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no); |
0 | 316 |
317 void new_instance (LIR_Opr dst, ciInstanceKlass* klass, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info); | |
318 | |
319 // machine dependent | |
320 void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info); | |
321 void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info); | |
322 void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info); | |
323 | |
324 void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type); | |
325 | |
326 // returns a LIR_Address to address an array location. May also | |
327 // emit some code as part of address calculation. If | |
328 // needs_card_mark is true then compute the full address for use by | |
329 // both the store and the card mark. | |
330 LIR_Address* generate_address(LIR_Opr base, | |
331 LIR_Opr index, int shift, | |
332 int disp, | |
333 BasicType type); | |
334 LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) { | |
335 return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type); | |
336 } | |
337 LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark); | |
338 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
339 // the helper for generate_address |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
340 void add_large_constant(LIR_Opr src, int c, LIR_Opr dest); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
341 |
0 | 342 // machine preferences and characteristics |
343 bool can_inline_as_constant(Value i) const; | |
344 bool can_inline_as_constant(LIR_Const* c) const; | |
345 bool can_store_as_constant(Value i, BasicType type) const; | |
346 | |
347 LIR_Opr safepoint_poll_register(); | |
1783 | 348 |
349 void profile_branch(If* if_instr, If::Condition cond); | |
350 void increment_event_counter_impl(CodeEmitInfo* info, | |
351 ciMethod *method, int frequency, | |
352 int bci, bool backedge, bool notify); | |
353 void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge); | |
354 void increment_invocation_counter(CodeEmitInfo *info) { | |
355 if (compilation()->count_invocations()) { | |
356 increment_event_counter(info, InvocationEntryBci, false); | |
357 } | |
358 } | |
359 void increment_backedge_counter(CodeEmitInfo* info, int bci) { | |
360 if (compilation()->count_backedges()) { | |
361 increment_event_counter(info, bci, true); | |
362 } | |
0 | 363 } |
364 | |
365 CodeEmitInfo* state_for(Instruction* x, ValueStack* state, bool ignore_xhandler = false); | |
366 CodeEmitInfo* state_for(Instruction* x); | |
367 | |
368 // allocates a virtual register for this instruction if | |
369 // one isn't already allocated. Only for Phi and Local. | |
370 LIR_Opr operand_for_instruction(Instruction *x); | |
371 | |
372 void set_block(BlockBegin* block) { _block = block; } | |
373 | |
374 void block_prolog(BlockBegin* block); | |
375 void block_epilog(BlockBegin* block); | |
376 | |
377 void do_root (Instruction* instr); | |
378 void walk (Instruction* instr); | |
379 | |
380 void bind_block_entry(BlockBegin* block); | |
381 void start_block(BlockBegin* block); | |
382 | |
383 LIR_Opr new_register(BasicType type); | |
384 LIR_Opr new_register(Value value) { return new_register(as_BasicType(value->type())); } | |
385 LIR_Opr new_register(ValueType* type) { return new_register(as_BasicType(type)); } | |
386 | |
387 // returns a register suitable for doing pointer math | |
388 LIR_Opr new_pointer_register() { | |
389 #ifdef _LP64 | |
390 return new_register(T_LONG); | |
391 #else | |
392 return new_register(T_INT); | |
393 #endif | |
394 } | |
395 | |
396 static LIR_Condition lir_cond(If::Condition cond) { | |
397 LIR_Condition l; | |
398 switch (cond) { | |
399 case If::eql: l = lir_cond_equal; break; | |
400 case If::neq: l = lir_cond_notEqual; break; | |
401 case If::lss: l = lir_cond_less; break; | |
402 case If::leq: l = lir_cond_lessEqual; break; | |
403 case If::geq: l = lir_cond_greaterEqual; break; | |
404 case If::gtr: l = lir_cond_greater; break; | |
405 }; | |
406 return l; | |
407 } | |
408 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
409 #ifdef __SOFTFP__ |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
410 void do_soft_float_compare(If *x); |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
411 #endif // __SOFTFP__ |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
412 |
0 | 413 void init(); |
414 | |
415 SwitchRangeArray* create_lookup_ranges(TableSwitch* x); | |
416 SwitchRangeArray* create_lookup_ranges(LookupSwitch* x); | |
417 void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux); | |
418 | |
419 public: | |
420 Compilation* compilation() const { return _compilation; } | |
421 FrameMap* frame_map() const { return _compilation->frame_map(); } | |
422 ciMethod* method() const { return _method; } | |
423 BlockBegin* block() const { return _block; } | |
424 IRScope* scope() const { return block()->scope(); } | |
425 | |
426 int max_virtual_register_number() const { return _virtual_register_number; } | |
427 | |
428 void block_do(BlockBegin* block); | |
429 | |
430 // Flags that can be set on vregs | |
431 enum VregFlag { | |
432 must_start_in_memory = 0 // needs to be assigned a memory location at beginning, but may then be loaded in a register | |
433 , callee_saved = 1 // must be in a callee saved register | |
434 , byte_reg = 2 // must be in a byte register | |
435 , num_vreg_flags | |
436 | |
437 }; | |
438 | |
439 LIRGenerator(Compilation* compilation, ciMethod* method) | |
440 : _compilation(compilation) | |
441 , _method(method) | |
442 , _virtual_register_number(LIR_OprDesc::vreg_base) | |
443 , _vreg_flags(NULL, 0, num_vreg_flags) { | |
444 init(); | |
445 } | |
446 | |
447 // for virtual registers, maps them back to Phi's or Local's | |
448 Instruction* instruction_for_opr(LIR_Opr opr); | |
449 Instruction* instruction_for_vreg(int reg_num); | |
450 | |
451 void set_vreg_flag (int vreg_num, VregFlag f); | |
452 bool is_vreg_flag_set(int vreg_num, VregFlag f); | |
453 void set_vreg_flag (LIR_Opr opr, VregFlag f) { set_vreg_flag(opr->vreg_number(), f); } | |
454 bool is_vreg_flag_set(LIR_Opr opr, VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); } | |
455 | |
456 // statics | |
457 static LIR_Opr exceptionOopOpr(); | |
458 static LIR_Opr exceptionPcOpr(); | |
459 static LIR_Opr divInOpr(); | |
460 static LIR_Opr divOutOpr(); | |
461 static LIR_Opr remOutOpr(); | |
462 static LIR_Opr shiftCountOpr(); | |
463 LIR_Opr syncTempOpr(); | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
464 LIR_Opr atomicLockOpr(); |
0 | 465 |
466 // returns a register suitable for saving the thread in a | |
467 // call_runtime_leaf if one is needed. | |
468 LIR_Opr getThreadTemp(); | |
469 | |
470 // visitor functionality | |
471 virtual void do_Phi (Phi* x); | |
472 virtual void do_Local (Local* x); | |
473 virtual void do_Constant (Constant* x); | |
474 virtual void do_LoadField (LoadField* x); | |
475 virtual void do_StoreField (StoreField* x); | |
476 virtual void do_ArrayLength (ArrayLength* x); | |
477 virtual void do_LoadIndexed (LoadIndexed* x); | |
478 virtual void do_StoreIndexed (StoreIndexed* x); | |
479 virtual void do_NegateOp (NegateOp* x); | |
480 virtual void do_ArithmeticOp (ArithmeticOp* x); | |
481 virtual void do_ShiftOp (ShiftOp* x); | |
482 virtual void do_LogicOp (LogicOp* x); | |
483 virtual void do_CompareOp (CompareOp* x); | |
484 virtual void do_IfOp (IfOp* x); | |
485 virtual void do_Convert (Convert* x); | |
486 virtual void do_NullCheck (NullCheck* x); | |
487 virtual void do_Invoke (Invoke* x); | |
488 virtual void do_NewInstance (NewInstance* x); | |
489 virtual void do_NewTypeArray (NewTypeArray* x); | |
490 virtual void do_NewObjectArray (NewObjectArray* x); | |
491 virtual void do_NewMultiArray (NewMultiArray* x); | |
492 virtual void do_CheckCast (CheckCast* x); | |
493 virtual void do_InstanceOf (InstanceOf* x); | |
494 virtual void do_MonitorEnter (MonitorEnter* x); | |
495 virtual void do_MonitorExit (MonitorExit* x); | |
496 virtual void do_Intrinsic (Intrinsic* x); | |
497 virtual void do_BlockBegin (BlockBegin* x); | |
498 virtual void do_Goto (Goto* x); | |
499 virtual void do_If (If* x); | |
500 virtual void do_IfInstanceOf (IfInstanceOf* x); | |
501 virtual void do_TableSwitch (TableSwitch* x); | |
502 virtual void do_LookupSwitch (LookupSwitch* x); | |
503 virtual void do_Return (Return* x); | |
504 virtual void do_Throw (Throw* x); | |
505 virtual void do_Base (Base* x); | |
506 virtual void do_OsrEntry (OsrEntry* x); | |
507 virtual void do_ExceptionObject(ExceptionObject* x); | |
508 virtual void do_RoundFP (RoundFP* x); | |
509 virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); | |
510 virtual void do_UnsafePutRaw (UnsafePutRaw* x); | |
511 virtual void do_UnsafeGetObject(UnsafeGetObject* x); | |
512 virtual void do_UnsafePutObject(UnsafePutObject* x); | |
513 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); | |
514 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); | |
515 virtual void do_ProfileCall (ProfileCall* x); | |
1783 | 516 virtual void do_ProfileInvoke (ProfileInvoke* x); |
0 | 517 }; |
518 | |
519 | |
520 class LIRItem: public CompilationResourceObj { | |
521 private: | |
522 Value _value; | |
523 LIRGenerator* _gen; | |
524 LIR_Opr _result; | |
525 bool _destroys_register; | |
526 LIR_Opr _new_result; | |
527 | |
528 LIRGenerator* gen() const { return _gen; } | |
529 | |
530 public: | |
531 LIRItem(Value value, LIRGenerator* gen) { | |
532 _destroys_register = false; | |
533 _gen = gen; | |
534 set_instruction(value); | |
535 } | |
536 | |
537 LIRItem(LIRGenerator* gen) { | |
538 _destroys_register = false; | |
539 _gen = gen; | |
540 _result = LIR_OprFact::illegalOpr; | |
541 set_instruction(NULL); | |
542 } | |
543 | |
544 void set_instruction(Value value) { | |
545 _value = value; | |
546 _result = LIR_OprFact::illegalOpr; | |
547 if (_value != NULL) { | |
548 _gen->walk(_value); | |
549 _result = _value->operand(); | |
550 } | |
551 _new_result = LIR_OprFact::illegalOpr; | |
552 } | |
553 | |
554 Value value() const { return _value; } | |
555 ValueType* type() const { return value()->type(); } | |
556 LIR_Opr result() { | |
557 assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()), | |
558 "shouldn't use set_destroys_register with physical regsiters"); | |
559 if (_destroys_register && _result->is_register()) { | |
560 if (_new_result->is_illegal()) { | |
561 _new_result = _gen->new_register(type()); | |
562 gen()->lir()->move(_result, _new_result); | |
563 } | |
564 return _new_result; | |
565 } else { | |
566 return _result; | |
567 } | |
568 return _result; | |
569 } | |
570 | |
571 void set_result(LIR_Opr opr); | |
572 | |
573 void load_item(); | |
574 void load_byte_item(); | |
575 void load_nonconstant(); | |
576 // load any values which can't be expressed as part of a single store instruction | |
577 void load_for_store(BasicType store_type); | |
578 void load_item_force(LIR_Opr reg); | |
579 | |
580 void dont_load_item() { | |
581 // do nothing | |
582 } | |
583 | |
584 void set_destroys_register() { | |
585 _destroys_register = true; | |
586 } | |
587 | |
588 bool is_constant() const { return value()->as_Constant() != NULL; } | |
589 bool is_stack() { return result()->is_stack(); } | |
590 bool is_register() { return result()->is_register(); } | |
591 | |
592 ciObject* get_jobject_constant() const; | |
593 jint get_jint_constant() const; | |
594 jlong get_jlong_constant() const; | |
595 jfloat get_jfloat_constant() const; | |
596 jdouble get_jdouble_constant() const; | |
597 jint get_address_constant() const; | |
598 }; |