< prev index next >

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

Print this page




  44   if (want_to_allocate >= min_word_size) {
  45     HeapWord* new_top = obj + want_to_allocate;
  46     set_top(new_top);
  47     assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
  48     *actual_size = want_to_allocate;
  49     return obj;
  50   } else {
  51     return NULL;
  52   }
  53 }
  54 
  55 inline HeapWord* HeapRegion::par_allocate_impl(size_t min_word_size,
  56                                                size_t desired_word_size,
  57                                                size_t* actual_size) {
  58   do {
  59     HeapWord* obj = top();
  60     size_t available = pointer_delta(end(), obj);
  61     size_t want_to_allocate = MIN2(available, desired_word_size);
  62     if (want_to_allocate >= min_word_size) {
  63       HeapWord* new_top = obj + want_to_allocate;
  64       HeapWord* result = Atomic::cmpxchg(new_top, &_top, obj);
  65       // result can be one of two:
  66       //  the old top value: the exchange succeeded
  67       //  otherwise: the new value of the top is returned.
  68       if (result == obj) {
  69         assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
  70         *actual_size = want_to_allocate;
  71         return obj;
  72       }
  73     } else {
  74       return NULL;
  75     }
  76   } while (true);
  77 }
  78 
  79 inline HeapWord* HeapRegion::allocate(size_t min_word_size,
  80                                       size_t desired_word_size,
  81                                       size_t* actual_size) {
  82   HeapWord* res = allocate_impl(min_word_size, desired_word_size, actual_size);
  83   if (res != NULL) {
  84     _bot_part.alloc_block(res, *actual_size);




  44   if (want_to_allocate >= min_word_size) {
  45     HeapWord* new_top = obj + want_to_allocate;
  46     set_top(new_top);
  47     assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
  48     *actual_size = want_to_allocate;
  49     return obj;
  50   } else {
  51     return NULL;
  52   }
  53 }
  54 
  55 inline HeapWord* HeapRegion::par_allocate_impl(size_t min_word_size,
  56                                                size_t desired_word_size,
  57                                                size_t* actual_size) {
  58   do {
  59     HeapWord* obj = top();
  60     size_t available = pointer_delta(end(), obj);
  61     size_t want_to_allocate = MIN2(available, desired_word_size);
  62     if (want_to_allocate >= min_word_size) {
  63       HeapWord* new_top = obj + want_to_allocate;
  64       HeapWord* result = Atomic::cmpxchg(&_top, obj, new_top);
  65       // result can be one of two:
  66       //  the old top value: the exchange succeeded
  67       //  otherwise: the new value of the top is returned.
  68       if (result == obj) {
  69         assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
  70         *actual_size = want_to_allocate;
  71         return obj;
  72       }
  73     } else {
  74       return NULL;
  75     }
  76   } while (true);
  77 }
  78 
  79 inline HeapWord* HeapRegion::allocate(size_t min_word_size,
  80                                       size_t desired_word_size,
  81                                       size_t* actual_size) {
  82   HeapWord* res = allocate_impl(min_word_size, desired_word_size, actual_size);
  83   if (res != NULL) {
  84     _bot_part.alloc_block(res, *actual_size);


< prev index next >