< prev index next >

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

Print this page
rev 49852 : imported patch 8191471-g1-retained-mutator-region


  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  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 #define assert_alloc_region(p, message)                                  \
  32   do {                                                                   \
  33     assert((p), "[%s] %s c: %u b: %s r: " PTR_FORMAT " u: " SIZE_FORMAT, \
  34            _name, (message), _count, BOOL_TO_STR(_bot_updates),          \
  35            p2i(_alloc_region), _used_bytes_before);                      \
  36   } while (0)
  37 
  38 




  39 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
  40                                          size_t word_size) {
  41   assert(alloc_region != NULL, "pre-condition");
  42 
  43   if (!_bot_updates) {
  44     return alloc_region->allocate_no_bot_updates(word_size);
  45   } else {
  46     return alloc_region->allocate(word_size);
  47   }
  48 }
  49 
  50 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size) {
  51   size_t temp;
  52   return par_allocate(alloc_region, word_size, word_size, &temp);
  53 }
  54 
  55 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
  56                                              size_t min_word_size,
  57                                              size_t desired_word_size,
  58                                              size_t* actual_word_size) {


 106   result = new_alloc_region_and_allocate(desired_word_size, false /* force */);
 107   if (result != NULL) {
 108     *actual_word_size = desired_word_size;
 109     trace("alloc locked (second attempt)", min_word_size, desired_word_size, *actual_word_size, result);
 110     return result;
 111   }
 112   trace("alloc locked failed", min_word_size, desired_word_size);
 113   return NULL;
 114 }
 115 
 116 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size) {
 117   assert_alloc_region(_alloc_region != NULL, "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


  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  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 #define assert_alloc_region(p, message)                                  \
  32   do {                                                                   \
  33     assert((p), "[%s] %s c: %u b: %s r: " PTR_FORMAT " u: " SIZE_FORMAT, \
  34            _name, (message), _count, BOOL_TO_STR(_bot_updates),          \
  35            p2i(_alloc_region), _used_bytes_before);                      \
  36   } while (0)
  37 
  38 
  39 inline void G1AllocRegion::reset_alloc_region() {
  40   _alloc_region = _dummy_region;
  41 }
  42 
  43 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
  44                                          size_t word_size) {
  45   assert(alloc_region != NULL, "pre-condition");
  46 
  47   if (!_bot_updates) {
  48     return alloc_region->allocate_no_bot_updates(word_size);
  49   } else {
  50     return alloc_region->allocate(word_size);
  51   }
  52 }
  53 
  54 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region, size_t word_size) {
  55   size_t temp;
  56   return par_allocate(alloc_region, word_size, word_size, &temp);
  57 }
  58 
  59 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
  60                                              size_t min_word_size,
  61                                              size_t desired_word_size,
  62                                              size_t* actual_word_size) {


 110   result = new_alloc_region_and_allocate(desired_word_size, false /* force */);
 111   if (result != NULL) {
 112     *actual_word_size = desired_word_size;
 113     trace("alloc locked (second attempt)", min_word_size, desired_word_size, *actual_word_size, result);
 114     return result;
 115   }
 116   trace("alloc locked failed", min_word_size, desired_word_size);
 117   return NULL;
 118 }
 119 
 120 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size) {
 121   assert_alloc_region(_alloc_region != NULL, "not initialized properly");
 122 
 123   trace("forcing alloc", word_size, word_size);
 124   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
 125   if (result != NULL) {
 126     trace("alloc forced", word_size, word_size, word_size, result);
 127     return result;
 128   }
 129   trace("alloc forced failed", word_size, word_size);
 130   return NULL;
 131 }
 132 
 133 inline HeapWord* MutatorAllocRegion::attempt_retained_allocation(size_t min_word_size,
 134                                                                  size_t desired_word_size,
 135                                                                  size_t* actual_word_size) {
 136   if (_retained_alloc_region != NULL) {
 137     HeapWord* result = par_allocate(_retained_alloc_region, min_word_size, desired_word_size, actual_word_size);
 138     if (result != NULL) {
 139       trace("alloc retained", min_word_size, desired_word_size, *actual_word_size, result);
 140       return result;
 141     }
 142   }
 143   return NULL;
 144 }
 145 
 146 #endif // SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
< prev index next >