src/hotspot/share/gc/g1/g1CollectedHeap.cpp
changeset 47790 4925ee84b4ac
parent 47789 a77a7d3bc4f6
child 47799 1772ebf07d1f
equal deleted inserted replaced
47789:a77a7d3bc4f6 47790:4925ee84b4ac
    52 #include "gc/g1/g1RootClosures.hpp"
    52 #include "gc/g1/g1RootClosures.hpp"
    53 #include "gc/g1/g1RootProcessor.hpp"
    53 #include "gc/g1/g1RootProcessor.hpp"
    54 #include "gc/g1/g1SerialFullCollector.hpp"
    54 #include "gc/g1/g1SerialFullCollector.hpp"
    55 #include "gc/g1/g1StringDedup.hpp"
    55 #include "gc/g1/g1StringDedup.hpp"
    56 #include "gc/g1/g1YCTypes.hpp"
    56 #include "gc/g1/g1YCTypes.hpp"
       
    57 #include "gc/g1/g1YoungRemSetSamplingThread.hpp"
    57 #include "gc/g1/heapRegion.inline.hpp"
    58 #include "gc/g1/heapRegion.inline.hpp"
    58 #include "gc/g1/heapRegionRemSet.hpp"
    59 #include "gc/g1/heapRegionRemSet.hpp"
    59 #include "gc/g1/heapRegionSet.inline.hpp"
    60 #include "gc/g1/heapRegionSet.inline.hpp"
    60 #include "gc/g1/vm_operations_g1.hpp"
    61 #include "gc/g1/vm_operations_g1.hpp"
    61 #include "gc/shared/gcHeapSummary.hpp"
    62 #include "gc/shared/gcHeapSummary.hpp"
  1539 
  1540 
  1540 // Public methods.
  1541 // Public methods.
  1541 
  1542 
  1542 G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) :
  1543 G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) :
  1543   CollectedHeap(),
  1544   CollectedHeap(),
       
  1545   _young_gen_sampling_thread(NULL),
  1544   _collector_policy(collector_policy),
  1546   _collector_policy(collector_policy),
  1545   _gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()),
  1547   _gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()),
  1546   _gc_tracer_stw(new (ResourceObj::C_HEAP, mtGC) G1NewTracer()),
  1548   _gc_tracer_stw(new (ResourceObj::C_HEAP, mtGC) G1NewTracer()),
  1547   _g1_policy(create_g1_policy(_gc_timer_stw)),
  1549   _g1_policy(create_g1_policy(_gc_timer_stw)),
  1548   _collection_set(this, _g1_policy),
  1550   _collection_set(this, _g1_policy),
  1635   jint ecode = JNI_OK;
  1637   jint ecode = JNI_OK;
  1636   _cr = G1ConcurrentRefine::create(&ecode);
  1638   _cr = G1ConcurrentRefine::create(&ecode);
  1637   return ecode;
  1639   return ecode;
  1638 }
  1640 }
  1639 
  1641 
       
  1642 jint G1CollectedHeap::initialize_young_gen_sampling_thread() {
       
  1643   _young_gen_sampling_thread = new G1YoungRemSetSamplingThread();
       
  1644   if (_young_gen_sampling_thread->osthread() == NULL) {
       
  1645     vm_shutdown_during_initialization("Could not create G1YoungRemSetSamplingThread");
       
  1646     return JNI_ENOMEM;
       
  1647   }
       
  1648   return JNI_OK;
       
  1649 }
       
  1650 
  1640 jint G1CollectedHeap::initialize() {
  1651 jint G1CollectedHeap::initialize() {
  1641   CollectedHeap::pre_initialize();
  1652   CollectedHeap::pre_initialize();
  1642   os::enable_vtime();
  1653   os::enable_vtime();
  1643 
  1654 
  1644   // Necessary to satisfy locking discipline assertions.
  1655   // Necessary to satisfy locking discipline assertions.
  1787   jint ecode = initialize_concurrent_refinement();
  1798   jint ecode = initialize_concurrent_refinement();
  1788   if (ecode != JNI_OK) {
  1799   if (ecode != JNI_OK) {
  1789     return ecode;
  1800     return ecode;
  1790   }
  1801   }
  1791 
  1802 
       
  1803   ecode = initialize_young_gen_sampling_thread();
       
  1804   if (ecode != JNI_OK) {
       
  1805     return ecode;
       
  1806   }
       
  1807 
  1792   JavaThread::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
  1808   JavaThread::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
  1793                                                 DirtyCardQ_FL_lock,
  1809                                                 DirtyCardQ_FL_lock,
  1794                                                 (int)concurrent_refine()->yellow_zone(),
  1810                                                 (int)concurrent_refine()->yellow_zone(),
  1795                                                 (int)concurrent_refine()->red_zone(),
  1811                                                 (int)concurrent_refine()->red_zone(),
  1796                                                 Shared_DirtyCardQ_lock,
  1812                                                 Shared_DirtyCardQ_lock,
  1835 void G1CollectedHeap::stop() {
  1851 void G1CollectedHeap::stop() {
  1836   // Stop all concurrent threads. We do this to make sure these threads
  1852   // Stop all concurrent threads. We do this to make sure these threads
  1837   // do not continue to execute and access resources (e.g. logging)
  1853   // do not continue to execute and access resources (e.g. logging)
  1838   // that are destroyed during shutdown.
  1854   // that are destroyed during shutdown.
  1839   _cr->stop();
  1855   _cr->stop();
       
  1856   _young_gen_sampling_thread->stop();
  1840   _cmThread->stop();
  1857   _cmThread->stop();
  1841   if (G1StringDedup::is_enabled()) {
  1858   if (G1StringDedup::is_enabled()) {
  1842     G1StringDedup::stop();
  1859     G1StringDedup::stop();
  1843   }
  1860   }
  1844 }
  1861 }
  2434 void G1CollectedHeap::print_gc_threads_on(outputStream* st) const {
  2451 void G1CollectedHeap::print_gc_threads_on(outputStream* st) const {
  2435   workers()->print_worker_threads_on(st);
  2452   workers()->print_worker_threads_on(st);
  2436   _cmThread->print_on(st);
  2453   _cmThread->print_on(st);
  2437   st->cr();
  2454   st->cr();
  2438   _cm->print_worker_threads_on(st);
  2455   _cm->print_worker_threads_on(st);
  2439   _cr->print_worker_threads_on(st); // also prints the sample thread
  2456   _cr->print_threads_on(st);
       
  2457   _young_gen_sampling_thread->print_on(st);
  2440   if (G1StringDedup::is_enabled()) {
  2458   if (G1StringDedup::is_enabled()) {
  2441     G1StringDedup::print_worker_threads_on(st);
  2459     G1StringDedup::print_worker_threads_on(st);
  2442   }
  2460   }
  2443 }
  2461 }
  2444 
  2462 
  2445 void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const {
  2463 void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const {
  2446   workers()->threads_do(tc);
  2464   workers()->threads_do(tc);
  2447   tc->do_thread(_cmThread);
  2465   tc->do_thread(_cmThread);
  2448   _cm->threads_do(tc);
  2466   _cm->threads_do(tc);
  2449   _cr->threads_do(tc); // also iterates over the sample thread
  2467   _cr->threads_do(tc);
       
  2468   tc->do_thread(_young_gen_sampling_thread);
  2450   if (G1StringDedup::is_enabled()) {
  2469   if (G1StringDedup::is_enabled()) {
  2451     G1StringDedup::threads_do(tc);
  2470     G1StringDedup::threads_do(tc);
  2452   }
  2471   }
  2453 }
  2472 }
  2454 
  2473