src/share/vm/c1/c1_ValueMap.hpp

Print this page
rev 4136 : 7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by:


 189   void do_BlockBegin     (BlockBegin*      x) { /* nothing to do */ }
 190   void do_Goto           (Goto*            x) { /* nothing to do */ }
 191   void do_If             (If*              x) { /* nothing to do */ }
 192   void do_IfInstanceOf   (IfInstanceOf*    x) { /* nothing to do */ }
 193   void do_TableSwitch    (TableSwitch*     x) { /* nothing to do */ }
 194   void do_LookupSwitch   (LookupSwitch*    x) { /* nothing to do */ }
 195   void do_Return         (Return*          x) { /* nothing to do */ }
 196   void do_Throw          (Throw*           x) { /* nothing to do */ }
 197   void do_Base           (Base*            x) { /* nothing to do */ }
 198   void do_OsrEntry       (OsrEntry*        x) { /* nothing to do */ }
 199   void do_ExceptionObject(ExceptionObject* x) { /* nothing to do */ }
 200   void do_RoundFP        (RoundFP*         x) { /* nothing to do */ }
 201   void do_UnsafeGetRaw   (UnsafeGetRaw*    x) { /* nothing to do */ }
 202   void do_UnsafeGetObject(UnsafeGetObject* x) { /* nothing to do */ }
 203   void do_UnsafePrefetchRead (UnsafePrefetchRead*  x) { /* nothing to do */ }
 204   void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { /* nothing to do */ }
 205   void do_ProfileCall    (ProfileCall*     x) { /* nothing to do */ }
 206   void do_ProfileInvoke  (ProfileInvoke*   x) { /* nothing to do */ };
 207   void do_RuntimeCall    (RuntimeCall*     x) { /* nothing to do */ };
 208   void do_MemBar         (MemBar*          x) { /* nothing to do */ };


 209 };
 210 
 211 
 212 class ValueNumberingEffects: public ValueNumberingVisitor {
 213  private:
 214   ValueMap*     _map;
 215 
 216  public:
 217   // implementation for abstract methods of ValueNumberingVisitor
 218   void          kill_memory()                                 { _map->kill_memory(); }
 219   void          kill_field(ciField* field, bool all_offsets)  { _map->kill_field(field, all_offsets); }
 220   void          kill_array(ValueType* type)                   { _map->kill_array(type); }
 221 
 222   ValueNumberingEffects(ValueMap* map): _map(map) {}
 223 };
 224 
 225 
 226 class GlobalValueNumbering: public ValueNumberingVisitor {
 227  private:

 228   ValueMap*     _current_map;     // value map of current block
 229   ValueMapArray _value_maps;      // list of value maps for all blocks


 230 
 231  public:
 232   // accessors

 233   ValueMap*     current_map()                    { return _current_map; }
 234   ValueMap*     value_map_of(BlockBegin* block)  { return _value_maps.at(block->linear_scan_number()); }
 235   void          set_value_map_of(BlockBegin* block, ValueMap* map)   { assert(value_map_of(block) == NULL, ""); _value_maps.at_put(block->linear_scan_number(), map); }
 236 



 237   // implementation for abstract methods of ValueNumberingVisitor
 238   void          kill_memory()                                 { current_map()->kill_memory(); }
 239   void          kill_field(ciField* field, bool all_offsets)  { current_map()->kill_field(field, all_offsets); }
 240   void          kill_array(ValueType* type)                   { current_map()->kill_array(type); }
 241 
 242   // main entry point that performs global value numbering
 243   GlobalValueNumbering(IR* ir);

 244 };
 245 
 246 #endif // SHARE_VM_C1_C1_VALUEMAP_HPP


 189   void do_BlockBegin     (BlockBegin*      x) { /* nothing to do */ }
 190   void do_Goto           (Goto*            x) { /* nothing to do */ }
 191   void do_If             (If*              x) { /* nothing to do */ }
 192   void do_IfInstanceOf   (IfInstanceOf*    x) { /* nothing to do */ }
 193   void do_TableSwitch    (TableSwitch*     x) { /* nothing to do */ }
 194   void do_LookupSwitch   (LookupSwitch*    x) { /* nothing to do */ }
 195   void do_Return         (Return*          x) { /* nothing to do */ }
 196   void do_Throw          (Throw*           x) { /* nothing to do */ }
 197   void do_Base           (Base*            x) { /* nothing to do */ }
 198   void do_OsrEntry       (OsrEntry*        x) { /* nothing to do */ }
 199   void do_ExceptionObject(ExceptionObject* x) { /* nothing to do */ }
 200   void do_RoundFP        (RoundFP*         x) { /* nothing to do */ }
 201   void do_UnsafeGetRaw   (UnsafeGetRaw*    x) { /* nothing to do */ }
 202   void do_UnsafeGetObject(UnsafeGetObject* x) { /* nothing to do */ }
 203   void do_UnsafePrefetchRead (UnsafePrefetchRead*  x) { /* nothing to do */ }
 204   void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) { /* nothing to do */ }
 205   void do_ProfileCall    (ProfileCall*     x) { /* nothing to do */ }
 206   void do_ProfileInvoke  (ProfileInvoke*   x) { /* nothing to do */ };
 207   void do_RuntimeCall    (RuntimeCall*     x) { /* nothing to do */ };
 208   void do_MemBar         (MemBar*          x) { /* nothing to do */ };
 209   void do_RangeCheckPredicate(RangeCheckPredicate* x) { /* nothing to do */ };
 210   void do_Assert         (Assert*          x) { /* nothing to do */ };
 211 };
 212 
 213 
 214 class ValueNumberingEffects: public ValueNumberingVisitor {
 215  private:
 216   ValueMap*     _map;
 217 
 218  public:
 219   // implementation for abstract methods of ValueNumberingVisitor
 220   void          kill_memory()                                 { _map->kill_memory(); }
 221   void          kill_field(ciField* field, bool all_offsets)  { _map->kill_field(field, all_offsets); }
 222   void          kill_array(ValueType* type)                   { _map->kill_array(type); }
 223 
 224   ValueNumberingEffects(ValueMap* map): _map(map) {}
 225 };
 226 
 227 
 228 class GlobalValueNumbering: public ValueNumberingVisitor {
 229  private:
 230   Compilation*  _compilation;     // compilation data
 231   ValueMap*     _current_map;     // value map of current block
 232   ValueMapArray _value_maps;      // list of value maps for all blocks
 233   ValueSet      _processed_values;  // marker for instructions that were already processed
 234   bool          _has_substitutions; // set to true when substitutions must be resolved
 235 
 236  public:
 237   // accessors
 238   Compilation*  compilation() const              { return _compilation; }
 239   ValueMap*     current_map()                    { return _current_map; }
 240   ValueMap*     value_map_of(BlockBegin* block)  { return _value_maps.at(block->linear_scan_number()); }
 241   void          set_value_map_of(BlockBegin* block, ValueMap* map)   { assert(value_map_of(block) == NULL, ""); _value_maps.at_put(block->linear_scan_number(), map); }
 242 
 243   bool          is_processed(Value v)            { return _processed_values.contains(v); }
 244   void          set_processed(Value v)           { _processed_values.put(v); }
 245 
 246   // implementation for abstract methods of ValueNumberingVisitor
 247   void          kill_memory()                                 { current_map()->kill_memory(); }
 248   void          kill_field(ciField* field, bool all_offsets)  { current_map()->kill_field(field, all_offsets); }
 249   void          kill_array(ValueType* type)                   { current_map()->kill_array(type); }
 250 
 251   // main entry point that performs global value numbering
 252   GlobalValueNumbering(IR* ir);
 253   void          substitute(Instruction* instr);  // substitute instruction if it is contained in current value map
 254 };
 255 
 256 #endif // SHARE_VM_C1_C1_VALUEMAP_HPP