hotspot/src/share/vm/gc/g1/g1AllocRegion.inline.hpp
changeset 33105 294e48b4f704
parent 32389 626f27450e12
equal deleted inserted replaced
33104:a7c0f60a1294 33105:294e48b4f704
    26 #define SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
    26 #define SHARE_VM_GC_G1_G1ALLOCREGION_INLINE_HPP
    27 
    27 
    28 #include "gc/g1/g1AllocRegion.hpp"
    28 #include "gc/g1/g1AllocRegion.hpp"
    29 #include "gc/g1/heapRegion.inline.hpp"
    29 #include "gc/g1/heapRegion.inline.hpp"
    30 
    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 
    31 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
    39 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
    32                                          size_t word_size,
    40                                          size_t word_size,
    33                                          bool bot_updates) {
    41                                          bool bot_updates) {
    34   assert(alloc_region != NULL, err_msg("pre-condition"));
    42   assert(alloc_region != NULL, "pre-condition");
    35 
    43 
    36   if (!bot_updates) {
    44   if (!bot_updates) {
    37     return alloc_region->allocate_no_bot_updates(word_size);
    45     return alloc_region->allocate_no_bot_updates(word_size);
    38   } else {
    46   } else {
    39     return alloc_region->allocate(word_size);
    47     return alloc_region->allocate(word_size);
    48 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
    56 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
    49                                              size_t min_word_size,
    57                                              size_t min_word_size,
    50                                              size_t desired_word_size,
    58                                              size_t desired_word_size,
    51                                              size_t* actual_word_size,
    59                                              size_t* actual_word_size,
    52                                              bool bot_updates) {
    60                                              bool bot_updates) {
    53   assert(alloc_region != NULL, err_msg("pre-condition"));
    61   assert(alloc_region != NULL, "pre-condition");
    54   assert(!alloc_region->is_empty(), err_msg("pre-condition"));
    62   assert(!alloc_region->is_empty(), "pre-condition");
    55 
    63 
    56   if (!bot_updates) {
    64   if (!bot_updates) {
    57     return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
    65     return alloc_region->par_allocate_no_bot_updates(min_word_size, desired_word_size, actual_word_size);
    58   } else {
    66   } else {
    59     return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
    67     return alloc_region->par_allocate(min_word_size, desired_word_size, actual_word_size);
    67 
    75 
    68 inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
    76 inline HeapWord* G1AllocRegion::attempt_allocation(size_t min_word_size,
    69                                                    size_t desired_word_size,
    77                                                    size_t desired_word_size,
    70                                                    size_t* actual_word_size,
    78                                                    size_t* actual_word_size,
    71                                                    bool bot_updates) {
    79                                                    bool bot_updates) {
    72   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    80   assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
    73 
    81 
    74   HeapRegion* alloc_region = _alloc_region;
    82   HeapRegion* alloc_region = _alloc_region;
    75   assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    83   assert_alloc_region(alloc_region != NULL, "not initialized properly");
    76 
    84 
    77   HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size, bot_updates);
    85   HeapWord* result = par_allocate(alloc_region, min_word_size, desired_word_size, actual_word_size, bot_updates);
    78   if (result != NULL) {
    86   if (result != NULL) {
    79     trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
    87     trace("alloc", min_word_size, desired_word_size, *actual_word_size, result);
    80     return result;
    88     return result;
   111   return NULL;
   119   return NULL;
   112 }
   120 }
   113 
   121 
   114 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
   122 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
   115                                                          bool bot_updates) {
   123                                                          bool bot_updates) {
   116   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
   124   assert_alloc_region(bot_updates == _bot_updates, "pre-condition");
   117   assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
   125   assert_alloc_region(_alloc_region != NULL, "not initialized properly");
   118 
   126 
   119   trace("forcing alloc", word_size, word_size);
   127   trace("forcing alloc", word_size, word_size);
   120   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
   128   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
   121   if (result != NULL) {
   129   if (result != NULL) {
   122     trace("alloc forced", word_size, word_size, word_size, result);
   130     trace("alloc forced", word_size, word_size, word_size, result);