src/share/vm/code/vtableStubs.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 





  25 // A VtableStub holds an individual code stub for a pair (vtable index, #args) for either itables or vtables
  26 // There's a one-to-one relationship between a VtableStub and such a pair.
  27 
  28 class VtableStub {
  29  private:
  30   friend class VtableStubs;
  31 
  32   static address _chunk;             // For allocation
  33   static address _chunk_end;         // For allocation
  34   static VMReg   _receiver_location; // Where to find receiver
  35 
  36   VtableStub*    _next;              // Pointer to next entry in hash table
  37   const short    _index;             // vtable index
  38   short          _ame_offset;        // Where an AbstractMethodError might occur
  39   short          _npe_offset;        // Where a NullPointerException might occur
  40   bool           _is_vtable_stub;    // True if vtable stub, false, is itable stub
  41   /* code follows here */            // The vtableStub code
  42 
  43   void* operator new(size_t size, int code_size);
  44 


 104   };
 105 
 106  private:
 107   static VtableStub* _table[N];                  // table of existing stubs
 108   static int         _number_of_vtable_stubs;    // number of stubs created so far (for statistics)
 109 
 110   static VtableStub* create_vtable_stub(int vtable_index);
 111   static VtableStub* create_itable_stub(int vtable_index);
 112   static VtableStub* lookup            (bool is_vtable_stub, int vtable_index);
 113   static void        enter             (bool is_vtable_stub, int vtable_index, VtableStub* s);
 114   static inline uint hash              (bool is_vtable_stub, int vtable_index);
 115 
 116  public:
 117   static address     create_stub(bool is_vtable_stub, int vtable_index, methodOop method); // return the entry point of a stub for this call
 118   static bool        is_entry_point(address pc);                     // is pc a vtable stub entry point?
 119   static bool        contains(address pc);                           // is pc within any stub?
 120   static VtableStub* stub_containing(address pc);                    // stub containing pc or NULL
 121   static int         number_of_vtable_stubs() { return _number_of_vtable_stubs; }
 122   static void        initialize();
 123 };


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_CODE_VTABLESTUBS_HPP
  26 #define SHARE_VM_CODE_VTABLESTUBS_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 
  30 // A VtableStub holds an individual code stub for a pair (vtable index, #args) for either itables or vtables
  31 // There's a one-to-one relationship between a VtableStub and such a pair.
  32 
  33 class VtableStub {
  34  private:
  35   friend class VtableStubs;
  36 
  37   static address _chunk;             // For allocation
  38   static address _chunk_end;         // For allocation
  39   static VMReg   _receiver_location; // Where to find receiver
  40 
  41   VtableStub*    _next;              // Pointer to next entry in hash table
  42   const short    _index;             // vtable index
  43   short          _ame_offset;        // Where an AbstractMethodError might occur
  44   short          _npe_offset;        // Where a NullPointerException might occur
  45   bool           _is_vtable_stub;    // True if vtable stub, false, is itable stub
  46   /* code follows here */            // The vtableStub code
  47 
  48   void* operator new(size_t size, int code_size);
  49 


 109   };
 110 
 111  private:
 112   static VtableStub* _table[N];                  // table of existing stubs
 113   static int         _number_of_vtable_stubs;    // number of stubs created so far (for statistics)
 114 
 115   static VtableStub* create_vtable_stub(int vtable_index);
 116   static VtableStub* create_itable_stub(int vtable_index);
 117   static VtableStub* lookup            (bool is_vtable_stub, int vtable_index);
 118   static void        enter             (bool is_vtable_stub, int vtable_index, VtableStub* s);
 119   static inline uint hash              (bool is_vtable_stub, int vtable_index);
 120 
 121  public:
 122   static address     create_stub(bool is_vtable_stub, int vtable_index, methodOop method); // return the entry point of a stub for this call
 123   static bool        is_entry_point(address pc);                     // is pc a vtable stub entry point?
 124   static bool        contains(address pc);                           // is pc within any stub?
 125   static VtableStub* stub_containing(address pc);                    // stub containing pc or NULL
 126   static int         number_of_vtable_stubs() { return _number_of_vtable_stubs; }
 127   static void        initialize();
 128 };
 129 
 130 #endif // SHARE_VM_CODE_VTABLESTUBS_HPP