< prev index next >

src/share/vm/runtime/stubCodeGenerator.hpp

Print this page
rev 8555 : 8206406: StubCodeDesc constructor publishes partially-constructed objects on StubCodeDesc::_list
Reviewed-by: dholmes


  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
  26 #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
  27 
  28 #include "asm/assembler.hpp"
  29 #include "memory/allocation.hpp"
  30 
  31 // All the basic framework for stubcode generation/debugging/printing.
  32 
  33 
  34 // A StubCodeDesc describes a piece of generated code (usually stubs).
  35 // This information is mainly useful for debugging and printing.
  36 // Currently, code descriptors are simply chained in a linked list,
  37 // this may have to change if searching becomes too slow.
  38 
  39 class StubCodeDesc: public CHeapObj<mtCode> {
  40  protected:
  41   static StubCodeDesc* _list;                  // the list of all descriptors
  42   static int           _count;                 // length of list
  43 
  44   StubCodeDesc*        _next;                  // the next element in the linked list
  45   const char*          _group;                 // the group to which the stub code belongs
  46   const char*          _name;                  // the name assigned to the stub code
  47   int                  _index;                 // serial number assigned to the stub
  48   address              _begin;                 // points to the first byte of the stub code    (included)
  49   address              _end;                   // points to the first byte after the stub code (excluded)
  50 
  51   void set_end(address end) {
  52     assert(_begin <= end, "begin & end not properly ordered");
  53     _end = end;
  54   }
  55 
  56   void set_begin(address begin) {
  57     assert(begin >= _begin, "begin may not decrease");
  58     assert(_end == NULL || begin <= _end, "begin & end not properly ordered");
  59     _begin = begin;
  60   }
  61 
  62   friend class StubCodeMark;
  63   friend class StubCodeGenerator;
  64 
  65  public:
  66   static StubCodeDesc* desc_for(address pc);     // returns the code descriptor for the code containing pc or NULL
  67   static StubCodeDesc* desc_for_index(int);      // returns the code descriptor for the index or NULL
  68   static const char*   name_for(address pc);     // returns the name of the code containing pc or NULL
  69 
  70   StubCodeDesc(const char* group, const char* name, address begin) {
  71     assert(name != NULL, "no name specified");
  72     _next           = _list;
  73     _group          = group;
  74     _name           = name;
  75     _index          = ++_count; // (never zero)
  76     _begin          = begin;
  77     _end            = NULL;
  78     _list           = this;
  79   };
  80 
  81   const char* group() const                      { return _group; }
  82   const char* name() const                       { return _name; }
  83   int         index() const                      { return _index; }
  84   address     begin() const                      { return _begin; }
  85   address     end() const                        { return _end; }
  86   int         size_in_bytes() const              { return _end - _begin; }
  87   bool        contains(address pc) const         { return _begin <= pc && pc < _end; }
  88   void        print_on(outputStream* st) const;
  89   void        print() const                      { print_on(tty); }
  90 };
  91 
  92 // The base class for all stub-generating code generators.
  93 // Provides utility functions.
  94 
  95 class StubCodeGenerator: public StackObj {
  96  protected:
  97   MacroAssembler*  _masm;
  98 




  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
  26 #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
  27 
  28 #include "asm/assembler.hpp"
  29 #include "memory/allocation.hpp"
  30 
  31 // All the basic framework for stubcode generation/debugging/printing.
  32 
  33 
  34 // A StubCodeDesc describes a piece of generated code (usually stubs).
  35 // This information is mainly useful for debugging and printing.
  36 // Currently, code descriptors are simply chained in a linked list,
  37 // this may have to change if searching becomes too slow.
  38 
  39 class StubCodeDesc: public CHeapObj<mtCode> {
  40  protected:
  41   static StubCodeDesc* volatile _list;         // the list of all descriptors
  42   static int           _count;                 // length of list
  43 
  44   StubCodeDesc*        _next;                  // the next element in the linked list
  45   const char*          _group;                 // the group to which the stub code belongs
  46   const char*          _name;                  // the name assigned to the stub code
  47   int                  _index;                 // serial number assigned to the stub
  48   address              _begin;                 // points to the first byte of the stub code    (included)
  49   address              _end;                   // points to the first byte after the stub code (excluded)
  50 
  51   void set_end(address end) {
  52     assert(_begin <= end, "begin & end not properly ordered");
  53     _end = end;
  54   }
  55 
  56   void set_begin(address begin) {
  57     assert(begin >= _begin, "begin may not decrease");
  58     assert(_end == NULL || begin <= _end, "begin & end not properly ordered");
  59     _begin = begin;
  60   }
  61 
  62   friend class StubCodeMark;
  63   friend class StubCodeGenerator;
  64 
  65  public:
  66   static StubCodeDesc* desc_for(address pc);     // returns the code descriptor for the code containing pc or NULL
  67   static StubCodeDesc* desc_for_index(int);      // returns the code descriptor for the index or NULL
  68   static const char*   name_for(address pc);     // returns the name of the code containing pc or NULL
  69 
  70   StubCodeDesc(const char* group, const char* name, address begin) {
  71     assert(name != NULL, "no name specified");
  72     _next           = (StubCodeDesc*)OrderAccess::load_ptr_acquire(&_list);
  73     _group          = group;
  74     _name           = name;
  75     _index          = ++_count; // (never zero)
  76     _begin          = begin;
  77     _end            = NULL;
  78     OrderAccess::release_store_ptr(&_list, this);
  79   };
  80 
  81   const char* group() const                      { return _group; }
  82   const char* name() const                       { return _name; }
  83   int         index() const                      { return _index; }
  84   address     begin() const                      { return _begin; }
  85   address     end() const                        { return _end; }
  86   int         size_in_bytes() const              { return _end - _begin; }
  87   bool        contains(address pc) const         { return _begin <= pc && pc < _end; }
  88   void        print_on(outputStream* st) const;
  89   void        print() const                      { print_on(tty); }
  90 };
  91 
  92 // The base class for all stub-generating code generators.
  93 // Provides utility functions.
  94 
  95 class StubCodeGenerator: public StackObj {
  96  protected:
  97   MacroAssembler*  _masm;
  98 


< prev index next >