author | coleenp |
Mon, 16 Oct 2017 22:36:06 -0400 | |
changeset 47634 | 6a0c42c40cd1 |
parent 47216 | 71c04702a3d5 |
child 49397 | d3a8aa01f26f |
permissions | -rw-r--r-- |
1 | 1 |
/* |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36559
diff
changeset
|
2 |
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1374
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1374
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1374
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_C1_C1_LIRGENERATOR_HPP |
26 |
#define SHARE_VM_C1_C1_LIRGENERATOR_HPP |
|
27 |
||
28 |
#include "c1/c1_Instruction.hpp" |
|
29 |
#include "c1/c1_LIR.hpp" |
|
30 |
#include "ci/ciMethodData.hpp" |
|
42063
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
31 |
#include "utilities/macros.hpp" |
7397 | 32 |
#include "utilities/sizes.hpp" |
33 |
||
1 | 34 |
// The classes responsible for code emission and register allocation |
35 |
||
36 |
||
37 |
class LIRGenerator; |
|
38 |
class LIREmitter; |
|
39 |
class Invoke; |
|
40 |
class SwitchRange; |
|
41 |
class LIRItem; |
|
42 |
||
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36559
diff
changeset
|
43 |
typedef GrowableArray<LIRItem*> LIRItemList; |
1 | 44 |
|
45 |
class SwitchRange: public CompilationResourceObj { |
|
46 |
private: |
|
47 |
int _low_key; |
|
48 |
int _high_key; |
|
49 |
BlockBegin* _sux; |
|
50 |
public: |
|
51 |
SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {} |
|
52 |
void set_high_key(int key) { _high_key = key; } |
|
53 |
||
54 |
int high_key() const { return _high_key; } |
|
55 |
int low_key() const { return _low_key; } |
|
56 |
BlockBegin* sux() const { return _sux; } |
|
57 |
}; |
|
58 |
||
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36559
diff
changeset
|
59 |
typedef GrowableArray<SwitchRange*> SwitchRangeArray; |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36559
diff
changeset
|
60 |
typedef GrowableArray<SwitchRange*> SwitchRangeList; |
1 | 61 |
|
62 |
class ResolveNode; |
|
63 |
||
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36559
diff
changeset
|
64 |
typedef GrowableArray<ResolveNode*> NodeList; |
1 | 65 |
|
66 |
// Node objects form a directed graph of LIR_Opr |
|
67 |
// Edges between Nodes represent moves from one Node to its destinations |
|
68 |
class ResolveNode: public CompilationResourceObj { |
|
69 |
private: |
|
70 |
LIR_Opr _operand; // the source or destinaton |
|
71 |
NodeList _destinations; // for the operand |
|
72 |
bool _assigned; // Value assigned to this Node? |
|
73 |
bool _visited; // Node already visited? |
|
74 |
bool _start_node; // Start node already visited? |
|
75 |
||
76 |
public: |
|
77 |
ResolveNode(LIR_Opr operand) |
|
78 |
: _operand(operand) |
|
79 |
, _assigned(false) |
|
80 |
, _visited(false) |
|
81 |
, _start_node(false) {}; |
|
82 |
||
83 |
// accessors |
|
84 |
LIR_Opr operand() const { return _operand; } |
|
85 |
int no_of_destinations() const { return _destinations.length(); } |
|
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36559
diff
changeset
|
86 |
ResolveNode* destination_at(int i) { return _destinations.at(i); } |
1 | 87 |
bool assigned() const { return _assigned; } |
88 |
bool visited() const { return _visited; } |
|
89 |
bool start_node() const { return _start_node; } |
|
90 |
||
91 |
// modifiers |
|
92 |
void append(ResolveNode* dest) { _destinations.append(dest); } |
|
93 |
void set_assigned() { _assigned = true; } |
|
94 |
void set_visited() { _visited = true; } |
|
95 |
void set_start_node() { _start_node = true; } |
|
96 |
}; |
|
97 |
||
98 |
||
99 |
// This is shared state to be used by the PhiResolver so the operand |
|
100 |
// arrays don't have to be reallocated for reach resolution. |
|
101 |
class PhiResolverState: public CompilationResourceObj { |
|
102 |
friend class PhiResolver; |
|
103 |
||
104 |
private: |
|
105 |
NodeList _virtual_operands; // Nodes where the operand is a virtual register |
|
106 |
NodeList _other_operands; // Nodes where the operand is not a virtual register |
|
107 |
NodeList _vreg_table; // Mapping from virtual register to Node |
|
108 |
||
109 |
public: |
|
110 |
PhiResolverState() {} |
|
111 |
||
112 |
void reset(int max_vregs); |
|
113 |
}; |
|
114 |
||
115 |
||
116 |
// class used to move value of phi operand to phi function |
|
117 |
class PhiResolver: public CompilationResourceObj { |
|
118 |
private: |
|
119 |
LIRGenerator* _gen; |
|
120 |
PhiResolverState& _state; // temporary state cached by LIRGenerator |
|
121 |
||
122 |
ResolveNode* _loop; |
|
123 |
LIR_Opr _temp; |
|
124 |
||
125 |
// access to shared state arrays |
|
126 |
NodeList& virtual_operands() { return _state._virtual_operands; } |
|
127 |
NodeList& other_operands() { return _state._other_operands; } |
|
128 |
NodeList& vreg_table() { return _state._vreg_table; } |
|
129 |
||
130 |
ResolveNode* create_node(LIR_Opr opr, bool source); |
|
131 |
ResolveNode* source_node(LIR_Opr opr) { return create_node(opr, true); } |
|
132 |
ResolveNode* destination_node(LIR_Opr opr) { return create_node(opr, false); } |
|
133 |
||
134 |
void emit_move(LIR_Opr src, LIR_Opr dest); |
|
135 |
void move_to_temp(LIR_Opr src); |
|
136 |
void move_temp_to(LIR_Opr dest); |
|
137 |
void move(ResolveNode* src, ResolveNode* dest); |
|
138 |
||
139 |
LIRGenerator* gen() { |
|
140 |
return _gen; |
|
141 |
} |
|
142 |
||
143 |
public: |
|
144 |
PhiResolver(LIRGenerator* _lir_gen, int max_vregs); |
|
145 |
~PhiResolver(); |
|
146 |
||
147 |
void move(LIR_Opr src, LIR_Opr dest); |
|
148 |
}; |
|
149 |
||
150 |
||
151 |
// only the classes below belong in the same file |
|
152 |
class LIRGenerator: public InstructionVisitor, public BlockClosure { |
|
33462 | 153 |
// LIRGenerator should never get instatiated on the heap. |
154 |
private: |
|
155 |
void* operator new(size_t size) throw(); |
|
156 |
void* operator new[](size_t size) throw(); |
|
35117
3191066d12e0
8144850: C1: operator delete needs an implementation
mdoerr
parents:
35109
diff
changeset
|
157 |
void operator delete(void* p) { ShouldNotReachHere(); } |
3191066d12e0
8144850: C1: operator delete needs an implementation
mdoerr
parents:
35109
diff
changeset
|
158 |
void operator delete[](void* p) { ShouldNotReachHere(); } |
1374 | 159 |
|
1 | 160 |
Compilation* _compilation; |
161 |
ciMethod* _method; // method that we are compiling |
|
162 |
PhiResolverState _resolver_state; |
|
163 |
BlockBegin* _block; |
|
164 |
int _virtual_register_number; |
|
165 |
Values _instruction_for_operand; |
|
166 |
BitMap2D _vreg_flags; // flags which can be set on a per-vreg basis |
|
167 |
LIR_List* _lir; |
|
1374 | 168 |
BarrierSet* _bs; |
1 | 169 |
|
170 |
LIRGenerator* gen() { |
|
171 |
return this; |
|
172 |
} |
|
173 |
||
24933
c16c7a4ac386
8031994: java/lang/Character/CheckProp test times out
rbackman
parents:
24442
diff
changeset
|
174 |
void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN; |
c16c7a4ac386
8031994: java/lang/Character/CheckProp test times out
rbackman
parents:
24442
diff
changeset
|
175 |
|
1 | 176 |
#ifdef ASSERT |
177 |
LIR_List* lir(const char * file, int line) const { |
|
178 |
_lir->set_file_and_line(file, line); |
|
179 |
return _lir; |
|
180 |
} |
|
181 |
#endif |
|
182 |
LIR_List* lir() const { |
|
183 |
return _lir; |
|
184 |
} |
|
185 |
||
186 |
// a simple cache of constants used within a block |
|
187 |
GrowableArray<LIR_Const*> _constants; |
|
188 |
LIR_OprList _reg_for_constants; |
|
189 |
Values _unpinned_constants; |
|
190 |
||
191 |
friend class PhiResolver; |
|
192 |
||
193 |
// unified bailout support |
|
194 |
void bailout(const char* msg) const { compilation()->bailout(msg); } |
|
195 |
bool bailed_out() const { return compilation()->bailed_out(); } |
|
196 |
||
197 |
void block_do_prolog(BlockBegin* block); |
|
198 |
void block_do_epilog(BlockBegin* block); |
|
199 |
||
200 |
// register allocation |
|
201 |
LIR_Opr rlock(Value instr); // lock a free register |
|
202 |
LIR_Opr rlock_result(Value instr); |
|
203 |
LIR_Opr rlock_result(Value instr, BasicType type); |
|
204 |
LIR_Opr rlock_byte(BasicType type); |
|
205 |
LIR_Opr rlock_callee_saved(BasicType type); |
|
206 |
||
207 |
// get a constant into a register and get track of what register was used |
|
208 |
LIR_Opr load_constant(Constant* x); |
|
209 |
LIR_Opr load_constant(LIR_Const* constant); |
|
210 |
||
6453 | 211 |
// Given an immediate value, return an operand usable in logical ops. |
212 |
LIR_Opr load_immediate(int x, BasicType type); |
|
213 |
||
1 | 214 |
void set_result(Value x, LIR_Opr opr) { |
215 |
assert(opr->is_valid(), "must set to valid value"); |
|
216 |
assert(x->operand()->is_illegal(), "operand should never change"); |
|
217 |
assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register"); |
|
218 |
x->set_operand(opr); |
|
219 |
assert(opr == x->operand(), "must be"); |
|
220 |
if (opr->is_virtual()) { |
|
221 |
_instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL); |
|
222 |
} |
|
223 |
} |
|
224 |
void set_no_result(Value x) { assert(!x->has_uses(), "can't have use"); x->clear_operand(); } |
|
225 |
||
226 |
friend class LIRItem; |
|
227 |
||
228 |
LIR_Opr round_item(LIR_Opr opr); |
|
229 |
LIR_Opr force_to_spill(LIR_Opr value, BasicType t); |
|
230 |
||
231 |
PhiResolverState& resolver_state() { return _resolver_state; } |
|
232 |
||
233 |
void move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val); |
|
234 |
void move_to_phi(ValueStack* cur_state); |
|
235 |
||
236 |
// code emission |
|
237 |
void do_ArithmeticOp_Long (ArithmeticOp* x); |
|
238 |
void do_ArithmeticOp_Int (ArithmeticOp* x); |
|
239 |
void do_ArithmeticOp_FPU (ArithmeticOp* x); |
|
240 |
||
241 |
// platform dependent |
|
242 |
LIR_Opr getThreadPointer(); |
|
243 |
||
244 |
void do_RegisterFinalizer(Intrinsic* x); |
|
12949 | 245 |
void do_isInstance(Intrinsic* x); |
36552 | 246 |
void do_isPrimitive(Intrinsic* x); |
1 | 247 |
void do_getClass(Intrinsic* x); |
248 |
void do_currentThread(Intrinsic* x); |
|
41323 | 249 |
void do_FmaIntrinsic(Intrinsic* x); |
1 | 250 |
void do_MathIntrinsic(Intrinsic* x); |
33465 | 251 |
void do_LibmIntrinsic(Intrinsic* x); |
1 | 252 |
void do_ArrayCopy(Intrinsic* x); |
253 |
void do_CompareAndSwap(Intrinsic* x, ValueType* type); |
|
254 |
void do_NIOCheckIndex(Intrinsic* x); |
|
255 |
void do_FPIntrinsics(Intrinsic* x); |
|
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8065
diff
changeset
|
256 |
void do_Reference_get(Intrinsic* x); |
18507
61bfc8995bb3
7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents:
17011
diff
changeset
|
257 |
void do_update_CRC32(Intrinsic* x); |
38237
d972e3a2df53
8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents:
38031
diff
changeset
|
258 |
void do_update_CRC32C(Intrinsic* x); |
38238
1bbcc430c78d
8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents:
38237
diff
changeset
|
259 |
void do_vectorizedMismatch(Intrinsic* x); |
1 | 260 |
|
261 |
LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info); |
|
262 |
LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info); |
|
263 |
||
264 |
// convenience functions |
|
265 |
LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info); |
|
266 |
LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info); |
|
267 |
||
268 |
// GC Barriers |
|
269 |
||
270 |
// generic interface |
|
271 |
||
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8065
diff
changeset
|
272 |
void pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val, bool do_load, bool patch, CodeEmitInfo* info); |
1 | 273 |
void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); |
274 |
||
275 |
// specific implementations |
|
1374 | 276 |
// pre barriers |
277 |
||
9176
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8065
diff
changeset
|
278 |
void G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val, |
42d9d1010f38
7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents:
8065
diff
changeset
|
279 |
bool do_load, bool patch, CodeEmitInfo* info); |
1 | 280 |
|
281 |
// post barriers |
|
282 |
||
1374 | 283 |
void G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); |
1 | 284 |
void CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val); |
29474
81a5c5330d08
8072383: resolve conflicts between open and closed ports
dlong
parents:
28954
diff
changeset
|
285 |
#ifdef CARDTABLEMODREF_POST_BARRIER_HELPER |
81a5c5330d08
8072383: resolve conflicts between open and closed ports
dlong
parents:
28954
diff
changeset
|
286 |
void CardTableModRef_post_barrier_helper(LIR_OprDesc* addr, LIR_Const* card_table_base); |
81a5c5330d08
8072383: resolve conflicts between open and closed ports
dlong
parents:
28954
diff
changeset
|
287 |
#endif |
1 | 288 |
|
289 |
||
290 |
static LIR_Opr result_register_for(ValueType* type, bool callee = false); |
|
291 |
||
292 |
ciObject* get_jobject_constant(Value value); |
|
293 |
||
294 |
LIRItemList* invoke_visit_arguments(Invoke* x); |
|
295 |
void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list); |
|
296 |
||
297 |
void trace_block_entry(BlockBegin* block); |
|
298 |
||
299 |
// volatile field operations are never patchable because a klass |
|
300 |
// must be loaded to know it's volatile which means that the offset |
|
301 |
// it always known as well. |
|
302 |
void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info); |
|
303 |
void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info); |
|
304 |
||
305 |
void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile); |
|
306 |
void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile); |
|
307 |
||
308 |
void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args); |
|
309 |
||
6453 | 310 |
void increment_counter(address counter, BasicType type, int step = 1); |
1 | 311 |
void increment_counter(LIR_Address* addr, int step = 1); |
312 |
||
313 |
// is_strictfp is only needed for mul and div (and only generates different code on i486) |
|
314 |
void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL); |
|
315 |
// machine dependent. returns true if it emitted code for the multiply |
|
45632
e56cfcaea55c
8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents:
42063
diff
changeset
|
316 |
bool strength_reduce_multiply(LIR_Opr left, jint constant, LIR_Opr result, LIR_Opr tmp); |
1 | 317 |
|
318 |
void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes); |
|
319 |
||
24933
c16c7a4ac386
8031994: java/lang/Character/CheckProp test times out
rbackman
parents:
24442
diff
changeset
|
320 |
void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve = false); |
1 | 321 |
|
322 |
// this loads the length and compares against the index |
|
323 |
void array_range_check (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info); |
|
324 |
// For java.nio.Buffer.checkIndex |
|
325 |
void nio_range_check (LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info); |
|
326 |
||
327 |
void arithmetic_op_int (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp); |
|
328 |
void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL); |
|
329 |
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); |
|
330 |
||
331 |
void shift_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp); |
|
332 |
||
333 |
void logic_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right); |
|
334 |
||
335 |
void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info); |
|
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
336 |
void monitor_exit (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no); |
1 | 337 |
|
24933
c16c7a4ac386
8031994: java/lang/Character/CheckProp test times out
rbackman
parents:
24442
diff
changeset
|
338 |
void new_instance (LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info); |
1 | 339 |
|
340 |
// machine dependent |
|
341 |
void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info); |
|
342 |
void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info); |
|
343 |
void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, LIR_Opr disp, BasicType type, CodeEmitInfo* info); |
|
344 |
||
345 |
void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type); |
|
346 |
||
347 |
// returns a LIR_Address to address an array location. May also |
|
348 |
// emit some code as part of address calculation. If |
|
349 |
// needs_card_mark is true then compute the full address for use by |
|
350 |
// both the store and the card mark. |
|
351 |
LIR_Address* generate_address(LIR_Opr base, |
|
352 |
LIR_Opr index, int shift, |
|
353 |
int disp, |
|
354 |
BasicType type); |
|
355 |
LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) { |
|
356 |
return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type); |
|
357 |
} |
|
358 |
LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark); |
|
359 |
||
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
360 |
// the helper for generate_address |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
361 |
void add_large_constant(LIR_Opr src, int c, LIR_Opr dest); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
362 |
|
1 | 363 |
// machine preferences and characteristics |
42063
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
364 |
bool can_inline_as_constant(Value i S390_ONLY(COMMA int bits = 20)) const; |
1 | 365 |
bool can_inline_as_constant(LIR_Const* c) const; |
366 |
bool can_store_as_constant(Value i, BasicType type) const; |
|
367 |
||
368 |
LIR_Opr safepoint_poll_register(); |
|
6453 | 369 |
|
370 |
void profile_branch(If* if_instr, If::Condition cond); |
|
371 |
void increment_event_counter_impl(CodeEmitInfo* info, |
|
372 |
ciMethod *method, int frequency, |
|
373 |
int bci, bool backedge, bool notify); |
|
374 |
void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge); |
|
375 |
void increment_invocation_counter(CodeEmitInfo *info) { |
|
376 |
if (compilation()->count_invocations()) { |
|
377 |
increment_event_counter(info, InvocationEntryBci, false); |
|
378 |
} |
|
379 |
} |
|
380 |
void increment_backedge_counter(CodeEmitInfo* info, int bci) { |
|
381 |
if (compilation()->count_backedges()) { |
|
382 |
increment_event_counter(info, bci, true); |
|
383 |
} |
|
1 | 384 |
} |
24442
4d4ae31dea26
8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents:
21579
diff
changeset
|
385 |
void decrement_age(CodeEmitInfo* info); |
1 | 386 |
CodeEmitInfo* state_for(Instruction* x, ValueStack* state, bool ignore_xhandler = false); |
387 |
CodeEmitInfo* state_for(Instruction* x); |
|
388 |
||
389 |
// allocates a virtual register for this instruction if |
|
390 |
// one isn't already allocated. Only for Phi and Local. |
|
391 |
LIR_Opr operand_for_instruction(Instruction *x); |
|
392 |
||
393 |
void set_block(BlockBegin* block) { _block = block; } |
|
394 |
||
395 |
void block_prolog(BlockBegin* block); |
|
396 |
void block_epilog(BlockBegin* block); |
|
397 |
||
398 |
void do_root (Instruction* instr); |
|
399 |
void walk (Instruction* instr); |
|
400 |
||
401 |
void bind_block_entry(BlockBegin* block); |
|
402 |
void start_block(BlockBegin* block); |
|
403 |
||
404 |
LIR_Opr new_register(BasicType type); |
|
405 |
LIR_Opr new_register(Value value) { return new_register(as_BasicType(value->type())); } |
|
406 |
LIR_Opr new_register(ValueType* type) { return new_register(as_BasicType(type)); } |
|
407 |
||
408 |
// returns a register suitable for doing pointer math |
|
409 |
LIR_Opr new_pointer_register() { |
|
410 |
#ifdef _LP64 |
|
411 |
return new_register(T_LONG); |
|
412 |
#else |
|
413 |
return new_register(T_INT); |
|
414 |
#endif |
|
415 |
} |
|
416 |
||
417 |
static LIR_Condition lir_cond(If::Condition cond) { |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
33089
diff
changeset
|
418 |
LIR_Condition l = lir_cond_unknown; |
1 | 419 |
switch (cond) { |
420 |
case If::eql: l = lir_cond_equal; break; |
|
421 |
case If::neq: l = lir_cond_notEqual; break; |
|
422 |
case If::lss: l = lir_cond_less; break; |
|
423 |
case If::leq: l = lir_cond_lessEqual; break; |
|
424 |
case If::geq: l = lir_cond_greaterEqual; break; |
|
425 |
case If::gtr: l = lir_cond_greater; break; |
|
16611 | 426 |
case If::aeq: l = lir_cond_aboveEqual; break; |
427 |
case If::beq: l = lir_cond_belowEqual; break; |
|
33589
7cbd1b2c139b
8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents:
33089
diff
changeset
|
428 |
default: fatal("You must pass valid If::Condition"); |
1 | 429 |
}; |
430 |
return l; |
|
431 |
} |
|
432 |
||
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
433 |
#ifdef __SOFTFP__ |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
434 |
void do_soft_float_compare(If *x); |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
435 |
#endif // __SOFTFP__ |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
436 |
|
1 | 437 |
void init(); |
438 |
||
439 |
SwitchRangeArray* create_lookup_ranges(TableSwitch* x); |
|
440 |
SwitchRangeArray* create_lookup_ranges(LookupSwitch* x); |
|
441 |
void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux); |
|
442 |
||
40899
d7140c75c2c6
8163589: Add back class id intrinsic method for event based tracing
rehn
parents:
38241
diff
changeset
|
443 |
#ifdef TRACE_HAVE_INTRINSICS |
d7140c75c2c6
8163589: Add back class id intrinsic method for event based tracing
rehn
parents:
38241
diff
changeset
|
444 |
void do_ClassIDIntrinsic(Intrinsic* x); |
42037
6269c5b5b651
8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents:
41330
diff
changeset
|
445 |
void do_getBufferWriter(Intrinsic* x); |
40899
d7140c75c2c6
8163589: Add back class id intrinsic method for event based tracing
rehn
parents:
38241
diff
changeset
|
446 |
#endif |
d7140c75c2c6
8163589: Add back class id intrinsic method for event based tracing
rehn
parents:
38241
diff
changeset
|
447 |
|
35109
92535200db7d
8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents:
34201
diff
changeset
|
448 |
void do_RuntimeCall(address routine, Intrinsic* x); |
36384 | 449 |
|
21579
c396d68f3e48
8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
21095
diff
changeset
|
450 |
ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k, |
c396d68f3e48
8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
21095
diff
changeset
|
451 |
Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k, |
c396d68f3e48
8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
21095
diff
changeset
|
452 |
ciKlass* callee_signature_k); |
20702
bbe0fcde6e13
8023657: New type profiling points: arguments to call
roland
parents:
18507
diff
changeset
|
453 |
void profile_arguments(ProfileCall* x); |
21095
1a04f7b3946e
8026251: New type profiling points: parameters to methods
roland
parents:
20709
diff
changeset
|
454 |
void profile_parameters(Base* x); |
1a04f7b3946e
8026251: New type profiling points: parameters to methods
roland
parents:
20709
diff
changeset
|
455 |
void profile_parameters_at_call(ProfileCall* x); |
37480 | 456 |
LIR_Opr maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info); |
12377
ae6def2813e0
7160570: Intrinsification support for tracing framework
rbackman
parents:
11886
diff
changeset
|
457 |
|
1 | 458 |
public: |
459 |
Compilation* compilation() const { return _compilation; } |
|
460 |
FrameMap* frame_map() const { return _compilation->frame_map(); } |
|
461 |
ciMethod* method() const { return _method; } |
|
462 |
BlockBegin* block() const { return _block; } |
|
463 |
IRScope* scope() const { return block()->scope(); } |
|
464 |
||
465 |
int max_virtual_register_number() const { return _virtual_register_number; } |
|
466 |
||
467 |
void block_do(BlockBegin* block); |
|
468 |
||
469 |
// Flags that can be set on vregs |
|
470 |
enum VregFlag { |
|
471 |
must_start_in_memory = 0 // needs to be assigned a memory location at beginning, but may then be loaded in a register |
|
472 |
, callee_saved = 1 // must be in a callee saved register |
|
473 |
, byte_reg = 2 // must be in a byte register |
|
474 |
, num_vreg_flags |
|
475 |
||
476 |
}; |
|
477 |
||
478 |
LIRGenerator(Compilation* compilation, ciMethod* method) |
|
479 |
: _compilation(compilation) |
|
480 |
, _method(method) |
|
481 |
, _virtual_register_number(LIR_OprDesc::vreg_base) |
|
38177 | 482 |
, _vreg_flags(num_vreg_flags) { |
1 | 483 |
init(); |
484 |
} |
|
485 |
||
486 |
// for virtual registers, maps them back to Phi's or Local's |
|
487 |
Instruction* instruction_for_opr(LIR_Opr opr); |
|
488 |
Instruction* instruction_for_vreg(int reg_num); |
|
489 |
||
490 |
void set_vreg_flag (int vreg_num, VregFlag f); |
|
491 |
bool is_vreg_flag_set(int vreg_num, VregFlag f); |
|
492 |
void set_vreg_flag (LIR_Opr opr, VregFlag f) { set_vreg_flag(opr->vreg_number(), f); } |
|
493 |
bool is_vreg_flag_set(LIR_Opr opr, VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); } |
|
494 |
||
495 |
// statics |
|
496 |
static LIR_Opr exceptionOopOpr(); |
|
497 |
static LIR_Opr exceptionPcOpr(); |
|
498 |
static LIR_Opr divInOpr(); |
|
499 |
static LIR_Opr divOutOpr(); |
|
500 |
static LIR_Opr remOutOpr(); |
|
42063
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
501 |
#ifdef S390 |
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
502 |
// On S390 we can do ldiv, lrem without RT call. |
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
503 |
static LIR_Opr ldivInOpr(); |
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
504 |
static LIR_Opr ldivOutOpr(); |
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
505 |
static LIR_Opr lremOutOpr(); |
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
506 |
#endif |
1 | 507 |
static LIR_Opr shiftCountOpr(); |
34201
2de6f3566659
8138895: C1: PPC64 Port needs special register for Locks in synchronization code
mdoerr
parents:
33626
diff
changeset
|
508 |
LIR_Opr syncLockOpr(); |
1 | 509 |
LIR_Opr syncTempOpr(); |
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
510 |
LIR_Opr atomicLockOpr(); |
1 | 511 |
|
512 |
// returns a register suitable for saving the thread in a |
|
513 |
// call_runtime_leaf if one is needed. |
|
514 |
LIR_Opr getThreadTemp(); |
|
515 |
||
516 |
// visitor functionality |
|
517 |
virtual void do_Phi (Phi* x); |
|
518 |
virtual void do_Local (Local* x); |
|
519 |
virtual void do_Constant (Constant* x); |
|
520 |
virtual void do_LoadField (LoadField* x); |
|
521 |
virtual void do_StoreField (StoreField* x); |
|
522 |
virtual void do_ArrayLength (ArrayLength* x); |
|
523 |
virtual void do_LoadIndexed (LoadIndexed* x); |
|
524 |
virtual void do_StoreIndexed (StoreIndexed* x); |
|
525 |
virtual void do_NegateOp (NegateOp* x); |
|
526 |
virtual void do_ArithmeticOp (ArithmeticOp* x); |
|
527 |
virtual void do_ShiftOp (ShiftOp* x); |
|
528 |
virtual void do_LogicOp (LogicOp* x); |
|
529 |
virtual void do_CompareOp (CompareOp* x); |
|
530 |
virtual void do_IfOp (IfOp* x); |
|
531 |
virtual void do_Convert (Convert* x); |
|
532 |
virtual void do_NullCheck (NullCheck* x); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
12957
diff
changeset
|
533 |
virtual void do_TypeCast (TypeCast* x); |
1 | 534 |
virtual void do_Invoke (Invoke* x); |
535 |
virtual void do_NewInstance (NewInstance* x); |
|
536 |
virtual void do_NewTypeArray (NewTypeArray* x); |
|
537 |
virtual void do_NewObjectArray (NewObjectArray* x); |
|
538 |
virtual void do_NewMultiArray (NewMultiArray* x); |
|
539 |
virtual void do_CheckCast (CheckCast* x); |
|
540 |
virtual void do_InstanceOf (InstanceOf* x); |
|
541 |
virtual void do_MonitorEnter (MonitorEnter* x); |
|
542 |
virtual void do_MonitorExit (MonitorExit* x); |
|
543 |
virtual void do_Intrinsic (Intrinsic* x); |
|
544 |
virtual void do_BlockBegin (BlockBegin* x); |
|
545 |
virtual void do_Goto (Goto* x); |
|
546 |
virtual void do_If (If* x); |
|
547 |
virtual void do_IfInstanceOf (IfInstanceOf* x); |
|
548 |
virtual void do_TableSwitch (TableSwitch* x); |
|
549 |
virtual void do_LookupSwitch (LookupSwitch* x); |
|
550 |
virtual void do_Return (Return* x); |
|
551 |
virtual void do_Throw (Throw* x); |
|
552 |
virtual void do_Base (Base* x); |
|
553 |
virtual void do_OsrEntry (OsrEntry* x); |
|
554 |
virtual void do_ExceptionObject(ExceptionObject* x); |
|
555 |
virtual void do_RoundFP (RoundFP* x); |
|
556 |
virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); |
|
557 |
virtual void do_UnsafePutRaw (UnsafePutRaw* x); |
|
558 |
virtual void do_UnsafeGetObject(UnsafeGetObject* x); |
|
559 |
virtual void do_UnsafePutObject(UnsafePutObject* x); |
|
13886
8d82c4dfa722
7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement()
roland
parents:
13728
diff
changeset
|
560 |
virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x); |
1 | 561 |
virtual void do_ProfileCall (ProfileCall* x); |
20709
034be898bf04
8026054: New type profiling points: type of return values at calls
roland
parents:
20702
diff
changeset
|
562 |
virtual void do_ProfileReturnType (ProfileReturnType* x); |
6453 | 563 |
virtual void do_ProfileInvoke (ProfileInvoke* x); |
8065
7ca689ce3d32
6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents:
7397
diff
changeset
|
564 |
virtual void do_RuntimeCall (RuntimeCall* x); |
11886
feebf5c9f40c
7120481: storeStore barrier in constructor with final field
jiangli
parents:
9176
diff
changeset
|
565 |
virtual void do_MemBar (MemBar* x); |
16611 | 566 |
virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); |
17011
def8879c5b81
8011648: C1: optimized build is broken after 7153771
roland
parents:
16611
diff
changeset
|
567 |
#ifdef ASSERT |
16611 | 568 |
virtual void do_Assert (Assert* x); |
17011
def8879c5b81
8011648: C1: optimized build is broken after 7153771
roland
parents:
16611
diff
changeset
|
569 |
#endif |
29474
81a5c5330d08
8072383: resolve conflicts between open and closed ports
dlong
parents:
28954
diff
changeset
|
570 |
|
81a5c5330d08
8072383: resolve conflicts between open and closed ports
dlong
parents:
28954
diff
changeset
|
571 |
#ifdef C1_LIRGENERATOR_MD_HPP |
81a5c5330d08
8072383: resolve conflicts between open and closed ports
dlong
parents:
28954
diff
changeset
|
572 |
#include C1_LIRGENERATOR_MD_HPP |
81a5c5330d08
8072383: resolve conflicts between open and closed ports
dlong
parents:
28954
diff
changeset
|
573 |
#endif |
1 | 574 |
}; |
575 |
||
576 |
||
577 |
class LIRItem: public CompilationResourceObj { |
|
578 |
private: |
|
579 |
Value _value; |
|
580 |
LIRGenerator* _gen; |
|
581 |
LIR_Opr _result; |
|
582 |
bool _destroys_register; |
|
583 |
LIR_Opr _new_result; |
|
584 |
||
585 |
LIRGenerator* gen() const { return _gen; } |
|
586 |
||
587 |
public: |
|
588 |
LIRItem(Value value, LIRGenerator* gen) { |
|
589 |
_destroys_register = false; |
|
590 |
_gen = gen; |
|
591 |
set_instruction(value); |
|
592 |
} |
|
593 |
||
594 |
LIRItem(LIRGenerator* gen) { |
|
595 |
_destroys_register = false; |
|
596 |
_gen = gen; |
|
597 |
_result = LIR_OprFact::illegalOpr; |
|
598 |
set_instruction(NULL); |
|
599 |
} |
|
600 |
||
601 |
void set_instruction(Value value) { |
|
602 |
_value = value; |
|
603 |
_result = LIR_OprFact::illegalOpr; |
|
604 |
if (_value != NULL) { |
|
605 |
_gen->walk(_value); |
|
606 |
_result = _value->operand(); |
|
607 |
} |
|
608 |
_new_result = LIR_OprFact::illegalOpr; |
|
609 |
} |
|
610 |
||
611 |
Value value() const { return _value; } |
|
612 |
ValueType* type() const { return value()->type(); } |
|
613 |
LIR_Opr result() { |
|
614 |
assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()), |
|
615 |
"shouldn't use set_destroys_register with physical regsiters"); |
|
616 |
if (_destroys_register && _result->is_register()) { |
|
617 |
if (_new_result->is_illegal()) { |
|
618 |
_new_result = _gen->new_register(type()); |
|
619 |
gen()->lir()->move(_result, _new_result); |
|
620 |
} |
|
621 |
return _new_result; |
|
622 |
} else { |
|
623 |
return _result; |
|
624 |
} |
|
625 |
return _result; |
|
626 |
} |
|
627 |
||
628 |
void set_result(LIR_Opr opr); |
|
629 |
||
630 |
void load_item(); |
|
631 |
void load_byte_item(); |
|
42063
dca9294d9f59
8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents:
42037
diff
changeset
|
632 |
void load_nonconstant(S390_ONLY(int bits = 20)); |
1 | 633 |
// load any values which can't be expressed as part of a single store instruction |
634 |
void load_for_store(BasicType store_type); |
|
635 |
void load_item_force(LIR_Opr reg); |
|
636 |
||
637 |
void dont_load_item() { |
|
638 |
// do nothing |
|
639 |
} |
|
640 |
||
641 |
void set_destroys_register() { |
|
642 |
_destroys_register = true; |
|
643 |
} |
|
644 |
||
645 |
bool is_constant() const { return value()->as_Constant() != NULL; } |
|
646 |
bool is_stack() { return result()->is_stack(); } |
|
647 |
bool is_register() { return result()->is_register(); } |
|
648 |
||
649 |
ciObject* get_jobject_constant() const; |
|
650 |
jint get_jint_constant() const; |
|
651 |
jlong get_jlong_constant() const; |
|
652 |
jfloat get_jfloat_constant() const; |
|
653 |
jdouble get_jdouble_constant() const; |
|
654 |
jint get_address_constant() const; |
|
655 |
}; |
|
7397 | 656 |
|
657 |
#endif // SHARE_VM_C1_C1_LIRGENERATOR_HPP |