< prev index next >

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

Print this page
rev 47400 : [mq]: cmpxchg_ptr


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




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


< prev index next >