< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.hpp

Print this page

152 };
153 
154 
155 // only the classes below belong in the same file
156 class LIRGenerator: public InstructionVisitor, public BlockClosure {
157  // LIRGenerator should never get instatiated on the heap.
158  private:
159   void* operator new(size_t size) throw();
160   void* operator new[](size_t size) throw();
161   void operator delete(void* p) { ShouldNotReachHere(); }
162   void operator delete[](void* p) { ShouldNotReachHere(); }
163 
164   Compilation*  _compilation;
165   ciMethod*     _method;    // method that we are compiling
166   PhiResolverState  _resolver_state;
167   BlockBegin*   _block;
168   int           _virtual_register_number;
169   Values        _instruction_for_operand;
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(int 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     if (opr->is_virtual()) {
227       _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL);
228     }
229   }
230   void  set_no_result(Value x)                     { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
231 
232   friend class LIRItem;
233 
234   LIR_Opr round_item(LIR_Opr opr);
235   LIR_Opr force_to_spill(LIR_Opr value, BasicType t);
236 

253   void do_RegisterFinalizer(Intrinsic* x);
254   void do_isInstance(Intrinsic* x);
255   void do_isPrimitive(Intrinsic* x);
256   void do_getModifiers(Intrinsic* x);
257   void do_getClass(Intrinsic* x);
258   void do_currentThread(Intrinsic* x);
259   void do_getObjectSize(Intrinsic* x);
260   void do_FmaIntrinsic(Intrinsic* x);
261   void do_MathIntrinsic(Intrinsic* x);
262   void do_LibmIntrinsic(Intrinsic* x);
263   void do_ArrayCopy(Intrinsic* x);
264   void do_CompareAndSwap(Intrinsic* x, ValueType* type);
265   void do_PreconditionsCheckIndex(Intrinsic* x, BasicType type);
266   void do_FPIntrinsics(Intrinsic* x);
267   void do_Reference_get(Intrinsic* x);
268   void do_update_CRC32(Intrinsic* x);
269   void do_update_CRC32C(Intrinsic* x);
270   void do_vectorizedMismatch(Intrinsic* x);
271   void do_blackhole(Intrinsic* x);
272 














273  public:
274   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
275   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
276 
277   // convenience functions
278   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
279   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
280 
281   // Access API
282 
283  private:
284   BarrierSetC1 *_barrier_set;
285 
286  public:
287   void access_store_at(DecoratorSet decorators, BasicType type,
288                        LIRItem& base, LIR_Opr offset, LIR_Opr value,
289                        CodeEmitInfo* patch_info = NULL, CodeEmitInfo* store_emit_info = NULL);
290 
291   void access_load_at(DecoratorSet decorators, BasicType type,
292                       LIRItem& base, LIR_Opr offset, LIR_Opr result,

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

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





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

509     , _barrier_set(BarrierSet::barrier_set()->barrier_set_c1()) {
510   }
511 
512   // for virtual registers, maps them back to Phi's or Local's
513   Instruction* instruction_for_opr(LIR_Opr opr);
514   Instruction* instruction_for_vreg(int reg_num);
515 
516   void set_vreg_flag   (int vreg_num, VregFlag f);
517   bool is_vreg_flag_set(int vreg_num, VregFlag f);
518   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
519   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
520 
521   // statics
522   static LIR_Opr exceptionOopOpr();
523   static LIR_Opr exceptionPcOpr();
524   static LIR_Opr divInOpr();
525   static LIR_Opr divOutOpr();
526   static LIR_Opr remOutOpr();
527 #ifdef S390
528   // On S390 we can do ldiv, lrem without RT call.

542   // visitor functionality
543   virtual void do_Phi            (Phi*             x);
544   virtual void do_Local          (Local*           x);
545   virtual void do_Constant       (Constant*        x);
546   virtual void do_LoadField      (LoadField*       x);
547   virtual void do_StoreField     (StoreField*      x);
548   virtual void do_ArrayLength    (ArrayLength*     x);
549   virtual void do_LoadIndexed    (LoadIndexed*     x);
550   virtual void do_StoreIndexed   (StoreIndexed*    x);
551   virtual void do_NegateOp       (NegateOp*        x);
552   virtual void do_ArithmeticOp   (ArithmeticOp*    x);
553   virtual void do_ShiftOp        (ShiftOp*         x);
554   virtual void do_LogicOp        (LogicOp*         x);
555   virtual void do_CompareOp      (CompareOp*       x);
556   virtual void do_IfOp           (IfOp*            x);
557   virtual void do_Convert        (Convert*         x);
558   virtual void do_NullCheck      (NullCheck*       x);
559   virtual void do_TypeCast       (TypeCast*        x);
560   virtual void do_Invoke         (Invoke*          x);
561   virtual void do_NewInstance    (NewInstance*     x);

562   virtual void do_NewTypeArray   (NewTypeArray*    x);
563   virtual void do_NewObjectArray (NewObjectArray*  x);
564   virtual void do_NewMultiArray  (NewMultiArray*   x);

565   virtual void do_CheckCast      (CheckCast*       x);
566   virtual void do_InstanceOf     (InstanceOf*      x);
567   virtual void do_MonitorEnter   (MonitorEnter*    x);
568   virtual void do_MonitorExit    (MonitorExit*     x);
569   virtual void do_Intrinsic      (Intrinsic*       x);
570   virtual void do_BlockBegin     (BlockBegin*      x);
571   virtual void do_Goto           (Goto*            x);
572   virtual void do_If             (If*              x);
573   virtual void do_TableSwitch    (TableSwitch*     x);
574   virtual void do_LookupSwitch   (LookupSwitch*    x);
575   virtual void do_Return         (Return*          x);
576   virtual void do_Throw          (Throw*           x);
577   virtual void do_Base           (Base*            x);
578   virtual void do_OsrEntry       (OsrEntry*        x);
579   virtual void do_ExceptionObject(ExceptionObject* x);
580   virtual void do_RoundFP        (RoundFP*         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 
154 
155 // only the classes below belong in the same file
156 class LIRGenerator: public InstructionVisitor, public BlockClosure {
157  // LIRGenerator should never get instatiated on the heap.
158  private:
159   void* operator new(size_t size) throw();
160   void* operator new[](size_t size) throw();
161   void operator delete(void* p) { ShouldNotReachHere(); }
162   void operator delete[](void* p) { ShouldNotReachHere(); }
163 
164   Compilation*  _compilation;
165   ciMethod*     _method;    // method that we are compiling
166   PhiResolverState  _resolver_state;
167   BlockBegin*   _block;
168   int           _virtual_register_number;
169   Values        _instruction_for_operand;
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(int 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     if (opr->is_virtual()) {
230       _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL);
231     }
232   }
233   void  set_no_result(Value x)                     { assert(!x->has_uses(), "can't have use"); x->clear_operand(); }
234 
235   friend class LIRItem;
236 
237   LIR_Opr round_item(LIR_Opr opr);
238   LIR_Opr force_to_spill(LIR_Opr value, BasicType t);
239 

256   void do_RegisterFinalizer(Intrinsic* x);
257   void do_isInstance(Intrinsic* x);
258   void do_isPrimitive(Intrinsic* x);
259   void do_getModifiers(Intrinsic* x);
260   void do_getClass(Intrinsic* x);
261   void do_currentThread(Intrinsic* x);
262   void do_getObjectSize(Intrinsic* x);
263   void do_FmaIntrinsic(Intrinsic* x);
264   void do_MathIntrinsic(Intrinsic* x);
265   void do_LibmIntrinsic(Intrinsic* x);
266   void do_ArrayCopy(Intrinsic* x);
267   void do_CompareAndSwap(Intrinsic* x, ValueType* type);
268   void do_PreconditionsCheckIndex(Intrinsic* x, BasicType type);
269   void do_FPIntrinsics(Intrinsic* x);
270   void do_Reference_get(Intrinsic* x);
271   void do_update_CRC32(Intrinsic* x);
272   void do_update_CRC32C(Intrinsic* x);
273   void do_vectorizedMismatch(Intrinsic* x);
274   void do_blackhole(Intrinsic* x);
275 
276   bool inline_type_field_access_prolog(AccessField* x);
277   void access_flattened_array(bool is_load, LIRItem& array, LIRItem& index, LIRItem& obj_item, ciField* field = NULL, int offset = 0);
278   void access_sub_element(LIRItem& array, LIRItem& index, LIR_Opr& result, ciField* field, int sub_offset);
279   LIR_Opr get_and_load_element_address(LIRItem& array, LIRItem& index);
280   bool needs_flattened_array_store_check(StoreIndexed* x);
281   void check_flattened_array(LIR_Opr array, LIR_Opr value, CodeStub* slow_path);
282   bool needs_null_free_array_store_check(StoreIndexed* x);
283   void check_null_free_array(LIRItem& array, LIRItem& value,  CodeEmitInfo* info);
284   void substitutability_check(IfOp* x, LIRItem& left, LIRItem& right, LIRItem& t_val, LIRItem& f_val);
285   void substitutability_check(If* x, LIRItem& left, LIRItem& right);
286   void substitutability_check_common(Value left_val, Value right_val, LIRItem& left, LIRItem& right,
287                                      LIR_Opr equal_result, LIR_Opr not_equal_result, LIR_Opr result, CodeEmitInfo* info);
288   void init_temps_for_substitutability_check(LIR_Opr& tmp1, LIR_Opr& tmp2);
289 
290  public:
291   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
292   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
293 
294   // convenience functions
295   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
296   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
297 
298   // Access API
299 
300  private:
301   BarrierSetC1 *_barrier_set;
302 
303  public:
304   void access_store_at(DecoratorSet decorators, BasicType type,
305                        LIRItem& base, LIR_Opr offset, LIR_Opr value,
306                        CodeEmitInfo* patch_info = NULL, CodeEmitInfo* store_emit_info = NULL);
307 
308   void access_load_at(DecoratorSet decorators, BasicType type,
309                       LIRItem& base, LIR_Opr offset, LIR_Opr result,

323 
324   // These need to guarantee JMM volatile semantics are preserved on each platform
325   // and requires one implementation per architecture.
326   LIR_Opr atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value);
327   LIR_Opr atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& new_value);
328   LIR_Opr atomic_add(BasicType type, LIR_Opr addr, LIRItem& new_value);
329 
330 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
331   virtual void CardTableBarrierSet_post_barrier_helper(LIR_Opr addr, LIR_Const* card_table_base);
332 #endif
333 
334   // specific implementations
335   void array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci);
336 
337   static LIR_Opr result_register_for(ValueType* type, bool callee = false);
338 
339   ciObject* get_jobject_constant(Value value);
340 
341   LIRItemList* invoke_visit_arguments(Invoke* x);
342   void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list);
343   void invoke_load_one_argument(LIRItem* param, LIR_Opr loc);
344   void trace_block_entry(BlockBegin* block);
345 
346   // volatile field operations are never patchable because a klass
347   // must be loaded to know it's volatile which means that the offset
348   // it always known as well.
349   void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info);
350   void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info);
351 
352   void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile);
353   void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile);
354 
355   void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args);
356 
357   void increment_counter(address counter, BasicType type, int step = 1);
358   void increment_counter(LIR_Address* addr, int step = 1);
359 
360   void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp, CodeEmitInfo* info = NULL);
361   // machine dependent.  returns true if it emitted code for the multiply
362   bool strength_reduce_multiply(LIR_Opr left, jint constant, LIR_Opr result, LIR_Opr tmp);
363 
364   void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes);
365 
366   void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve = false);
367 
368   // this loads the length and compares against the index
369   void array_range_check          (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info);
370 
371   void arithmetic_op_int  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp);
372   void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL);
373   void arithmetic_op_fpu  (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp = LIR_OprFact::illegalOpr);
374 
375   void shift_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp);
376 
377   void logic_op   (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right);
378 
379   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_imse_stub);
380   void monitor_exit  (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no);
381 
382   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);
383 
384   // machine dependent
385   void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
386   void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info);
387 
388   void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type);
389 
390   // returns a LIR_Address to address an array location.  May also
391   // emit some code as part of address calculation.  If
392   // needs_card_mark is true then compute the full address for use by
393   // both the store and the card mark.
394   LIR_Address* generate_address(LIR_Opr base,
395                                 LIR_Opr index, int shift,
396                                 int disp,
397                                 BasicType type);
398   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
399     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
400   }
401   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type);
402 

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

565   // visitor functionality
566   virtual void do_Phi            (Phi*             x);
567   virtual void do_Local          (Local*           x);
568   virtual void do_Constant       (Constant*        x);
569   virtual void do_LoadField      (LoadField*       x);
570   virtual void do_StoreField     (StoreField*      x);
571   virtual void do_ArrayLength    (ArrayLength*     x);
572   virtual void do_LoadIndexed    (LoadIndexed*     x);
573   virtual void do_StoreIndexed   (StoreIndexed*    x);
574   virtual void do_NegateOp       (NegateOp*        x);
575   virtual void do_ArithmeticOp   (ArithmeticOp*    x);
576   virtual void do_ShiftOp        (ShiftOp*         x);
577   virtual void do_LogicOp        (LogicOp*         x);
578   virtual void do_CompareOp      (CompareOp*       x);
579   virtual void do_IfOp           (IfOp*            x);
580   virtual void do_Convert        (Convert*         x);
581   virtual void do_NullCheck      (NullCheck*       x);
582   virtual void do_TypeCast       (TypeCast*        x);
583   virtual void do_Invoke         (Invoke*          x);
584   virtual void do_NewInstance    (NewInstance*     x);
585   virtual void do_NewInlineTypeInstance(NewInlineTypeInstance* x);
586   virtual void do_NewTypeArray   (NewTypeArray*    x);
587   virtual void do_NewObjectArray (NewObjectArray*  x);
588   virtual void do_NewMultiArray  (NewMultiArray*   x);
589   virtual void do_Deoptimize     (Deoptimize*      x);
590   virtual void do_CheckCast      (CheckCast*       x);
591   virtual void do_InstanceOf     (InstanceOf*      x);
592   virtual void do_MonitorEnter   (MonitorEnter*    x);
593   virtual void do_MonitorExit    (MonitorExit*     x);
594   virtual void do_Intrinsic      (Intrinsic*       x);
595   virtual void do_BlockBegin     (BlockBegin*      x);
596   virtual void do_Goto           (Goto*            x);
597   virtual void do_If             (If*              x);
598   virtual void do_TableSwitch    (TableSwitch*     x);
599   virtual void do_LookupSwitch   (LookupSwitch*    x);
600   virtual void do_Return         (Return*          x);
601   virtual void do_Throw          (Throw*           x);
602   virtual void do_Base           (Base*            x);
603   virtual void do_OsrEntry       (OsrEntry*        x);
604   virtual void do_ExceptionObject(ExceptionObject* x);
605   virtual void do_RoundFP        (RoundFP*         x);
606   virtual void do_UnsafeGet      (UnsafeGet*       x);
607   virtual void do_UnsafePut      (UnsafePut*       x);
608   virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x);
609   virtual void do_ProfileCall    (ProfileCall*     x);
610   virtual void do_ProfileReturnType (ProfileReturnType* x);
611   virtual void do_ProfileInvoke  (ProfileInvoke*   x);
612   virtual void do_ProfileACmpTypes(ProfileACmpTypes* x);
613   virtual void do_RuntimeCall    (RuntimeCall*     x);
614   virtual void do_MemBar         (MemBar*          x);
615   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x);
616 #ifdef ASSERT
617   virtual void do_Assert         (Assert*          x);
618 #endif
619 
620 #ifdef C1_LIRGENERATOR_MD_HPP
621 #include C1_LIRGENERATOR_MD_HPP
622 #endif
623 };
624 
625 
626 class LIRItem: public CompilationResourceObj {
627  private:
628   Value         _value;
629   LIRGenerator* _gen;
630   LIR_Opr       _result;
631   bool          _destroys_register;
632   LIR_Opr       _new_result;
< prev index next >