annotate src/share/vm/c1/c1_LIRGenerator.hpp @ 11080:b800986664f4

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