src/share/vm/code/vtableStubs.hpp

Wed, 01 Dec 2010 15:04:06 +0100

author
stefank
date
Wed, 01 Dec 2010 15:04:06 +0100
changeset 2325
c760f78e0a53
parent 2314
f95d63e2154a
child 3969
1d7922586cf6
permissions
-rw-r--r--

7003125: precompiled.hpp is included when precompiled headers are not used
Summary: Added an ifndef DONT_USE_PRECOMPILED_HEADER to precompiled.hpp. Set up DONT_USE_PRECOMPILED_HEADER when compiling with Sun Studio or when the user specifies USE_PRECOMPILED_HEADER=0. Fixed broken include dependencies.
Reviewed-by: coleenp, kvn

     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  */
    25 #ifndef SHARE_VM_CODE_VTABLESTUBS_HPP
    26 #define SHARE_VM_CODE_VTABLESTUBS_HPP
    28 #include "code/vmreg.hpp"
    29 #include "memory/allocation.hpp"
    31 // A VtableStub holds an individual code stub for a pair (vtable index, #args) for either itables or vtables
    32 // There's a one-to-one relationship between a VtableStub and such a pair.
    34 class VtableStub {
    35  private:
    36   friend class VtableStubs;
    38   static address _chunk;             // For allocation
    39   static address _chunk_end;         // For allocation
    40   static VMReg   _receiver_location; // Where to find receiver
    42   VtableStub*    _next;              // Pointer to next entry in hash table
    43   const short    _index;             // vtable index
    44   short          _ame_offset;        // Where an AbstractMethodError might occur
    45   short          _npe_offset;        // Where a NullPointerException might occur
    46   bool           _is_vtable_stub;    // True if vtable stub, false, is itable stub
    47   /* code follows here */            // The vtableStub code
    49   void* operator new(size_t size, int code_size);
    51   VtableStub(bool is_vtable_stub, int index)
    52         : _next(NULL), _is_vtable_stub(is_vtable_stub),
    53           _index(index), _ame_offset(-1), _npe_offset(-1) {}
    54   VtableStub* next() const                       { return _next; }
    55   int index() const                              { return _index; }
    56   static VMReg receiver_location()               { return _receiver_location; }
    57   void set_next(VtableStub* n)                   { _next = n; }
    58   address code_begin() const                     { return (address)(this + 1); }
    59   address code_end() const                       { return code_begin() + pd_code_size_limit(_is_vtable_stub); }
    60   address entry_point() const                    { return code_begin(); }
    61   static int entry_offset()                      { return sizeof(class VtableStub); }
    63   bool matches(bool is_vtable_stub, int index) const {
    64     return _index == index && _is_vtable_stub == is_vtable_stub;
    65   }
    66   bool contains(address pc) const                { return code_begin() <= pc && pc < code_end(); }
    68   void set_exception_points(address npe_addr, address ame_addr) {
    69     _npe_offset = npe_addr - code_begin();
    70     _ame_offset = ame_addr - code_begin();
    71     assert(is_abstract_method_error(ame_addr),   "offset must be correct");
    72     assert(is_null_pointer_exception(npe_addr),  "offset must be correct");
    73     assert(!is_abstract_method_error(npe_addr),  "offset must be correct");
    74     assert(!is_null_pointer_exception(ame_addr), "offset must be correct");
    75   }
    77   // platform-dependent routines
    78   static int  pd_code_size_limit(bool is_vtable_stub);
    79   static int  pd_code_alignment();
    80   // CNC: Removed because vtable stubs are now made with an ideal graph
    81   // static bool pd_disregard_arg_size();
    83   static void align_chunk() {
    84     uintptr_t off = (uintptr_t)( _chunk + sizeof(VtableStub) ) % pd_code_alignment();
    85     if (off != 0)  _chunk += pd_code_alignment() - off;
    86   }
    88  public:
    89   // Query
    90   bool is_itable_stub()                          { return !_is_vtable_stub; }
    91   bool is_vtable_stub()                          { return  _is_vtable_stub; }
    92   bool is_abstract_method_error(address epc)     { return epc == code_begin()+_ame_offset; }
    93   bool is_null_pointer_exception(address epc)    { return epc == code_begin()+_npe_offset; }
    95   void print_on(outputStream* st) const;
    96   void print() const                             { print_on(tty); }
    98 };
   101 // VtableStubs creates the code stubs for compiled calls through vtables.
   102 // There is one stub per (vtable index, args_size) pair, and the stubs are
   103 // never deallocated. They don't need to be GCed because they contain no oops.
   105 class VtableStubs : AllStatic {
   106  public:                                         // N must be public (some compilers need this for _table)
   107   enum {
   108     N    = 256,                                  // size of stub table; must be power of two
   109     mask = N - 1
   110   };
   112  private:
   113   static VtableStub* _table[N];                  // table of existing stubs
   114   static int         _number_of_vtable_stubs;    // number of stubs created so far (for statistics)
   116   static VtableStub* create_vtable_stub(int vtable_index);
   117   static VtableStub* create_itable_stub(int vtable_index);
   118   static VtableStub* lookup            (bool is_vtable_stub, int vtable_index);
   119   static void        enter             (bool is_vtable_stub, int vtable_index, VtableStub* s);
   120   static inline uint hash              (bool is_vtable_stub, int vtable_index);
   122  public:
   123   static address     create_stub(bool is_vtable_stub, int vtable_index, methodOop method); // return the entry point of a stub for this call
   124   static bool        is_entry_point(address pc);                     // is pc a vtable stub entry point?
   125   static bool        contains(address pc);                           // is pc within any stub?
   126   static VtableStub* stub_containing(address pc);                    // stub containing pc or NULL
   127   static int         number_of_vtable_stubs() { return _number_of_vtable_stubs; }
   128   static void        initialize();
   129 };
   131 #endif // SHARE_VM_CODE_VTABLESTUBS_HPP

mercurial