89 // size_t size(); -- to determine how much data to copy
90 // void metaspace_pointers_do(MetaspaceClosure*); -- to locate all the embedded pointers
91 //
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();
|
89 // size_t size(); -- to determine how much data to copy
90 // void metaspace_pointers_do(MetaspaceClosure*); -- to locate all the embedded pointers
91 //
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<mtMetaspace> {
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();
|