25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "gc/cms/compactibleFreeListSpace.hpp" |
26 #include "gc/cms/compactibleFreeListSpace.hpp" |
27 #include "gc/cms/promotionInfo.hpp" |
27 #include "gc/cms/promotionInfo.hpp" |
28 #include "gc/shared/genOopClosures.hpp" |
28 #include "gc/shared/genOopClosures.hpp" |
29 #include "oops/compressedOops.inline.hpp" |
29 #include "oops/compressedOops.inline.hpp" |
30 #include "oops/markOop.inline.hpp" |
30 #include "oops/markWord.inline.hpp" |
31 #include "oops/oop.hpp" |
31 #include "oops/oop.inline.hpp" |
32 |
32 |
33 ///////////////////////////////////////////////////////////////////////// |
33 ///////////////////////////////////////////////////////////////////////// |
34 //// PromotionInfo |
34 //// PromotionInfo |
35 ///////////////////////////////////////////////////////////////////////// |
35 ///////////////////////////////////////////////////////////////////////// |
36 |
36 |
60 assert(!((FreeChunk*)this)->is_free(), "Error"); |
60 assert(!((FreeChunk*)this)->is_free(), "Error"); |
61 } |
61 } |
62 |
62 |
63 // Return the next displaced header, incrementing the pointer and |
63 // Return the next displaced header, incrementing the pointer and |
64 // recycling spool area as necessary. |
64 // recycling spool area as necessary. |
65 markOop PromotionInfo::nextDisplacedHeader() { |
65 markWord PromotionInfo::nextDisplacedHeader() { |
66 assert(_spoolHead != NULL, "promotionInfo inconsistency"); |
66 assert(_spoolHead != NULL, "promotionInfo inconsistency"); |
67 assert(_spoolHead != _spoolTail || _firstIndex < _nextIndex, |
67 assert(_spoolHead != _spoolTail || _firstIndex < _nextIndex, |
68 "Empty spool space: no displaced header can be fetched"); |
68 "Empty spool space: no displaced header can be fetched"); |
69 assert(_spoolHead->bufferSize > _firstIndex, "Off by one error at head?"); |
69 assert(_spoolHead->bufferSize > _firstIndex, "Off by one error at head?"); |
70 markOop hdr = _spoolHead->displacedHdr[_firstIndex]; |
70 markWord hdr = _spoolHead->displacedHdr[_firstIndex]; |
71 // Spool forward |
71 // Spool forward |
72 if (++_firstIndex == _spoolHead->bufferSize) { // last location in this block |
72 if (++_firstIndex == _spoolHead->bufferSize) { // last location in this block |
73 // forward to next block, recycling this block into spare spool buffer |
73 // forward to next block, recycling this block into spare spool buffer |
74 SpoolBlock* tmp = _spoolHead->nextSpoolBlock; |
74 SpoolBlock* tmp = _spoolHead->nextSpoolBlock; |
75 assert(_spoolHead != _spoolTail, "Spooling storage mix-up"); |
75 assert(_spoolHead != _spoolTail, "Spooling storage mix-up"); |
91 track(trackOop, oop(trackOop)->klass()); |
91 track(trackOop, oop(trackOop)->klass()); |
92 } |
92 } |
93 |
93 |
94 void PromotionInfo::track(PromotedObject* trackOop, Klass* klassOfOop) { |
94 void PromotionInfo::track(PromotedObject* trackOop, Klass* klassOfOop) { |
95 // make a copy of header as it may need to be spooled |
95 // make a copy of header as it may need to be spooled |
96 markOop mark = oop(trackOop)->mark_raw(); |
96 markWord mark = oop(trackOop)->mark_raw(); |
97 trackOop->clear_next(); |
97 trackOop->clear_next(); |
98 if (mark->must_be_preserved_for_cms_scavenge(klassOfOop)) { |
98 if (mark.must_be_preserved_for_cms_scavenge(klassOfOop)) { |
99 // save non-prototypical header, and mark oop |
99 // save non-prototypical header, and mark oop |
100 saveDisplacedHeader(mark); |
100 saveDisplacedHeader(mark); |
101 trackOop->setDisplacedMark(); |
101 trackOop->setDisplacedMark(); |
102 } else { |
102 } else { |
103 // we'd like to assert something like the following: |
103 // we'd like to assert something like the following: |
104 // assert(mark == markOopDesc::prototype(), "consistency check"); |
104 // assert(mark == markWord::prototype(), "consistency check"); |
105 // ... but the above won't work because the age bits have not (yet) been |
105 // ... but the above won't work because the age bits have not (yet) been |
106 // cleared. The remainder of the check would be identical to the |
106 // cleared. The remainder of the check would be identical to the |
107 // condition checked in must_be_preserved() above, so we don't really |
107 // condition checked in must_be_preserved() above, so we don't really |
108 // have anything useful to check here! |
108 // have anything useful to check here! |
109 } |
109 } |
121 trackOop->setPromotedMark(); |
121 trackOop->setPromotedMark(); |
122 } |
122 } |
123 |
123 |
124 // Save the given displaced header, incrementing the pointer and |
124 // Save the given displaced header, incrementing the pointer and |
125 // obtaining more spool area as necessary. |
125 // obtaining more spool area as necessary. |
126 void PromotionInfo::saveDisplacedHeader(markOop hdr) { |
126 void PromotionInfo::saveDisplacedHeader(markWord hdr) { |
127 assert(_spoolHead != NULL && _spoolTail != NULL, |
127 assert(_spoolHead != NULL && _spoolTail != NULL, |
128 "promotionInfo inconsistency"); |
128 "promotionInfo inconsistency"); |
129 assert(_spoolTail->bufferSize > _nextIndex, "Off by one error at tail?"); |
129 assert(_spoolTail->bufferSize > _nextIndex, "Off by one error at tail?"); |
130 _spoolTail->displacedHdr[_nextIndex] = hdr; |
130 _spoolTail->displacedHdr[_nextIndex] = hdr; |
131 // Spool forward |
131 // Spool forward |