2128 // Verify that the SpoolBlocks look like free blocks of |
2127 // Verify that the SpoolBlocks look like free blocks of |
2129 // appropriate sizes... To be done ... |
2128 // appropriate sizes... To be done ... |
2130 } |
2129 } |
2131 |
2130 |
2132 class VerifyAllBlksClosure: public BlkClosure { |
2131 class VerifyAllBlksClosure: public BlkClosure { |
|
2132 private: |
2133 const CompactibleFreeListSpace* _sp; |
2133 const CompactibleFreeListSpace* _sp; |
2134 const MemRegion _span; |
2134 const MemRegion _span; |
2135 |
2135 |
2136 public: |
2136 public: |
2137 VerifyAllBlksClosure(const CompactibleFreeListSpace* sp, |
2137 VerifyAllBlksClosure(const CompactibleFreeListSpace* sp, |
2138 MemRegion span) : _sp(sp), _span(span) { } |
2138 MemRegion span) : _sp(sp), _span(span) { } |
2139 |
2139 |
2140 size_t do_blk(HeapWord* addr) { |
2140 virtual size_t do_blk(HeapWord* addr) { |
2141 size_t res; |
2141 size_t res; |
2142 if (_sp->block_is_obj(addr)) { |
2142 if (_sp->block_is_obj(addr)) { |
2143 oop p = oop(addr); |
2143 oop p = oop(addr); |
2144 guarantee(p->is_oop(), "Should be an oop"); |
2144 guarantee(p->is_oop(), "Should be an oop"); |
2145 res = _sp->adjustObjectSize(p->size()); |
2145 res = _sp->adjustObjectSize(p->size()); |
2158 return res; |
2158 return res; |
2159 } |
2159 } |
2160 }; |
2160 }; |
2161 |
2161 |
2162 class VerifyAllOopsClosure: public OopClosure { |
2162 class VerifyAllOopsClosure: public OopClosure { |
|
2163 private: |
2163 const CMSCollector* _collector; |
2164 const CMSCollector* _collector; |
2164 const CompactibleFreeListSpace* _sp; |
2165 const CompactibleFreeListSpace* _sp; |
2165 const MemRegion _span; |
2166 const MemRegion _span; |
2166 const bool _past_remark; |
2167 const bool _past_remark; |
2167 const CMSBitMap* _bit_map; |
2168 const CMSBitMap* _bit_map; |
|
2169 |
|
2170 protected: |
|
2171 void do_oop(void* p, oop obj) { |
|
2172 if (_span.contains(obj)) { // the interior oop points into CMS heap |
|
2173 if (!_span.contains(p)) { // reference from outside CMS heap |
|
2174 // Should be a valid object; the first disjunct below allows |
|
2175 // us to sidestep an assertion in block_is_obj() that insists |
|
2176 // that p be in _sp. Note that several generations (and spaces) |
|
2177 // are spanned by _span (CMS heap) above. |
|
2178 guarantee(!_sp->is_in_reserved(obj) || |
|
2179 _sp->block_is_obj((HeapWord*)obj), |
|
2180 "Should be an object"); |
|
2181 guarantee(obj->is_oop(), "Should be an oop"); |
|
2182 obj->verify(); |
|
2183 if (_past_remark) { |
|
2184 // Remark has been completed, the object should be marked |
|
2185 _bit_map->isMarked((HeapWord*)obj); |
|
2186 } |
|
2187 } else { // reference within CMS heap |
|
2188 if (_past_remark) { |
|
2189 // Remark has been completed -- so the referent should have |
|
2190 // been marked, if referring object is. |
|
2191 if (_bit_map->isMarked(_collector->block_start(p))) { |
|
2192 guarantee(_bit_map->isMarked((HeapWord*)obj), "Marking error?"); |
|
2193 } |
|
2194 } |
|
2195 } |
|
2196 } else if (_sp->is_in_reserved(p)) { |
|
2197 // the reference is from FLS, and points out of FLS |
|
2198 guarantee(obj->is_oop(), "Should be an oop"); |
|
2199 obj->verify(); |
|
2200 } |
|
2201 } |
|
2202 |
|
2203 template <class T> void do_oop_work(T* p) { |
|
2204 T heap_oop = oopDesc::load_heap_oop(p); |
|
2205 if (!oopDesc::is_null(heap_oop)) { |
|
2206 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); |
|
2207 do_oop(p, obj); |
|
2208 } |
|
2209 } |
2168 |
2210 |
2169 public: |
2211 public: |
2170 VerifyAllOopsClosure(const CMSCollector* collector, |
2212 VerifyAllOopsClosure(const CMSCollector* collector, |
2171 const CompactibleFreeListSpace* sp, MemRegion span, |
2213 const CompactibleFreeListSpace* sp, MemRegion span, |
2172 bool past_remark, CMSBitMap* bit_map) : |
2214 bool past_remark, CMSBitMap* bit_map) : |
2173 OopClosure(), _collector(collector), _sp(sp), _span(span), |
2215 OopClosure(), _collector(collector), _sp(sp), _span(span), |
2174 _past_remark(past_remark), _bit_map(bit_map) { } |
2216 _past_remark(past_remark), _bit_map(bit_map) { } |
2175 |
2217 |
2176 void do_oop(oop* ptr) { |
2218 virtual void do_oop(oop* p) { VerifyAllOopsClosure::do_oop_work(p); } |
2177 oop p = *ptr; |
2219 virtual void do_oop(narrowOop* p) { VerifyAllOopsClosure::do_oop_work(p); } |
2178 if (p != NULL) { |
|
2179 if (_span.contains(p)) { // the interior oop points into CMS heap |
|
2180 if (!_span.contains(ptr)) { // reference from outside CMS heap |
|
2181 // Should be a valid object; the first disjunct below allows |
|
2182 // us to sidestep an assertion in block_is_obj() that insists |
|
2183 // that p be in _sp. Note that several generations (and spaces) |
|
2184 // are spanned by _span (CMS heap) above. |
|
2185 guarantee(!_sp->is_in_reserved(p) || _sp->block_is_obj((HeapWord*)p), |
|
2186 "Should be an object"); |
|
2187 guarantee(p->is_oop(), "Should be an oop"); |
|
2188 p->verify(); |
|
2189 if (_past_remark) { |
|
2190 // Remark has been completed, the object should be marked |
|
2191 _bit_map->isMarked((HeapWord*)p); |
|
2192 } |
|
2193 } |
|
2194 else { // reference within CMS heap |
|
2195 if (_past_remark) { |
|
2196 // Remark has been completed -- so the referent should have |
|
2197 // been marked, if referring object is. |
|
2198 if (_bit_map->isMarked(_collector->block_start(ptr))) { |
|
2199 guarantee(_bit_map->isMarked((HeapWord*)p), "Marking error?"); |
|
2200 } |
|
2201 } |
|
2202 } |
|
2203 } else if (_sp->is_in_reserved(ptr)) { |
|
2204 // the reference is from FLS, and points out of FLS |
|
2205 guarantee(p->is_oop(), "Should be an oop"); |
|
2206 p->verify(); |
|
2207 } |
|
2208 } |
|
2209 } |
|
2210 }; |
2220 }; |
2211 |
2221 |
2212 void CompactibleFreeListSpace::verify(bool ignored) const { |
2222 void CompactibleFreeListSpace::verify(bool ignored) const { |
2213 assert_lock_strong(&_freelistLock); |
2223 assert_lock_strong(&_freelistLock); |
2214 verify_objects_initialized(); |
2224 verify_objects_initialized(); |