< prev index next >

src/hotspot/share/code/relocInfo.hpp

Print this page




 235 //
 236 // Note that the compiler is responsible for ensuring the "fldOffset" when
 237 // added to "%lo(myObject)" does not overflow the immediate fields of the
 238 // memory instructions.
 239 //
 240 //
 241 // [About Offsets] Relative offsets are supplied to this module as
 242 // positive byte offsets, but they may be internally stored scaled
 243 // and/or negated, depending on what is most compact for the target
 244 // system.  Since the object pointed to by the offset typically
 245 // precedes the relocation address, it is profitable to store
 246 // these negative offsets as positive numbers, but this decision
 247 // is internal to the relocation information abstractions.
 248 //
 249 
 250 class Relocation;
 251 class CodeBuffer;
 252 class CodeSection;
 253 class RelocIterator;
 254 
 255 class relocInfo VALUE_OBJ_CLASS_SPEC {
 256   friend class RelocIterator;
 257  public:
 258   enum relocType {
 259     none                    =  0, // Used when no relocation should be generated
 260     oop_type                =  1, // embedded oop
 261     virtual_call_type       =  2, // a standard inline cache call for a virtual send
 262     opt_virtual_call_type   =  3, // a virtual call that has been statically bound (i.e., no IC cache)
 263     static_call_type        =  4, // a static send
 264     static_stub_type        =  5, // stub-entry for static send  (takes care of interpreter case)
 265     runtime_call_type       =  6, // call to fixed external routine
 266     external_word_type      =  7, // reference to fixed external address
 267     internal_word_type      =  8, // reference within the current code blob
 268     section_word_type       =  9, // internal, but a cross-section reference
 269     poll_type               = 10, // polling instruction for safepoints
 270     poll_return_type        = 11, // polling instruction for safepoints at return
 271     metadata_type           = 12, // metadata that used to be oops
 272     trampoline_stub_type    = 13, // stub-entry for trampoline
 273     runtime_call_w_cp_type  = 14, // Runtime call which may load its target from the constant pool
 274     data_prefix_tag         = 15, // tag for a prefix (carries data arguments)
 275     type_mask               = 15  // A mask which selects only the above values


 452 #define FORWARD_DECLARE_EACH_CLASS(name)              \
 453 class name##_Relocation;
 454 APPLY_TO_RELOCATIONS(FORWARD_DECLARE_EACH_CLASS)
 455 #undef FORWARD_DECLARE_EACH_CLASS
 456 
 457 
 458 
 459 inline relocInfo filler_relocInfo() {
 460   return relocInfo(relocInfo::none, relocInfo::offset_limit() - relocInfo::offset_unit);
 461 }
 462 
 463 inline relocInfo prefix_relocInfo(int datalen = 0) {
 464   assert(relocInfo::fits_into_immediate(datalen), "datalen in limits");
 465   return relocInfo(relocInfo::data_prefix_tag, relocInfo::RAW_BITS, relocInfo::datalen_tag | datalen);
 466 }
 467 
 468 
 469 // Holder for flyweight relocation objects.
 470 // Although the flyweight subclasses are of varying sizes,
 471 // the holder is "one size fits all".
 472 class RelocationHolder VALUE_OBJ_CLASS_SPEC {
 473   friend class Relocation;
 474   friend class CodeSection;
 475 
 476  private:
 477   // this preallocated memory must accommodate all subclasses of Relocation
 478   // (this number is assertion-checked in Relocation::operator new)
 479   enum { _relocbuf_size = 5 };
 480   void* _relocbuf[ _relocbuf_size ];
 481 
 482  public:
 483   Relocation* reloc() const { return (Relocation*) &_relocbuf[0]; }
 484   inline relocInfo::relocType type() const;
 485 
 486   // Add a constant offset to a relocation.  Helper for class Address.
 487   RelocationHolder plus(int offset) const;
 488 
 489   inline RelocationHolder();                // initializes type to none
 490 
 491   inline RelocationHolder(Relocation* r);   // make a copy
 492 


 623   // type-specific relocation accessors:  oop_Relocation* oop_reloc(), etc.
 624   #define EACH_TYPE(name)                               \
 625   inline name##_Relocation* name##_reloc();
 626   APPLY_TO_RELOCATIONS(EACH_TYPE)
 627   #undef EACH_TYPE
 628   // generic relocation accessor; switches on type to call the above
 629   Relocation* reloc();
 630 
 631 #ifndef PRODUCT
 632  public:
 633   void print();
 634   void print_current();
 635 #endif
 636 };
 637 
 638 
 639 // A Relocation is a flyweight object allocated within a RelocationHolder.
 640 // It represents the relocation data of relocation record.
 641 // So, the RelocIterator unpacks relocInfos into Relocations.
 642 
 643 class Relocation VALUE_OBJ_CLASS_SPEC {
 644   friend class RelocationHolder;
 645   friend class RelocIterator;
 646 
 647  private:
 648   static void guarantee_size();
 649 
 650   // When a relocation has been created by a RelocIterator,
 651   // this field is non-null.  It allows the relocation to know
 652   // its context, such as the address to which it applies.
 653   RelocIterator* _binding;
 654 
 655  protected:
 656   RelocIterator* binding() const {
 657     assert(_binding != NULL, "must be bound");
 658     return _binding;
 659   }
 660   void set_binding(RelocIterator* b) {
 661     assert(_binding == NULL, "must be unbound");
 662     _binding = b;
 663     assert(_binding != NULL, "must now be bound");




 235 //
 236 // Note that the compiler is responsible for ensuring the "fldOffset" when
 237 // added to "%lo(myObject)" does not overflow the immediate fields of the
 238 // memory instructions.
 239 //
 240 //
 241 // [About Offsets] Relative offsets are supplied to this module as
 242 // positive byte offsets, but they may be internally stored scaled
 243 // and/or negated, depending on what is most compact for the target
 244 // system.  Since the object pointed to by the offset typically
 245 // precedes the relocation address, it is profitable to store
 246 // these negative offsets as positive numbers, but this decision
 247 // is internal to the relocation information abstractions.
 248 //
 249 
 250 class Relocation;
 251 class CodeBuffer;
 252 class CodeSection;
 253 class RelocIterator;
 254 
 255 class relocInfo {
 256   friend class RelocIterator;
 257  public:
 258   enum relocType {
 259     none                    =  0, // Used when no relocation should be generated
 260     oop_type                =  1, // embedded oop
 261     virtual_call_type       =  2, // a standard inline cache call for a virtual send
 262     opt_virtual_call_type   =  3, // a virtual call that has been statically bound (i.e., no IC cache)
 263     static_call_type        =  4, // a static send
 264     static_stub_type        =  5, // stub-entry for static send  (takes care of interpreter case)
 265     runtime_call_type       =  6, // call to fixed external routine
 266     external_word_type      =  7, // reference to fixed external address
 267     internal_word_type      =  8, // reference within the current code blob
 268     section_word_type       =  9, // internal, but a cross-section reference
 269     poll_type               = 10, // polling instruction for safepoints
 270     poll_return_type        = 11, // polling instruction for safepoints at return
 271     metadata_type           = 12, // metadata that used to be oops
 272     trampoline_stub_type    = 13, // stub-entry for trampoline
 273     runtime_call_w_cp_type  = 14, // Runtime call which may load its target from the constant pool
 274     data_prefix_tag         = 15, // tag for a prefix (carries data arguments)
 275     type_mask               = 15  // A mask which selects only the above values


 452 #define FORWARD_DECLARE_EACH_CLASS(name)              \
 453 class name##_Relocation;
 454 APPLY_TO_RELOCATIONS(FORWARD_DECLARE_EACH_CLASS)
 455 #undef FORWARD_DECLARE_EACH_CLASS
 456 
 457 
 458 
 459 inline relocInfo filler_relocInfo() {
 460   return relocInfo(relocInfo::none, relocInfo::offset_limit() - relocInfo::offset_unit);
 461 }
 462 
 463 inline relocInfo prefix_relocInfo(int datalen = 0) {
 464   assert(relocInfo::fits_into_immediate(datalen), "datalen in limits");
 465   return relocInfo(relocInfo::data_prefix_tag, relocInfo::RAW_BITS, relocInfo::datalen_tag | datalen);
 466 }
 467 
 468 
 469 // Holder for flyweight relocation objects.
 470 // Although the flyweight subclasses are of varying sizes,
 471 // the holder is "one size fits all".
 472 class RelocationHolder {
 473   friend class Relocation;
 474   friend class CodeSection;
 475 
 476  private:
 477   // this preallocated memory must accommodate all subclasses of Relocation
 478   // (this number is assertion-checked in Relocation::operator new)
 479   enum { _relocbuf_size = 5 };
 480   void* _relocbuf[ _relocbuf_size ];
 481 
 482  public:
 483   Relocation* reloc() const { return (Relocation*) &_relocbuf[0]; }
 484   inline relocInfo::relocType type() const;
 485 
 486   // Add a constant offset to a relocation.  Helper for class Address.
 487   RelocationHolder plus(int offset) const;
 488 
 489   inline RelocationHolder();                // initializes type to none
 490 
 491   inline RelocationHolder(Relocation* r);   // make a copy
 492 


 623   // type-specific relocation accessors:  oop_Relocation* oop_reloc(), etc.
 624   #define EACH_TYPE(name)                               \
 625   inline name##_Relocation* name##_reloc();
 626   APPLY_TO_RELOCATIONS(EACH_TYPE)
 627   #undef EACH_TYPE
 628   // generic relocation accessor; switches on type to call the above
 629   Relocation* reloc();
 630 
 631 #ifndef PRODUCT
 632  public:
 633   void print();
 634   void print_current();
 635 #endif
 636 };
 637 
 638 
 639 // A Relocation is a flyweight object allocated within a RelocationHolder.
 640 // It represents the relocation data of relocation record.
 641 // So, the RelocIterator unpacks relocInfos into Relocations.
 642 
 643 class Relocation {
 644   friend class RelocationHolder;
 645   friend class RelocIterator;
 646 
 647  private:
 648   static void guarantee_size();
 649 
 650   // When a relocation has been created by a RelocIterator,
 651   // this field is non-null.  It allows the relocation to know
 652   // its context, such as the address to which it applies.
 653   RelocIterator* _binding;
 654 
 655  protected:
 656   RelocIterator* binding() const {
 657     assert(_binding != NULL, "must be bound");
 658     return _binding;
 659   }
 660   void set_binding(RelocIterator* b) {
 661     assert(_binding == NULL, "must be unbound");
 662     _binding = b;
 663     assert(_binding != NULL, "must now be bound");


< prev index next >