< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.hpp

Print this page


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

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

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


 249   void do_ArithmeticOp_Int (ArithmeticOp* x);
 250   void do_ArithmeticOp_FPU (ArithmeticOp* x);
 251 
 252   void do_RegisterFinalizer(Intrinsic* x);
 253   void do_isInstance(Intrinsic* x);
 254   void do_isPrimitive(Intrinsic* x);
 255   void do_getClass(Intrinsic* x);
 256   void do_currentThread(Intrinsic* x);
 257   void do_FmaIntrinsic(Intrinsic* x);
 258   void do_MathIntrinsic(Intrinsic* x);
 259   void do_LibmIntrinsic(Intrinsic* x);
 260   void do_ArrayCopy(Intrinsic* x);
 261   void do_CompareAndSwap(Intrinsic* x, ValueType* type);
 262   void do_NIOCheckIndex(Intrinsic* x);
 263   void do_FPIntrinsics(Intrinsic* x);
 264   void do_Reference_get(Intrinsic* x);
 265   void do_update_CRC32(Intrinsic* x);
 266   void do_update_CRC32C(Intrinsic* x);
 267   void do_vectorizedMismatch(Intrinsic* x);
 268 
 269   Value flattenable_load_field_prolog(LoadField* x, CodeEmitInfo* info);
 270   void access_flattened_array(bool is_load, LIRItem& array, LIRItem& index, LIRItem& obj_item);
 271   bool needs_flattened_array_store_check(StoreIndexed* x);
 272   void check_flattened_array(LIR_Opr array, LIR_Opr value, CodeStub* slow_path);
 273   bool needs_null_free_array_store_check(StoreIndexed* x);
 274   void check_null_free_array(LIRItem& array, LIRItem& value,  CodeEmitInfo* info);
 275   void substitutability_check(IfOp* x, LIRItem& left, LIRItem& right, LIRItem& t_val, LIRItem& f_val);
 276   void substitutability_check(If* x, LIRItem& left, LIRItem& right);
 277   void substitutability_check_common(Value left_val, Value right_val, LIRItem& left, LIRItem& right,
 278                                      LIR_Opr equal_result, LIR_Opr not_equal_result, LIR_Opr result, CodeEmitInfo* info);
 279   void init_temps_for_substitutability_check(LIR_Opr& tmp1, LIR_Opr& tmp2);
 280 
 281  public:
 282   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
 283   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
 284 
 285   // convenience functions
 286   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
 287   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
 288 
 289   // Access API


 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_OprDesc::vreg_base)
 526     , _vreg_flags(num_vreg_flags)

 527     , _barrier_set(BarrierSet::barrier_set()->barrier_set_c1()) {
 528   }
 529 
 530   // for virtual registers, maps them back to Phi's or Local's
 531   Instruction* instruction_for_opr(LIR_Opr opr);
 532   Instruction* instruction_for_vreg(int reg_num);
 533 
 534   void set_vreg_flag   (int vreg_num, VregFlag f);
 535   bool is_vreg_flag_set(int vreg_num, VregFlag f);
 536   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
 537   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
 538 
 539   // statics
 540   static LIR_Opr exceptionOopOpr();
 541   static LIR_Opr exceptionPcOpr();
 542   static LIR_Opr divInOpr();
 543   static LIR_Opr divOutOpr();
 544   static LIR_Opr remOutOpr();
 545 #ifdef S390
 546   // On S390 we can do ldiv, lrem without RT call.




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


 252   void do_ArithmeticOp_Int (ArithmeticOp* x);
 253   void do_ArithmeticOp_FPU (ArithmeticOp* x);
 254 
 255   void do_RegisterFinalizer(Intrinsic* x);
 256   void do_isInstance(Intrinsic* x);
 257   void do_isPrimitive(Intrinsic* x);
 258   void do_getClass(Intrinsic* x);
 259   void do_currentThread(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_NIOCheckIndex(Intrinsic* x);
 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 
 272   Constant* flattenable_load_field_prolog(LoadField* x, CodeEmitInfo* info);
 273   void access_flattened_array(bool is_load, LIRItem& array, LIRItem& index, LIRItem& obj_item);
 274   bool needs_flattened_array_store_check(StoreIndexed* x);
 275   void check_flattened_array(LIR_Opr array, LIR_Opr value, CodeStub* slow_path);
 276   bool needs_null_free_array_store_check(StoreIndexed* x);
 277   void check_null_free_array(LIRItem& array, LIRItem& value,  CodeEmitInfo* info);
 278   void substitutability_check(IfOp* x, LIRItem& left, LIRItem& right, LIRItem& t_val, LIRItem& f_val);
 279   void substitutability_check(If* x, LIRItem& left, LIRItem& right);
 280   void substitutability_check_common(Value left_val, Value right_val, LIRItem& left, LIRItem& right,
 281                                      LIR_Opr equal_result, LIR_Opr not_equal_result, LIR_Opr result, CodeEmitInfo* info);
 282   void init_temps_for_substitutability_check(LIR_Opr& tmp1, LIR_Opr& tmp2);
 283 
 284  public:
 285   LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
 286   LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info);
 287 
 288   // convenience functions
 289   LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info);
 290   LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info);
 291 
 292   // Access API


 510   IRScope*      scope() const                    { return block()->scope(); }
 511 
 512   int max_virtual_register_number() const        { return _virtual_register_number; }
 513 
 514   void block_do(BlockBegin* block);
 515 
 516   // Flags that can be set on vregs
 517   enum VregFlag {
 518       must_start_in_memory = 0  // needs to be assigned a memory location at beginning, but may then be loaded in a register
 519     , callee_saved     = 1    // must be in a callee saved register
 520     , byte_reg         = 2    // must be in a byte register
 521     , num_vreg_flags
 522 
 523   };
 524 
 525   LIRGenerator(Compilation* compilation, ciMethod* method)
 526     : _compilation(compilation)
 527     , _method(method)
 528     , _virtual_register_number(LIR_OprDesc::vreg_base)
 529     , _vreg_flags(num_vreg_flags)
 530     , _in_conditional_code(false)
 531     , _barrier_set(BarrierSet::barrier_set()->barrier_set_c1()) {
 532   }
 533 
 534   // for virtual registers, maps them back to Phi's or Local's
 535   Instruction* instruction_for_opr(LIR_Opr opr);
 536   Instruction* instruction_for_vreg(int reg_num);
 537 
 538   void set_vreg_flag   (int vreg_num, VregFlag f);
 539   bool is_vreg_flag_set(int vreg_num, VregFlag f);
 540   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
 541   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
 542 
 543   // statics
 544   static LIR_Opr exceptionOopOpr();
 545   static LIR_Opr exceptionPcOpr();
 546   static LIR_Opr divInOpr();
 547   static LIR_Opr divOutOpr();
 548   static LIR_Opr remOutOpr();
 549 #ifdef S390
 550   // On S390 we can do ldiv, lrem without RT call.


< prev index next >