hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
changeset 3908 24b55ad4c228
parent 2885 7dd49b9daa4a
child 3912 3aaaaad1ccb0
equal deleted inserted replaced
3906:6767b0c66883 3908:24b55ad4c228
  2855   MarkRefsIntoClosure notOlder(_span, verification_mark_bm(), true /* nmethods */);
  2855   MarkRefsIntoClosure notOlder(_span, verification_mark_bm(), true /* nmethods */);
  2856   gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
  2856   gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
  2857 
  2857 
  2858   gch->gen_process_strong_roots(_cmsGen->level(),
  2858   gch->gen_process_strong_roots(_cmsGen->level(),
  2859                                 true,   // younger gens are roots
  2859                                 true,   // younger gens are roots
       
  2860                                 true,   // activate StrongRootsScope
  2860                                 true,   // collecting perm gen
  2861                                 true,   // collecting perm gen
  2861                                 SharedHeap::ScanningOption(roots_scanning_options()),
  2862                                 SharedHeap::ScanningOption(roots_scanning_options()),
  2862                                 NULL, &notOlder);
  2863                                 &notOlder,
       
  2864                                 true,   // walk code active on stacks
       
  2865                                 NULL);
  2863 
  2866 
  2864   // Now mark from the roots
  2867   // Now mark from the roots
  2865   assert(_revisitStack.isEmpty(), "Should be empty");
  2868   assert(_revisitStack.isEmpty(), "Should be empty");
  2866   MarkFromRootsClosure markFromRootsClosure(this, _span,
  2869   MarkFromRootsClosure markFromRootsClosure(this, _span,
  2867     verification_mark_bm(), verification_mark_stack(), &_revisitStack,
  2870     verification_mark_bm(), verification_mark_stack(), &_revisitStack,
  2903   MarkRefsIntoVerifyClosure notOlder(_span, verification_mark_bm(),
  2906   MarkRefsIntoVerifyClosure notOlder(_span, verification_mark_bm(),
  2904                                      markBitMap(), true /* nmethods */);
  2907                                      markBitMap(), true /* nmethods */);
  2905   gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
  2908   gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
  2906   gch->gen_process_strong_roots(_cmsGen->level(),
  2909   gch->gen_process_strong_roots(_cmsGen->level(),
  2907                                 true,   // younger gens are roots
  2910                                 true,   // younger gens are roots
       
  2911                                 true,   // activate StrongRootsScope
  2908                                 true,   // collecting perm gen
  2912                                 true,   // collecting perm gen
  2909                                 SharedHeap::ScanningOption(roots_scanning_options()),
  2913                                 SharedHeap::ScanningOption(roots_scanning_options()),
  2910                                 NULL, &notOlder);
  2914                                 &notOlder,
       
  2915                                 true,   // walk code active on stacks
       
  2916                                 NULL);
  2911 
  2917 
  2912   // Now mark from the roots
  2918   // Now mark from the roots
  2913   assert(_revisitStack.isEmpty(), "Should be empty");
  2919   assert(_revisitStack.isEmpty(), "Should be empty");
  2914   MarkFromRootsVerifyClosure markFromRootsClosure(this, _span,
  2920   MarkFromRootsVerifyClosure markFromRootsClosure(this, _span,
  2915     verification_mark_bm(), markBitMap(), verification_mark_stack());
  2921     verification_mark_bm(), markBitMap(), verification_mark_stack());
  3501   {
  3507   {
  3502     COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
  3508     COMPILER2_PRESENT(DerivedPointerTableDeactivate dpt_deact;)
  3503     gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
  3509     gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
  3504     gch->gen_process_strong_roots(_cmsGen->level(),
  3510     gch->gen_process_strong_roots(_cmsGen->level(),
  3505                                   true,   // younger gens are roots
  3511                                   true,   // younger gens are roots
       
  3512                                   true,   // activate StrongRootsScope
  3506                                   true,   // collecting perm gen
  3513                                   true,   // collecting perm gen
  3507                                   SharedHeap::ScanningOption(roots_scanning_options()),
  3514                                   SharedHeap::ScanningOption(roots_scanning_options()),
  3508                                   NULL, &notOlder);
  3515                                   &notOlder,
       
  3516                                   true,   // walk all of code cache if (so & SO_CodeCache)
       
  3517                                   NULL);
  3509   }
  3518   }
  3510 
  3519 
  3511   // Clear mod-union table; it will be dirtied in the prologue of
  3520   // Clear mod-union table; it will be dirtied in the prologue of
  3512   // CMS generation per each younger generation collection.
  3521   // CMS generation per each younger generation collection.
  3513 
  3522 
  5013   // ---------- remaining roots --------------
  5022   // ---------- remaining roots --------------
  5014   _timer.reset();
  5023   _timer.reset();
  5015   _timer.start();
  5024   _timer.start();
  5016   gch->gen_process_strong_roots(_collector->_cmsGen->level(),
  5025   gch->gen_process_strong_roots(_collector->_cmsGen->level(),
  5017                                 false,     // yg was scanned above
  5026                                 false,     // yg was scanned above
       
  5027                                 false,     // this is parallel code
  5018                                 true,      // collecting perm gen
  5028                                 true,      // collecting perm gen
  5019                                 SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
  5029                                 SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()),
  5020                                 NULL, &par_mrias_cl);
  5030                                 &par_mrias_cl,
       
  5031                                 true,   // walk all of code cache if (so & SO_CodeCache)
       
  5032                                 NULL);
       
  5033   assert(_collector->should_unload_classes()
       
  5034          || (_collector->CMSCollector::roots_scanning_options() & SharedHeap::SO_CodeCache),
       
  5035          "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
  5021   _timer.stop();
  5036   _timer.stop();
  5022   if (PrintCMSStatistics != 0) {
  5037   if (PrintCMSStatistics != 0) {
  5023     gclog_or_tty->print_cr(
  5038     gclog_or_tty->print_cr(
  5024       "Finished remaining root rescan work in %dth thread: %3.3f sec",
  5039       "Finished remaining root rescan work in %dth thread: %3.3f sec",
  5025       i, _timer.seconds());
  5040       i, _timer.seconds());
  5396     cms_space, perm_space,
  5411     cms_space, perm_space,
  5397     n_workers, workers, task_queues());
  5412     n_workers, workers, task_queues());
  5398 
  5413 
  5399   // Set up for parallel process_strong_roots work.
  5414   // Set up for parallel process_strong_roots work.
  5400   gch->set_par_threads(n_workers);
  5415   gch->set_par_threads(n_workers);
  5401   gch->change_strong_roots_parity();
       
  5402   // We won't be iterating over the cards in the card table updating
  5416   // We won't be iterating over the cards in the card table updating
  5403   // the younger_gen cards, so we shouldn't call the following else
  5417   // the younger_gen cards, so we shouldn't call the following else
  5404   // the verification code as well as subsequent younger_refs_iterate
  5418   // the verification code as well as subsequent younger_refs_iterate
  5405   // code would get confused. XXX
  5419   // code would get confused. XXX
  5406   // gch->rem_set()->prepare_for_younger_refs_iterate(true); // parallel
  5420   // gch->rem_set()->prepare_for_younger_refs_iterate(true); // parallel
  5427   // in the multi-threaded case, but we special-case n=1 here to get
  5441   // in the multi-threaded case, but we special-case n=1 here to get
  5428   // repeatable measurements of the 1-thread overhead of the parallel code.
  5442   // repeatable measurements of the 1-thread overhead of the parallel code.
  5429   if (n_workers > 1) {
  5443   if (n_workers > 1) {
  5430     // Make refs discovery MT-safe
  5444     // Make refs discovery MT-safe
  5431     ReferenceProcessorMTMutator mt(ref_processor(), true);
  5445     ReferenceProcessorMTMutator mt(ref_processor(), true);
       
  5446     GenCollectedHeap::StrongRootsScope srs(gch);
  5432     workers->run_task(&tsk);
  5447     workers->run_task(&tsk);
  5433   } else {
  5448   } else {
       
  5449     GenCollectedHeap::StrongRootsScope srs(gch);
  5434     tsk.work(0);
  5450     tsk.work(0);
  5435   }
  5451   }
  5436   gch->set_par_threads(0);  // 0 ==> non-parallel.
  5452   gch->set_par_threads(0);  // 0 ==> non-parallel.
  5437   // restore, single-threaded for now, any preserved marks
  5453   // restore, single-threaded for now, any preserved marks
  5438   // as a result of work_q overflow
  5454   // as a result of work_q overflow
  5512     TraceTime t("root rescan", PrintGCDetails, false, gclog_or_tty);
  5528     TraceTime t("root rescan", PrintGCDetails, false, gclog_or_tty);
  5513 
  5529 
  5514     verify_work_stacks_empty();
  5530     verify_work_stacks_empty();
  5515 
  5531 
  5516     gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
  5532     gch->rem_set()->prepare_for_younger_refs_iterate(false); // Not parallel.
       
  5533     GenCollectedHeap::StrongRootsScope srs(gch);
  5517     gch->gen_process_strong_roots(_cmsGen->level(),
  5534     gch->gen_process_strong_roots(_cmsGen->level(),
  5518                                   true,  // younger gens as roots
  5535                                   true,  // younger gens as roots
       
  5536                                   false, // use the local StrongRootsScope
  5519                                   true,  // collecting perm gen
  5537                                   true,  // collecting perm gen
  5520                                   SharedHeap::ScanningOption(roots_scanning_options()),
  5538                                   SharedHeap::ScanningOption(roots_scanning_options()),
  5521                                   NULL, &mrias_cl);
  5539                                   &mrias_cl,
       
  5540                                   true,   // walk code active on stacks
       
  5541                                   NULL);
       
  5542     assert(should_unload_classes()
       
  5543            || (roots_scanning_options() & SharedHeap::SO_CodeCache),
       
  5544            "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
  5522   }
  5545   }
  5523   verify_work_stacks_empty();
  5546   verify_work_stacks_empty();
  5524   // Restore evacuated mark words, if any, used for overflow list links
  5547   // Restore evacuated mark words, if any, used for overflow list links
  5525   if (!CMSOverflowEarlyRestoration) {
  5548   if (!CMSOverflowEarlyRestoration) {
  5526     restore_preserved_marks_if_any();
  5549     restore_preserved_marks_if_any();