< prev index next >

src/share/vm/memory/allocation.inline.hpp

Print this page




  45 #else
  46   // possible word-tearing during load/store
  47   *dest += add_value;
  48 #endif
  49 }
  50 #endif
  51 
  52 // allocate using malloc; will fail if no memory available
  53 inline char* AllocateHeap(size_t size, MEMFLAGS flags,
  54     const NativeCallStack& stack,
  55     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
  56   char* p = (char*) os::malloc(size, flags, stack);
  57   #ifdef ASSERT
  58   if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p);
  59   #endif
  60   if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
  61     vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
  62   }
  63   return p;
  64 }




  65 inline char* AllocateHeap(size_t size, MEMFLAGS flags,
  66     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
  67   return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode);
  68 }
  69 



  70 inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag,
  71     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
  72   char* p = (char*) os::realloc(old, size, flag, CURRENT_PC);
  73   #ifdef ASSERT
  74   if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p);
  75   #endif
  76   if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
  77     vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
  78   }
  79   return p;
  80 }
  81 
  82 inline void FreeHeap(void* p) {
  83   #ifdef ASSERT
  84   if (PrintMallocFree) trace_heap_free(p);
  85   #endif
  86   os::free(p);
  87 }
  88 
  89 




  45 #else
  46   // possible word-tearing during load/store
  47   *dest += add_value;
  48 #endif
  49 }
  50 #endif
  51 
  52 // allocate using malloc; will fail if no memory available
  53 inline char* AllocateHeap(size_t size, MEMFLAGS flags,
  54     const NativeCallStack& stack,
  55     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
  56   char* p = (char*) os::malloc(size, flags, stack);
  57   #ifdef ASSERT
  58   if (PrintMallocFree) trace_heap_malloc(size, "AllocateHeap", p);
  59   #endif
  60   if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
  61     vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
  62   }
  63   return p;
  64 }
  65 
  66 #ifdef __GNUC__
  67 __attribute__((always_inline))
  68 #endif
  69 inline char* AllocateHeap(size_t size, MEMFLAGS flags,
  70     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
  71   return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode);
  72 }
  73 
  74 #ifdef __GNUC__
  75 __attribute__((always_inline))
  76 #endif
  77 inline char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag,
  78     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
  79   char* p = (char*) os::realloc(old, size, flag, CURRENT_PC);
  80   #ifdef ASSERT
  81   if (PrintMallocFree) trace_heap_malloc(size, "ReallocateHeap", p);
  82   #endif
  83   if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
  84     vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
  85   }
  86   return p;
  87 }
  88 
  89 inline void FreeHeap(void* p) {
  90   #ifdef ASSERT
  91   if (PrintMallocFree) trace_heap_free(p);
  92   #endif
  93   os::free(p);
  94 }
  95 
  96 


< prev index next >