--- old/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-01-27 17:28:14.222399331 -0500 +++ new/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp 2015-01-27 17:28:13.870378979 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -361,6 +361,23 @@ reset_from_card_cache(start_idx, num_regions); } +////////////////////// G1CollectedHeap methods //////////////////////////////// + +// Records the fact that a marking phase is no longer in progress. +void G1CollectedHeap::set_marking_complete() { + g1_policy()->collector_state()->set_marking_complete(); +} + +// Records the fact that a marking phase has commenced. +void G1CollectedHeap::set_marking_started() { + g1_policy()->collector_state()->set_marking_started(); +} + +// Returns whether a marking phase is currently in progress. +bool G1CollectedHeap::mark_in_progress() { + return g1_policy()->collector_state()->mark_in_progress(); +} + void G1CollectedHeap::push_dirty_cards_region(HeapRegion* hr) { // Claim the right to put the region on the dirty cards region list @@ -1076,7 +1093,7 @@ } else { HeapWord* result = humongous_obj_allocate(word_size, context); if (result != NULL && g1_policy()->need_to_start_conc_mark("STW humongous allocation")) { - g1_policy()->set_initiate_conc_mark_if_possible(); + g1_policy()->collector_state()->set_initiate_conc_mark_if_possible(true); } return result; } @@ -1288,7 +1305,7 @@ g1_policy()->stop_incremental_cset_building(); tear_down_region_sets(false /* free_list_only */); - g1_policy()->set_gcs_are_young(true); + g1_policy()->collector_state()->set_gcs_are_young(true); // See the comments in g1CollectedHeap.hpp and // G1CollectedHeap::ref_processing_init() about @@ -1770,7 +1787,6 @@ _process_strong_tasks(new SubTasksDone(G1H_PS_NumElements)), _bot_shared(NULL), _evac_failure_scan_stack(NULL), - _mark_in_progress(false), _cg1r(NULL), _g1mm(NULL), _refine_cte_cl(NULL), @@ -2378,8 +2394,8 @@ } G1YCType G1CollectedHeap::yc_type() { - bool is_young = g1_policy()->gcs_are_young(); - bool is_initial_mark = g1_policy()->during_initial_mark_pause(); + bool is_young = g1_policy()->collector_state()->gcs_are_young(); + bool is_initial_mark = g1_policy()->collector_state()->during_initial_mark_pause(); bool is_during_mark = mark_in_progress(); if (is_initial_mark) { @@ -3663,8 +3679,8 @@ gclog_or_tty->gclog_stamp(_gc_tracer_stw->gc_id()); GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause()) - .append(g1_policy()->gcs_are_young() ? "(young)" : "(mixed)") - .append(g1_policy()->during_initial_mark_pause() ? " (initial-mark)" : ""); + .append(g1_policy()->collector_state()->gcs_are_young() ? "(young)" : "(mixed)") + .append(g1_policy()->collector_state()->during_initial_mark_pause() ? " (initial-mark)" : ""); gclog_or_tty->print("[%s", (const char*)gc_cause_str); } @@ -3720,22 +3736,22 @@ g1_policy()->decide_on_conc_mark_initiation(); // We do not allow initial-mark to be piggy-backed on a mixed GC. - assert(!g1_policy()->during_initial_mark_pause() || - g1_policy()->gcs_are_young(), "sanity"); + assert(!g1_policy()->collector_state()->during_initial_mark_pause() || + g1_policy()->collector_state()->gcs_are_young(), "sanity"); // We also do not allow mixed GCs during marking. - assert(!mark_in_progress() || g1_policy()->gcs_are_young(), "sanity"); + assert(!mark_in_progress() || g1_policy()->collector_state()->gcs_are_young(), "sanity"); // Record whether this pause is an initial mark. When the current // thread has completed its logging output and it's safe to signal // the CM thread, the flag's value in the policy has been reset. - bool should_start_conc_mark = g1_policy()->during_initial_mark_pause(); + bool should_start_conc_mark = g1_policy()->collector_state()->during_initial_mark_pause(); // Inner scope for scope based logging, timers, and stats collection { EvacuationInfo evacuation_info; - if (g1_policy()->during_initial_mark_pause()) { + if (g1_policy()->collector_state()->during_initial_mark_pause()) { // We are about to start a marking cycle, so we increment the // full collection counter. increment_old_marking_cycles_started(); @@ -3842,7 +3858,7 @@ _young_list->print(); #endif // YOUNG_LIST_VERBOSE - if (g1_policy()->during_initial_mark_pause()) { + if (g1_policy()->collector_state()->during_initial_mark_pause()) { concurrent_mark()->checkpointRootsInitialPre(); } @@ -3946,7 +3962,7 @@ _allocator->increase_used(g1_policy()->bytes_copied_during_gc()); } - if (g1_policy()->during_initial_mark_pause()) { + if (g1_policy()->collector_state()->during_initial_mark_pause()) { // We have to do this before we notify the CM threads that // they can start working to make sure that all the // appropriate initialization is done on the CM object. @@ -4495,7 +4511,7 @@ pss.set_evac_failure_closure(&evac_failure_cl); - bool only_young = _g1h->g1_policy()->gcs_are_young(); + bool only_young = _g1h->g1_policy()->collector_state()->gcs_are_young(); // Non-IM young GC. G1ParCopyClosure scan_only_root_cl(_g1h, &pss, rp); @@ -4524,7 +4540,7 @@ CLDClosure* weak_cld_cl; CodeBlobClosure* strong_code_cl; - if (_g1h->g1_policy()->during_initial_mark_pause()) { + if (_g1h->g1_policy()->collector_state()->during_initial_mark_pause()) { // We also need to mark copied objects. strong_root_cl = &scan_mark_root_cl; strong_cld_cl = &scan_mark_cld_cl; @@ -4605,7 +4621,7 @@ double ext_roots_start = os::elapsedTime(); double closure_app_time_sec = 0.0; - bool during_im = _g1h->g1_policy()->during_initial_mark_pause(); + bool during_im = _g1h->g1_policy()->collector_state()->during_initial_mark_pause(); bool trace_metadata = during_im && ClassUnloadingWithConcurrentMark; BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots); @@ -5295,7 +5311,7 @@ OopClosure* copy_non_heap_cl = &only_copy_non_heap_cl; - if (_g1h->g1_policy()->during_initial_mark_pause()) { + if (_g1h->g1_policy()->collector_state()->during_initial_mark_pause()) { // We also need to mark copied objects. copy_non_heap_cl = ©_mark_non_heap_cl; } @@ -5400,7 +5416,7 @@ OopClosure* copy_non_heap_cl = &only_copy_non_heap_cl; - if (_g1h->g1_policy()->during_initial_mark_pause()) { + if (_g1h->g1_policy()->collector_state()->during_initial_mark_pause()) { // We also need to mark copied objects. copy_non_heap_cl = ©_mark_non_heap_cl; } @@ -5515,7 +5531,7 @@ OopClosure* copy_non_heap_cl = &only_copy_non_heap_cl; - if (_g1h->g1_policy()->during_initial_mark_pause()) { + if (_g1h->g1_policy()->collector_state()->during_initial_mark_pause()) { // We also need to mark copied objects. copy_non_heap_cl = ©_mark_non_heap_cl; } @@ -5633,7 +5649,7 @@ { StrongRootsScope srs(this); // InitialMark needs claim bits to keep track of the marked-through CLDs. - if (g1_policy()->during_initial_mark_pause()) { + if (g1_policy()->collector_state()->during_initial_mark_pause()) { ClassLoaderDataGraph::clear_claimed_marks(); } @@ -6586,7 +6602,7 @@ _hr_printer.alloc(new_alloc_region, G1HRPrinter::Old); check_bitmaps("Old Region Allocation", new_alloc_region); } - bool during_im = g1_policy()->during_initial_mark_pause(); + bool during_im = g1_policy()->collector_state()->during_initial_mark_pause(); new_alloc_region->note_start_of_copying(during_im); return new_alloc_region; } @@ -6597,7 +6613,7 @@ void G1CollectedHeap::retire_gc_alloc_region(HeapRegion* alloc_region, size_t allocated_bytes, InCSetState dest) { - bool during_im = g1_policy()->during_initial_mark_pause(); + bool during_im = g1_policy()->collector_state()->during_initial_mark_pause(); alloc_region->note_end_of_copying(during_im); g1_policy()->record_bytes_copied_during_gc(allocated_bytes); if (dest.is_young()) {