< prev index next >

src/hotspot/share/memory/metaspaceClosure.hpp

Print this page
rev 57095 : [mq]: use
rev 57096 : [mq]: trailing_semi


  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_MEMORY_METASPACECLOSURE_HPP
  26 #define SHARE_MEMORY_METASPACECLOSURE_HPP
  27 
  28 #include "logging/log.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "oops/array.hpp"
  31 #include "utilities/growableArray.hpp"
  32 #include "utilities/hashtable.inline.hpp"

  33 
  34 // The metadata hierarchy is separate from the oop hierarchy
  35   class MetaspaceObj;        // no C++ vtable
  36 //class   Array;             // no C++ vtable
  37   class   Annotations;       // no C++ vtable
  38   class   ConstantPoolCache; // no C++ vtable
  39   class   ConstMethod;       // no C++ vtable
  40   class   MethodCounters;    // no C++ vtable
  41   class   Symbol;            // no C++ vtable
  42   class   Metadata;          // has C++ vtable (so do all subclasses)
  43   class     ConstantPool;
  44   class     MethodData;
  45   class     Method;
  46   class     Klass;
  47   class       InstanceKlass;
  48   class         InstanceMirrorKlass;
  49   class         InstanceClassLoaderKlass;
  50   class         InstanceRefKlass;
  51   class       ArrayKlass;
  52   class         ObjArrayKlass;


  91   // Calling these methods would be trivial if these two were virtual methods.
  92   // However, to save space, MetaspaceObj has NO vtable. The vtable is introduced
  93   // only in the Metadata class.
  94   //
  95   // To work around the lack of a vtable, we use Ref class with templates
  96   // (see ObjectRef, PrimitiveArrayRef and PointerArrayRef)
  97   // so that we can statically discover the type of a object. The use of Ref
  98   // depends on the fact that:
  99   //
 100   // [1] We don't use polymorphic pointers for MetaspaceObj's that are not subclasses
 101   //     of Metadata. I.e., we don't do this:
 102   //     class Klass {
 103   //         MetaspaceObj *_obj;
 104   //         Array<int>* foo() { return (Array<int>*)_obj; }
 105   //         Symbol*     bar() { return (Symbol*)    _obj; }
 106   //
 107   // [2] All Array<T> dimensions are statically declared.
 108   class Ref : public CHeapObj<mtInternal> {
 109     Writability _writability;
 110     Ref* _next;
 111     // Noncopyable.
 112     Ref(const Ref&);
 113     Ref& operator=(const Ref&);
 114   protected:
 115     virtual void** mpp() const = 0;
 116     Ref(Writability w) : _writability(w), _next(NULL) {}
 117   public:
 118     virtual bool not_null() const = 0;
 119     virtual int size() const = 0;
 120     virtual void metaspace_pointers_do(MetaspaceClosure *it) const = 0;
 121     virtual void metaspace_pointers_do_at(MetaspaceClosure *it, address new_loc) const = 0;
 122     virtual MetaspaceObj::Type msotype() const = 0;
 123     virtual bool is_read_only_by_default() const = 0;
 124     virtual ~Ref() {}
 125 
 126     address obj() const {
 127       // In some rare cases (see CPSlot in constantPool.hpp) we store some flags in the lowest
 128       // 2 bits of a MetaspaceObj pointer. Unmask these when manipulating the pointer.
 129       uintx p = (uintx)*mpp();
 130       return (address)(p & (~FLAG_MASK));
 131     }
 132 
 133     address* addr() const {




  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_MEMORY_METASPACECLOSURE_HPP
  26 #define SHARE_MEMORY_METASPACECLOSURE_HPP
  27 
  28 #include "logging/log.hpp"
  29 #include "memory/allocation.hpp"
  30 #include "oops/array.hpp"
  31 #include "utilities/growableArray.hpp"
  32 #include "utilities/hashtable.inline.hpp"
  33 #include "utilities/macros.hpp"
  34 
  35 // The metadata hierarchy is separate from the oop hierarchy
  36   class MetaspaceObj;        // no C++ vtable
  37 //class   Array;             // no C++ vtable
  38   class   Annotations;       // no C++ vtable
  39   class   ConstantPoolCache; // no C++ vtable
  40   class   ConstMethod;       // no C++ vtable
  41   class   MethodCounters;    // no C++ vtable
  42   class   Symbol;            // no C++ vtable
  43   class   Metadata;          // has C++ vtable (so do all subclasses)
  44   class     ConstantPool;
  45   class     MethodData;
  46   class     Method;
  47   class     Klass;
  48   class       InstanceKlass;
  49   class         InstanceMirrorKlass;
  50   class         InstanceClassLoaderKlass;
  51   class         InstanceRefKlass;
  52   class       ArrayKlass;
  53   class         ObjArrayKlass;


  92   // Calling these methods would be trivial if these two were virtual methods.
  93   // However, to save space, MetaspaceObj has NO vtable. The vtable is introduced
  94   // only in the Metadata class.
  95   //
  96   // To work around the lack of a vtable, we use Ref class with templates
  97   // (see ObjectRef, PrimitiveArrayRef and PointerArrayRef)
  98   // so that we can statically discover the type of a object. The use of Ref
  99   // depends on the fact that:
 100   //
 101   // [1] We don't use polymorphic pointers for MetaspaceObj's that are not subclasses
 102   //     of Metadata. I.e., we don't do this:
 103   //     class Klass {
 104   //         MetaspaceObj *_obj;
 105   //         Array<int>* foo() { return (Array<int>*)_obj; }
 106   //         Symbol*     bar() { return (Symbol*)    _obj; }
 107   //
 108   // [2] All Array<T> dimensions are statically declared.
 109   class Ref : public CHeapObj<mtInternal> {
 110     Writability _writability;
 111     Ref* _next;
 112     NONCOPYABLE(Ref);
 113 

 114   protected:
 115     virtual void** mpp() const = 0;
 116     Ref(Writability w) : _writability(w), _next(NULL) {}
 117   public:
 118     virtual bool not_null() const = 0;
 119     virtual int size() const = 0;
 120     virtual void metaspace_pointers_do(MetaspaceClosure *it) const = 0;
 121     virtual void metaspace_pointers_do_at(MetaspaceClosure *it, address new_loc) const = 0;
 122     virtual MetaspaceObj::Type msotype() const = 0;
 123     virtual bool is_read_only_by_default() const = 0;
 124     virtual ~Ref() {}
 125 
 126     address obj() const {
 127       // In some rare cases (see CPSlot in constantPool.hpp) we store some flags in the lowest
 128       // 2 bits of a MetaspaceObj pointer. Unmask these when manipulating the pointer.
 129       uintx p = (uintx)*mpp();
 130       return (address)(p & (~FLAG_MASK));
 131     }
 132 
 133     address* addr() const {


< prev index next >