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

Print this page
rev 3708 : 8000244: G1: Ergonomically set MarkStackSize and use virtual space for global marking stack
Summary: Set the value of MarkStackSize to a value based on the number of parallel marking threads with a reasonable minimum. Expand the marking stack if we have to restart marking due to an overflow up to a reasonable maximum. Allocate the underlying space for the marking stack from virtual memory.
Reviewed-by: jmasa


2062 
2063   _g1h = this;
2064 
2065    _in_cset_fast_test_length = max_regions();
2066    _in_cset_fast_test_base =
2067                    NEW_C_HEAP_ARRAY(bool, (size_t) _in_cset_fast_test_length, mtGC);
2068 
2069    // We're biasing _in_cset_fast_test to avoid subtracting the
2070    // beginning of the heap every time we want to index; basically
2071    // it's the same with what we do with the card table.
2072    _in_cset_fast_test = _in_cset_fast_test_base -
2073                ((uintx) _g1_reserved.start() >> HeapRegion::LogOfHRGrainBytes);
2074 
2075    // Clear the _cset_fast_test bitmap in anticipation of adding
2076    // regions to the incremental collection set for the first
2077    // evacuation pause.
2078    clear_cset_fast_test();
2079 
2080   // Create the ConcurrentMark data structure and thread.
2081   // (Must do this late, so that "max_regions" is defined.)
2082   _cm       = new ConcurrentMark(heap_rs, max_regions());




2083   _cmThread = _cm->cmThread();
2084 
2085   // Initialize the from_card cache structure of HeapRegionRemSet.
2086   HeapRegionRemSet::init_heap(max_regions());
2087 
2088   // Now expand into the initial heap size.
2089   if (!expand(init_byte_size)) {
2090     vm_exit_during_initialization("Failed to allocate initial heap.");
2091     return JNI_ENOMEM;
2092   }
2093 
2094   // Perform any initialization actions delegated to the policy.
2095   g1_policy()->init();
2096 
2097   _refine_cte_cl =
2098     new RefineCardTableEntryClosure(ConcurrentG1RefineThread::sts(),
2099                                     g1_rem_set(),
2100                                     concurrent_g1_refine());
2101   JavaThread::dirty_card_queue_set().set_closure(_refine_cte_cl);
2102 
2103   JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon,
2104                                                SATB_Q_FL_lock,
2105                                                G1SATBProcessCompletedThreshold,
2106                                                Shared_SATB_Q_lock);
2107 
2108   JavaThread::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
2109                                                 DirtyCardQ_FL_lock,
2110                                                 concurrent_g1_refine()->yellow_zone(),




2062 
2063   _g1h = this;
2064 
2065    _in_cset_fast_test_length = max_regions();
2066    _in_cset_fast_test_base =
2067                    NEW_C_HEAP_ARRAY(bool, (size_t) _in_cset_fast_test_length, mtGC);
2068 
2069    // We're biasing _in_cset_fast_test to avoid subtracting the
2070    // beginning of the heap every time we want to index; basically
2071    // it's the same with what we do with the card table.
2072    _in_cset_fast_test = _in_cset_fast_test_base -
2073                ((uintx) _g1_reserved.start() >> HeapRegion::LogOfHRGrainBytes);
2074 
2075    // Clear the _cset_fast_test bitmap in anticipation of adding
2076    // regions to the incremental collection set for the first
2077    // evacuation pause.
2078    clear_cset_fast_test();
2079 
2080   // Create the ConcurrentMark data structure and thread.
2081   // (Must do this late, so that "max_regions" is defined.)
2082   _cm = new ConcurrentMark(this, heap_rs);
2083   if (_cm == NULL || !_cm->completed_initialization()) {
2084     vm_shutdown_during_initialization("Could not create/initialize ConcurrentMark");
2085     return JNI_ENOMEM;
2086   }
2087   _cmThread = _cm->cmThread();
2088 
2089   // Initialize the from_card cache structure of HeapRegionRemSet.
2090   HeapRegionRemSet::init_heap(max_regions());
2091 
2092   // Now expand into the initial heap size.
2093   if (!expand(init_byte_size)) {
2094     vm_shutdown_during_initialization("Failed to allocate initial heap.");
2095     return JNI_ENOMEM;
2096   }
2097 
2098   // Perform any initialization actions delegated to the policy.
2099   g1_policy()->init();
2100 
2101   _refine_cte_cl =
2102     new RefineCardTableEntryClosure(ConcurrentG1RefineThread::sts(),
2103                                     g1_rem_set(),
2104                                     concurrent_g1_refine());
2105   JavaThread::dirty_card_queue_set().set_closure(_refine_cte_cl);
2106 
2107   JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon,
2108                                                SATB_Q_FL_lock,
2109                                                G1SATBProcessCompletedThreshold,
2110                                                Shared_SATB_Q_lock);
2111 
2112   JavaThread::dirty_card_queue_set().initialize(DirtyCardQ_CBL_mon,
2113                                                 DirtyCardQ_FL_lock,
2114                                                 concurrent_g1_refine()->yellow_zone(),