< prev index next >

src/hotspot/share/c1/c1_ValueMap.cpp

Print this page




 248 }
 249 
 250 void ValueMap::print_statistics() {
 251   float hit_rate = 0;
 252   if (_number_of_finds != 0) {
 253     hit_rate = (float)_number_of_hits / _number_of_finds;
 254   }
 255 
 256   tty->print_cr("finds:%3d  hits:%3d   kills:%3d  hit rate: %1.4f", _number_of_finds, _number_of_hits, _number_of_kills, hit_rate);
 257 }
 258 
 259 #endif
 260 
 261 
 262 
 263 class ShortLoopOptimizer : public ValueNumberingVisitor {
 264  private:
 265   GlobalValueNumbering* _gvn;
 266   BlockList             _loop_blocks;
 267   bool                  _too_complicated_loop;
 268   bool                  _has_field_store[T_ARRAY + 1];
 269   bool                  _has_indexed_store[T_ARRAY + 1];
 270 
 271   // simplified access to methods of GlobalValueNumbering
 272   ValueMap* current_map()                        { return _gvn->current_map(); }
 273   ValueMap* value_map_of(BlockBegin* block)      { return _gvn->value_map_of(block); }
 274 
 275   // implementation for abstract methods of ValueNumberingVisitor
 276   void      kill_memory()                                 { _too_complicated_loop = true; }
 277   void      kill_field(ciField* field, bool all_offsets)  {
 278     current_map()->kill_field(field, all_offsets);
 279     assert(field->type()->basic_type() >= 0 && field->type()->basic_type() <= T_ARRAY, "Invalid type");
 280     _has_field_store[field->type()->basic_type()] = true;
 281   }
 282   void      kill_array(ValueType* type)                   {
 283     current_map()->kill_array(type);
 284     BasicType basic_type = as_BasicType(type); assert(basic_type >= 0 && basic_type <= T_ARRAY, "Invalid type");
 285     _has_indexed_store[basic_type] = true;
 286   }
 287 
 288  public:
 289   ShortLoopOptimizer(GlobalValueNumbering* gvn)
 290     : _gvn(gvn)
 291     , _loop_blocks(ValueMapMaxLoopSize)
 292     , _too_complicated_loop(false)
 293   {
 294     for (int i=0; i<= T_ARRAY; i++){
 295       _has_field_store[i] = false;
 296       _has_indexed_store[i] = false;
 297     }
 298   }
 299 
 300   bool has_field_store(BasicType type) {
 301     assert(type >= 0 && type <= T_ARRAY, "Invalid type");
 302     return _has_field_store[type];
 303   }
 304 
 305   bool has_indexed_store(BasicType type) {
 306     assert(type >= 0 && type <= T_ARRAY, "Invalid type");
 307     return _has_indexed_store[type];
 308   }
 309 
 310   bool process(BlockBegin* loop_header);
 311 };
 312 
 313 class LoopInvariantCodeMotion : public StackObj  {
 314  private:
 315   GlobalValueNumbering* _gvn;
 316   ShortLoopOptimizer*   _short_loop_optimizer;
 317   Instruction*          _insertion_point;
 318   ValueStack *          _state;
 319   bool                  _insert_is_pred;
 320 
 321   void set_invariant(Value v) const    { _gvn->set_processed(v); }
 322   bool is_invariant(Value v) const     { return _gvn->is_processed(v); }
 323 
 324   void process_block(BlockBegin* block);
 325 
 326  public:




 248 }
 249 
 250 void ValueMap::print_statistics() {
 251   float hit_rate = 0;
 252   if (_number_of_finds != 0) {
 253     hit_rate = (float)_number_of_hits / _number_of_finds;
 254   }
 255 
 256   tty->print_cr("finds:%3d  hits:%3d   kills:%3d  hit rate: %1.4f", _number_of_finds, _number_of_hits, _number_of_kills, hit_rate);
 257 }
 258 
 259 #endif
 260 
 261 
 262 
 263 class ShortLoopOptimizer : public ValueNumberingVisitor {
 264  private:
 265   GlobalValueNumbering* _gvn;
 266   BlockList             _loop_blocks;
 267   bool                  _too_complicated_loop;
 268   bool                  _has_field_store[T_VALUETYPE + 1];
 269   bool                  _has_indexed_store[T_VALUETYPE + 1];
 270 
 271   // simplified access to methods of GlobalValueNumbering
 272   ValueMap* current_map()                        { return _gvn->current_map(); }
 273   ValueMap* value_map_of(BlockBegin* block)      { return _gvn->value_map_of(block); }
 274 
 275   // implementation for abstract methods of ValueNumberingVisitor
 276   void      kill_memory()                                 { _too_complicated_loop = true; }
 277   void      kill_field(ciField* field, bool all_offsets)  {
 278     current_map()->kill_field(field, all_offsets);
 279     assert(field->type()->basic_type() >= 0 && field->type()->basic_type() <= T_VALUETYPE, "Invalid type");
 280     _has_field_store[field->type()->basic_type()] = true;
 281   }
 282   void      kill_array(ValueType* type)                   {
 283     current_map()->kill_array(type);
 284     BasicType basic_type = as_BasicType(type); assert(basic_type >= 0 && basic_type <= T_VALUETYPE, "Invalid type");
 285     _has_indexed_store[basic_type] = true;
 286   }
 287 
 288  public:
 289   ShortLoopOptimizer(GlobalValueNumbering* gvn)
 290     : _gvn(gvn)
 291     , _loop_blocks(ValueMapMaxLoopSize)
 292     , _too_complicated_loop(false)
 293   {
 294     for (int i=0; i<= T_VALUETYPE; i++){
 295       _has_field_store[i] = false;
 296       _has_indexed_store[i] = false;
 297     }
 298   }
 299 
 300   bool has_field_store(BasicType type) {
 301     assert(type >= 0 && type <= T_VALUETYPE, "Invalid type");
 302     return _has_field_store[type];
 303   }
 304 
 305   bool has_indexed_store(BasicType type) {
 306     assert(type >= 0 && type <= T_VALUETYPE, "Invalid type");
 307     return _has_indexed_store[type];
 308   }
 309 
 310   bool process(BlockBegin* loop_header);
 311 };
 312 
 313 class LoopInvariantCodeMotion : public StackObj  {
 314  private:
 315   GlobalValueNumbering* _gvn;
 316   ShortLoopOptimizer*   _short_loop_optimizer;
 317   Instruction*          _insertion_point;
 318   ValueStack *          _state;
 319   bool                  _insert_is_pred;
 320 
 321   void set_invariant(Value v) const    { _gvn->set_processed(v); }
 322   bool is_invariant(Value v) const     { return _gvn->is_processed(v); }
 323 
 324   void process_block(BlockBegin* block);
 325 
 326  public:


< prev index next >