15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/cms/cmsLockVerifier.hpp"
27 #include "gc/cms/compactibleFreeListSpace.hpp"
28 #include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
29 #include "gc/cms/concurrentMarkSweepThread.hpp"
30 #include "gc/shared/blockOffsetTable.inline.hpp"
31 #include "gc/shared/collectedHeap.inline.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/space.inline.hpp"
34 #include "gc/shared/spaceDecorator.hpp"
35 #include "logging/logStream.inline.hpp"
36 #include "memory/allocation.inline.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "memory/universe.inline.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "runtime/globals.hpp"
41 #include "runtime/handles.inline.hpp"
42 #include "runtime/init.hpp"
43 #include "runtime/java.hpp"
44 #include "runtime/orderAccess.inline.hpp"
45 #include "runtime/vmThread.hpp"
46 #include "utilities/copy.hpp"
47
48 /////////////////////////////////////////////////////////////////////////
49 //// CompactibleFreeListSpace
50 /////////////////////////////////////////////////////////////////////////
51
52 // highest ranked free list lock rank
53 int CompactibleFreeListSpace::_lockRank = Mutex::leaf + 3;
54
55 // Defaults are 0 so things will break badly if incorrectly initialized.
2179 res = _sp->adjustObjectSize(p->size());
2180 if (_sp->obj_is_alive(addr)) {
2181 was_live = true;
2182 p->verify();
2183 }
2184 } else {
2185 FreeChunk* fc = (FreeChunk*)addr;
2186 res = fc->size();
2187 if (FLSVerifyLists && !fc->cantCoalesce()) {
2188 guarantee(_sp->verify_chunk_in_free_list(fc),
2189 "Chunk should be on a free list");
2190 }
2191 }
2192 if (res == 0) {
2193 Log(gc, verify) log;
2194 log.error("Livelock: no rank reduction!");
2195 log.error(" Current: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
2196 " Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
2197 p2i(addr), res, was_obj ?"true":"false", was_live ?"true":"false",
2198 p2i(_last_addr), _last_size, _last_was_obj?"true":"false", _last_was_live?"true":"false");
2199 ResourceMark rm;
2200 _sp->print_on(log.error_stream());
2201 guarantee(false, "Verification failed.");
2202 }
2203 _last_addr = addr;
2204 _last_size = res;
2205 _last_was_obj = was_obj;
2206 _last_was_live = was_live;
2207 return res;
2208 }
2209 };
2210
2211 class VerifyAllOopsClosure: public OopClosure {
2212 private:
2213 const CMSCollector* _collector;
2214 const CompactibleFreeListSpace* _sp;
2215 const MemRegion _span;
2216 const bool _past_remark;
2217 const CMSBitMap* _bit_map;
2218
2219 protected:
2220 void do_oop(void* p, oop obj) {
2354 void CompactibleFreeListSpace::check_free_list_consistency() const {
2355 assert((TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >::min_size() <= IndexSetSize),
2356 "Some sizes can't be allocated without recourse to"
2357 " linear allocation buffers");
2358 assert((TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >::min_size()*HeapWordSize == sizeof(TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >)),
2359 "else MIN_TREE_CHUNK_SIZE is wrong");
2360 assert(IndexSetStart != 0, "IndexSetStart not initialized");
2361 assert(IndexSetStride != 0, "IndexSetStride not initialized");
2362 }
2363 #endif
2364
2365 void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
2366 assert_lock_strong(&_freelistLock);
2367 LogTarget(Debug, gc, freelist, census) log;
2368 if (!log.is_enabled()) {
2369 return;
2370 }
2371 AdaptiveFreeList<FreeChunk> total;
2372 log.print("end sweep# " SIZE_FORMAT, sweep_count);
2373 ResourceMark rm;
2374 outputStream* out = log.stream();
2375 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2376 size_t total_free = 0;
2377 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
2378 const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
2379 total_free += fl->count() * fl->size();
2380 if (i % (40*IndexSetStride) == 0) {
2381 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2382 }
2383 fl->print_on(out);
2384 total.set_bfr_surp( total.bfr_surp() + fl->bfr_surp() );
2385 total.set_surplus( total.surplus() + fl->surplus() );
2386 total.set_desired( total.desired() + fl->desired() );
2387 total.set_prev_sweep( total.prev_sweep() + fl->prev_sweep() );
2388 total.set_before_sweep(total.before_sweep() + fl->before_sweep());
2389 total.set_count( total.count() + fl->count() );
2390 total.set_coal_births( total.coal_births() + fl->coal_births() );
2391 total.set_coal_deaths( total.coal_deaths() + fl->coal_deaths() );
2392 total.set_split_births(total.split_births() + fl->split_births());
2393 total.set_split_deaths(total.split_deaths() + fl->split_deaths());
2394 }
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/cms/cmsLockVerifier.hpp"
27 #include "gc/cms/compactibleFreeListSpace.hpp"
28 #include "gc/cms/concurrentMarkSweepGeneration.inline.hpp"
29 #include "gc/cms/concurrentMarkSweepThread.hpp"
30 #include "gc/shared/blockOffsetTable.inline.hpp"
31 #include "gc/shared/collectedHeap.inline.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "gc/shared/space.inline.hpp"
34 #include "gc/shared/spaceDecorator.hpp"
35 #include "logging/log.hpp"
36 #include "logging/logStream.hpp"
37 #include "memory/allocation.inline.hpp"
38 #include "memory/resourceArea.hpp"
39 #include "memory/universe.inline.hpp"
40 #include "oops/oop.inline.hpp"
41 #include "runtime/globals.hpp"
42 #include "runtime/handles.inline.hpp"
43 #include "runtime/init.hpp"
44 #include "runtime/java.hpp"
45 #include "runtime/orderAccess.inline.hpp"
46 #include "runtime/vmThread.hpp"
47 #include "utilities/copy.hpp"
48
49 /////////////////////////////////////////////////////////////////////////
50 //// CompactibleFreeListSpace
51 /////////////////////////////////////////////////////////////////////////
52
53 // highest ranked free list lock rank
54 int CompactibleFreeListSpace::_lockRank = Mutex::leaf + 3;
55
56 // Defaults are 0 so things will break badly if incorrectly initialized.
2180 res = _sp->adjustObjectSize(p->size());
2181 if (_sp->obj_is_alive(addr)) {
2182 was_live = true;
2183 p->verify();
2184 }
2185 } else {
2186 FreeChunk* fc = (FreeChunk*)addr;
2187 res = fc->size();
2188 if (FLSVerifyLists && !fc->cantCoalesce()) {
2189 guarantee(_sp->verify_chunk_in_free_list(fc),
2190 "Chunk should be on a free list");
2191 }
2192 }
2193 if (res == 0) {
2194 Log(gc, verify) log;
2195 log.error("Livelock: no rank reduction!");
2196 log.error(" Current: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
2197 " Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
2198 p2i(addr), res, was_obj ?"true":"false", was_live ?"true":"false",
2199 p2i(_last_addr), _last_size, _last_was_obj?"true":"false", _last_was_live?"true":"false");
2200 LogStream ls(log.error());
2201 _sp->print_on(&ls);
2202 guarantee(false, "Verification failed.");
2203 }
2204 _last_addr = addr;
2205 _last_size = res;
2206 _last_was_obj = was_obj;
2207 _last_was_live = was_live;
2208 return res;
2209 }
2210 };
2211
2212 class VerifyAllOopsClosure: public OopClosure {
2213 private:
2214 const CMSCollector* _collector;
2215 const CompactibleFreeListSpace* _sp;
2216 const MemRegion _span;
2217 const bool _past_remark;
2218 const CMSBitMap* _bit_map;
2219
2220 protected:
2221 void do_oop(void* p, oop obj) {
2355 void CompactibleFreeListSpace::check_free_list_consistency() const {
2356 assert((TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >::min_size() <= IndexSetSize),
2357 "Some sizes can't be allocated without recourse to"
2358 " linear allocation buffers");
2359 assert((TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >::min_size()*HeapWordSize == sizeof(TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >)),
2360 "else MIN_TREE_CHUNK_SIZE is wrong");
2361 assert(IndexSetStart != 0, "IndexSetStart not initialized");
2362 assert(IndexSetStride != 0, "IndexSetStride not initialized");
2363 }
2364 #endif
2365
2366 void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
2367 assert_lock_strong(&_freelistLock);
2368 LogTarget(Debug, gc, freelist, census) log;
2369 if (!log.is_enabled()) {
2370 return;
2371 }
2372 AdaptiveFreeList<FreeChunk> total;
2373 log.print("end sweep# " SIZE_FORMAT, sweep_count);
2374 ResourceMark rm;
2375 LogStream ls(log);
2376 outputStream* out = &ls;
2377 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2378 size_t total_free = 0;
2379 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
2380 const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
2381 total_free += fl->count() * fl->size();
2382 if (i % (40*IndexSetStride) == 0) {
2383 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2384 }
2385 fl->print_on(out);
2386 total.set_bfr_surp( total.bfr_surp() + fl->bfr_surp() );
2387 total.set_surplus( total.surplus() + fl->surplus() );
2388 total.set_desired( total.desired() + fl->desired() );
2389 total.set_prev_sweep( total.prev_sweep() + fl->prev_sweep() );
2390 total.set_before_sweep(total.before_sweep() + fl->before_sweep());
2391 total.set_count( total.count() + fl->count() );
2392 total.set_coal_births( total.coal_births() + fl->coal_births() );
2393 total.set_coal_deaths( total.coal_deaths() + fl->coal_deaths() );
2394 total.set_split_births(total.split_births() + fl->split_births());
2395 total.set_split_deaths(total.split_deaths() + fl->split_deaths());
2396 }
|