< prev index next >

src/share/vm/gc/g1/g1AllocRegion.inline.hpp

Print this page
rev 8868 : imported patch 8067336-allow-that-plab-allocations-at-end-of-regions-are-flexible
rev 8869 : [mq]: refactor-desired-actual-size
rev 8870 : [mq]: tom-review


  24 
  25 #ifndef SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
  26 #define SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
  27 
  28 #include "gc/g1/g1AllocRegion.hpp"
  29 #include "gc/g1/heapRegion.inline.hpp"
  30 
  31 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
  32                                          size_t word_size,
  33                                          bool bot_updates) {
  34   assert(alloc_region != NULL, err_msg("pre-condition"));
  35 
  36   if (!bot_updates) {
  37     return alloc_region->allocate_no_bot_updates(word_size);
  38   } else {
  39     return alloc_region->allocate(word_size);
  40   }
  41 }
  42 
  43 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size, bool bot_updates) {
  44   return par_allocate(alloc_region, word_size, &word_size, bot_updates);

  45 }
  46 
  47 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
  48                                              size_t min_word_size,
  49                                              size_t* word_size,

  50                                              bool bot_updates) {
  51   assert(alloc_region != NULL, err_msg("pre-condition"));
  52   assert(!alloc_region->is_empty(), err_msg("pre-condition"));
  53 
  54   if (!bot_updates) {
  55     return alloc_region->par_allocate_no_bot_updates(min_word_size, word_size);
  56   } else {
  57     return alloc_region->par_allocate(min_word_size, word_size);
  58   }
  59 }
  60 
  61 inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size, bool bot_updates) {
  62   return attempt_allocation(word_size, &word_size, bot_updates);

  63 }
  64 
  65 inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
  66                                                    size_t* word_size,

  67                                                    bool bot_updates) {
  68   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
  69 
  70   HeapRegion* alloc_region = _alloc_region;
  71   assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
  72 
  73   HeapWord* result = par_allocate(alloc_region, min_word_size, word_size, bot_updates);
  74   if (result != NULL) {
  75     trace("alloc", *word_size, result);
  76     return result;
  77   }
  78   trace("alloc failed", *word_size);
  79   return NULL;
  80 }
  81 
  82 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size, bool bot_updates) {
  83   return attempt_allocation_locked(word_size, &word_size, bot_updates);

  84 }
  85 
  86 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t min_word_size,
  87                                                           size_t* word_size,

  88                                                           bool bot_updates) {
  89   // First we have to redo the allocation, assuming we're holding the
  90   // appropriate lock, in case another thread changed the region while
  91   // we were waiting to get the lock.
  92   HeapWord* result = attempt_allocation(min_word_size, word_size, bot_updates);
  93   if (result != NULL) {
  94     return result;
  95   }
  96 
  97   retire(true /* fill_up */);
  98   result = new_alloc_region_and_allocate(*word_size, false /* force */);
  99   if (result != NULL) {
 100     trace("alloc locked (second attempt)", *word_size, result);

 101     return result;
 102   }
 103   trace("alloc locked failed", *word_size);
 104   return NULL;
 105 }
 106 
 107 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
 108                                                          bool bot_updates) {
 109   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
 110   assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
 111 
 112   trace("forcing alloc");
 113   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
 114   if (result != NULL) {
 115     trace("alloc forced", word_size, result);
 116     return result;
 117   }
 118   trace("alloc forced failed", word_size);
 119   return NULL;
 120 }
 121 
 122 #endif // SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP


  24 
  25 #ifndef SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
  26 #define SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
  27 
  28 #include "gc/g1/g1AllocRegion.hpp"
  29 #include "gc/g1/heapRegion.inline.hpp"
  30 
  31 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
  32                                          size_t word_size,
  33                                          bool bot_updates) {
  34   assert(alloc_region != NULL, err_msg("pre-condition"));
  35 
  36   if (!bot_updates) {
  37     return alloc_region->allocate_no_bot_updates(word_size);
  38   } else {
  39     return alloc_region->allocate(word_size);
  40   }
  41 }
  42 
  43 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size, bool bot_updates) {
  44   size_t temp;
  45   return par_allocate(alloc_region, word_size, word_size, &temp, bot_updates);
  46 }
  47 
  48 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
  49                                              size_t min_word_size,
  50                                              size_t desired_word_size,
  51                                              size_t* actual_word_size,
  52                                              bool bot_updates) {
  53   assert(alloc_region != NULL, err_msg("pre-condition"));
  54   assert(!alloc_region->is_empty(), err_msg("pre-condition"));
  55 
  56   if (!bot_updates) {
  57     return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
  58   } else {
  59     return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
  60   }
  61 }
  62 
  63 inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size, bool bot_updates) {
  64   size_t temp;
  65   return attempt_allocation(word_size, word_size, &temp, bot_updates);
  66 }
  67 
  68 inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
  69                                                    size_t desired_word_size,
  70                                                    size_t* actual_word_size,
  71                                                    bool bot_updates) {
  72   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
  73 
  74   HeapRegion* alloc_region = _alloc_region;
  75   assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
  76 
  77   HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size, bot_updates);
  78   if (result != NULL) {
  79     trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
  80     return result;
  81   }
  82   trace("alloc failed", min_word_size, desired_word_size);
  83   return NULL;
  84 }
  85 
  86 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size, bool bot_updates) {
  87   size_t temp;
  88   return attempt_allocation_locked(word_size, word_size, &temp, bot_updates);
  89 }
  90 
  91 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t min_word_size,
  92                                                           size_t desired_word_size,
  93                                                           size_t* actual_word_size,
  94                                                           bool bot_updates) {
  95   // First we have to redo the allocation, assuming we're holding the
  96   // appropriate lock, in case another thread changed the region while
  97   // we were waiting to get the lock.
  98   HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size, bot_updates);
  99   if (result != NULL) {
 100     return result;
 101   }
 102 
 103   retire(true /* fill_up */);
 104   result = new_alloc_region_and_allocate(desired_word_size, false /* force */);
 105   if (result != NULL) {
 106     *actual_word_size = desired_word_size;
 107     trace("alloc locked (second attempt)", min_word_size, desired_word_size, *actual_word_size, result);
 108     return result;
 109   }
 110   trace("alloc locked failed", min_word_size, desired_word_size);
 111   return NULL;
 112 }
 113 
 114 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
 115                                                          bool bot_updates) {
 116   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
 117   assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
 118 
 119   trace("forcing alloc", word_size, word_size);
 120   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
 121   if (result != NULL) {
 122     trace("alloc forced", word_size, word_size, word_size, result);
 123     return result;
 124   }
 125   trace("alloc forced failed", word_size, word_size);
 126   return NULL;
 127 }
 128 
 129 #endif // SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
< prev index next >