< prev index next >

src/hotspot/share/gc/g1/g1FullGCCompactionPoint.cpp

Print this page

 78 GrowableArray<HeapRegion*>* G1FullGCCompactionPoint::regions() {
 79   return _compaction_regions;
 80 }
 81 
 82 bool G1FullGCCompactionPoint::object_will_fit(size_t size) {
 83   size_t space_left = pointer_delta(_current_region->end(), _compaction_top);
 84   return size <= space_left;
 85 }
 86 
 87 void G1FullGCCompactionPoint::switch_region() {
 88   // Save compaction top in the region.
 89   _current_region->set_compaction_top(_compaction_top);
 90   // Get the next region and re-initialize the values.
 91   _current_region = next_region();
 92   initialize_values(true);
 93 }
 94 
 95 void G1FullGCCompactionPoint::forward(oop object, size_t size) {
 96   assert(_current_region != NULL, "Must have been initialized");
 97 


 98   // Ensure the object fit in the current region.
 99   while (!object_will_fit(size)) {
100     switch_region();
101   }
102 
103   // Store a forwarding pointer if the object should be moved.
104   if (cast_from_oop<HeapWord*>(object) != _compaction_top) {
105     object->forward_to(cast_to_oop(_compaction_top));

106   } else {
107     if (object->forwardee() != NULL) {
108       // Object should not move but mark-word is used so it looks like the
109       // object is forwarded. Need to clear the mark and it's no problem
110       // since it will be restored by preserved marks.
111       object->init_mark();
112     } else {
113       // Make sure object has the correct mark-word set or that it will be
114       // fixed when restoring the preserved marks.
115       assert(object->mark() == markWord::prototype() || // Correct mark
116              object->mark_must_be_preserved(), // Will be restored by PreservedMarksSet
117              "should have correct prototype obj: " PTR_FORMAT " mark: " PTR_FORMAT " prototype: " PTR_FORMAT,
118              p2i(object), object->mark().value(), markWord::prototype().value());
119     }
120     assert(object->forwardee() == NULL, "should be forwarded to NULL");
121   }
122 
123   // Update compaction values.
124   _compaction_top += size;
125   _current_region->alloc_block_in_bot(_compaction_top - size, _compaction_top);

 78 GrowableArray<HeapRegion*>* G1FullGCCompactionPoint::regions() {
 79   return _compaction_regions;
 80 }
 81 
 82 bool G1FullGCCompactionPoint::object_will_fit(size_t size) {
 83   size_t space_left = pointer_delta(_current_region->end(), _compaction_top);
 84   return size <= space_left;
 85 }
 86 
 87 void G1FullGCCompactionPoint::switch_region() {
 88   // Save compaction top in the region.
 89   _current_region->set_compaction_top(_compaction_top);
 90   // Get the next region and re-initialize the values.
 91   _current_region = next_region();
 92   initialize_values(true);
 93 }
 94 
 95 void G1FullGCCompactionPoint::forward(oop object, size_t size) {
 96   assert(_current_region != NULL, "Must have been initialized");
 97 
 98   size_t csize = object->compact_size((int)size); // TODO LOOM TRICKY; CONSIDER
 99 
100   // Ensure the object fit in the current region.
101   while (!object_will_fit(csize)) {
102     switch_region();
103   }
104 
105   // Store a forwarding pointer if the object should be moved or compacted in place.
106   if (cast_from_oop<HeapWord*>(object) != _compaction_top || csize < size) {
107     object->forward_to(cast_to_oop(_compaction_top));
108     size = csize;
109   } else {
110     if (object->forwardee() != NULL) {
111       // Object should not move but mark-word is used so it looks like the
112       // object is forwarded. Need to clear the mark and it's no problem
113       // since it will be restored by preserved marks.
114       object->init_mark();
115     } else {
116       // Make sure object has the correct mark-word set or that it will be
117       // fixed when restoring the preserved marks.
118       assert(object->mark() == markWord::prototype() || // Correct mark
119              object->mark_must_be_preserved(), // Will be restored by PreservedMarksSet
120              "should have correct prototype obj: " PTR_FORMAT " mark: " PTR_FORMAT " prototype: " PTR_FORMAT,
121              p2i(object), object->mark().value(), markWord::prototype().value());
122     }
123     assert(object->forwardee() == NULL, "should be forwarded to NULL");
124   }
125 
126   // Update compaction values.
127   _compaction_top += size;
128   _current_region->alloc_block_in_bot(_compaction_top - size, _compaction_top);
< prev index next >