< prev index next >

src/hotspot/share/gc/shared/plab.inline.hpp

Print this page




  26 #define SHARE_GC_SHARED_PLAB_INLINE_HPP
  27 
  28 #include "gc/shared/collectedHeap.inline.hpp"
  29 #include "gc/shared/plab.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "runtime/atomic.hpp"
  32 
  33 inline HeapWord* PLAB::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
  34   HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
  35   if (res == NULL) {
  36     return NULL;
  37   }
  38 
  39   // Set _top so that allocate(), which expects _top to be correctly set,
  40   // can be used below.
  41   _top = res;
  42   return allocate(word_sz);
  43 }
  44 
  45 void PLABStats::add_allocated(size_t v) {
  46   Atomic::add(v, &_allocated);
  47 }
  48 
  49 void PLABStats::add_unused(size_t v) {
  50   Atomic::add(v, &_unused);
  51 }
  52 
  53 void PLABStats::add_wasted(size_t v) {
  54   Atomic::add(v, &_wasted);
  55 }
  56 
  57 void PLABStats::add_undo_wasted(size_t v) {
  58   Atomic::add(v, &_undo_wasted);
  59 }
  60 
  61 #endif // SHARE_GC_SHARED_PLAB_INLINE_HPP


  26 #define SHARE_GC_SHARED_PLAB_INLINE_HPP
  27 
  28 #include "gc/shared/collectedHeap.inline.hpp"
  29 #include "gc/shared/plab.hpp"
  30 #include "memory/allocation.inline.hpp"
  31 #include "runtime/atomic.hpp"
  32 
  33 inline HeapWord* PLAB::allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes) {
  34   HeapWord* res = CollectedHeap::align_allocation_or_fail(_top, _end, alignment_in_bytes);
  35   if (res == NULL) {
  36     return NULL;
  37   }
  38 
  39   // Set _top so that allocate(), which expects _top to be correctly set,
  40   // can be used below.
  41   _top = res;
  42   return allocate(word_sz);
  43 }
  44 
  45 void PLABStats::add_allocated(size_t v) {
  46   Atomic::add(&_allocated, v);
  47 }
  48 
  49 void PLABStats::add_unused(size_t v) {
  50   Atomic::add(&_unused, v);
  51 }
  52 
  53 void PLABStats::add_wasted(size_t v) {
  54   Atomic::add(&_wasted, v);
  55 }
  56 
  57 void PLABStats::add_undo_wasted(size_t v) {
  58   Atomic::add(&_undo_wasted, v);
  59 }
  60 
  61 #endif // SHARE_GC_SHARED_PLAB_INLINE_HPP
< prev index next >