src/share/vm/compiler/oopMap.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/compiler

src/share/vm/compiler/oopMap.hpp

Print this page




 126 
 127   // Physical location queries
 128   bool is_register_loc()      { return reg()->is_reg(); }
 129   bool is_stack_loc()         { return reg()->is_stack(); }
 130 
 131   // Returns offset from sp.
 132   int stack_offset() {
 133     assert(is_stack_loc(), "must be stack location");
 134     return reg()->reg2stack();
 135   }
 136 
 137   void print_on(outputStream* st) const;
 138   void print() const { print_on(tty); }
 139 };
 140 
 141 
 142 class OopMap: public ResourceObj {
 143   friend class OopMapStream;
 144   friend class VMStructs;
 145  private:
 146   int  _pc_offset;
 147   int  _omv_count;
 148   int  _omv_data_size;
 149   unsigned char* _omv_data;
 150   CompressedWriteStream* _write_stream;
 151 
 152   debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;)
 153 
 154   // Accessors
 155   unsigned char* omv_data() const             { return _omv_data; }
 156   void set_omv_data(unsigned char* value)     { _omv_data = value; }
 157   int omv_data_size() const                   { return _omv_data_size; }
 158   void set_omv_data_size(int value)           { _omv_data_size = value; }
 159   int omv_count() const                       { return _omv_count; }
 160   void set_omv_count(int value)               { _omv_count = value; }
 161   void increment_count()                      { _omv_count++; }
 162   CompressedWriteStream* write_stream() const { return _write_stream; }
 163   void set_write_stream(CompressedWriteStream* value) { _write_stream = value; }
 164 
 165  private:
 166   enum DeepCopyToken { _deep_copy_token };
 167   OopMap(DeepCopyToken, OopMap* source);  // used only by deep_copy
 168 
 169  public:
 170   OopMap(int frame_size, int arg_count);
 171 
 172   // pc-offset handling
 173   int offset() const     { return _pc_offset; }
 174   void set_offset(int o) { _pc_offset = o; }



 175 
 176   // Check to avoid double insertion
 177   debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; })
 178 
 179   // Construction
 180   // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
 181   // slots to hold 4-byte values like ints and floats in the LP64 build.
 182   void set_oop  ( VMReg local);
 183   void set_value( VMReg local);
 184   void set_narrowoop(VMReg local);
 185   void set_dead ( VMReg local);
 186   void set_callee_saved( VMReg local, VMReg caller_machine_register );
 187   void set_derived_oop ( VMReg local, VMReg derived_from_local_register );
 188   void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional);
 189 
 190   int heap_size() const;
 191   void copy_to(address addr);
 192   OopMap* deep_copy();
 193 
 194   bool has_derived_pointer() const PRODUCT_RETURN0;
 195 
 196   bool legal_vm_reg_name(VMReg local) {
 197      return OopMapValue::legal_vm_reg_name(local);
 198   }
 199 
 200   // Printing
 201   void print_on(outputStream* st) const;
 202   void print() const { print_on(tty); }

 203 };
 204 
 205 
 206 class OopMapSet : public ResourceObj {
 207   friend class VMStructs;
 208  private:
 209   int _om_count;
 210   int _om_size;
 211   OopMap** _om_data;
 212 
 213   int om_count() const              { return _om_count; }
 214   void set_om_count(int value)      { _om_count = value; }
 215   void increment_count()            { _om_count++; }
 216   int om_size() const               { return _om_size; }
 217   void set_om_size(int value)       { _om_size = value; }
 218   OopMap** om_data() const          { return _om_data; }
 219   void set_om_data(OopMap** value)  { _om_data = value; }
 220   void grow_om_data();
 221   void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; }
 222 
 223  public:
 224   OopMapSet();
 225 
 226   // returns the number of OopMaps in this OopMapSet
 227   int size() const            { return _om_count; }
 228   // returns the OopMap at a given index
 229   OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; }
 230 
 231   // Collect OopMaps.
 232   void add_gc_map(int pc, OopMap* map);
 233 
 234   // Returns the only oop map. Used for reconstructing
 235   // Adapter frames during deoptimization
 236   OopMap* singular_oop_map();
 237 
 238   // returns OopMap in that is anchored to the pc
 239   OopMap* find_map_at_offset(int pc_offset) const;
 240 
 241   int heap_size() const;
 242   void copy_to(address addr);
 243 
 244   // Methods oops_do() and all_do() filter out NULL oops and
 245   // oop == Universe::narrow_oop_base() before passing oops
 246   // to closures.
 247 
 248   // Iterates through frame for a compiled method
 249   static void oops_do            (const frame* fr,
 250                                   const RegisterMap* reg_map, OopClosure* f);
 251   static void update_register_map(const frame* fr, RegisterMap *reg_map);
 252 
 253   // Iterates through frame for a compiled method for dead ones and values, too
 254   static void all_do(const frame* fr, const RegisterMap* reg_map,
 255                      OopClosure* oop_fn,
 256                      void derived_oop_fn(oop* base, oop* derived),
 257                      OopClosure* value_fn);
 258 
 259   // Printing
 260   void print_on(outputStream* st) const;
 261   void print() const { print_on(tty); }
 262 };
 263 









































































 264 
 265 class OopMapStream : public StackObj {
 266  private:
 267   CompressedReadStream* _stream;
 268   int _mask;
 269   int _size;
 270   int _position;
 271   bool _valid_omv;
 272   OopMapValue _omv;
 273   void find_next();
 274 
 275  public:
 276   OopMapStream(OopMap* oop_map);
 277   OopMapStream(OopMap* oop_map, int oop_types_mask);
 278   bool is_done()                        { if(!_valid_omv) { find_next(); } return !_valid_omv; }
 279   void next()                           { find_next(); }
 280   OopMapValue current()                 { return _omv; }
 281 };
 282 
 283 
 284 // Derived pointer support. This table keeps track of all derived points on a
 285 // stack.  It is cleared before each scavenge/GC.  During the traversal of all
 286 // oops, it is filled in with references to all locations that contains a
 287 // derived oop (assumed to be very few).  When the GC is complete, the derived
 288 // pointers are updated based on their base pointers new value and an offset.
 289 #ifdef COMPILER2
 290 class DerivedPointerTable : public AllStatic {
 291   friend class VMStructs;
 292  private:
 293    static GrowableArray<DerivedPointerEntry*>* _list;
 294    static bool _active;                      // do not record pointers for verify pass etc.
 295  public:
 296   static void clear();                       // Called before scavenge/GC
 297   static void add(oop *derived, oop *base);  // Called during scavenge/GC




 126 
 127   // Physical location queries
 128   bool is_register_loc()      { return reg()->is_reg(); }
 129   bool is_stack_loc()         { return reg()->is_stack(); }
 130 
 131   // Returns offset from sp.
 132   int stack_offset() {
 133     assert(is_stack_loc(), "must be stack location");
 134     return reg()->reg2stack();
 135   }
 136 
 137   void print_on(outputStream* st) const;
 138   void print() const { print_on(tty); }
 139 };
 140 
 141 
 142 class OopMap: public ResourceObj {
 143   friend class OopMapStream;
 144   friend class VMStructs;
 145  private:
 146   int  _pc_offset; // offset in the code that this OopMap corresponds to
 147   int  _omv_count; // number of OopMapValues in the stream


 148   CompressedWriteStream* _write_stream;
 149 
 150   debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;)
 151 
 152   // Accessors




 153   int omv_count() const                       { return _omv_count; }
 154   void set_omv_count(int value)               { _omv_count = value; }
 155   void increment_count()                      { _omv_count++; }
 156   CompressedWriteStream* write_stream() const { return _write_stream; }
 157   void set_write_stream(CompressedWriteStream* value) { _write_stream = value; }
 158 
 159  private:
 160   enum DeepCopyToken { _deep_copy_token };
 161   OopMap(DeepCopyToken, OopMap* source);  // used only by deep_copy
 162 
 163  public:
 164   OopMap(int frame_size, int arg_count);
 165 
 166   // pc-offset handling
 167   int offset() const     { return _pc_offset; }
 168   void set_offset(int o) { _pc_offset = o; }
 169   int count() const { return _omv_count; }
 170   int data_size() const  { return write_stream()->position(); }
 171   address data() const { return write_stream()->buffer(); }
 172 
 173   // Check to avoid double insertion
 174   debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; })
 175 
 176   // Construction
 177   // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
 178   // slots to hold 4-byte values like ints and floats in the LP64 build.
 179   void set_oop  ( VMReg local);
 180   void set_value( VMReg local);
 181   void set_narrowoop(VMReg local);
 182   void set_dead ( VMReg local);
 183   void set_callee_saved( VMReg local, VMReg caller_machine_register );
 184   void set_derived_oop ( VMReg local, VMReg derived_from_local_register );
 185   void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional);
 186 
 187   int heap_size() const;
 188   void copy_data_to(address addr) const;
 189   OopMap* deep_copy();
 190 


 191   bool legal_vm_reg_name(VMReg local) {
 192      return OopMapValue::legal_vm_reg_name(local);
 193   }
 194 
 195   // Printing
 196   void print_on(outputStream* st) const;
 197   void print() const { print_on(tty); }
 198   bool equals(const OopMap* other) const;
 199 };
 200 
 201 
 202 class OopMapSet : public ResourceObj {
 203   friend class VMStructs;
 204  private:
 205   int _om_count;
 206   int _om_size;
 207   OopMap** _om_data;
 208 
 209   int om_count() const              { return _om_count; }
 210   void set_om_count(int value)      { _om_count = value; }
 211   void increment_count()            { _om_count++; }
 212   int om_size() const               { return _om_size; }
 213   void set_om_size(int value)       { _om_size = value; }
 214   OopMap** om_data() const          { return _om_data; }
 215   void set_om_data(OopMap** value)  { _om_data = value; }
 216   void grow_om_data();
 217   void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; }
 218 
 219  public:
 220   OopMapSet();
 221 
 222   // returns the number of OopMaps in this OopMapSet
 223   int size() const            { return _om_count; }
 224   // returns the OopMap at a given index
 225   OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; }
 226 
 227   // Collect OopMaps.
 228   void add_gc_map(int pc, OopMap* map);
 229 
 230   // Returns the only oop map. Used for reconstructing
 231   // Adapter frames during deoptimization
 232   OopMap* singular_oop_map();
 233 
 234   // returns OopMap in that is anchored to the pc
 235   OopMap* find_map_at_offset(int pc_offset) const;
 236 
 237   int heap_size() const;

 238 
 239   // Methods oops_do() and all_do() filter out NULL oops and
 240   // oop == Universe::narrow_oop_base() before passing oops
 241   // to closures.
 242 
 243   // Iterates through frame for a compiled method
 244   static void oops_do            (const frame* fr,
 245                                   const RegisterMap* reg_map, OopClosure* f);
 246   static void update_register_map(const frame* fr, RegisterMap *reg_map);
 247 
 248   // Iterates through frame for a compiled method for dead ones and values, too
 249   static void all_do(const frame* fr, const RegisterMap* reg_map,
 250                      OopClosure* oop_fn,
 251                      void derived_oop_fn(oop* base, oop* derived),
 252                      OopClosure* value_fn);
 253 
 254   // Printing
 255   void print_on(outputStream* st) const;
 256   void print() const { print_on(tty); }
 257 };
 258 
 259 class ImmutableOopMapBuilder;
 260 
 261 class ImmutableOopMap {
 262   friend class OopMapStream;
 263   friend class VMStructs;
 264 #ifdef ASSERT
 265   friend class ImmutableOopMapBuilder;
 266 #endif
 267 private:
 268   int _count; // contains the number of entries in this OopMap
 269 
 270   address data_addr() const { return (address) this + sizeof(ImmutableOopMap); }
 271 public:
 272   ImmutableOopMap(const OopMap* oopmap);
 273 
 274   bool has_derived_pointer() const PRODUCT_RETURN0;
 275   int count() const { return _count; }
 276 
 277   // Printing
 278   void print_on(outputStream* st) const;
 279   void print() const { print_on(tty); }
 280 };
 281 
 282 class ImmutableOopMapSet;
 283 class ImmutableOopMap;
 284 class OopMapSet;
 285 
 286 class ImmutableOopMapPair {
 287   friend class VMStructs;
 288 private:
 289   int _pc_offset; // program counter offset from the beginning of the method
 290   int _oopmap_offset; // offset in the data in the ImmutableOopMapSet where the ImmutableOopMap is located
 291 public:
 292   ImmutableOopMapPair(int pc_offset, int oopmap_offset) : _pc_offset(pc_offset), _oopmap_offset(oopmap_offset) {
 293     assert(pc_offset >= 0 && oopmap_offset >= 0, "check");
 294   }
 295   const ImmutableOopMap* get_from(const ImmutableOopMapSet* set) const;
 296 
 297   int pc_offset() const { return _pc_offset; }
 298   int oopmap_offset() const { return _oopmap_offset; }
 299 };
 300 
 301 class ImmutableOopMapSet {
 302   friend class VMStructs;
 303 private:
 304   int _count; // nr of ImmutableOopMapPairs in the Set
 305   int _size; // nr of bytes including ImmutableOopMapSet itself
 306 
 307   address data() const { return (address) this + sizeof(*this) + sizeof(ImmutableOopMapPair) * _count; }
 308 
 309 public:
 310   ImmutableOopMapSet(const OopMapSet* oopmap_set, int size) : _count(oopmap_set->size()), _size(size) {}
 311 
 312   ImmutableOopMap* oopmap_at_offset(int offset) const {
 313     assert(offset >= 0 && offset < _size, "must be within boundaries");
 314     address addr = data() + offset;
 315     return (ImmutableOopMap*) addr;
 316   }
 317 
 318   ImmutableOopMapPair* get_pairs() const { return (ImmutableOopMapPair*) ((address) this + sizeof(*this)); }
 319 
 320   static ImmutableOopMapSet* build_from(const OopMapSet* oopmap_set);
 321 
 322   const ImmutableOopMap* find_map_at_offset(int pc_offset) const;
 323 
 324   const ImmutableOopMapPair* pair_at(int index) const { assert(index >= 0 && index < _count, "check"); return &get_pairs()[index]; }
 325 
 326   int count() const { return _count; }
 327   int size() const { return _size; }
 328 
 329   void print_on(outputStream* st) const;
 330   void print() const { print_on(tty); }
 331 };
 332 
 333 class OopMapStream : public StackObj {
 334  private:
 335   CompressedReadStream* _stream;
 336   int _mask;
 337   int _size;
 338   int _position;
 339   bool _valid_omv;
 340   OopMapValue _omv;
 341   void find_next();
 342 
 343  public:
 344   OopMapStream(OopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place);
 345   OopMapStream(const ImmutableOopMap* oop_map, int oop_types_mask = OopMapValue::type_mask_in_place);
 346   bool is_done()                        { if(!_valid_omv) { find_next(); } return !_valid_omv; }
 347   void next()                           { find_next(); }
 348   OopMapValue current()                 { return _omv; }
 349 };
 350 
 351 
 352 // Derived pointer support. This table keeps track of all derived points on a
 353 // stack.  It is cleared before each scavenge/GC.  During the traversal of all
 354 // oops, it is filled in with references to all locations that contains a
 355 // derived oop (assumed to be very few).  When the GC is complete, the derived
 356 // pointers are updated based on their base pointers new value and an offset.
 357 #ifdef COMPILER2
 358 class DerivedPointerTable : public AllStatic {
 359   friend class VMStructs;
 360  private:
 361    static GrowableArray<DerivedPointerEntry*>* _list;
 362    static bool _active;                      // do not record pointers for verify pass etc.
 363  public:
 364   static void clear();                       // Called before scavenge/GC
 365   static void add(oop *derived, oop *base);  // Called during scavenge/GC


src/share/vm/compiler/oopMap.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File