src/share/vm/runtime/stubCodeGenerator.hpp

Sat, 01 Dec 2007 00:00:00 +0000

author
duke
date
Sat, 01 Dec 2007 00:00:00 +0000
changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Initial load

     1 /*
     2  * Copyright 1997-2000 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // All the basic framework for stubcode generation/debugging/printing.
    28 // A StubCodeDesc describes a piece of generated code (usually stubs).
    29 // This information is mainly useful for debugging and printing.
    30 // Currently, code descriptors are simply chained in a linked list,
    31 // this may have to change if searching becomes too slow.
    33 class StubCodeDesc: public CHeapObj {
    34  protected:
    35   static StubCodeDesc* _list;                  // the list of all descriptors
    36   static int           _count;                 // length of list
    38   StubCodeDesc*        _next;                  // the next element in the linked list
    39   const char*          _group;                 // the group to which the stub code belongs
    40   const char*          _name;                  // the name assigned to the stub code
    41   int                  _index;                 // serial number assigned to the stub
    42   address              _begin;                 // points to the first byte of the stub code    (included)
    43   address              _end;                   // points to the first byte after the stub code (excluded)
    45   void set_end(address end) {
    46     assert(_begin <= end, "begin & end not properly ordered");
    47     _end = end;
    48   }
    50   void set_begin(address begin) {
    51     assert(begin >= _begin, "begin may not decrease");
    52     assert(_end == NULL || begin <= _end, "begin & end not properly ordered");
    53     _begin = begin;
    54   }
    56   friend class StubCodeMark;
    57   friend class StubCodeGenerator;
    59  public:
    60   static StubCodeDesc* desc_for(address pc);     // returns the code descriptor for the code containing pc or NULL
    61   static StubCodeDesc* desc_for_index(int);      // returns the code descriptor for the index or NULL
    62   static const char*   name_for(address pc);     // returns the name of the code containing pc or NULL
    64   StubCodeDesc(const char* group, const char* name, address begin) {
    65     assert(name != NULL, "no name specified");
    66     _next           = _list;
    67     _group          = group;
    68     _name           = name;
    69     _index          = ++_count; // (never zero)
    70     _begin          = begin;
    71     _end            = NULL;
    72     _list           = this;
    73   };
    75   const char* group() const                      { return _group; }
    76   const char* name() const                       { return _name; }
    77   int         index() const                      { return _index; }
    78   address     begin() const                      { return _begin; }
    79   address     end() const                        { return _end; }
    80   int         size_in_bytes() const              { return _end - _begin; }
    81   bool        contains(address pc) const         { return _begin <= pc && pc < _end; }
    82   void        print();
    83 };
    85 // The base class for all stub-generating code generators.
    86 // Provides utility functions.
    88 class StubCodeGenerator: public StackObj {
    89  protected:
    90   MacroAssembler*  _masm;
    92   StubCodeDesc* _first_stub;
    93   StubCodeDesc* _last_stub;
    95  public:
    96   StubCodeGenerator(CodeBuffer* code);
    97   ~StubCodeGenerator();
    99   MacroAssembler* assembler() const              { return _masm; }
   101   virtual void stub_prolog(StubCodeDesc* cdesc); // called by StubCodeMark constructor
   102   virtual void stub_epilog(StubCodeDesc* cdesc); // called by StubCodeMark destructor
   103 };
   106 // Stack-allocated helper class used to assciate a stub code with a name.
   107 // All stub code generating functions that use a StubCodeMark will be registered
   108 // in the global StubCodeDesc list and the generated stub code can be identified
   109 // later via an address pointing into it.
   111 class StubCodeMark: public StackObj {
   112  protected:
   113   StubCodeGenerator* _cgen;
   114   StubCodeDesc*      _cdesc;
   116  public:
   117   StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name);
   118   ~StubCodeMark();
   120 };

mercurial