src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page




1495                 (dirty_card_queue_set().completed_buffers_num() == 0)), "Should not be any");
1496 
1497       _young_list->reset_sampled_info();
1498       // At this point there should be no regions in the
1499       // entire heap tagged as young.
1500       assert(check_young_list_empty(true /* check_heap */),
1501              "young list should be empty at this point");
1502 
1503       // Update the number of full collections that have been completed.
1504       increment_old_marking_cycles_completed(false /* concurrent */);
1505 
1506       _hrs.verify_optional();
1507       verify_region_sets_optional();
1508 
1509       verify_after_gc();
1510 
1511       // Start a new incremental collection set for the next pause
1512       assert(g1_policy()->collection_set() == NULL, "must be");
1513       g1_policy()->start_incremental_cset_building();
1514 
1515       // Clear the _cset_fast_test bitmap in anticipation of adding
1516       // regions to the incremental collection set for the next
1517       // evacuation pause.
1518       clear_cset_fast_test();
1519 
1520       init_mutator_alloc_region();
1521 
1522       double end = os::elapsedTime();
1523       g1_policy()->record_full_collection_end();
1524 
1525       if (G1Log::fine()) {
1526         g1_policy()->print_heap_transition();
1527       }
1528 
1529       // We must call G1MonitoringSupport::update_sizes() in the same scoping level
1530       // as an active TraceMemoryManagerStats object (i.e. before the destructor for the
1531       // TraceMemoryManagerStats is called) so that the G1 memory pools are updated
1532       // before any GC notifications are raised.
1533       g1mm()->update_sizes();
1534 
1535       gc_epilogue(true);
1536     }
1537 


1917   _mark_in_progress(false),
1918   _cg1r(NULL), _summary_bytes_used(0),
1919   _g1mm(NULL),
1920   _refine_cte_cl(NULL),
1921   _full_collection(false),
1922   _free_list("Master Free List", new MasterFreeRegionListMtSafeChecker()),
1923   _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()),
1924   _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()),
1925   _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()),
1926   _free_regions_coming(false),
1927   _young_list(new YoungList(this)),
1928   _gc_time_stamp(0),
1929   _retained_old_gc_alloc_region(NULL),
1930   _survivor_plab_stats(YoungPLABSize, PLABWeight),
1931   _old_plab_stats(OldPLABSize, PLABWeight),
1932   _expand_heap_after_alloc_failure(true),
1933   _surviving_young_words(NULL),
1934   _old_marking_cycles_started(0),
1935   _old_marking_cycles_completed(0),
1936   _concurrent_cycle_started(false),
1937   _in_cset_fast_test(NULL),
1938   _in_cset_fast_test_base(NULL),
1939   _dirty_cards_region_list(NULL),
1940   _worker_cset_start_region(NULL),
1941   _worker_cset_start_region_time_stamp(NULL),
1942   _gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()),
1943   _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()),
1944   _gc_tracer_stw(new (ResourceObj::C_HEAP, mtGC) G1NewTracer()),
1945   _gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) G1OldTracer()) {
1946 
1947   _g1h = this;
1948   if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) {
1949     vm_exit_during_initialization("Failed necessary allocation.");
1950   }
1951 
1952   _humongous_object_threshold_in_words = HeapRegion::GrainWords / 2;
1953 
1954   int n_queues = MAX2((int)ParallelGCThreads, 1);
1955   _task_queues = new RefToScanQueueSet(n_queues);
1956 
1957   uint n_rem_sets = HeapRegionRemSet::num_par_rem_sets();
1958   assert(n_rem_sets > 0, "Invariant.");


2060   // Do later initialization work for concurrent refinement.
2061   _cg1r->init();
2062 
2063   // 6843694 - ensure that the maximum region index can fit
2064   // in the remembered set structures.
2065   const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
2066   guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
2067 
2068   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
2069   guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
2070   guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
2071             "too many cards per region");
2072 
2073   FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
2074 
2075   _bot_shared = new G1BlockOffsetSharedArray(_reserved,
2076                                              heap_word_size(init_byte_size));
2077 
2078   _g1h = this;
2079 
2080   _in_cset_fast_test_length = max_regions();
2081   _in_cset_fast_test_base =
2082                    NEW_C_HEAP_ARRAY(bool, (size_t) _in_cset_fast_test_length, mtGC);
2083 
2084   // We're biasing _in_cset_fast_test to avoid subtracting the
2085   // beginning of the heap every time we want to index; basically
2086   // it's the same with what we do with the card table.
2087   _in_cset_fast_test = _in_cset_fast_test_base -
2088                ((uintx) _g1_reserved.start() >> HeapRegion::LogOfHRGrainBytes);
2089 
2090   // Clear the _cset_fast_test bitmap in anticipation of adding
2091   // regions to the incremental collection set for the first
2092   // evacuation pause.
2093   clear_cset_fast_test();
2094 
2095   // Create the ConcurrentMark data structure and thread.
2096   // (Must do this late, so that "max_regions" is defined.)
2097   _cm = new ConcurrentMark(this, heap_rs);
2098   if (_cm == NULL || !_cm->completed_initialization()) {
2099     vm_shutdown_during_initialization("Could not create/initialize ConcurrentMark");
2100     return JNI_ENOMEM;
2101   }
2102   _cmThread = _cm->cmThread();
2103 
2104   // Initialize the from_card cache structure of HeapRegionRemSet.
2105   HeapRegionRemSet::init_heap(max_regions());
2106 
2107   // Now expand into the initial heap size.
2108   if (!expand(init_byte_size)) {
2109     vm_shutdown_during_initialization("Failed to allocate initial heap.");
2110     return JNI_ENOMEM;
2111   }
2112 
2113   // Perform any initialization actions delegated to the policy.


4108         evacuate_collection_set(evacuation_info);
4109 
4110         // We do this to mainly verify the per-thread SATB buffers
4111         // (which have been filtered by now) since we didn't verify
4112         // them earlier. No point in re-checking the stacks / enqueued
4113         // buffers given that the CSet has not changed since last time
4114         // we checked.
4115         _cm->verify_no_cset_oops(false /* verify_stacks */,
4116                                  false /* verify_enqueued_buffers */,
4117                                  true  /* verify_thread_buffers */,
4118                                  true  /* verify_fingers */);
4119 
4120         free_collection_set(g1_policy()->collection_set(), evacuation_info);
4121         g1_policy()->clear_collection_set();
4122 
4123         cleanup_surviving_young_words();
4124 
4125         // Start a new incremental collection set for the next pause.
4126         g1_policy()->start_incremental_cset_building();
4127 
4128         // Clear the _cset_fast_test bitmap in anticipation of adding
4129         // regions to the incremental collection set for the next
4130         // evacuation pause.
4131         clear_cset_fast_test();
4132 
4133         _young_list->reset_sampled_info();
4134 
4135         // Don't check the whole heap at this point as the
4136         // GC alloc regions from this pause have been tagged
4137         // as survivors and moved on to the survivor list.
4138         // Survivor regions will fail the !is_young() check.
4139         assert(check_young_list_empty(false /* check_heap */),
4140           "young list should be empty");
4141 
4142 #if YOUNG_LIST_VERBOSE
4143         gclog_or_tty->print_cr("Before recording survivors.\nYoung List:");
4144         _young_list->print();
4145 #endif // YOUNG_LIST_VERBOSE
4146 
4147         g1_policy()->record_survivor_regions(_young_list->survivor_length(),
4148                                              _young_list->first_survivor_region(),
4149                                              _young_list->last_survivor_region());
4150 




1495                 (dirty_card_queue_set().completed_buffers_num() == 0)), "Should not be any");
1496 
1497       _young_list->reset_sampled_info();
1498       // At this point there should be no regions in the
1499       // entire heap tagged as young.
1500       assert(check_young_list_empty(true /* check_heap */),
1501              "young list should be empty at this point");
1502 
1503       // Update the number of full collections that have been completed.
1504       increment_old_marking_cycles_completed(false /* concurrent */);
1505 
1506       _hrs.verify_optional();
1507       verify_region_sets_optional();
1508 
1509       verify_after_gc();
1510 
1511       // Start a new incremental collection set for the next pause
1512       assert(g1_policy()->collection_set() == NULL, "must be");
1513       g1_policy()->start_incremental_cset_building();
1514 



1515       clear_cset_fast_test();
1516 
1517       init_mutator_alloc_region();
1518 
1519       double end = os::elapsedTime();
1520       g1_policy()->record_full_collection_end();
1521 
1522       if (G1Log::fine()) {
1523         g1_policy()->print_heap_transition();
1524       }
1525 
1526       // We must call G1MonitoringSupport::update_sizes() in the same scoping level
1527       // as an active TraceMemoryManagerStats object (i.e. before the destructor for the
1528       // TraceMemoryManagerStats is called) so that the G1 memory pools are updated
1529       // before any GC notifications are raised.
1530       g1mm()->update_sizes();
1531 
1532       gc_epilogue(true);
1533     }
1534 


1914   _mark_in_progress(false),
1915   _cg1r(NULL), _summary_bytes_used(0),
1916   _g1mm(NULL),
1917   _refine_cte_cl(NULL),
1918   _full_collection(false),
1919   _free_list("Master Free List", new MasterFreeRegionListMtSafeChecker()),
1920   _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()),
1921   _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()),
1922   _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()),
1923   _free_regions_coming(false),
1924   _young_list(new YoungList(this)),
1925   _gc_time_stamp(0),
1926   _retained_old_gc_alloc_region(NULL),
1927   _survivor_plab_stats(YoungPLABSize, PLABWeight),
1928   _old_plab_stats(OldPLABSize, PLABWeight),
1929   _expand_heap_after_alloc_failure(true),
1930   _surviving_young_words(NULL),
1931   _old_marking_cycles_started(0),
1932   _old_marking_cycles_completed(0),
1933   _concurrent_cycle_started(false),
1934   _in_cset_fast_test(),

1935   _dirty_cards_region_list(NULL),
1936   _worker_cset_start_region(NULL),
1937   _worker_cset_start_region_time_stamp(NULL),
1938   _gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()),
1939   _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()),
1940   _gc_tracer_stw(new (ResourceObj::C_HEAP, mtGC) G1NewTracer()),
1941   _gc_tracer_cm(new (ResourceObj::C_HEAP, mtGC) G1OldTracer()) {
1942 
1943   _g1h = this;
1944   if (_process_strong_tasks == NULL || !_process_strong_tasks->valid()) {
1945     vm_exit_during_initialization("Failed necessary allocation.");
1946   }
1947 
1948   _humongous_object_threshold_in_words = HeapRegion::GrainWords / 2;
1949 
1950   int n_queues = MAX2((int)ParallelGCThreads, 1);
1951   _task_queues = new RefToScanQueueSet(n_queues);
1952 
1953   uint n_rem_sets = HeapRegionRemSet::num_par_rem_sets();
1954   assert(n_rem_sets > 0, "Invariant.");


2056   // Do later initialization work for concurrent refinement.
2057   _cg1r->init();
2058 
2059   // 6843694 - ensure that the maximum region index can fit
2060   // in the remembered set structures.
2061   const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
2062   guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
2063 
2064   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
2065   guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
2066   guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
2067             "too many cards per region");
2068 
2069   FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
2070 
2071   _bot_shared = new G1BlockOffsetSharedArray(_reserved,
2072                                              heap_word_size(init_byte_size));
2073 
2074   _g1h = this;
2075 
2076   _in_cset_fast_test.initialize(_g1_reserved.start(), _g1_reserved.end(), HeapRegion::GrainBytes);













2077 
2078   // Create the ConcurrentMark data structure and thread.
2079   // (Must do this late, so that "max_regions" is defined.)
2080   _cm = new ConcurrentMark(this, heap_rs);
2081   if (_cm == NULL || !_cm->completed_initialization()) {
2082     vm_shutdown_during_initialization("Could not create/initialize ConcurrentMark");
2083     return JNI_ENOMEM;
2084   }
2085   _cmThread = _cm->cmThread();
2086 
2087   // Initialize the from_card cache structure of HeapRegionRemSet.
2088   HeapRegionRemSet::init_heap(max_regions());
2089 
2090   // Now expand into the initial heap size.
2091   if (!expand(init_byte_size)) {
2092     vm_shutdown_during_initialization("Failed to allocate initial heap.");
2093     return JNI_ENOMEM;
2094   }
2095 
2096   // Perform any initialization actions delegated to the policy.


4091         evacuate_collection_set(evacuation_info);
4092 
4093         // We do this to mainly verify the per-thread SATB buffers
4094         // (which have been filtered by now) since we didn't verify
4095         // them earlier. No point in re-checking the stacks / enqueued
4096         // buffers given that the CSet has not changed since last time
4097         // we checked.
4098         _cm->verify_no_cset_oops(false /* verify_stacks */,
4099                                  false /* verify_enqueued_buffers */,
4100                                  true  /* verify_thread_buffers */,
4101                                  true  /* verify_fingers */);
4102 
4103         free_collection_set(g1_policy()->collection_set(), evacuation_info);
4104         g1_policy()->clear_collection_set();
4105 
4106         cleanup_surviving_young_words();
4107 
4108         // Start a new incremental collection set for the next pause.
4109         g1_policy()->start_incremental_cset_building();
4110 



4111         clear_cset_fast_test();
4112 
4113         _young_list->reset_sampled_info();
4114 
4115         // Don't check the whole heap at this point as the
4116         // GC alloc regions from this pause have been tagged
4117         // as survivors and moved on to the survivor list.
4118         // Survivor regions will fail the !is_young() check.
4119         assert(check_young_list_empty(false /* check_heap */),
4120           "young list should be empty");
4121 
4122 #if YOUNG_LIST_VERBOSE
4123         gclog_or_tty->print_cr("Before recording survivors.\nYoung List:");
4124         _young_list->print();
4125 #endif // YOUNG_LIST_VERBOSE
4126 
4127         g1_policy()->record_survivor_regions(_young_list->survivor_length(),
4128                                              _young_list->first_survivor_region(),
4129                                              _young_list->last_survivor_region());
4130