< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.hpp

Print this page

152 
153 // only the classes below belong in the same file
154 class LIRGenerator: public InstructionVisitor, public BlockClosure {
155  // LIRGenerator should never get instatiated on the heap.
156  private:
157   void* operator new(size_t size) throw();
158   void* operator new[](size_t size) throw();
159   void operator delete(void* p) { ShouldNotReachHere(); }
160   void operator delete[](void* p) { ShouldNotReachHere(); }
161 
162   Compilation*  _compilation;
163   ciMethod*     _method;    // method that we are compiling
164   PhiResolverState  _resolver_state;
165   BlockBegin*   _block;
166   int           _virtual_register_number;
167 #ifdef ASSERT
168   Values        _instruction_for_operand;
169 #endif
170   BitMap2D      _vreg_flags; // flags which can be set on a per-vreg basis
171   LIR_List*     _lir;

172 
173   LIRGenerator* gen() {
174     return this;
175   }
176 
177   void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN;
178 
179  public:
180 #ifdef ASSERT
181   LIR_List* lir(const char * file, int line) const {
182     _lir->set_file_and_line(file, line);
183     return _lir;
184   }
185 #endif
186   LIR_List* lir() const {
187     return _lir;
188   }
189 
190  private:
191   // a simple cache of constants used within a block
192   GrowableArray<LIR_Const*>       _constants;
193   LIR_OprList                     _reg_for_constants;
194   Values                          _unpinned_constants;
195 
196   friend class PhiResolver;
197 

198  public:
199   // unified bailout support
200   void bailout(const char* msg) const            { compilation()->bailout(msg); }
201   bool bailed_out() const                        { return compilation()->bailed_out(); }
202 
203   void block_do_prolog(BlockBegin* block);
204   void block_do_epilog(BlockBegin* block);
205 
206   // register allocation
207   LIR_Opr rlock(Value instr);                      // lock a free register
208   LIR_Opr rlock_result(Value instr);
209   LIR_Opr rlock_result(Value instr, BasicType type);
210   LIR_Opr rlock_byte(BasicType type);
211   LIR_Opr rlock_callee_saved(BasicType type);
212 
213   // get a constant into a register and get track of what register was used
214   LIR_Opr load_constant(Constant* x);
215   LIR_Opr load_constant(LIR_Const* constant);
216 

217   // Given an immediate value, return an operand usable in logical ops.
218   LIR_Opr load_immediate(jlong x, BasicType type);
219 
220   void  set_result(Value x, LIR_Opr opr)           {
221     assert(opr->is_valid(), "must set to valid value");
222     assert(x->operand()->is_illegal(), "operand should never change");
223     assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register");
224     x->set_operand(opr);
225     assert(opr == x->operand(), "must be");
226 #ifdef ASSERT
227     if (opr->is_virtual()) {
228       _instruction_for_operand.at_put_grow(opr->vreg_number(), x, nullptr);
229     }
230 #endif
231   }
232   void  set_no_result(Value x)                     { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
233 
234   friend class LIRItem;
235 
236   LIR_Opr force_to_spill(LIR_Opr value, BasicType t);

255   void do_isInstance(Intrinsic* x);
256   void do_getClass(Intrinsic* x);
257   void do_getObjectSize(Intrinsic* x);
258   void do_currentCarrierThread(Intrinsic* x);
259   void do_scopedValueCache(Intrinsic* x);
260   void do_vthread(Intrinsic* x);
261   void do_JavaThreadField(Intrinsic* x, ByteSize offset);
262   void do_FmaIntrinsic(Intrinsic* x);
263   void do_MathIntrinsic(Intrinsic* x);
264   void do_LibmIntrinsic(Intrinsic* x);
265   void do_ArrayCopy(Intrinsic* x);
266   void do_CompareAndSwap(Intrinsic* x, ValueType* type);
267   void do_PreconditionsCheckIndex(Intrinsic* x, BasicType type);
268   void do_FPIntrinsics(Intrinsic* x);
269   void do_Reference_get(Intrinsic* x);
270   void do_update_CRC32(Intrinsic* x);
271   void do_update_CRC32C(Intrinsic* x);
272   void do_vectorizedMismatch(Intrinsic* x);
273   void do_blackhole(Intrinsic* x);
274 













275  public:
276   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
277   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
278 
279   // convenience functions
280   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
281   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
282 
283   // Access API
284 
285  private:
286   BarrierSetC1 *_barrier_set;
287 
288  public:
289   void access_store_at(DecoratorSet decorators, BasicType type,
290                        LIRItem& base, LIR_Opr offset, LIR_Opr value,
291                        CodeEmitInfo* patch_info = nullptr, CodeEmitInfo* store_emit_info = nullptr);
292 
293   void access_load_at(DecoratorSet decorators, BasicType type,
294                       LIRItem& base, LIR_Opr offset, LIR_Opr result,
295                       CodeEmitInfo* patch_info = nullptr, CodeEmitInfo* load_emit_info = nullptr);
296 
297   void access_load(DecoratorSet decorators, BasicType type,
298                    LIR_Opr addr, LIR_Opr result);
299 
300   LIR_Opr access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,
301                                    LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value);
302 
303   LIR_Opr access_atomic_xchg_at(DecoratorSet decorators, BasicType type,
304                                 LIRItem& base, LIRItem& offset, LIRItem& value);
305 
306   LIR_Opr access_atomic_add_at(DecoratorSet decorators, BasicType type,
307                                LIRItem& base, LIRItem& offset, LIRItem& value);
308 
309   // These need to guarantee JMM volatile semantics are preserved on each platform
310   // and requires one implementation per architecture.
311   LIR_Opr atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value);
312   LIR_Opr atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& new_value);
313   LIR_Opr atomic_add(BasicType type, LIR_Opr addr, LIRItem& new_value);
314 
315 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
316   virtual void CardTableBarrierSet_post_barrier_helper(LIR_Opr addr, LIR_Const* card_table_base);
317 #endif
318 
319   // specific implementations
320   void array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci);
321 
322   static LIR_Opr result_register_for(ValueType* type, bool callee = false);
323 
324   ciObject* get_jobject_constant(Value value);
325 
326   LIRItemList* invoke_visit_arguments(Invoke* x);
327   void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list);
328 
329   void trace_block_entry(BlockBegin* block);
330 
331   // volatile field operations are never patchable because a klass
332   // must be loaded to know it's volatile which means that the offset
333   // it always known as well.
334   void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info);
335   void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info);
336 
337   void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile);
338   void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile);
339 
340   void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args);
341 
342   void increment_counter(address counter, BasicType type, int step = 1);
343   void increment_counter(LIR_Address* addr, int step = 1);
344 
345   void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp, CodeEmitInfo* info = nullptr);
346   // machine dependent.  returns true if it emitted code for the multiply
347   bool strength_reduce_multiply(LIR_Opr left, jint constant, LIR_Opr result, LIR_Opr tmp);
348 
349   void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes);
350 
351   void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve = false);
352 
353   // this loads the length and compares against the index
354   void array_range_check          (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info);
355 
356   void arithmetic_op_int  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp);
357   void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = nullptr);
358   void arithmetic_op_fpu  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp = LIR_OprFact::illegalOpr);
359 
360   void shift_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp);
361 
362   void logic_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right);
363 
364   void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info);
365   void monitor_exit  (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no);
366 
367   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);
368 
369   // machine dependent
370   void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
371   void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info);
372 
373   void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type);
374 
375   // returns a LIR_Address to address an array location.  May also
376   // emit some code as part of address calculation.  If
377   // needs_card_mark is true then compute the full address for use by
378   // both the store and the card mark.
379   LIR_Address* generate_address(LIR_Opr base,
380                                 LIR_Opr index, int shift,
381                                 int disp,
382                                 BasicType type);
383   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
384     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
385   }
386   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type);
387 

459     };
460     return l;
461   }
462 
463 #ifdef __SOFTFP__
464   void do_soft_float_compare(If *x);
465 #endif // __SOFTFP__
466 
467   SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
468   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
469   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
470 
471   void do_RuntimeCall(address routine, Intrinsic* x);
472 
473   ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k,
474                         Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k,
475                         ciKlass* callee_signature_k);
476   void profile_arguments(ProfileCall* x);
477   void profile_parameters(Base* x);
478   void profile_parameters_at_call(ProfileCall* x);





479   LIR_Opr mask_boolean(LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info);
480 
481  public:
482   Compilation*  compilation() const              { return _compilation; }
483   FrameMap*     frame_map() const                { return _compilation->frame_map(); }
484   ciMethod*     method() const                   { return _method; }
485   BlockBegin*   block() const                    { return _block; }
486   IRScope*      scope() const                    { return block()->scope(); }
487 
488   int max_virtual_register_number() const        { return _virtual_register_number; }
489 
490   void block_do(BlockBegin* block);
491 
492   // Flags that can be set on vregs
493   enum VregFlag {
494       must_start_in_memory = 0  // needs to be assigned a memory location at beginning, but may then be loaded in a register
495     , callee_saved     = 1    // must be in a callee saved register
496     , byte_reg         = 2    // must be in a byte register
497     , num_vreg_flags
498 
499   };
500 
501   LIRGenerator(Compilation* compilation, ciMethod* method)
502     : _compilation(compilation)
503     , _method(method)
504     , _virtual_register_number(LIR_Opr::vreg_base)
505     , _vreg_flags(num_vreg_flags)

506     , _barrier_set(BarrierSet::barrier_set()->barrier_set_c1()) {
507   }
508 
509 #ifdef ASSERT
510   // for virtual registers, maps them back to Phi's or Local's
511   Instruction* instruction_for_vreg(int reg_num);
512 #endif
513 
514   void set_vreg_flag   (int vreg_num, VregFlag f);
515   bool is_vreg_flag_set(int vreg_num, VregFlag f);
516   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
517   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
518 
519   // statics
520   static LIR_Opr exceptionOopOpr();
521   static LIR_Opr exceptionPcOpr();
522   static LIR_Opr divInOpr();
523   static LIR_Opr divOutOpr();
524   static LIR_Opr remOutOpr();
525 #ifdef S390

567   virtual void do_InstanceOf     (InstanceOf*      x);
568   virtual void do_MonitorEnter   (MonitorEnter*    x);
569   virtual void do_MonitorExit    (MonitorExit*     x);
570   virtual void do_Intrinsic      (Intrinsic*       x);
571   virtual void do_BlockBegin     (BlockBegin*      x);
572   virtual void do_Goto           (Goto*            x);
573   virtual void do_If             (If*              x);
574   virtual void do_TableSwitch    (TableSwitch*     x);
575   virtual void do_LookupSwitch   (LookupSwitch*    x);
576   virtual void do_Return         (Return*          x);
577   virtual void do_Throw          (Throw*           x);
578   virtual void do_Base           (Base*            x);
579   virtual void do_OsrEntry       (OsrEntry*        x);
580   virtual void do_ExceptionObject(ExceptionObject* x);
581   virtual void do_UnsafeGet      (UnsafeGet*       x);
582   virtual void do_UnsafePut      (UnsafePut*       x);
583   virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x);
584   virtual void do_ProfileCall    (ProfileCall*     x);
585   virtual void do_ProfileReturnType (ProfileReturnType* x);
586   virtual void do_ProfileInvoke  (ProfileInvoke*   x);

587   virtual void do_RuntimeCall    (RuntimeCall*     x);
588   virtual void do_MemBar         (MemBar*          x);
589   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x);
590 #ifdef ASSERT
591   virtual void do_Assert         (Assert*          x);
592 #endif
593 
594 #ifdef C1_LIRGENERATOR_MD_HPP
595 #include C1_LIRGENERATOR_MD_HPP
596 #endif
597 };
598 
599 
600 class LIRItem: public CompilationResourceObj {
601  private:
602   Value         _value;
603   LIRGenerator* _gen;
604   LIR_Opr       _result;
605   bool          _destroys_register;
606   LIR_Opr       _new_result;

152 
153 // only the classes below belong in the same file
154 class LIRGenerator: public InstructionVisitor, public BlockClosure {
155  // LIRGenerator should never get instatiated on the heap.
156  private:
157   void* operator new(size_t size) throw();
158   void* operator new[](size_t size) throw();
159   void operator delete(void* p) { ShouldNotReachHere(); }
160   void operator delete[](void* p) { ShouldNotReachHere(); }
161 
162   Compilation*  _compilation;
163   ciMethod*     _method;    // method that we are compiling
164   PhiResolverState  _resolver_state;
165   BlockBegin*   _block;
166   int           _virtual_register_number;
167 #ifdef ASSERT
168   Values        _instruction_for_operand;
169 #endif
170   BitMap2D      _vreg_flags; // flags which can be set on a per-vreg basis
171   LIR_List*     _lir;
172   bool          _in_conditional_code;
173 
174   LIRGenerator* gen() {
175     return this;
176   }
177 
178   void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN;
179 
180  public:
181 #ifdef ASSERT
182   LIR_List* lir(const char * file, int line) const {
183     _lir->set_file_and_line(file, line);
184     return _lir;
185   }
186 #endif
187   LIR_List* lir() const {
188     return _lir;
189   }
190 
191  private:
192   // a simple cache of constants used within a block
193   GrowableArray<LIR_Const*>       _constants;
194   LIR_OprList                     _reg_for_constants;
195   Values                          _unpinned_constants;
196 
197   friend class PhiResolver;
198 
199   void set_in_conditional_code(bool v);
200  public:
201   // unified bailout support
202   void bailout(const char* msg) const            { compilation()->bailout(msg); }
203   bool bailed_out() const                        { return compilation()->bailed_out(); }
204 
205   void block_do_prolog(BlockBegin* block);
206   void block_do_epilog(BlockBegin* block);
207 
208   // register allocation
209   LIR_Opr rlock(Value instr);                      // lock a free register
210   LIR_Opr rlock_result(Value instr);
211   LIR_Opr rlock_result(Value instr, BasicType type);
212   LIR_Opr rlock_byte(BasicType type);
213   LIR_Opr rlock_callee_saved(BasicType type);
214 
215   // get a constant into a register and get track of what register was used
216   LIR_Opr load_constant(Constant* x);
217   LIR_Opr load_constant(LIR_Const* constant);
218 
219   bool in_conditional_code() { return _in_conditional_code; }
220   // Given an immediate value, return an operand usable in logical ops.
221   LIR_Opr load_immediate(jlong x, BasicType type);
222 
223   void  set_result(Value x, LIR_Opr opr)           {
224     assert(opr->is_valid(), "must set to valid value");
225     assert(x->operand()->is_illegal(), "operand should never change");
226     assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register");
227     x->set_operand(opr);
228     assert(opr == x->operand(), "must be");
229 #ifdef ASSERT
230     if (opr->is_virtual()) {
231       _instruction_for_operand.at_put_grow(opr->vreg_number(), x, nullptr);
232     }
233 #endif
234   }
235   void  set_no_result(Value x)                     { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
236 
237   friend class LIRItem;
238 
239   LIR_Opr force_to_spill(LIR_Opr value, BasicType t);

258   void do_isInstance(Intrinsic* x);
259   void do_getClass(Intrinsic* x);
260   void do_getObjectSize(Intrinsic* x);
261   void do_currentCarrierThread(Intrinsic* x);
262   void do_scopedValueCache(Intrinsic* x);
263   void do_vthread(Intrinsic* x);
264   void do_JavaThreadField(Intrinsic* x, ByteSize offset);
265   void do_FmaIntrinsic(Intrinsic* x);
266   void do_MathIntrinsic(Intrinsic* x);
267   void do_LibmIntrinsic(Intrinsic* x);
268   void do_ArrayCopy(Intrinsic* x);
269   void do_CompareAndSwap(Intrinsic* x, ValueType* type);
270   void do_PreconditionsCheckIndex(Intrinsic* x, BasicType type);
271   void do_FPIntrinsics(Intrinsic* x);
272   void do_Reference_get(Intrinsic* x);
273   void do_update_CRC32(Intrinsic* x);
274   void do_update_CRC32C(Intrinsic* x);
275   void do_vectorizedMismatch(Intrinsic* x);
276   void do_blackhole(Intrinsic* x);
277 
278   void access_flat_array(bool is_load, LIRItem& array, LIRItem& index, LIRItem& obj_item, ciField* field = nullptr, int offset = 0);
279   void access_sub_element(LIRItem& array, LIRItem& index, LIR_Opr& result, ciField* field, int sub_offset);
280   LIR_Opr get_and_load_element_address(LIRItem& array, LIRItem& index);
281   bool needs_flat_array_store_check(StoreIndexed* x);
282   void check_flat_array(LIR_Opr array, LIR_Opr value, CodeStub* slow_path);
283   bool needs_null_free_array_store_check(StoreIndexed* x);
284   void check_null_free_array(LIRItem& array, LIRItem& value,  CodeEmitInfo* info);
285   void substitutability_check(IfOp* x, LIRItem& left, LIRItem& right, LIRItem& t_val, LIRItem& f_val);
286   void substitutability_check(If* x, LIRItem& left, LIRItem& right);
287   void substitutability_check_common(Value left_val, Value right_val, LIRItem& left, LIRItem& right,
288                                      LIR_Opr equal_result, LIR_Opr not_equal_result, LIR_Opr result, CodeEmitInfo* info);
289   void init_temps_for_substitutability_check(LIR_Opr& tmp1, LIR_Opr& tmp2);
290 
291  public:
292   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
293   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
294 
295   // convenience functions
296   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
297   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
298 
299   // Access API
300 
301  private:
302   BarrierSetC1 *_barrier_set;
303 
304  public:
305   void access_store_at(DecoratorSet decorators, BasicType type,
306                        LIRItem& base, LIR_Opr offset, LIR_Opr value,
307                        CodeEmitInfo* patch_info = nullptr, CodeEmitInfo* store_emit_info = nullptr, ciInlineKlass* vk = nullptr);
308 
309   void access_load_at(DecoratorSet decorators, BasicType type,
310                       LIRItem& base, LIR_Opr offset, LIR_Opr result,
311                       CodeEmitInfo* patch_info = nullptr, CodeEmitInfo* load_emit_info = nullptr);
312 
313   void access_load(DecoratorSet decorators, BasicType type,
314                    LIR_Opr addr, LIR_Opr result);
315 
316   LIR_Opr access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,
317                                    LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value);
318 
319   LIR_Opr access_atomic_xchg_at(DecoratorSet decorators, BasicType type,
320                                 LIRItem& base, LIRItem& offset, LIRItem& value);
321 
322   LIR_Opr access_atomic_add_at(DecoratorSet decorators, BasicType type,
323                                LIRItem& base, LIRItem& offset, LIRItem& value);
324 
325   // These need to guarantee JMM volatile semantics are preserved on each platform
326   // and requires one implementation per architecture.
327   LIR_Opr atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value);
328   LIR_Opr atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& new_value);
329   LIR_Opr atomic_add(BasicType type, LIR_Opr addr, LIRItem& new_value);
330 
331 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
332   virtual void CardTableBarrierSet_post_barrier_helper(LIR_Opr addr, LIR_Const* card_table_base);
333 #endif
334 
335   // specific implementations
336   void array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci);
337 
338   static LIR_Opr result_register_for(ValueType* type, bool callee = false);
339 
340   ciObject* get_jobject_constant(Value value);
341 
342   LIRItemList* invoke_visit_arguments(Invoke* x);
343   void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list);
344   void invoke_load_one_argument(LIRItem* param, LIR_Opr loc);
345   void trace_block_entry(BlockBegin* block);
346 
347   // volatile field operations are never patchable because a klass
348   // must be loaded to know it's volatile which means that the offset
349   // it always known as well.
350   void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info);
351   void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info);
352 
353   void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile);
354   void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile);
355 
356   void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args);
357 
358   void increment_counter(address counter, BasicType type, int step = 1);
359   void increment_counter(LIR_Address* addr, int step = 1);
360 
361   void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp, CodeEmitInfo* info = nullptr);
362   // machine dependent.  returns true if it emitted code for the multiply
363   bool strength_reduce_multiply(LIR_Opr left, jint constant, LIR_Opr result, LIR_Opr tmp);
364 
365   void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes);
366 
367   void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve = false);
368 
369   // this loads the length and compares against the index
370   void array_range_check          (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info);
371 
372   void arithmetic_op_int  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp);
373   void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = nullptr);
374   void arithmetic_op_fpu  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp = LIR_OprFact::illegalOpr);
375 
376   void shift_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp);
377 
378   void logic_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right);
379 
380   void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info, CodeStub* throw_ie_stub);
381   void monitor_exit  (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no);
382 
383   void new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, bool allow_inline, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info);
384 
385   // machine dependent
386   void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
387   void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info);
388 
389   void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type);
390 
391   // returns a LIR_Address to address an array location.  May also
392   // emit some code as part of address calculation.  If
393   // needs_card_mark is true then compute the full address for use by
394   // both the store and the card mark.
395   LIR_Address* generate_address(LIR_Opr base,
396                                 LIR_Opr index, int shift,
397                                 int disp,
398                                 BasicType type);
399   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
400     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
401   }
402   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type);
403 

475     };
476     return l;
477   }
478 
479 #ifdef __SOFTFP__
480   void do_soft_float_compare(If *x);
481 #endif // __SOFTFP__
482 
483   SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
484   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
485   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
486 
487   void do_RuntimeCall(address routine, Intrinsic* x);
488 
489   ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k,
490                         Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k,
491                         ciKlass* callee_signature_k);
492   void profile_arguments(ProfileCall* x);
493   void profile_parameters(Base* x);
494   void profile_parameters_at_call(ProfileCall* x);
495   void profile_flags(ciMethodData* md, ciProfileData* load_store, int flag, LIR_Condition condition = lir_cond_always);
496   template <class ArrayData> void profile_null_free_array(LIRItem array, ciMethodData* md, ArrayData* load_store);
497   template <class ArrayData> void profile_array_type(AccessIndexed* x, ciMethodData*& md, ArrayData*& load_store);
498   void profile_element_type(Value element, ciMethodData* md, ciArrayLoadData* load_store);
499   bool profile_inline_klass(ciMethodData* md, ciProfileData* data, Value value, int flag);
500   LIR_Opr mask_boolean(LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info);
501 
502  public:
503   Compilation*  compilation() const              { return _compilation; }
504   FrameMap*     frame_map() const                { return _compilation->frame_map(); }
505   ciMethod*     method() const                   { return _method; }
506   BlockBegin*   block() const                    { return _block; }
507   IRScope*      scope() const                    { return block()->scope(); }
508 
509   int max_virtual_register_number() const        { return _virtual_register_number; }
510 
511   void block_do(BlockBegin* block);
512 
513   // Flags that can be set on vregs
514   enum VregFlag {
515       must_start_in_memory = 0  // needs to be assigned a memory location at beginning, but may then be loaded in a register
516     , callee_saved     = 1    // must be in a callee saved register
517     , byte_reg         = 2    // must be in a byte register
518     , num_vreg_flags
519 
520   };
521 
522   LIRGenerator(Compilation* compilation, ciMethod* method)
523     : _compilation(compilation)
524     , _method(method)
525     , _virtual_register_number(LIR_Opr::vreg_base)
526     , _vreg_flags(num_vreg_flags)
527     , _in_conditional_code(false)
528     , _barrier_set(BarrierSet::barrier_set()->barrier_set_c1()) {
529   }
530 
531 #ifdef ASSERT
532   // for virtual registers, maps them back to Phi's or Local's
533   Instruction* instruction_for_vreg(int reg_num);
534 #endif
535 
536   void set_vreg_flag   (int vreg_num, VregFlag f);
537   bool is_vreg_flag_set(int vreg_num, VregFlag f);
538   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
539   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
540 
541   // statics
542   static LIR_Opr exceptionOopOpr();
543   static LIR_Opr exceptionPcOpr();
544   static LIR_Opr divInOpr();
545   static LIR_Opr divOutOpr();
546   static LIR_Opr remOutOpr();
547 #ifdef S390

589   virtual void do_InstanceOf     (InstanceOf*      x);
590   virtual void do_MonitorEnter   (MonitorEnter*    x);
591   virtual void do_MonitorExit    (MonitorExit*     x);
592   virtual void do_Intrinsic      (Intrinsic*       x);
593   virtual void do_BlockBegin     (BlockBegin*      x);
594   virtual void do_Goto           (Goto*            x);
595   virtual void do_If             (If*              x);
596   virtual void do_TableSwitch    (TableSwitch*     x);
597   virtual void do_LookupSwitch   (LookupSwitch*    x);
598   virtual void do_Return         (Return*          x);
599   virtual void do_Throw          (Throw*           x);
600   virtual void do_Base           (Base*            x);
601   virtual void do_OsrEntry       (OsrEntry*        x);
602   virtual void do_ExceptionObject(ExceptionObject* x);
603   virtual void do_UnsafeGet      (UnsafeGet*       x);
604   virtual void do_UnsafePut      (UnsafePut*       x);
605   virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x);
606   virtual void do_ProfileCall    (ProfileCall*     x);
607   virtual void do_ProfileReturnType (ProfileReturnType* x);
608   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
609   virtual void do_ProfileACmpTypes(ProfileACmpTypes* x);
610   virtual void do_RuntimeCall    (RuntimeCall*     x);
611   virtual void do_MemBar         (MemBar*          x);
612   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x);
613 #ifdef ASSERT
614   virtual void do_Assert         (Assert*          x);
615 #endif
616 
617 #ifdef C1_LIRGENERATOR_MD_HPP
618 #include C1_LIRGENERATOR_MD_HPP
619 #endif
620 };
621 
622 
623 class LIRItem: public CompilationResourceObj {
624  private:
625   Value         _value;
626   LIRGenerator* _gen;
627   LIR_Opr       _result;
628   bool          _destroys_register;
629   LIR_Opr       _new_result;
< prev index next >