< 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(RecordComponent)





318 
319 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
320 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
321 
322   enum Type {
323     // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
324     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
325     _number_of_types
326   };
327 
328   static const char * type_name(Type type) {
329     switch(type) {
330     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE)
331     default:
332       ShouldNotReachHere();
333       return nullptr;
334     }
335   }
336 
337   static MetaspaceObj::Type array_type(size_t elem_size) {
338     switch (elem_size) {
339     case 1: return TypeArrayU1Type;
340     case 2: return TypeArrayU2Type;
341     case 4: return TypeArrayU4Type;
342     case 8: return TypeArrayU8Type;
343     default:
344       return TypeArrayOtherType;
345     }
346   }
347 
348   void* operator new(size_t size, ClassLoaderData* loader_data,
349                      size_t word_size,
350                      Type type, JavaThread* thread) throw();
351                      // can't use TRAPS from this header file.
352   void* operator new(size_t size, ClassLoaderData* loader_data,
353                      size_t word_size,
354                      Type type) throw();


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

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(AdapterHandlerEntry) \
322   f(AdapterFingerPrint)
323 
324 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
325 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
326 
327   enum Type {
328     // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
329     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
330     _number_of_types
331   };
332 
333   static const char * type_name(Type type) {
334     switch(type) {
335     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE)
336     default:
337       ShouldNotReachHere();
338       return nullptr;
339     }
340   }
341 
342   static MetaspaceObj::Type array_type(size_t elem_size) {
343     switch (elem_size) {
344     case 1: return TypeArrayU1Type;
345     case 2: return TypeArrayU2Type;
346     case 4: return TypeArrayU4Type;
347     case 8: return TypeArrayU8Type;
348     default:
349       return TypeArrayOtherType;
350     }
351   }
352 
353   void* operator new(size_t size, ClassLoaderData* loader_data,
354                      size_t word_size,
355                      Type type, JavaThread* thread) throw();
356                      // can't use TRAPS from this header file.
357   void* operator new(size_t size, ClassLoaderData* loader_data,
358                      size_t word_size,
359                      Type type) throw();
360   // HACK -- this is used for allocating training data. See JDK-8331086
361   void* operator new(size_t size, MemTag flags) throw();
362   void operator delete(void* p) = delete;
363 
364   // Declare a *static* method with the same signature in any subclass of MetaspaceObj
365   // that should be read-only by default. See symbol.hpp for an example. This function
366   // is used by the templates in metaspaceClosure.hpp
367   static bool is_read_only_by_default() { return false; }
368 };
369 
370 // Base class for classes that constitute name spaces.
371 
372 class Arena;
373 
374 extern char* resource_allocate_bytes(size_t size,
375     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
376 extern char* resource_allocate_bytes(Thread* thread, size_t size,
377     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
378 extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size,
379     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
380 extern void resource_free_bytes( Thread* thread, char *old, size_t size );
381 
< prev index next >