@@ -116,51 +116,45 @@ class SplitInfo
116116 // Return true if this split info is valid (i.e., if a split has been
117117 // recorded). The very first region cannot have a partial object and thus is
118118 // never split, so 0 is the 'invalid' value.
119- bool is_valid () const { return _src_region_idx > 0 ; }
119+ bool is_valid () const { return _split_region_idx > 0 ; }
120120
121121 // Return true if this split holds data for the specified source region.
122- inline bool is_split (size_t source_region ) const ;
122+ inline bool is_split (size_t region_idx ) const ;
123123
124- // The index of the split region, the size of the partial object on that
125- // region and the destination of the partial object.
126- size_t partial_obj_size () const { return _partial_obj_size; }
127- HeapWord* destination () const { return _destination; }
124+ // Obj at the split point doesn't fit the previous space and will be relocated to the next space.
125+ HeapWord* split_point () const { return _split_point; }
128126
129- // The destination count of the partial object referenced by this split
130- // (either 1 or 2). This must be added to the destination count of the
131- // remainder of the source region.
132- unsigned int destination_count () const { return _destination_count; }
127+ // Number of live words before the split point on this region.
128+ size_t preceding_live_words () const { return _preceding_live_words; }
133129
134- // If a word within the partial object will be written to the first word of a
135- // destination region, this is the address of the destination region;
136- // otherwise this is null.
137- HeapWord* dest_region_addr () const { return _dest_region_addr; }
130+ // A split region has two "destinations", living in two spaces. This method
131+ // returns the first one -- destination for the first live word on
132+ // this split region.
133+ HeapWord* preceding_destination () const {
134+ assert (_preceding_destination != nullptr , " inv" );
135+ return _preceding_destination;
136+ }
138137
139- // If a word within the partial object will be written to the first word of a
140- // destination region, this is the address of that word within the partial
141- // object; otherwise this is null.
142- HeapWord* first_src_addr () const { return _first_src_addr; }
138+ // Number of regions the preceding live words are relocated into.
139+ uint preceding_destination_count () const { return _preceding_destination_count; }
143140
144- // Record the data necessary to split the region src_region_idx.
145- void record (size_t src_region_idx, size_t partial_obj_size,
146- HeapWord* destination);
141+ void record (size_t split_region_idx, HeapWord* split_point, size_t preceding_live_words);
147142
148143 void clear ();
149144
150145 DEBUG_ONLY (void verify_clear ();)
151146
152147private:
153- size_t _src_region_idx;
154- size_t _partial_obj_size;
155- HeapWord* _destination;
156- unsigned int _destination_count;
157- HeapWord* _dest_region_addr;
158- HeapWord* _first_src_addr;
148+ size_t _split_region_idx;
149+ HeapWord* _split_point;
150+ size_t _preceding_live_words;
151+ HeapWord* _preceding_destination;
152+ uint _preceding_destination_count;
159153};
160154
161155inline bool SplitInfo::is_split (size_t region_idx) const
162156{
163- return _src_region_idx == region_idx && is_valid ();
157+ return _split_region_idx == region_idx && is_valid ();
164158}
165159
166160class SpaceInfo
@@ -215,10 +209,18 @@ class ParallelCompactData
215209 class RegionData
216210 {
217211 public:
218- // Destination address of the region.
212+ // Destination for the first live word in this region.
213+ // Therefore, the new addr for every live obj on this region can be calculated as:
214+ //
215+ // new_addr := _destination + live_words_offset(old_addr);
216+ //
217+ // where, live_words_offset is the number of live words accumulated from
218+ // region-start to old_addr.
219219 HeapWord* destination () const { return _destination; }
220220
221- // The first region containing data destined for this region.
221+ // A destination region can have multiple source regions; only the first
222+ // one is recorded. Since all live objs are slided down, subsequent source
223+ // regions can be found via plain heap-region iteration.
222224 size_t source_region () const { return _source_region; }
223225
224226 // Reuse _source_region to store the corresponding shadow region index
@@ -313,9 +315,12 @@ class ParallelCompactData
313315 // Return to the normal path here
314316 inline void shadow_to_normal ();
315317
316-
317318 int shadow_state () { return _shadow_state; }
318319
320+ bool is_clear ();
321+
322+ void verify_clear () NOT_DEBUG_RETURN;
323+
319324 private:
320325 // The type used to represent object sizes within a region.
321326 typedef uint region_sz_t ;
@@ -873,7 +878,10 @@ class MoveAndUpdateClosure: public StackObj {
873878 size_t words_remaining () const { return _words_remaining; }
874879 bool is_full () const { return _words_remaining == 0 ; }
875880 HeapWord* source () const { return _source; }
876- void set_source (HeapWord* addr) { _source = addr; }
881+ void set_source (HeapWord* addr) {
882+ assert (addr != nullptr , " precondition" );
883+ _source = addr;
884+ }
877885
878886 // If the object will fit (size <= words_remaining()), copy it to the current
879887 // destination, update the interior oops and the start array.
@@ -902,9 +910,8 @@ inline size_t MoveAndUpdateClosure::calculate_words_remaining(size_t region) {
902910 HeapWord* dest_addr = PSParallelCompact::summary_data ().region_to_addr (region);
903911 PSParallelCompact::SpaceId dest_space_id = PSParallelCompact::space_id (dest_addr);
904912 HeapWord* new_top = PSParallelCompact::new_top (dest_space_id);
905- assert (dest_addr < new_top, " sanity" );
906-
907- return MIN2 (pointer_delta (new_top, dest_addr), ParallelCompactData::RegionSize);
913+ return MIN2 (pointer_delta (new_top, dest_addr),
914+ ParallelCompactData::RegionSize);
908915}
909916
910917inline
0 commit comments