< prev index next >

src/share/vm/gc_implementation/g1/g1AllocRegion.cpp

Print this page




 123     // Need to do this before the allocation
 124     _used_bytes_before = new_alloc_region->used();
 125     HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates);
 126     assert(result != NULL, ar_ext_msg(this, "the allocation should succeeded"));
 127 
 128     OrderAccess::storestore();
 129     // Note that we first perform the allocation and then we store the
 130     // region in _alloc_region. This is the reason why an active region
 131     // can never be empty.
 132     update_alloc_region(new_alloc_region);
 133     trace("region allocation successful");
 134     return result;
 135   } else {
 136     trace("region allocation failed");
 137     return NULL;
 138   }
 139   ShouldNotReachHere();
 140 }
 141 
 142 void G1AllocRegion::fill_in_ext_msg(ar_ext_msg* msg, const char* message) {
 143   msg->append("[%s] %s c: %u b: %s r: "PTR_FORMAT" u: "SIZE_FORMAT,
 144               _name, message, _count, BOOL_TO_STR(_bot_updates),
 145               p2i(_alloc_region), _used_bytes_before);
 146 }
 147 
 148 void G1AllocRegion::init() {
 149   trace("initializing");
 150   assert(_alloc_region == NULL && _used_bytes_before == 0,
 151          ar_ext_msg(this, "pre-condition"));
 152   assert(_dummy_region != NULL, ar_ext_msg(this, "should have been set"));
 153   _alloc_region = _dummy_region;
 154   _count = 0;
 155   trace("initialized");
 156 }
 157 
 158 void G1AllocRegion::set(HeapRegion* alloc_region) {
 159   trace("setting");
 160   // We explicitly check that the region is not empty to make sure we
 161   // maintain the "the alloc region cannot be empty" invariant.
 162   assert(alloc_region != NULL && !alloc_region->is_empty(),
 163          ar_ext_msg(this, "pre-condition"));


 200   // All the calls to trace that set either just the size or the size
 201   // and the result are considered part of level 2 tracing and are
 202   // skipped during level 1 tracing.
 203   if ((word_size == 0 && result == NULL) || (G1_ALLOC_REGION_TRACING > 1)) {
 204     const size_t buffer_length = 128;
 205     char hr_buffer[buffer_length];
 206     char rest_buffer[buffer_length];
 207 
 208     HeapRegion* alloc_region = _alloc_region;
 209     if (alloc_region == NULL) {
 210       jio_snprintf(hr_buffer, buffer_length, "NULL");
 211     } else if (alloc_region == _dummy_region) {
 212       jio_snprintf(hr_buffer, buffer_length, "DUMMY");
 213     } else {
 214       jio_snprintf(hr_buffer, buffer_length,
 215                    HR_FORMAT, HR_FORMAT_PARAMS(alloc_region));
 216     }
 217 
 218     if (G1_ALLOC_REGION_TRACING > 1) {
 219       if (result != NULL) {
 220         jio_snprintf(rest_buffer, buffer_length, SIZE_FORMAT" "PTR_FORMAT,
 221                      word_size, result);
 222       } else if (word_size != 0) {
 223         jio_snprintf(rest_buffer, buffer_length, SIZE_FORMAT, word_size);
 224       } else {
 225         jio_snprintf(rest_buffer, buffer_length, "");
 226       }
 227     } else {
 228       jio_snprintf(rest_buffer, buffer_length, "");
 229     }
 230 
 231     tty->print_cr("[%s] %u %s : %s %s",
 232                   _name, _count, hr_buffer, str, rest_buffer);
 233   }
 234 }
 235 #endif // G1_ALLOC_REGION_TRACING
 236 
 237 G1AllocRegion::G1AllocRegion(const char* name,
 238                              bool bot_updates)
 239   : _name(name), _bot_updates(bot_updates),
 240     _alloc_region(NULL), _count(0), _used_bytes_before(0),




 123     // Need to do this before the allocation
 124     _used_bytes_before = new_alloc_region->used();
 125     HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates);
 126     assert(result != NULL, ar_ext_msg(this, "the allocation should succeeded"));
 127 
 128     OrderAccess::storestore();
 129     // Note that we first perform the allocation and then we store the
 130     // region in _alloc_region. This is the reason why an active region
 131     // can never be empty.
 132     update_alloc_region(new_alloc_region);
 133     trace("region allocation successful");
 134     return result;
 135   } else {
 136     trace("region allocation failed");
 137     return NULL;
 138   }
 139   ShouldNotReachHere();
 140 }
 141 
 142 void G1AllocRegion::fill_in_ext_msg(ar_ext_msg* msg, const char* message) {
 143   msg->append("[%s] %s c: %u b: %s r: " PTR_FORMAT " u: " SIZE_FORMAT,
 144               _name, message, _count, BOOL_TO_STR(_bot_updates),
 145               p2i(_alloc_region), _used_bytes_before);
 146 }
 147 
 148 void G1AllocRegion::init() {
 149   trace("initializing");
 150   assert(_alloc_region == NULL && _used_bytes_before == 0,
 151          ar_ext_msg(this, "pre-condition"));
 152   assert(_dummy_region != NULL, ar_ext_msg(this, "should have been set"));
 153   _alloc_region = _dummy_region;
 154   _count = 0;
 155   trace("initialized");
 156 }
 157 
 158 void G1AllocRegion::set(HeapRegion* alloc_region) {
 159   trace("setting");
 160   // We explicitly check that the region is not empty to make sure we
 161   // maintain the "the alloc region cannot be empty" invariant.
 162   assert(alloc_region != NULL && !alloc_region->is_empty(),
 163          ar_ext_msg(this, "pre-condition"));


 200   // All the calls to trace that set either just the size or the size
 201   // and the result are considered part of level 2 tracing and are
 202   // skipped during level 1 tracing.
 203   if ((word_size == 0 && result == NULL) || (G1_ALLOC_REGION_TRACING > 1)) {
 204     const size_t buffer_length = 128;
 205     char hr_buffer[buffer_length];
 206     char rest_buffer[buffer_length];
 207 
 208     HeapRegion* alloc_region = _alloc_region;
 209     if (alloc_region == NULL) {
 210       jio_snprintf(hr_buffer, buffer_length, "NULL");
 211     } else if (alloc_region == _dummy_region) {
 212       jio_snprintf(hr_buffer, buffer_length, "DUMMY");
 213     } else {
 214       jio_snprintf(hr_buffer, buffer_length,
 215                    HR_FORMAT, HR_FORMAT_PARAMS(alloc_region));
 216     }
 217 
 218     if (G1_ALLOC_REGION_TRACING > 1) {
 219       if (result != NULL) {
 220         jio_snprintf(rest_buffer, buffer_length, SIZE_FORMAT " " PTR_FORMAT,
 221                      word_size, result);
 222       } else if (word_size != 0) {
 223         jio_snprintf(rest_buffer, buffer_length, SIZE_FORMAT, word_size);
 224       } else {
 225         jio_snprintf(rest_buffer, buffer_length, "");
 226       }
 227     } else {
 228       jio_snprintf(rest_buffer, buffer_length, "");
 229     }
 230 
 231     tty->print_cr("[%s] %u %s : %s %s",
 232                   _name, _count, hr_buffer, str, rest_buffer);
 233   }
 234 }
 235 #endif // G1_ALLOC_REGION_TRACING
 236 
 237 G1AllocRegion::G1AllocRegion(const char* name,
 238                              bool bot_updates)
 239   : _name(name), _bot_updates(bot_updates),
 240     _alloc_region(NULL), _count(0), _used_bytes_before(0),


< prev index next >