< prev index next >

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

Print this page

 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);
126 }
127 
128 void G1FullGCCompactionPoint::add(HeapRegion* hr) {
129   _compaction_regions->append(hr);
130 }
131 
132 HeapRegion* G1FullGCCompactionPoint::remove_last() {
133   return _compaction_regions->pop();
134 }

 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() == object->klass()->prototype_header() || // 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(), object->klass()->prototype_header().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);
126 }
127 
128 void G1FullGCCompactionPoint::add(HeapRegion* hr) {
129   _compaction_regions->append(hr);
130 }
131 
132 HeapRegion* G1FullGCCompactionPoint::remove_last() {
133   return _compaction_regions->pop();
134 }
< prev index next >