hotspot/src/share/vm/gc/g1/g1AllocRegion.inline.hpp
changeset 32389 626f27450e12
parent 30764 fec48bf5a827
child 33105 294e48b4f704
equal deleted inserted replaced
32388:81663b0d3631 32389:626f27450e12
    38   } else {
    38   } else {
    39     return alloc_region->allocate(word_size);
    39     return alloc_region->allocate(word_size);
    40   }
    40   }
    41 }
    41 }
    42 
    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 
    43 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
    48 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
    44                                              size_t word_size,
    49                                              size_t min_word_size,
       
    50                                              size_t desired_word_size,
       
    51                                              size_t* actual_word_size,
    45                                              bool bot_updates) {
    52                                              bool bot_updates) {
    46   assert(alloc_region != NULL, err_msg("pre-condition"));
    53   assert(alloc_region != NULL, err_msg("pre-condition"));
    47   assert(!alloc_region->is_empty(), err_msg("pre-condition"));
    54   assert(!alloc_region->is_empty(), err_msg("pre-condition"));
    48 
    55 
    49   if (!bot_updates) {
    56   if (!bot_updates) {
    50     return alloc_region->par_allocate_no_bot_updates(word_size);
    57     return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
    51   } else {
    58   } else {
    52     return alloc_region->par_allocate(word_size);
    59     return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
    53   }
    60   }
    54 }
    61 }
    55 
    62 
    56 inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size,
    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,
    57                                                    bool bot_updates) {
    71                                                    bool bot_updates) {
    58   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    72   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    59 
    73 
    60   HeapRegion* alloc_region = _alloc_region;
    74   HeapRegion* alloc_region = _alloc_region;
    61   assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    75   assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    62 
    76 
    63   HeapWord* result = par_allocate(alloc_region, word_size, bot_updates);
    77   HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size, bot_updates);
    64   if (result != NULL) {
    78   if (result != NULL) {
    65     trace("alloc", word_size, result);
    79     trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
    66     return result;
    80     return result;
    67   }
    81   }
    68   trace("alloc failed", word_size);
    82   trace("alloc failed", min_word_size, desired_word_size);
    69   return NULL;
    83   return NULL;
    70 }
    84 }
    71 
    85 
    72 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size,
    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,
    73                                                           bool bot_updates) {
    94                                                           bool bot_updates) {
    74   // First we have to redo the allocation, assuming we're holding the
    95   // First we have to redo the allocation, assuming we're holding the
    75   // appropriate lock, in case another thread changed the region while
    96   // appropriate lock, in case another thread changed the region while
    76   // we were waiting to get the lock.
    97   // we were waiting to get the lock.
    77   HeapWord* result = attempt_allocation(word_size, bot_updates);
    98   HeapWord* result = attempt_allocation(min_word_size, desired_word_size, actual_word_size, bot_updates);
    78   if (result != NULL) {
    99   if (result != NULL) {
    79     return result;
   100     return result;
    80   }
   101   }
    81 
   102 
    82   retire(true /* fill_up */);
   103   retire(true /* fill_up */);
    83   result = new_alloc_region_and_allocate(word_size, false /* force */);
   104   result = new_alloc_region_and_allocate(desired_word_size, false /* force */);
    84   if (result != NULL) {
   105   if (result != NULL) {
    85     trace("alloc locked (second attempt)", word_size, result);
   106     *actual_word_size = desired_word_size;
       
   107     trace("alloc locked (second attempt)", min_word_size, desired_word_size, *actual_word_size, result);
    86     return result;
   108     return result;
    87   }
   109   }
    88   trace("alloc locked failed", word_size);
   110   trace("alloc locked failed", min_word_size, desired_word_size);
    89   return NULL;
   111   return NULL;
    90 }
   112 }
    91 
   113 
    92 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
   114 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
    93                                                          bool bot_updates) {
   115                                                          bool bot_updates) {
    94   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
   116   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    95   assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
   117   assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    96 
   118 
    97   trace("forcing alloc");
   119   trace("forcing alloc", word_size, word_size);
    98   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
   120   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
    99   if (result != NULL) {
   121   if (result != NULL) {
   100     trace("alloc forced", word_size, result);
   122     trace("alloc forced", word_size, word_size, word_size, result);
   101     return result;
   123     return result;
   102   }
   124   }
   103   trace("alloc forced failed", word_size);
   125   trace("alloc forced failed", word_size, word_size);
   104   return NULL;
   126   return NULL;
   105 }
   127 }
   106 
   128 
   107 #endif // SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
   129 #endif // SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP