src/hotspot/share/c1/c1_LIRGenerator.hpp
changeset 49906 4bb58f644e4e
parent 49455 848864ed9b17
child 49938 2c2a722a2c0c
equal deleted inserted replaced
49905:a09af8ef8e5c 49906:4bb58f644e4e
    23  */
    23  */
    24 
    24 
    25 #ifndef SHARE_VM_C1_C1_LIRGENERATOR_HPP
    25 #ifndef SHARE_VM_C1_C1_LIRGENERATOR_HPP
    26 #define SHARE_VM_C1_C1_LIRGENERATOR_HPP
    26 #define SHARE_VM_C1_C1_LIRGENERATOR_HPP
    27 
    27 
       
    28 #include "c1/c1_Decorators.hpp"
    28 #include "c1/c1_Instruction.hpp"
    29 #include "c1/c1_Instruction.hpp"
    29 #include "c1/c1_LIR.hpp"
    30 #include "c1/c1_LIR.hpp"
    30 #include "ci/ciMethodData.hpp"
    31 #include "ci/ciMethodData.hpp"
       
    32 #include "gc/shared/barrierSet.hpp"
    31 #include "utilities/macros.hpp"
    33 #include "utilities/macros.hpp"
    32 #include "utilities/sizes.hpp"
    34 #include "utilities/sizes.hpp"
       
    35 
       
    36 class BarrierSetC1;
    33 
    37 
    34 // The classes responsible for code emission and register allocation
    38 // The classes responsible for code emission and register allocation
    35 
    39 
    36 
    40 
    37 class LIRGenerator;
    41 class LIRGenerator;
   163   BlockBegin*   _block;
   167   BlockBegin*   _block;
   164   int           _virtual_register_number;
   168   int           _virtual_register_number;
   165   Values        _instruction_for_operand;
   169   Values        _instruction_for_operand;
   166   BitMap2D      _vreg_flags; // flags which can be set on a per-vreg basis
   170   BitMap2D      _vreg_flags; // flags which can be set on a per-vreg basis
   167   LIR_List*     _lir;
   171   LIR_List*     _lir;
   168   BarrierSet*   _bs;
       
   169 
   172 
   170   LIRGenerator* gen() {
   173   LIRGenerator* gen() {
   171     return this;
   174     return this;
   172   }
   175   }
   173 
   176 
   174   void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN;
   177   void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN;
   175 
   178 
       
   179  public:
   176 #ifdef ASSERT
   180 #ifdef ASSERT
   177   LIR_List* lir(const char * file, int line) const {
   181   LIR_List* lir(const char * file, int line) const {
   178     _lir->set_file_and_line(file, line);
   182     _lir->set_file_and_line(file, line);
   179     return _lir;
   183     return _lir;
   180   }
   184   }
   181 #endif
   185 #endif
   182   LIR_List* lir() const {
   186   LIR_List* lir() const {
   183     return _lir;
   187     return _lir;
   184   }
   188   }
   185 
   189 
       
   190  private:
   186   // a simple cache of constants used within a block
   191   // a simple cache of constants used within a block
   187   GrowableArray<LIR_Const*>       _constants;
   192   GrowableArray<LIR_Const*>       _constants;
   188   LIR_OprList                     _reg_for_constants;
   193   LIR_OprList                     _reg_for_constants;
   189   Values                          _unpinned_constants;
   194   Values                          _unpinned_constants;
   190 
   195 
   191   friend class PhiResolver;
   196   friend class PhiResolver;
   192 
   197 
       
   198  public:
   193   // unified bailout support
   199   // unified bailout support
   194   void bailout(const char* msg) const            { compilation()->bailout(msg); }
   200   void bailout(const char* msg) const            { compilation()->bailout(msg); }
   195   bool bailed_out() const                        { return compilation()->bailed_out(); }
   201   bool bailed_out() const                        { return compilation()->bailed_out(); }
   196 
   202 
   197   void block_do_prolog(BlockBegin* block);
   203   void block_do_prolog(BlockBegin* block);
   231   PhiResolverState& resolver_state() { return _resolver_state; }
   237   PhiResolverState& resolver_state() { return _resolver_state; }
   232 
   238 
   233   void  move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val);
   239   void  move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val);
   234   void  move_to_phi(ValueStack* cur_state);
   240   void  move_to_phi(ValueStack* cur_state);
   235 
   241 
   236   // code emission
       
   237   void do_ArithmeticOp_Long   (ArithmeticOp*    x);
       
   238   void do_ArithmeticOp_Int    (ArithmeticOp*    x);
       
   239   void do_ArithmeticOp_FPU    (ArithmeticOp*    x);
       
   240 
       
   241   // platform dependent
   242   // platform dependent
   242   LIR_Opr getThreadPointer();
   243   LIR_Opr getThreadPointer();
       
   244 
       
   245  private:
       
   246   // code emission
       
   247   void do_ArithmeticOp_Long(ArithmeticOp* x);
       
   248   void do_ArithmeticOp_Int (ArithmeticOp* x);
       
   249   void do_ArithmeticOp_FPU (ArithmeticOp* x);
   243 
   250 
   244   void do_RegisterFinalizer(Intrinsic* x);
   251   void do_RegisterFinalizer(Intrinsic* x);
   245   void do_isInstance(Intrinsic* x);
   252   void do_isInstance(Intrinsic* x);
   246   void do_isPrimitive(Intrinsic* x);
   253   void do_isPrimitive(Intrinsic* x);
   247   void do_getClass(Intrinsic* x);
   254   void do_getClass(Intrinsic* x);
   256   void do_Reference_get(Intrinsic* x);
   263   void do_Reference_get(Intrinsic* x);
   257   void do_update_CRC32(Intrinsic* x);
   264   void do_update_CRC32(Intrinsic* x);
   258   void do_update_CRC32C(Intrinsic* x);
   265   void do_update_CRC32C(Intrinsic* x);
   259   void do_vectorizedMismatch(Intrinsic* x);
   266   void do_vectorizedMismatch(Intrinsic* x);
   260 
   267 
       
   268  public:
   261   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
   269   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
   262   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
   270   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
   263 
   271 
   264   // convenience functions
   272   // convenience functions
   265   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
   273   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
   266   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
   274   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
   267 
   275 
   268   // GC Barriers
   276   // Access API
   269 
   277 
   270   // generic interface
   278  private:
   271 
   279   BarrierSetC1 *_barrier_set;
   272   void pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val, bool do_load, bool patch, CodeEmitInfo* info);
   280 
   273   void post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
   281  public:
       
   282   void access_store_at(DecoratorSet decorators, BasicType type,
       
   283                        LIRItem& base, LIR_Opr offset, LIR_Opr value,
       
   284                        CodeEmitInfo* patch_info = NULL, CodeEmitInfo* store_emit_info = NULL);
       
   285 
       
   286   void access_load_at(DecoratorSet decorators, BasicType type,
       
   287                       LIRItem& base, LIR_Opr offset, LIR_Opr result,
       
   288                       CodeEmitInfo* patch_info = NULL, CodeEmitInfo* load_emit_info = NULL);
       
   289 
       
   290   LIR_Opr access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,
       
   291                                    LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value);
       
   292 
       
   293   LIR_Opr access_atomic_xchg_at(DecoratorSet decorators, BasicType type,
       
   294                                 LIRItem& base, LIRItem& offset, LIRItem& value);
       
   295 
       
   296   LIR_Opr access_atomic_add_at(DecoratorSet decorators, BasicType type,
       
   297                                LIRItem& base, LIRItem& offset, LIRItem& value);
       
   298 
       
   299   // These need to guarantee JMM volatile semantics are preserved on each platform
       
   300   // and requires one implementation per architecture.
       
   301   LIR_Opr atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value);
       
   302   LIR_Opr atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& new_value);
       
   303   LIR_Opr atomic_add(BasicType type, LIR_Opr addr, LIRItem& new_value);
   274 
   304 
   275   // specific implementations
   305   // specific implementations
   276   // pre barriers
   306   void array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci);
   277 
       
   278   void G1BarrierSet_pre_barrier(LIR_Opr addr_opr, LIR_Opr pre_val,
       
   279                                 bool do_load, bool patch, CodeEmitInfo* info);
       
   280 
       
   281   // post barriers
       
   282 
       
   283   void G1BarrierSet_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
       
   284   void CardTableBarrierSet_post_barrier(LIR_OprDesc* addr, LIR_OprDesc* new_val);
       
   285 #ifdef CARDTABLEBARRIERSET_POST_BARRIER_HELPER
       
   286   void CardTableBarrierSet_post_barrier_helper(LIR_OprDesc* addr, LIR_Const* card_table_base);
       
   287 #endif
       
   288 
       
   289 
   307 
   290   static LIR_Opr result_register_for(ValueType* type, bool callee = false);
   308   static LIR_Opr result_register_for(ValueType* type, bool callee = false);
   291 
   309 
   292   ciObject* get_jobject_constant(Value value);
   310   ciObject* get_jobject_constant(Value value);
   293 
   311 
   352                                 int disp,
   370                                 int disp,
   353                                 BasicType type);
   371                                 BasicType type);
   354   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
   372   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
   355     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
   373     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
   356   }
   374   }
   357   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark);
   375   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type);
   358 
   376 
   359   // the helper for generate_address
   377   // the helper for generate_address
   360   void add_large_constant(LIR_Opr src, int c, LIR_Opr dest);
   378   void add_large_constant(LIR_Opr src, int c, LIR_Opr dest);
   361 
   379 
   362   // machine preferences and characteristics
   380   // machine preferences and characteristics
   431 
   449 
   432 #ifdef __SOFTFP__
   450 #ifdef __SOFTFP__
   433   void do_soft_float_compare(If *x);
   451   void do_soft_float_compare(If *x);
   434 #endif // __SOFTFP__
   452 #endif // __SOFTFP__
   435 
   453 
   436   void init();
       
   437 
       
   438   SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
   454   SwitchRangeArray* create_lookup_ranges(TableSwitch* x);
   439   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
   455   SwitchRangeArray* create_lookup_ranges(LookupSwitch* x);
   440   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
   456   void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux);
   441 
   457 
   442 #ifdef TRACE_HAVE_INTRINSICS
   458 #ifdef TRACE_HAVE_INTRINSICS
   450                         Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k,
   466                         Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k,
   451                         ciKlass* callee_signature_k);
   467                         ciKlass* callee_signature_k);
   452   void profile_arguments(ProfileCall* x);
   468   void profile_arguments(ProfileCall* x);
   453   void profile_parameters(Base* x);
   469   void profile_parameters(Base* x);
   454   void profile_parameters_at_call(ProfileCall* x);
   470   void profile_parameters_at_call(ProfileCall* x);
       
   471   LIR_Opr mask_boolean(LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info);
   455   LIR_Opr maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info);
   472   LIR_Opr maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info);
   456 
   473 
   457  public:
   474  public:
   458   Compilation*  compilation() const              { return _compilation; }
   475   Compilation*  compilation() const              { return _compilation; }
   459   FrameMap*     frame_map() const                { return _compilation->frame_map(); }
   476   FrameMap*     frame_map() const                { return _compilation->frame_map(); }
   476 
   493 
   477   LIRGenerator(Compilation* compilation, ciMethod* method)
   494   LIRGenerator(Compilation* compilation, ciMethod* method)
   478     : _compilation(compilation)
   495     : _compilation(compilation)
   479     , _method(method)
   496     , _method(method)
   480     , _virtual_register_number(LIR_OprDesc::vreg_base)
   497     , _virtual_register_number(LIR_OprDesc::vreg_base)
   481     , _vreg_flags(num_vreg_flags) {
   498     , _vreg_flags(num_vreg_flags)
   482     init();
   499     , _barrier_set(BarrierSet::barrier_set()->barrier_set_c1()) {
   483   }
   500   }
   484 
   501 
   485   // for virtual registers, maps them back to Phi's or Local's
   502   // for virtual registers, maps them back to Phi's or Local's
   486   Instruction* instruction_for_opr(LIR_Opr opr);
   503   Instruction* instruction_for_opr(LIR_Opr opr);
   487   Instruction* instruction_for_vreg(int reg_num);
   504   Instruction* instruction_for_vreg(int reg_num);