< prev index next >

src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp

Print this page




2350 
2351 
2352   // Allocate marking bit map if not already allocated
2353   if (!init) { // first time
2354     if (!verification_mark_bm()->allocate(_span)) {
2355       return false;
2356     }
2357     init = true;
2358   }
2359 
2360   assert(verification_mark_stack()->isEmpty(), "Should be empty");
2361 
2362   // Turn off refs discovery -- so we will be tracing through refs.
2363   // This is as intended, because by this time
2364   // GC must already have cleared any refs that need to be cleared,
2365   // and traced those that need to be marked; moreover,
2366   // the marking done here is not going to interfere in any
2367   // way with the marking information used by GC.
2368   NoRefDiscovery no_discovery(ref_processor());
2369 
2370   COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)


2371 
2372   // Clear any marks from a previous round
2373   verification_mark_bm()->clear_all();
2374   assert(verification_mark_stack()->isEmpty(), "markStack should be empty");
2375   verify_work_stacks_empty();
2376 
2377   GenCollectedHeap* gch = GenCollectedHeap::heap();
2378   gch->ensure_parsability(false);  // fill TLABs, but no need to retire them
2379   // Update the saved marks which may affect the root scans.
2380   gch->save_marks();
2381 
2382   if (CMSRemarkVerifyVariant == 1) {
2383     // In this first variant of verification, we complete
2384     // all marking, then check if the new marks-vector is
2385     // a subset of the CMS marks-vector.
2386     verify_after_remark_work_1();
2387   } else if (CMSRemarkVerifyVariant == 2) {
2388     // In this second variant of verification, we flag an error
2389     // (i.e. an object reachable in the new marks-vector not reachable
2390     // in the CMS marks-vector) immediately, also indicating the


2970   gch->ensure_parsability(false);  // fill TLABs, but no need to retire them
2971   // Update the saved marks which may affect the root scans.
2972   gch->save_marks();
2973 
2974   // weak reference processing has not started yet.
2975   ref_processor()->set_enqueuing_is_done(false);
2976 
2977   // Need to remember all newly created CLDs,
2978   // so that we can guarantee that the remark finds them.
2979   ClassLoaderDataGraph::remember_new_clds(true);
2980 
2981   // Whenever a CLD is found, it will be claimed before proceeding to mark
2982   // the klasses. The claimed marks need to be cleared before marking starts.
2983   ClassLoaderDataGraph::clear_claimed_marks();
2984 
2985   if (CMSPrintEdenSurvivorChunks) {
2986     print_eden_and_survivor_chunk_arrays();
2987   }
2988 
2989   {
2990     COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)


2991     if (CMSParallelInitialMarkEnabled) {
2992       // The parallel version.
2993       WorkGang* workers = gch->workers();
2994       assert(workers != NULL, "Need parallel worker threads.");
2995       uint n_workers = workers->active_workers();
2996 
2997       StrongRootsScope srs(n_workers);
2998 
2999       CMSParInitialMarkTask tsk(this, &srs, n_workers);
3000       initialize_sequential_subtasks_for_young_gen_rescan(n_workers);
3001       if (n_workers > 1) {
3002         workers->run_task(&tsk);
3003       } else {
3004         tsk.work(0);
3005       }
3006     } else {
3007       // The serial version.
3008       CLDToOopClosure cld_closure(&notOlder, true);
3009       gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
3010 


4299   // CMSScavengeBeforeRemark is set, because we may have just done
4300   // a scavenge which would have filled all TLAB's -- and besides
4301   // Eden would be empty. This however may not always be the case --
4302   // for instance although we asked for a scavenge, it may not have
4303   // happened because of a JNI critical section. We probably need
4304   // a policy for deciding whether we can in that case wait until
4305   // the critical section releases and then do the remark following
4306   // the scavenge, and skip it here. In the absence of that policy,
4307   // or of an indication of whether the scavenge did indeed occur,
4308   // we cannot rely on TLAB's having been filled and must do
4309   // so here just in case a scavenge did not happen.
4310   gch->ensure_parsability(false);  // fill TLAB's, but no need to retire them
4311   // Update the saved marks which may affect the root scans.
4312   gch->save_marks();
4313 
4314   if (CMSPrintEdenSurvivorChunks) {
4315     print_eden_and_survivor_chunk_arrays();
4316   }
4317 
4318   {
4319     COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)


4320 
4321     // Note on the role of the mod union table:
4322     // Since the marker in "markFromRoots" marks concurrently with
4323     // mutators, it is possible for some reachable objects not to have been
4324     // scanned. For instance, an only reference to an object A was
4325     // placed in object B after the marker scanned B. Unless B is rescanned,
4326     // A would be collected. Such updates to references in marked objects
4327     // are detected via the mod union table which is the set of all cards
4328     // dirtied since the first checkpoint in this GC cycle and prior to
4329     // the most recent young generation GC, minus those cleaned up by the
4330     // concurrent precleaning.
4331     if (CMSParallelRemarkEnabled) {
4332       GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());
4333       do_remark_parallel();
4334     } else {
4335       GCTraceTime t("Rescan (non-parallel) ", PrintGCDetails, false,
4336                   _gc_timer_cm, _gc_tracer_cm->gc_id());
4337       do_remark_non_parallel();
4338     }
4339   }




2350 
2351 
2352   // Allocate marking bit map if not already allocated
2353   if (!init) { // first time
2354     if (!verification_mark_bm()->allocate(_span)) {
2355       return false;
2356     }
2357     init = true;
2358   }
2359 
2360   assert(verification_mark_stack()->isEmpty(), "Should be empty");
2361 
2362   // Turn off refs discovery -- so we will be tracing through refs.
2363   // This is as intended, because by this time
2364   // GC must already have cleared any refs that need to be cleared,
2365   // and traced those that need to be marked; moreover,
2366   // the marking done here is not going to interfere in any
2367   // way with the marking information used by GC.
2368   NoRefDiscovery no_discovery(ref_processor());
2369 
2370 #if defined(COMPILER2) || INCLUDE_JVMCI
2371   DerivedPointerTableDeactivate dpt_deact;
2372 #endif
2373 
2374   // Clear any marks from a previous round
2375   verification_mark_bm()->clear_all();
2376   assert(verification_mark_stack()->isEmpty(), "markStack should be empty");
2377   verify_work_stacks_empty();
2378 
2379   GenCollectedHeap* gch = GenCollectedHeap::heap();
2380   gch->ensure_parsability(false);  // fill TLABs, but no need to retire them
2381   // Update the saved marks which may affect the root scans.
2382   gch->save_marks();
2383 
2384   if (CMSRemarkVerifyVariant == 1) {
2385     // In this first variant of verification, we complete
2386     // all marking, then check if the new marks-vector is
2387     // a subset of the CMS marks-vector.
2388     verify_after_remark_work_1();
2389   } else if (CMSRemarkVerifyVariant == 2) {
2390     // In this second variant of verification, we flag an error
2391     // (i.e. an object reachable in the new marks-vector not reachable
2392     // in the CMS marks-vector) immediately, also indicating the


2972   gch->ensure_parsability(false);  // fill TLABs, but no need to retire them
2973   // Update the saved marks which may affect the root scans.
2974   gch->save_marks();
2975 
2976   // weak reference processing has not started yet.
2977   ref_processor()->set_enqueuing_is_done(false);
2978 
2979   // Need to remember all newly created CLDs,
2980   // so that we can guarantee that the remark finds them.
2981   ClassLoaderDataGraph::remember_new_clds(true);
2982 
2983   // Whenever a CLD is found, it will be claimed before proceeding to mark
2984   // the klasses. The claimed marks need to be cleared before marking starts.
2985   ClassLoaderDataGraph::clear_claimed_marks();
2986 
2987   if (CMSPrintEdenSurvivorChunks) {
2988     print_eden_and_survivor_chunk_arrays();
2989   }
2990 
2991   {
2992 #if defined(COMPILER2) || INCLUDE_JVMCI
2993     DerivedPointerTableDeactivate dpt_deact;
2994 #endif
2995     if (CMSParallelInitialMarkEnabled) {
2996       // The parallel version.
2997       WorkGang* workers = gch->workers();
2998       assert(workers != NULL, "Need parallel worker threads.");
2999       uint n_workers = workers->active_workers();
3000 
3001       StrongRootsScope srs(n_workers);
3002 
3003       CMSParInitialMarkTask tsk(this, &srs, n_workers);
3004       initialize_sequential_subtasks_for_young_gen_rescan(n_workers);
3005       if (n_workers > 1) {
3006         workers->run_task(&tsk);
3007       } else {
3008         tsk.work(0);
3009       }
3010     } else {
3011       // The serial version.
3012       CLDToOopClosure cld_closure(&notOlder, true);
3013       gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
3014 


4303   // CMSScavengeBeforeRemark is set, because we may have just done
4304   // a scavenge which would have filled all TLAB's -- and besides
4305   // Eden would be empty. This however may not always be the case --
4306   // for instance although we asked for a scavenge, it may not have
4307   // happened because of a JNI critical section. We probably need
4308   // a policy for deciding whether we can in that case wait until
4309   // the critical section releases and then do the remark following
4310   // the scavenge, and skip it here. In the absence of that policy,
4311   // or of an indication of whether the scavenge did indeed occur,
4312   // we cannot rely on TLAB's having been filled and must do
4313   // so here just in case a scavenge did not happen.
4314   gch->ensure_parsability(false);  // fill TLAB's, but no need to retire them
4315   // Update the saved marks which may affect the root scans.
4316   gch->save_marks();
4317 
4318   if (CMSPrintEdenSurvivorChunks) {
4319     print_eden_and_survivor_chunk_arrays();
4320   }
4321 
4322   {
4323 #if defined(COMPILER2) || INCLUDE_JVMCI
4324     DerivedPointerTableDeactivate dpt_deact;
4325 #endif
4326 
4327     // Note on the role of the mod union table:
4328     // Since the marker in "markFromRoots" marks concurrently with
4329     // mutators, it is possible for some reachable objects not to have been
4330     // scanned. For instance, an only reference to an object A was
4331     // placed in object B after the marker scanned B. Unless B is rescanned,
4332     // A would be collected. Such updates to references in marked objects
4333     // are detected via the mod union table which is the set of all cards
4334     // dirtied since the first checkpoint in this GC cycle and prior to
4335     // the most recent young generation GC, minus those cleaned up by the
4336     // concurrent precleaning.
4337     if (CMSParallelRemarkEnabled) {
4338       GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());
4339       do_remark_parallel();
4340     } else {
4341       GCTraceTime t("Rescan (non-parallel) ", PrintGCDetails, false,
4342                   _gc_timer_cm, _gc_tracer_cm->gc_id());
4343       do_remark_non_parallel();
4344     }
4345   }


< prev index next >