421 _summary_bytes_used += word_size * HeapWordSize; 422 423 return old_top; 424 } 425 426 void G1ArchiveAllocator::complete_archive(GrowableArray<MemRegion>* ranges, 427 size_t end_alignment_in_bytes) { 428 assert((end_alignment_in_bytes >> LogHeapWordSize) < HeapRegion::min_region_size_in_words(), 429 "alignment " SIZE_FORMAT " too large", end_alignment_in_bytes); 430 assert(is_size_aligned(end_alignment_in_bytes, HeapWordSize), 431 "alignment " SIZE_FORMAT " is not HeapWord (%u) aligned", end_alignment_in_bytes, HeapWordSize); 432 433 // If we've allocated nothing, simply return. 434 if (_allocation_region == NULL) { 435 return; 436 } 437 438 // If an end alignment was requested, insert filler objects. 439 if (end_alignment_in_bytes != 0) { 440 HeapWord* currtop = _allocation_region->top(); 441 HeapWord* newtop = (HeapWord*)align_pointer_up(currtop, end_alignment_in_bytes); 442 size_t fill_size = pointer_delta(newtop, currtop); 443 if (fill_size != 0) { 444 if (fill_size < CollectedHeap::min_fill_size()) { 445 // If the required fill is smaller than we can represent, 446 // bump up to the next aligned address. We know we won't exceed the current 447 // region boundary because the max supported alignment is smaller than the min 448 // region size, and because the allocation code never leaves space smaller than 449 // the min_fill_size at the top of the current allocation region. 450 newtop = (HeapWord*)align_pointer_up(currtop + CollectedHeap::min_fill_size(), 451 end_alignment_in_bytes); 452 fill_size = pointer_delta(newtop, currtop); 453 } 454 HeapWord* fill = archive_mem_allocate(fill_size); 455 CollectedHeap::fill_with_objects(fill, fill_size); 456 } 457 } 458 459 // Loop through the allocated regions, and create MemRegions summarizing 460 // the allocated address range, combining contiguous ranges. Add the 461 // MemRegions to the GrowableArray provided by the caller. 462 int index = _allocated_regions.length() - 1; 463 assert(_allocated_regions.at(index) == _allocation_region, 464 "expected region %u at end of array, found %u", 465 _allocation_region->hrm_index(), _allocated_regions.at(index)->hrm_index()); 466 HeapWord* base_address = _allocation_region->bottom(); 467 HeapWord* top = base_address; 468 469 while (index >= 0) { 470 HeapRegion* next = _allocated_regions.at(index); | 421 _summary_bytes_used += word_size * HeapWordSize; 422 423 return old_top; 424 } 425 426 void G1ArchiveAllocator::complete_archive(GrowableArray<MemRegion>* ranges, 427 size_t end_alignment_in_bytes) { 428 assert((end_alignment_in_bytes >> LogHeapWordSize) < HeapRegion::min_region_size_in_words(), 429 "alignment " SIZE_FORMAT " too large", end_alignment_in_bytes); 430 assert(is_size_aligned(end_alignment_in_bytes, HeapWordSize), 431 "alignment " SIZE_FORMAT " is not HeapWord (%u) aligned", end_alignment_in_bytes, HeapWordSize); 432 433 // If we've allocated nothing, simply return. 434 if (_allocation_region == NULL) { 435 return; 436 } 437 438 // If an end alignment was requested, insert filler objects. 439 if (end_alignment_in_bytes != 0) { 440 HeapWord* currtop = _allocation_region->top(); 441 HeapWord* newtop = (HeapWord*)align_ptr_up(currtop, end_alignment_in_bytes); 442 size_t fill_size = pointer_delta(newtop, currtop); 443 if (fill_size != 0) { 444 if (fill_size < CollectedHeap::min_fill_size()) { 445 // If the required fill is smaller than we can represent, 446 // bump up to the next aligned address. We know we won't exceed the current 447 // region boundary because the max supported alignment is smaller than the min 448 // region size, and because the allocation code never leaves space smaller than 449 // the min_fill_size at the top of the current allocation region. 450 newtop = (HeapWord*)align_ptr_up(currtop + CollectedHeap::min_fill_size(), 451 end_alignment_in_bytes); 452 fill_size = pointer_delta(newtop, currtop); 453 } 454 HeapWord* fill = archive_mem_allocate(fill_size); 455 CollectedHeap::fill_with_objects(fill, fill_size); 456 } 457 } 458 459 // Loop through the allocated regions, and create MemRegions summarizing 460 // the allocated address range, combining contiguous ranges. Add the 461 // MemRegions to the GrowableArray provided by the caller. 462 int index = _allocated_regions.length() - 1; 463 assert(_allocated_regions.at(index) == _allocation_region, 464 "expected region %u at end of array, found %u", 465 _allocation_region->hrm_index(), _allocated_regions.at(index)->hrm_index()); 466 HeapWord* base_address = _allocation_region->bottom(); 467 HeapWord* top = base_address; 468 469 while (index >= 0) { 470 HeapRegion* next = _allocated_regions.at(index); |