714 void reset_chunk(size_t chunk_index); |
714 void reset_chunk(size_t chunk_index); |
715 |
715 |
716 virtual IterationStatus do_addr(HeapWord* addr, size_t words); |
716 virtual IterationStatus do_addr(HeapWord* addr, size_t words); |
717 }; |
717 }; |
718 |
718 |
|
719 // The UseParallelOldGC collector is a stop-the-world garbage |
|
720 // collector that does parts of the collection using parallel threads. |
|
721 // The collection includes the tenured generation and the young |
|
722 // generation. The permanent generation is collected at the same |
|
723 // time as the other two generations but the permanent generation |
|
724 // is collect by a single GC thread. The permanent generation is |
|
725 // collected serially because of the requirement that during the |
|
726 // processing of a klass AAA, any objects reference by AAA must |
|
727 // already have been processed. This requirement is enforced by |
|
728 // a left (lower address) to right (higher address) sliding compaction. |
|
729 // |
|
730 // There are four phases of the collection. |
|
731 // |
|
732 // - marking phase |
|
733 // - summary phase |
|
734 // - compacting phase |
|
735 // - clean up phase |
|
736 // |
|
737 // Roughly speaking these phases correspond, respectively, to |
|
738 // - mark all the live objects |
|
739 // - calculate the destination of each object at the end of the collection |
|
740 // - move the objects to their destination |
|
741 // - update some references and reinitialize some variables |
|
742 // |
|
743 // These three phases are invoked in PSParallelCompact::invoke_no_policy(). |
|
744 // The marking phase is implemented in PSParallelCompact::marking_phase() |
|
745 // and does a complete marking of the heap. |
|
746 // The summary phase is implemented in PSParallelCompact::summary_phase(). |
|
747 // The move and update phase is implemented in PSParallelCompact::compact(). |
|
748 // |
|
749 // A space that is being collected is divided into chunks and with |
|
750 // each chunk is associated an object of type ParallelCompactData. |
|
751 // Each chunk is of a fixed size and typically will contain more than |
|
752 // 1 object and may have parts of objects at the front and back of the |
|
753 // chunk. |
|
754 // |
|
755 // chunk -----+---------------------+---------- |
|
756 // objects covered [ AAA )[ BBB )[ CCC )[ DDD ) |
|
757 // |
|
758 // The marking phase does a complete marking of all live objects in the |
|
759 // heap. The marking also compiles the size of the data for |
|
760 // all live objects covered by the chunk. This size includes the |
|
761 // part of any live object spanning onto the chunk (part of AAA |
|
762 // if it is live) from the front, all live objects contained in the chunk |
|
763 // (BBB and/or CCC if they are live), and the part of any live objects |
|
764 // covered by the chunk that extends off the chunk (part of DDD if it is |
|
765 // live). The marking phase uses multiple GC threads and marking is |
|
766 // done in a bit array of type ParMarkBitMap. The marking of the |
|
767 // bit map is done atomically as is the accumulation of the size of the |
|
768 // live objects covered by a chunk. |
|
769 // |
|
770 // The summary phase calculates the total live data to the left of |
|
771 // each chunk XXX. Based on that total and the bottom of the space, |
|
772 // it can calculate the starting location of the live data in XXX. |
|
773 // The summary phase calculates for each chunk XXX quantites such as |
|
774 // |
|
775 // - the amount of live data at the beginning of a chunk from an object |
|
776 // entering the chunk. |
|
777 // - the location of the first live data on the chunk |
|
778 // - a count of the number of chunks receiving live data from XXX. |
|
779 // |
|
780 // See ParallelCompactData for precise details. The summary phase also |
|
781 // calculates the dense prefix for the compaction. The dense prefix |
|
782 // is a portion at the beginning of the space that is not moved. The |
|
783 // objects in the dense prefix do need to have their object references |
|
784 // updated. See method summarize_dense_prefix(). |
|
785 // |
|
786 // The summary phase is done using 1 GC thread. |
|
787 // |
|
788 // The compaction phase moves objects to their new location and updates |
|
789 // all references in the object. |
|
790 // |
|
791 // A current exception is that objects that cross a chunk boundary |
|
792 // are moved but do not have their references updated. References are |
|
793 // not updated because it cannot easily be determined if the klass |
|
794 // pointer KKK for the object AAA has been updated. KKK likely resides |
|
795 // in a chunk to the left of the chunk containing AAA. These AAA's |
|
796 // have there references updated at the end in a clean up phase. |
|
797 // See the method PSParallelCompact::update_deferred_objects(). An |
|
798 // alternate strategy is being investigated for this deferral of updating. |
|
799 // |
|
800 // Compaction is done on a chunk basis. A chunk that is ready to be |
|
801 // filled is put on a ready list and GC threads take chunk off the list |
|
802 // and fill them. A chunk is ready to be filled if it |
|
803 // empty of live objects. Such a chunk may have been initially |
|
804 // empty (only contained |
|
805 // dead objects) or may have had all its live objects copied out already. |
|
806 // A chunk that compacts into itself is also ready for filling. The |
|
807 // ready list is initially filled with empty chunks and chunks compacting |
|
808 // into themselves. There is always at least 1 chunk that can be put on |
|
809 // the ready list. The chunks are atomically added and removed from |
|
810 // the ready list. |
|
811 // |
719 class PSParallelCompact : AllStatic { |
812 class PSParallelCompact : AllStatic { |
720 public: |
813 public: |
721 // Convenient access to type names. |
814 // Convenient access to type names. |
722 typedef ParMarkBitMap::idx_t idx_t; |
815 typedef ParMarkBitMap::idx_t idx_t; |
723 typedef ParallelCompactData::ChunkData ChunkData; |
816 typedef ParallelCompactData::ChunkData ChunkData; |