< 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 bool is_training_data(Type type) {
343     return (type == Type::KlassTrainingDataType)  ||
344            (type == Type::MethodTrainingDataType) ||
345            (type == Type::CompileTrainingDataType);
346   }
347 
348   static MetaspaceObj::Type array_type(size_t elem_size) {
349     switch (elem_size) {
350     case 1: return TypeArrayU1Type;
351     case 2: return TypeArrayU2Type;
352     case 4: return TypeArrayU4Type;
353     case 8: return TypeArrayU8Type;
354     default:
355       return TypeArrayOtherType;
356     }
357   }
358 
359   void* operator new(size_t size, ClassLoaderData* loader_data,
360                      size_t word_size,
361                      Type type, JavaThread* thread) throw();
362                      // can't use TRAPS from this header file.
363   void* operator new(size_t size, ClassLoaderData* loader_data,
364                      size_t word_size,
365                      Type type) throw();
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) = delete;
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 >