< prev index next >

src/hotspot/share/memory/allocation.hpp

Print this page

297   }
298 
299   static void* shared_metaspace_base() { return _shared_metaspace_base; }
300   static void* shared_metaspace_top()  { return _shared_metaspace_top;  }
301 
302 #define METASPACE_OBJ_TYPES_DO(f) \
303   f(Class) \
304   f(Symbol) \
305   f(TypeArrayU1) \
306   f(TypeArrayU2) \
307   f(TypeArrayU4) \
308   f(TypeArrayU8) \
309   f(TypeArrayOther) \
310   f(Method) \
311   f(ConstMethod) \
312   f(MethodData) \
313   f(ConstantPool) \
314   f(ConstantPoolCache) \
315   f(Annotations) \
316   f(MethodCounters) \
317   f(SharedClassPathEntry) \
318   f(RecordComponent)



319 
320 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
321 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
322 
323   enum Type {
324     // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
325     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
326     _number_of_types
327   };
328 
329   static const char * type_name(Type type) {
330     switch(type) {
331     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE)
332     default:
333       ShouldNotReachHere();
334       return nullptr;
335     }
336   }
337 






338   static MetaspaceObj::Type array_type(size_t elem_size) {
339     switch (elem_size) {
340     case 1: return TypeArrayU1Type;
341     case 2: return TypeArrayU2Type;
342     case 4: return TypeArrayU4Type;
343     case 8: return TypeArrayU8Type;
344     default:
345       return TypeArrayOtherType;
346     }
347   }
348 
349   void* operator new(size_t size, ClassLoaderData* loader_data,
350                      size_t word_size,
351                      Type type, JavaThread* thread) throw();
352                      // can't use TRAPS from this header file.
353   void* operator new(size_t size, ClassLoaderData* loader_data,
354                      size_t word_size,
355                      Type type) throw();



356   void operator delete(void* p) { ShouldNotCallThis(); }
357 
358   // Declare a *static* method with the same signature in any subclass of MetaspaceObj
359   // that should be read-only by default. See symbol.hpp for an example. This function
360   // is used by the templates in metaspaceClosure.hpp
361   static bool is_read_only_by_default() { return false; }
362 };
363 
364 // Base class for classes that constitute name spaces.
365 
366 class Arena;
367 
368 extern char* resource_allocate_bytes(size_t size,
369     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
370 extern char* resource_allocate_bytes(Thread* thread, size_t size,
371     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
372 extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size,
373     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
374 extern void resource_free_bytes( Thread* thread, char *old, size_t size );
375 

297   }
298 
299   static void* shared_metaspace_base() { return _shared_metaspace_base; }
300   static void* shared_metaspace_top()  { return _shared_metaspace_top;  }
301 
302 #define METASPACE_OBJ_TYPES_DO(f) \
303   f(Class) \
304   f(Symbol) \
305   f(TypeArrayU1) \
306   f(TypeArrayU2) \
307   f(TypeArrayU4) \
308   f(TypeArrayU8) \
309   f(TypeArrayOther) \
310   f(Method) \
311   f(ConstMethod) \
312   f(MethodData) \
313   f(ConstantPool) \
314   f(ConstantPoolCache) \
315   f(Annotations) \
316   f(MethodCounters) \
317   f(RecordComponent) \
318   f(KlassTrainingData) \
319   f(MethodTrainingData) \
320   f(CompileTrainingData) \
321   f(SharedClassPathEntry)
322 
323 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
324 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
325 
326   enum Type {
327     // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
328     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
329     _number_of_types
330   };
331 
332   static const char * type_name(Type type) {
333     switch(type) {
334     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE)
335     default:
336       ShouldNotReachHere();
337       return nullptr;
338     }
339   }
340 
341   static bool is_training_data(Type type) {
342     return (type == Type::KlassTrainingDataType)  ||
343            (type == Type::MethodTrainingDataType) ||
344            (type == Type::CompileTrainingDataType);
345   }
346 
347   static MetaspaceObj::Type array_type(size_t elem_size) {
348     switch (elem_size) {
349     case 1: return TypeArrayU1Type;
350     case 2: return TypeArrayU2Type;
351     case 4: return TypeArrayU4Type;
352     case 8: return TypeArrayU8Type;
353     default:
354       return TypeArrayOtherType;
355     }
356   }
357 
358   void* operator new(size_t size, ClassLoaderData* loader_data,
359                      size_t word_size,
360                      Type type, JavaThread* thread) throw();
361                      // can't use TRAPS from this header file.
362   void* operator new(size_t size, ClassLoaderData* loader_data,
363                      size_t word_size,
364                      Type type) throw();
365 
366   // HACK -- this is used for allocating training data. See JDK-8331086
367   void* operator new(size_t size, MemTag flags) throw();
368   void operator delete(void* p) { ShouldNotCallThis(); }
369 
370   // Declare a *static* method with the same signature in any subclass of MetaspaceObj
371   // that should be read-only by default. See symbol.hpp for an example. This function
372   // is used by the templates in metaspaceClosure.hpp
373   static bool is_read_only_by_default() { return false; }
374 };
375 
376 // Base class for classes that constitute name spaces.
377 
378 class Arena;
379 
380 extern char* resource_allocate_bytes(size_t size,
381     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
382 extern char* resource_allocate_bytes(Thread* thread, size_t size,
383     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
384 extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size,
385     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
386 extern void resource_free_bytes( Thread* thread, char *old, size_t size );
387 
< prev index next >