131
132 void emit_move(LIR_Opr src, LIR_Opr dest);
133 void move_to_temp(LIR_Opr src);
134 void move_temp_to(LIR_Opr dest);
135 void move(ResolveNode* src, ResolveNode* dest);
136
137 LIRGenerator* gen() {
138 return _gen;
139 }
140
141 public:
142 PhiResolver(LIRGenerator* _lir_gen, int max_vregs);
143 ~PhiResolver();
144
145 void move(LIR_Opr src, LIR_Opr dest);
146 };
147
148
149 // only the classes below belong in the same file
150 class LIRGenerator: public InstructionVisitor, public BlockClosure {
151 private:
152 Compilation* _compilation;
153 ciMethod* _method; // method that we are compiling
154 PhiResolverState _resolver_state;
155 BlockBegin* _block;
156 int _virtual_register_number;
157 Values _instruction_for_operand;
158 BitMap2D _vreg_flags; // flags which can be set on a per-vreg basis
159 LIR_List* _lir;
160
161 LIRGenerator* gen() {
162 return this;
163 }
164
165 #ifdef ASSERT
166 LIR_List* lir(const char * file, int line) const {
167 _lir->set_file_and_line(file, line);
168 return _lir;
169 }
170 #endif
171 LIR_List* lir() const {
172 return _lir;
173 }
174
175 // a simple cache of constants used within a block
176 GrowableArray<LIR_Const*> _constants;
177 LIR_OprList _reg_for_constants;
178 Values _unpinned_constants;
179
180 LIR_Const* _card_table_base;
181
182 friend class PhiResolver;
183
184 // unified bailout support
185 void bailout(const char* msg) const { compilation()->bailout(msg); }
186 bool bailed_out() const { return compilation()->bailed_out(); }
187
188 void block_do_prolog(BlockBegin* block);
189 void block_do_epilog(BlockBegin* block);
190
191 // register allocation
192 LIR_Opr rlock(Value instr); // lock a free register
193 LIR_Opr rlock_result(Value instr);
194 LIR_Opr rlock_result(Value instr, BasicType type);
195 LIR_Opr rlock_byte(BasicType type);
196 LIR_Opr rlock_callee_saved(BasicType type);
197
198 // get a constant into a register and get track of what register was used
199 LIR_Opr load_constant(Constant* x);
200 LIR_Opr load_constant(LIR_Const* constant);
201
202 LIR_Const* card_table_base() const { return _card_table_base; }
203
204 void set_result(Value x, LIR_Opr opr) {
205 assert(opr->is_valid(), "must set to valid value");
206 assert(x->operand()->is_illegal(), "operand should never change");
207 assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register");
208 x->set_operand(opr);
209 assert(opr == x->operand(), "must be");
210 if (opr->is_virtual()) {
211 _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL);
212 }
213 }
214 void set_no_result(Value x) { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
215
216 friend class LIRItem;
217
218 LIR_Opr round_item(LIR_Opr opr);
219 LIR_Opr force_to_spill(LIR_Opr value, BasicType t);
220
221 void profile_branch(If* if_instr, If::Condition cond);
222
223 PhiResolverState& resolver_state() { return _resolver_state; }
239 void do_MathIntrinsic(Intrinsic* x);
240 void do_ArrayCopy(Intrinsic* x);
241 void do_CompareAndSwap(Intrinsic* x, ValueType* type);
242 void do_AttemptUpdate(Intrinsic* x);
243 void do_NIOCheckIndex(Intrinsic* x);
244 void do_FPIntrinsics(Intrinsic* x);
245
246 void do_UnsafePrefetch(UnsafePrefetch* x, bool is_store);
247
248 LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
249 LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
250
251 // convenience functions
252 LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
253 LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
254
255 // GC Barriers
256
257 // generic interface
258
259 void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
260
261 // specific implementations
262
263 // post barriers
264
265 void CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
266
267
268 static LIR_Opr result_register_for(ValueType* type, bool callee = false);
269
270 ciObject* get_jobject_constant(Value value);
271
272 LIRItemList* invoke_visit_arguments(Invoke* x);
273 void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list);
274
275 void trace_block_entry(BlockBegin* block);
276
277 // volatile field operations are never patchable because a klass
278 // must be loaded to know it's volatile which means that the offset
279 // it always known as well.
280 void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info);
281 void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info);
282
283 void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile);
284 void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile);
|
131
132 void emit_move(LIR_Opr src, LIR_Opr dest);
133 void move_to_temp(LIR_Opr src);
134 void move_temp_to(LIR_Opr dest);
135 void move(ResolveNode* src, ResolveNode* dest);
136
137 LIRGenerator* gen() {
138 return _gen;
139 }
140
141 public:
142 PhiResolver(LIRGenerator* _lir_gen, int max_vregs);
143 ~PhiResolver();
144
145 void move(LIR_Opr src, LIR_Opr dest);
146 };
147
148
149 // only the classes below belong in the same file
150 class LIRGenerator: public InstructionVisitor, public BlockClosure {
151
152 private:
153 Compilation* _compilation;
154 ciMethod* _method; // method that we are compiling
155 PhiResolverState _resolver_state;
156 BlockBegin* _block;
157 int _virtual_register_number;
158 Values _instruction_for_operand;
159 BitMap2D _vreg_flags; // flags which can be set on a per-vreg basis
160 LIR_List* _lir;
161 BarrierSet* _bs;
162
163 LIRGenerator* gen() {
164 return this;
165 }
166
167 #ifdef ASSERT
168 LIR_List* lir(const char * file, int line) const {
169 _lir->set_file_and_line(file, line);
170 return _lir;
171 }
172 #endif
173 LIR_List* lir() const {
174 return _lir;
175 }
176
177 // a simple cache of constants used within a block
178 GrowableArray<LIR_Const*> _constants;
179 LIR_OprList _reg_for_constants;
180 Values _unpinned_constants;
181
182 friend class PhiResolver;
183
184 // unified bailout support
185 void bailout(const char* msg) const { compilation()->bailout(msg); }
186 bool bailed_out() const { return compilation()->bailed_out(); }
187
188 void block_do_prolog(BlockBegin* block);
189 void block_do_epilog(BlockBegin* block);
190
191 // register allocation
192 LIR_Opr rlock(Value instr); // lock a free register
193 LIR_Opr rlock_result(Value instr);
194 LIR_Opr rlock_result(Value instr, BasicType type);
195 LIR_Opr rlock_byte(BasicType type);
196 LIR_Opr rlock_callee_saved(BasicType type);
197
198 // get a constant into a register and get track of what register was used
199 LIR_Opr load_constant(Constant* x);
200 LIR_Opr load_constant(LIR_Const* constant);
201
202 void set_result(Value x, LIR_Opr opr) {
203 assert(opr->is_valid(), "must set to valid value");
204 assert(x->operand()->is_illegal(), "operand should never change");
205 assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register");
206 x->set_operand(opr);
207 assert(opr == x->operand(), "must be");
208 if (opr->is_virtual()) {
209 _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL);
210 }
211 }
212 void set_no_result(Value x) { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
213
214 friend class LIRItem;
215
216 LIR_Opr round_item(LIR_Opr opr);
217 LIR_Opr force_to_spill(LIR_Opr value, BasicType t);
218
219 void profile_branch(If* if_instr, If::Condition cond);
220
221 PhiResolverState& resolver_state() { return _resolver_state; }
237 void do_MathIntrinsic(Intrinsic* x);
238 void do_ArrayCopy(Intrinsic* x);
239 void do_CompareAndSwap(Intrinsic* x, ValueType* type);
240 void do_AttemptUpdate(Intrinsic* x);
241 void do_NIOCheckIndex(Intrinsic* x);
242 void do_FPIntrinsics(Intrinsic* x);
243
244 void do_UnsafePrefetch(UnsafePrefetch* x, bool is_store);
245
246 LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
247 LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
248
249 // convenience functions
250 LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
251 LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
252
253 // GC Barriers
254
255 // generic interface
256
257 void pre_barrier(LIR_Opr addr_opr, bool patch, CodeEmitInfo* info);
258 void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
259
260 // specific implementations
261 // pre barriers
262
263 void G1SATBCardTableModRef_pre_barrier(LIR_Opr addr_opr, bool patch, CodeEmitInfo* info);
264
265 // post barriers
266
267 void G1SATBCardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
268 void CardTableModRef_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
269
270
271 static LIR_Opr result_register_for(ValueType* type, bool callee = false);
272
273 ciObject* get_jobject_constant(Value value);
274
275 LIRItemList* invoke_visit_arguments(Invoke* x);
276 void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list);
277
278 void trace_block_entry(BlockBegin* block);
279
280 // volatile field operations are never patchable because a klass
281 // must be loaded to know it's volatile which means that the offset
282 // it always known as well.
283 void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info);
284 void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info);
285
286 void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile);
287 void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile);
|