< prev index next >

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Print this page




  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 "classfile/metadataOnStackMark.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "gc/g1/g1BarrierSet.hpp"
  30 #include "gc/g1/g1CollectedHeap.inline.hpp"
  31 #include "gc/g1/g1CollectorState.hpp"
  32 #include "gc/g1/g1ConcurrentMark.inline.hpp"
  33 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
  34 #include "gc/g1/g1HeapVerifier.hpp"
  35 #include "gc/g1/g1OopClosures.inline.hpp"
  36 #include "gc/g1/g1Policy.hpp"
  37 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
  38 #include "gc/g1/g1StringDedup.hpp"

  39 #include "gc/g1/heapRegion.inline.hpp"
  40 #include "gc/g1/heapRegionRemSet.hpp"
  41 #include "gc/g1/heapRegionSet.inline.hpp"
  42 #include "gc/shared/adaptiveSizePolicy.hpp"
  43 #include "gc/shared/gcId.hpp"
  44 #include "gc/shared/gcTimer.hpp"
  45 #include "gc/shared/gcTrace.hpp"
  46 #include "gc/shared/gcTraceTime.inline.hpp"
  47 #include "gc/shared/genOopClosures.inline.hpp"
  48 #include "gc/shared/referencePolicy.hpp"
  49 #include "gc/shared/strongRootsScope.hpp"
  50 #include "gc/shared/suspendibleThreadSet.hpp"
  51 #include "gc/shared/taskqueue.inline.hpp"
  52 #include "gc/shared/vmGCOperations.hpp"
  53 #include "gc/shared/weakProcessor.hpp"
  54 #include "include/jvm.h"
  55 #include "logging/log.hpp"
  56 #include "memory/allocation.hpp"
  57 #include "memory/resourceArea.hpp"
  58 #include "oops/access.inline.hpp"


1675  public:
1676   G1RemarkThreadsClosure(G1CollectedHeap* g1h, G1CMTask* task) :
1677     _cm_satb_cl(task, g1h),
1678     _cm_cl(g1h, task),
1679     _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations),
1680     _thread_parity(Threads::thread_claim_parity()) {}
1681 
1682   void do_thread(Thread* thread) {
1683     if (thread->is_Java_thread()) {
1684       if (thread->claim_oops_do(true, _thread_parity)) {
1685         JavaThread* jt = (JavaThread*)thread;
1686 
1687         // In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking
1688         // however the liveness of oops reachable from nmethods have very complex lifecycles:
1689         // * Alive if on the stack of an executing method
1690         // * Weakly reachable otherwise
1691         // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
1692         // live by the SATB invariant but other oops recorded in nmethods may behave differently.
1693         jt->nmethods_do(&_code_cl);
1694 
1695         jt->satb_mark_queue().apply_closure_and_empty(&_cm_satb_cl);
1696       }
1697     } else if (thread->is_VM_thread()) {
1698       if (thread->claim_oops_do(true, _thread_parity)) {
1699         G1BarrierSet::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(&_cm_satb_cl);
1700       }
1701     }
1702   }
1703 };
1704 
1705 class G1CMRemarkTask : public AbstractGangTask {
1706   G1ConcurrentMark* _cm;
1707 public:
1708   void work(uint worker_id) {
1709     G1CMTask* task = _cm->task(worker_id);
1710     task->record_start_time();
1711     {
1712       ResourceMark rm;
1713       HandleMark hm;
1714 
1715       G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task);




  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 "classfile/metadataOnStackMark.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "code/codeCache.hpp"
  29 #include "gc/g1/g1BarrierSet.hpp"
  30 #include "gc/g1/g1CollectedHeap.inline.hpp"
  31 #include "gc/g1/g1CollectorState.hpp"
  32 #include "gc/g1/g1ConcurrentMark.inline.hpp"
  33 #include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
  34 #include "gc/g1/g1HeapVerifier.hpp"
  35 #include "gc/g1/g1OopClosures.inline.hpp"
  36 #include "gc/g1/g1Policy.hpp"
  37 #include "gc/g1/g1RegionMarkStatsCache.inline.hpp"
  38 #include "gc/g1/g1StringDedup.hpp"
  39 #include "gc/g1/g1ThreadLocalData.hpp"
  40 #include "gc/g1/heapRegion.inline.hpp"
  41 #include "gc/g1/heapRegionRemSet.hpp"
  42 #include "gc/g1/heapRegionSet.inline.hpp"
  43 #include "gc/shared/adaptiveSizePolicy.hpp"
  44 #include "gc/shared/gcId.hpp"
  45 #include "gc/shared/gcTimer.hpp"
  46 #include "gc/shared/gcTrace.hpp"
  47 #include "gc/shared/gcTraceTime.inline.hpp"
  48 #include "gc/shared/genOopClosures.inline.hpp"
  49 #include "gc/shared/referencePolicy.hpp"
  50 #include "gc/shared/strongRootsScope.hpp"
  51 #include "gc/shared/suspendibleThreadSet.hpp"
  52 #include "gc/shared/taskqueue.inline.hpp"
  53 #include "gc/shared/vmGCOperations.hpp"
  54 #include "gc/shared/weakProcessor.hpp"
  55 #include "include/jvm.h"
  56 #include "logging/log.hpp"
  57 #include "memory/allocation.hpp"
  58 #include "memory/resourceArea.hpp"
  59 #include "oops/access.inline.hpp"


1676  public:
1677   G1RemarkThreadsClosure(G1CollectedHeap* g1h, G1CMTask* task) :
1678     _cm_satb_cl(task, g1h),
1679     _cm_cl(g1h, task),
1680     _code_cl(&_cm_cl, !CodeBlobToOopClosure::FixRelocations),
1681     _thread_parity(Threads::thread_claim_parity()) {}
1682 
1683   void do_thread(Thread* thread) {
1684     if (thread->is_Java_thread()) {
1685       if (thread->claim_oops_do(true, _thread_parity)) {
1686         JavaThread* jt = (JavaThread*)thread;
1687 
1688         // In theory it should not be neccessary to explicitly walk the nmethods to find roots for concurrent marking
1689         // however the liveness of oops reachable from nmethods have very complex lifecycles:
1690         // * Alive if on the stack of an executing method
1691         // * Weakly reachable otherwise
1692         // Some objects reachable from nmethods, such as the class loader (or klass_holder) of the receiver should be
1693         // live by the SATB invariant but other oops recorded in nmethods may behave differently.
1694         jt->nmethods_do(&_code_cl);
1695 
1696         G1ThreadLocalData::satb_mark_queue(jt).apply_closure_and_empty(&_cm_satb_cl);
1697       }
1698     } else if (thread->is_VM_thread()) {
1699       if (thread->claim_oops_do(true, _thread_parity)) {
1700         G1BarrierSet::satb_mark_queue_set().shared_satb_queue()->apply_closure_and_empty(&_cm_satb_cl);
1701       }
1702     }
1703   }
1704 };
1705 
1706 class G1CMRemarkTask : public AbstractGangTask {
1707   G1ConcurrentMark* _cm;
1708 public:
1709   void work(uint worker_id) {
1710     G1CMTask* task = _cm->task(worker_id);
1711     task->record_start_time();
1712     {
1713       ResourceMark rm;
1714       HandleMark hm;
1715 
1716       G1RemarkThreadsClosure threads_f(G1CollectedHeap::heap(), task);


< prev index next >