changeset 35492 | c8c0273e6b91 |
parent 35169 | e75913632d00 |
child 35862 | 411842d0c882 |
35491:663c609dfeee | 35492:c8c0273e6b91 |
---|---|
574 addChunkToFreeListsAtEndRecordingStats(prevEnd, newFcSize); |
574 addChunkToFreeListsAtEndRecordingStats(prevEnd, newFcSize); |
575 } |
575 } |
576 } |
576 } |
577 } |
577 } |
578 |
578 |
579 class FreeListSpace_DCTOC : public Filtering_DCTOC { |
579 class FreeListSpaceDCTOC : public FilteringDCTOC { |
580 CompactibleFreeListSpace* _cfls; |
580 CompactibleFreeListSpace* _cfls; |
581 CMSCollector* _collector; |
581 CMSCollector* _collector; |
582 bool _parallel; |
582 bool _parallel; |
583 protected: |
583 protected: |
584 // Override. |
584 // Override. |
594 ClosureType* cl) |
594 ClosureType* cl) |
595 walk_mem_region_with_cl_DECL(ExtendedOopClosure); |
595 walk_mem_region_with_cl_DECL(ExtendedOopClosure); |
596 walk_mem_region_with_cl_DECL(FilteringClosure); |
596 walk_mem_region_with_cl_DECL(FilteringClosure); |
597 |
597 |
598 public: |
598 public: |
599 FreeListSpace_DCTOC(CompactibleFreeListSpace* sp, |
599 FreeListSpaceDCTOC(CompactibleFreeListSpace* sp, |
600 CMSCollector* collector, |
600 CMSCollector* collector, |
601 ExtendedOopClosure* cl, |
601 ExtendedOopClosure* cl, |
602 CardTableModRefBS::PrecisionStyle precision, |
602 CardTableModRefBS::PrecisionStyle precision, |
603 HeapWord* boundary, |
603 HeapWord* boundary, |
604 bool parallel) : |
604 bool parallel) : |
605 Filtering_DCTOC(sp, cl, precision, boundary), |
605 FilteringDCTOC(sp, cl, precision, boundary), |
606 _cfls(sp), _collector(collector), _parallel(parallel) {} |
606 _cfls(sp), _collector(collector), _parallel(parallel) {} |
607 }; |
607 }; |
608 |
608 |
609 // We de-virtualize the block-related calls below, since we know that our |
609 // We de-virtualize the block-related calls below, since we know that our |
610 // space is a CompactibleFreeListSpace. |
610 // space is a CompactibleFreeListSpace. |
611 |
611 |
612 #define FreeListSpace_DCTOC__walk_mem_region_with_cl_DEFN(ClosureType) \ |
612 #define FreeListSpaceDCTOC__walk_mem_region_with_cl_DEFN(ClosureType) \ |
613 void FreeListSpace_DCTOC::walk_mem_region_with_cl(MemRegion mr, \ |
613 void FreeListSpaceDCTOC::walk_mem_region_with_cl(MemRegion mr, \ |
614 HeapWord* bottom, \ |
614 HeapWord* bottom, \ |
615 HeapWord* top, \ |
615 HeapWord* top, \ |
616 ClosureType* cl) { \ |
616 ClosureType* cl) { \ |
617 if (_parallel) { \ |
617 if (_parallel) { \ |
618 walk_mem_region_with_cl_par(mr, bottom, top, cl); \ |
618 walk_mem_region_with_cl_par(mr, bottom, top, cl); \ |
619 } else { \ |
619 } else { \ |
620 walk_mem_region_with_cl_nopar(mr, bottom, top, cl); \ |
620 walk_mem_region_with_cl_nopar(mr, bottom, top, cl); \ |
621 } \ |
621 } \ |
622 } \ |
622 } \ |
623 void FreeListSpace_DCTOC::walk_mem_region_with_cl_par(MemRegion mr, \ |
623 void FreeListSpaceDCTOC::walk_mem_region_with_cl_par(MemRegion mr, \ |
624 HeapWord* bottom, \ |
624 HeapWord* bottom, \ |
625 HeapWord* top, \ |
625 HeapWord* top, \ |
626 ClosureType* cl) { \ |
626 ClosureType* cl) { \ |
627 /* Skip parts that are before "mr", in case "block_start" sent us \ |
627 /* Skip parts that are before "mr", in case "block_start" sent us \ |
628 back too far. */ \ |
628 back too far. */ \ |
629 HeapWord* mr_start = mr.start(); \ |
629 HeapWord* mr_start = mr.start(); \ |
630 size_t bot_size = _cfls->CompactibleFreeListSpace::block_size(bottom); \ |
630 size_t bot_size = _cfls->CompactibleFreeListSpace::block_size(bottom); \ |
631 HeapWord* next = bottom + bot_size; \ |
631 HeapWord* next = bottom + bot_size; \ |
645 } else { \ |
645 } else { \ |
646 bottom += _cfls->CompactibleFreeListSpace::block_size(bottom); \ |
646 bottom += _cfls->CompactibleFreeListSpace::block_size(bottom); \ |
647 } \ |
647 } \ |
648 } \ |
648 } \ |
649 } \ |
649 } \ |
650 void FreeListSpace_DCTOC::walk_mem_region_with_cl_nopar(MemRegion mr, \ |
650 void FreeListSpaceDCTOC::walk_mem_region_with_cl_nopar(MemRegion mr, \ |
651 HeapWord* bottom, \ |
651 HeapWord* bottom, \ |
652 HeapWord* top, \ |
652 HeapWord* top, \ |
653 ClosureType* cl) { \ |
653 ClosureType* cl) { \ |
654 /* Skip parts that are before "mr", in case "block_start" sent us \ |
654 /* Skip parts that are before "mr", in case "block_start" sent us \ |
655 back too far. */ \ |
655 back too far. */ \ |
656 HeapWord* mr_start = mr.start(); \ |
656 HeapWord* mr_start = mr.start(); \ |
657 size_t bot_size = _cfls->CompactibleFreeListSpace::block_size_nopar(bottom); \ |
657 size_t bot_size = _cfls->CompactibleFreeListSpace::block_size_nopar(bottom); \ |
658 HeapWord* next = bottom + bot_size; \ |
658 HeapWord* next = bottom + bot_size; \ |
676 } |
676 } |
677 |
677 |
678 // (There are only two of these, rather than N, because the split is due |
678 // (There are only two of these, rather than N, because the split is due |
679 // only to the introduction of the FilteringClosure, a local part of the |
679 // only to the introduction of the FilteringClosure, a local part of the |
680 // impl of this abstraction.) |
680 // impl of this abstraction.) |
681 FreeListSpace_DCTOC__walk_mem_region_with_cl_DEFN(ExtendedOopClosure) |
681 FreeListSpaceDCTOC__walk_mem_region_with_cl_DEFN(ExtendedOopClosure) |
682 FreeListSpace_DCTOC__walk_mem_region_with_cl_DEFN(FilteringClosure) |
682 FreeListSpaceDCTOC__walk_mem_region_with_cl_DEFN(FilteringClosure) |
683 |
683 |
684 DirtyCardToOopClosure* |
684 DirtyCardToOopClosure* |
685 CompactibleFreeListSpace::new_dcto_cl(ExtendedOopClosure* cl, |
685 CompactibleFreeListSpace::new_dcto_cl(ExtendedOopClosure* cl, |
686 CardTableModRefBS::PrecisionStyle precision, |
686 CardTableModRefBS::PrecisionStyle precision, |
687 HeapWord* boundary, |
687 HeapWord* boundary, |
688 bool parallel) { |
688 bool parallel) { |
689 return new FreeListSpace_DCTOC(this, _collector, cl, precision, boundary, parallel); |
689 return new FreeListSpaceDCTOC(this, _collector, cl, precision, boundary, parallel); |
690 } |
690 } |
691 |
691 |
692 |
692 |
693 // Note on locking for the space iteration functions: |
693 // Note on locking for the space iteration functions: |
694 // since the collector's iteration activities are concurrent with |
694 // since the collector's iteration activities are concurrent with |
2411 (double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0)); |
2411 (double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0)); |
2412 _dictionary->print_dict_census(out); |
2412 _dictionary->print_dict_census(out); |
2413 } |
2413 } |
2414 |
2414 |
2415 /////////////////////////////////////////////////////////////////////////// |
2415 /////////////////////////////////////////////////////////////////////////// |
2416 // CFLS_LAB |
2416 // CompactibleFreeListSpaceLAB |
2417 /////////////////////////////////////////////////////////////////////////// |
2417 /////////////////////////////////////////////////////////////////////////// |
2418 |
2418 |
2419 #define VECTOR_257(x) \ |
2419 #define VECTOR_257(x) \ |
2420 /* 1 2 3 4 5 6 7 8 9 1x 11 12 13 14 15 16 17 18 19 2x 21 22 23 24 25 26 27 28 29 3x 31 32 */ \ |
2420 /* 1 2 3 4 5 6 7 8 9 1x 11 12 13 14 15 16 17 18 19 2x 21 22 23 24 25 26 27 28 29 3x 31 32 */ \ |
2421 { x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, \ |
2421 { x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, \ |
2430 |
2430 |
2431 // Initialize with default setting for CMS, _not_ |
2431 // Initialize with default setting for CMS, _not_ |
2432 // generic OldPLABSize, whose static default is different; if overridden at the |
2432 // generic OldPLABSize, whose static default is different; if overridden at the |
2433 // command-line, this will get reinitialized via a call to |
2433 // command-line, this will get reinitialized via a call to |
2434 // modify_initialization() below. |
2434 // modify_initialization() below. |
2435 AdaptiveWeightedAverage CFLS_LAB::_blocks_to_claim[] = |
2435 AdaptiveWeightedAverage CompactibleFreeListSpaceLAB::_blocks_to_claim[] = |
2436 VECTOR_257(AdaptiveWeightedAverage(OldPLABWeight, (float)CFLS_LAB::_default_dynamic_old_plab_size)); |
2436 VECTOR_257(AdaptiveWeightedAverage(OldPLABWeight, (float)CompactibleFreeListSpaceLAB::_default_dynamic_old_plab_size)); |
2437 size_t CFLS_LAB::_global_num_blocks[] = VECTOR_257(0); |
2437 size_t CompactibleFreeListSpaceLAB::_global_num_blocks[] = VECTOR_257(0); |
2438 uint CFLS_LAB::_global_num_workers[] = VECTOR_257(0); |
2438 uint CompactibleFreeListSpaceLAB::_global_num_workers[] = VECTOR_257(0); |
2439 |
2439 |
2440 CFLS_LAB::CFLS_LAB(CompactibleFreeListSpace* cfls) : |
2440 CompactibleFreeListSpaceLAB::CompactibleFreeListSpaceLAB(CompactibleFreeListSpace* cfls) : |
2441 _cfls(cfls) |
2441 _cfls(cfls) |
2442 { |
2442 { |
2443 assert(CompactibleFreeListSpace::IndexSetSize == 257, "Modify VECTOR_257() macro above"); |
2443 assert(CompactibleFreeListSpace::IndexSetSize == 257, "Modify VECTOR_257() macro above"); |
2444 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |
2444 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |
2445 i < CompactibleFreeListSpace::IndexSetSize; |
2445 i < CompactibleFreeListSpace::IndexSetSize; |
2449 } |
2449 } |
2450 } |
2450 } |
2451 |
2451 |
2452 static bool _CFLS_LAB_modified = false; |
2452 static bool _CFLS_LAB_modified = false; |
2453 |
2453 |
2454 void CFLS_LAB::modify_initialization(size_t n, unsigned wt) { |
2454 void CompactibleFreeListSpaceLAB::modify_initialization(size_t n, unsigned wt) { |
2455 assert(!_CFLS_LAB_modified, "Call only once"); |
2455 assert(!_CFLS_LAB_modified, "Call only once"); |
2456 _CFLS_LAB_modified = true; |
2456 _CFLS_LAB_modified = true; |
2457 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |
2457 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |
2458 i < CompactibleFreeListSpace::IndexSetSize; |
2458 i < CompactibleFreeListSpace::IndexSetSize; |
2459 i += CompactibleFreeListSpace::IndexSetStride) { |
2459 i += CompactibleFreeListSpace::IndexSetStride) { |
2460 _blocks_to_claim[i].modify(n, wt, true /* force */); |
2460 _blocks_to_claim[i].modify(n, wt, true /* force */); |
2461 } |
2461 } |
2462 } |
2462 } |
2463 |
2463 |
2464 HeapWord* CFLS_LAB::alloc(size_t word_sz) { |
2464 HeapWord* CompactibleFreeListSpaceLAB::alloc(size_t word_sz) { |
2465 FreeChunk* res; |
2465 FreeChunk* res; |
2466 assert(word_sz == _cfls->adjustObjectSize(word_sz), "Error"); |
2466 assert(word_sz == _cfls->adjustObjectSize(word_sz), "Error"); |
2467 if (word_sz >= CompactibleFreeListSpace::IndexSetSize) { |
2467 if (word_sz >= CompactibleFreeListSpace::IndexSetSize) { |
2468 // This locking manages sync with other large object allocations. |
2468 // This locking manages sync with other large object allocations. |
2469 MutexLockerEx x(_cfls->parDictionaryAllocLock(), |
2469 MutexLockerEx x(_cfls->parDictionaryAllocLock(), |
2489 return (HeapWord*)res; |
2489 return (HeapWord*)res; |
2490 } |
2490 } |
2491 |
2491 |
2492 // Get a chunk of blocks of the right size and update related |
2492 // Get a chunk of blocks of the right size and update related |
2493 // book-keeping stats |
2493 // book-keeping stats |
2494 void CFLS_LAB::get_from_global_pool(size_t word_sz, AdaptiveFreeList<FreeChunk>* fl) { |
2494 void CompactibleFreeListSpaceLAB::get_from_global_pool(size_t word_sz, AdaptiveFreeList<FreeChunk>* fl) { |
2495 // Get the #blocks we want to claim |
2495 // Get the #blocks we want to claim |
2496 size_t n_blks = (size_t)_blocks_to_claim[word_sz].average(); |
2496 size_t n_blks = (size_t)_blocks_to_claim[word_sz].average(); |
2497 assert(n_blks > 0, "Error"); |
2497 assert(n_blks > 0, "Error"); |
2498 assert(ResizeOldPLAB || n_blks == OldPLABSize, "Error"); |
2498 assert(ResizeOldPLAB || n_blks == OldPLABSize, "Error"); |
2499 // In some cases, when the application has a phase change, |
2499 // In some cases, when the application has a phase change, |
2523 _cfls->par_get_chunk_of_blocks(word_sz, n_blks, fl); |
2523 _cfls->par_get_chunk_of_blocks(word_sz, n_blks, fl); |
2524 // Update stats table entry for this block size |
2524 // Update stats table entry for this block size |
2525 _num_blocks[word_sz] += fl->count(); |
2525 _num_blocks[word_sz] += fl->count(); |
2526 } |
2526 } |
2527 |
2527 |
2528 void CFLS_LAB::compute_desired_plab_size() { |
2528 void CompactibleFreeListSpaceLAB::compute_desired_plab_size() { |
2529 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |
2529 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |
2530 i < CompactibleFreeListSpace::IndexSetSize; |
2530 i < CompactibleFreeListSpace::IndexSetSize; |
2531 i += CompactibleFreeListSpace::IndexSetStride) { |
2531 i += CompactibleFreeListSpace::IndexSetStride) { |
2532 assert((_global_num_workers[i] == 0) == (_global_num_blocks[i] == 0), |
2532 assert((_global_num_workers[i] == 0) == (_global_num_blocks[i] == 0), |
2533 "Counter inconsistency"); |
2533 "Counter inconsistency"); |
2549 |
2549 |
2550 // If this is changed in the future to allow parallel |
2550 // If this is changed in the future to allow parallel |
2551 // access, one would need to take the FL locks and, |
2551 // access, one would need to take the FL locks and, |
2552 // depending on how it is used, stagger access from |
2552 // depending on how it is used, stagger access from |
2553 // parallel threads to reduce contention. |
2553 // parallel threads to reduce contention. |
2554 void CFLS_LAB::retire(int tid) { |
2554 void CompactibleFreeListSpaceLAB::retire(int tid) { |
2555 // We run this single threaded with the world stopped; |
2555 // We run this single threaded with the world stopped; |
2556 // so no need for locks and such. |
2556 // so no need for locks and such. |
2557 NOT_PRODUCT(Thread* t = Thread::current();) |
2557 NOT_PRODUCT(Thread* t = Thread::current();) |
2558 assert(Thread::current()->is_VM_thread(), "Error"); |
2558 assert(Thread::current()->is_VM_thread(), "Error"); |
2559 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |
2559 for (size_t i = CompactibleFreeListSpace::IndexSetStart; |