252 friend class VMStructs; |
252 friend class VMStructs; |
253 // When CDS is enabled, all shared metaspace objects are mapped |
253 // When CDS is enabled, all shared metaspace objects are mapped |
254 // into a single contiguous memory block, so we can use these |
254 // into a single contiguous memory block, so we can use these |
255 // two pointers to quickly determine if something is in the |
255 // two pointers to quickly determine if something is in the |
256 // shared metaspace. |
256 // shared metaspace. |
257 // |
|
258 // When CDS is not enabled, both pointers are set to NULL. |
257 // When CDS is not enabled, both pointers are set to NULL. |
259 static void* _shared_metaspace_base; // (inclusive) low address |
258 static void* _shared_metaspace_base; // (inclusive) low address |
260 static void* _shared_metaspace_top; // (exclusive) high address |
259 static void* _shared_metaspace_top; // (exclusive) high address |
261 |
260 |
262 public: |
261 public: |
263 |
262 |
264 // Returns true if the pointer points to a valid MetaspaceObj. A valid |
263 // Returns true if the pointer points to a valid MetaspaceObj. A valid |
265 // MetaspaceObj is MetaWord-aligned and contained within either |
264 // MetaspaceObj is MetaWord-aligned and contained within either |
267 static bool is_valid(const MetaspaceObj* p); |
266 static bool is_valid(const MetaspaceObj* p); |
268 |
267 |
269 static bool is_shared(const MetaspaceObj* p) { |
268 static bool is_shared(const MetaspaceObj* p) { |
270 // If no shared metaspace regions are mapped, _shared_metaspace_{base,top} will |
269 // If no shared metaspace regions are mapped, _shared_metaspace_{base,top} will |
271 // both be NULL and all values of p will be rejected quickly. |
270 // both be NULL and all values of p will be rejected quickly. |
272 return (((void*)p) < _shared_metaspace_top && ((void*)p) >= _shared_metaspace_base); |
271 return (((void*)p) < _shared_metaspace_top && |
|
272 ((void*)p) >= _shared_metaspace_base); |
273 } |
273 } |
274 bool is_shared() const { return MetaspaceObj::is_shared(this); } |
274 bool is_shared() const { return MetaspaceObj::is_shared(this); } |
275 |
275 |
276 void print_address_on(outputStream* st) const; // nonvirtual address printing |
276 void print_address_on(outputStream* st) const; // nonvirtual address printing |
277 |
277 |
278 static void set_shared_metaspace_range(void* base, void* top) { |
278 static void set_shared_metaspace_range(void* base, void* top) { |
279 _shared_metaspace_base = base; |
279 _shared_metaspace_base = base; |
280 _shared_metaspace_top = top; |
280 _shared_metaspace_top = top; |
281 } |
281 } |
|
282 |
|
283 static void expand_shared_metaspace_range(void* top) { |
|
284 assert(top >= _shared_metaspace_top, "must be"); |
|
285 _shared_metaspace_top = top; |
|
286 } |
|
287 |
282 static void* shared_metaspace_base() { return _shared_metaspace_base; } |
288 static void* shared_metaspace_base() { return _shared_metaspace_base; } |
283 static void* shared_metaspace_top() { return _shared_metaspace_top; } |
289 static void* shared_metaspace_top() { return _shared_metaspace_top; } |
284 |
290 |
285 #define METASPACE_OBJ_TYPES_DO(f) \ |
291 #define METASPACE_OBJ_TYPES_DO(f) \ |
286 f(Class) \ |
292 f(Class) \ |