hotspot/src/share/vm/runtime/stubCodeGenerator.hpp
changeset 36074 11263906664c
parent 31620 53be635ad49c
child 36301 cb578d8c6cba
equal deleted inserted replaced
36073:1c0381cc1e1d 36074:11263906664c
    26 #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
    26 #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
    27 
    27 
    28 #include "asm/assembler.hpp"
    28 #include "asm/assembler.hpp"
    29 #include "memory/allocation.hpp"
    29 #include "memory/allocation.hpp"
    30 
    30 
    31 // All the basic framework for stubcode generation/debugging/printing.
    31 // All the basic framework for stub code generation/debugging/printing.
    32 
    32 
    33 
    33 
    34 // A StubCodeDesc describes a piece of generated code (usually stubs).
    34 // A StubCodeDesc describes a piece of generated code (usually stubs).
    35 // This information is mainly useful for debugging and printing.
    35 // This information is mainly useful for debugging and printing.
    36 // Currently, code descriptors are simply chained in a linked list,
    36 // Currently, code descriptors are simply chained in a linked list,
    37 // this may have to change if searching becomes too slow.
    37 // this may have to change if searching becomes too slow.
    38 
    38 
    39 class StubCodeDesc: public CHeapObj<mtCode> {
    39 class StubCodeDesc: public CHeapObj<mtCode> {
    40  protected:
    40  private:
    41   static StubCodeDesc* _list;                  // the list of all descriptors
    41   static StubCodeDesc* _list;                  // the list of all descriptors
    42   static int           _count;                 // length of list
    42   static int           _count;                 // length of list
       
    43   static bool          _frozen;                // determines whether _list modifications are allowed
    43 
    44 
    44   StubCodeDesc*        _next;                  // the next element in the linked list
    45   StubCodeDesc*        _next;                  // the next element in the linked list
    45   const char*          _group;                 // the group to which the stub code belongs
    46   const char*          _group;                 // the group to which the stub code belongs
    46   const char*          _name;                  // the name assigned to the stub code
    47   const char*          _name;                  // the name assigned to the stub code
    47   int                  _index;                 // serial number assigned to the stub
    48   int                  _index;                 // serial number assigned to the stub
    66   static StubCodeDesc* desc_for(address pc);     // returns the code descriptor for the code containing pc or NULL
    67   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 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   static const char*   name_for(address pc);     // returns the name of the code containing pc or NULL
    69 
    70 
    70   StubCodeDesc(const char* group, const char* name, address begin, address end = NULL) {
    71   StubCodeDesc(const char* group, const char* name, address begin, address end = NULL) {
       
    72     assert(!_frozen, "no modifications allowed");
    71     assert(name != NULL, "no name specified");
    73     assert(name != NULL, "no name specified");
    72     _next           = _list;
    74     _next           = _list;
    73     _group          = group;
    75     _group          = group;
    74     _name           = name;
    76     _name           = name;
    75     _index          = ++_count; // (never zero)
    77     _index          = ++_count; // (never zero)
    76     _begin          = begin;
    78     _begin          = begin;
    77     _end            = end;
    79     _end            = end;
    78     _list           = this;
    80     _list           = this;
    79   };
    81   };
       
    82 
       
    83   static void freeze();
    80 
    84 
    81   const char* group() const                      { return _group; }
    85   const char* group() const                      { return _group; }
    82   const char* name() const                       { return _name; }
    86   const char* name() const                       { return _name; }
    83   int         index() const                      { return _index; }
    87   int         index() const                      { return _index; }
    84   address     begin() const                      { return _begin; }
    88   address     begin() const                      { return _begin; }
   115 // All stub code generating functions that use a StubCodeMark will be registered
   119 // All stub code generating functions that use a StubCodeMark will be registered
   116 // in the global StubCodeDesc list and the generated stub code can be identified
   120 // in the global StubCodeDesc list and the generated stub code can be identified
   117 // later via an address pointing into it.
   121 // later via an address pointing into it.
   118 
   122 
   119 class StubCodeMark: public StackObj {
   123 class StubCodeMark: public StackObj {
   120  protected:
   124  private:
   121   StubCodeGenerator* _cgen;
   125   StubCodeGenerator* _cgen;
   122   StubCodeDesc*      _cdesc;
   126   StubCodeDesc*      _cdesc;
   123 
   127 
   124  public:
   128  public:
   125   StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name);
   129   StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name);