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/align.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
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 ResourceMark rm;
2201 _sp->print_on(log.error_stream());
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 outputStream* out = log.stream();
2376 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2377 size_t total_free = 0;
2378 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
2379 const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
2380 total_free += fl->count() * fl->size();
2381 if (i % (40*IndexSetStride) == 0) {
2382 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2383 }
2384 fl->print_on(out);
2385 total.set_bfr_surp( total.bfr_surp() + fl->bfr_surp() );
2386 total.set_surplus( total.surplus() + fl->surplus() );
2387 total.set_desired( total.desired() + fl->desired() );
2388 total.set_prev_sweep( total.prev_sweep() + fl->prev_sweep() );
2389 total.set_before_sweep(total.before_sweep() + fl->before_sweep());
2390 total.set_count( total.count() + fl->count() );
2391 total.set_coal_births( total.coal_births() + fl->coal_births() );
2392 total.set_coal_deaths( total.coal_deaths() + fl->coal_deaths() );
2393 total.set_split_births(total.split_births() + fl->split_births());
2394 total.set_split_deaths(total.split_deaths() + fl->split_deaths());
2395 }
|
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/align.hpp"
48 #include "utilities/copy.hpp"
49
50 /////////////////////////////////////////////////////////////////////////
51 //// CompactibleFreeListSpace
52 /////////////////////////////////////////////////////////////////////////
53
54 // highest ranked free list lock rank
55 int CompactibleFreeListSpace::_lockRank = Mutex::leaf + 3;
56
2181 res = _sp->adjustObjectSize(p->size());
2182 if (_sp->obj_is_alive(addr)) {
2183 was_live = true;
2184 p->verify();
2185 }
2186 } else {
2187 FreeChunk* fc = (FreeChunk*)addr;
2188 res = fc->size();
2189 if (FLSVerifyLists && !fc->cantCoalesce()) {
2190 guarantee(_sp->verify_chunk_in_free_list(fc),
2191 "Chunk should be on a free list");
2192 }
2193 }
2194 if (res == 0) {
2195 Log(gc, verify) log;
2196 log.error("Livelock: no rank reduction!");
2197 log.error(" Current: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
2198 " Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
2199 p2i(addr), res, was_obj ?"true":"false", was_live ?"true":"false",
2200 p2i(_last_addr), _last_size, _last_was_obj?"true":"false", _last_was_live?"true":"false");
2201 LogStream ls(log.error());
2202 _sp->print_on(&ls);
2203 guarantee(false, "Verification failed.");
2204 }
2205 _last_addr = addr;
2206 _last_size = res;
2207 _last_was_obj = was_obj;
2208 _last_was_live = was_live;
2209 return res;
2210 }
2211 };
2212
2213 class VerifyAllOopsClosure: public OopClosure {
2214 private:
2215 const CMSCollector* _collector;
2216 const CompactibleFreeListSpace* _sp;
2217 const MemRegion _span;
2218 const bool _past_remark;
2219 const CMSBitMap* _bit_map;
2220
2221 protected:
2222 void do_oop(void* p, oop obj) {
2356 void CompactibleFreeListSpace::check_free_list_consistency() const {
2357 assert((TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >::min_size() <= IndexSetSize),
2358 "Some sizes can't be allocated without recourse to"
2359 " linear allocation buffers");
2360 assert((TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >::min_size()*HeapWordSize == sizeof(TreeChunk<FreeChunk, AdaptiveFreeList<FreeChunk> >)),
2361 "else MIN_TREE_CHUNK_SIZE is wrong");
2362 assert(IndexSetStart != 0, "IndexSetStart not initialized");
2363 assert(IndexSetStride != 0, "IndexSetStride not initialized");
2364 }
2365 #endif
2366
2367 void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
2368 assert_lock_strong(&_freelistLock);
2369 LogTarget(Debug, gc, freelist, census) log;
2370 if (!log.is_enabled()) {
2371 return;
2372 }
2373 AdaptiveFreeList<FreeChunk> total;
2374 log.print("end sweep# " SIZE_FORMAT, sweep_count);
2375 ResourceMark rm;
2376 LogStream ls(log);
2377 outputStream* out = &ls;
2378 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2379 size_t total_free = 0;
2380 for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
2381 const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
2382 total_free += fl->count() * fl->size();
2383 if (i % (40*IndexSetStride) == 0) {
2384 AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
2385 }
2386 fl->print_on(out);
2387 total.set_bfr_surp( total.bfr_surp() + fl->bfr_surp() );
2388 total.set_surplus( total.surplus() + fl->surplus() );
2389 total.set_desired( total.desired() + fl->desired() );
2390 total.set_prev_sweep( total.prev_sweep() + fl->prev_sweep() );
2391 total.set_before_sweep(total.before_sweep() + fl->before_sweep());
2392 total.set_count( total.count() + fl->count() );
2393 total.set_coal_births( total.coal_births() + fl->coal_births() );
2394 total.set_coal_deaths( total.coal_deaths() + fl->coal_deaths() );
2395 total.set_split_births(total.split_births() + fl->split_births());
2396 total.set_split_deaths(total.split_deaths() + fl->split_deaths());
2397 }
|