2008-06-05 15:57:56 -07:00
|
|
|
/*
|
2018-02-26 09:34:12 +01:00
|
|
|
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
|
2008-06-05 15:57:56 -07:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2008-06-05 15:57:56 -07:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#ifndef SHARE_VM_GC_G1_G1REMSET_HPP
|
|
|
|
#define SHARE_VM_GC_G1_G1REMSET_HPP
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2015-12-21 12:02:03 +01:00
|
|
|
#include "gc/g1/dirtyCardQueue.hpp"
|
2018-02-26 09:34:12 +01:00
|
|
|
#include "gc/g1/g1CardTable.hpp"
|
2018-03-26 16:51:43 +02:00
|
|
|
#include "gc/g1/g1OopClosures.hpp"
|
2018-12-07 13:54:45 +01:00
|
|
|
#include "gc/g1/g1GCPhaseTimes.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/g1/g1RemSetSummary.hpp"
|
2015-12-21 12:02:03 +01:00
|
|
|
#include "gc/g1/heapRegion.hpp"
|
|
|
|
#include "memory/allocation.hpp"
|
|
|
|
#include "memory/iterator.hpp"
|
2018-04-27 12:06:46 +02:00
|
|
|
#include "utilities/ticks.hpp"
|
2013-05-28 09:32:06 +02:00
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
// A G1RemSet provides ways of iterating over pointers into a selected
|
|
|
|
// collection set.
|
|
|
|
|
2015-12-21 12:02:03 +01:00
|
|
|
class BitMap;
|
2018-03-19 07:38:18 +01:00
|
|
|
class CardTableBarrierSet;
|
2016-01-07 16:25:53 +01:00
|
|
|
class G1BlockOffsetTable;
|
2015-12-21 12:02:03 +01:00
|
|
|
class CodeBlobClosure;
|
|
|
|
class G1CollectedHeap;
|
2018-03-26 16:51:43 +02:00
|
|
|
class G1CMBitMap;
|
2016-05-02 12:07:58 -04:00
|
|
|
class G1HotCardCache;
|
2016-04-18 16:51:14 +02:00
|
|
|
class G1RemSetScanState;
|
2017-06-28 10:58:19 +02:00
|
|
|
class G1ParScanThreadState;
|
2016-03-18 15:20:43 +01:00
|
|
|
class G1Policy;
|
2017-06-28 10:58:19 +02:00
|
|
|
class G1ScanObjsDuringScanRSClosure;
|
|
|
|
class G1ScanObjsDuringUpdateRSClosure;
|
2015-12-21 12:02:03 +01:00
|
|
|
class HeapRegionClaimer;
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2010-10-12 09:36:48 -07:00
|
|
|
// A G1RemSet in which each heap region has a rem set that records the
|
|
|
|
// external heap references into it. Uses a mod ref bs to track updates,
|
|
|
|
// so that they can be used to update the individual region remsets.
|
2012-06-28 17:03:16 -04:00
|
|
|
class G1RemSet: public CHeapObj<mtGC> {
|
2013-05-28 09:32:06 +02:00
|
|
|
private:
|
2016-04-18 16:51:14 +02:00
|
|
|
G1RemSetScanState* _scan_state;
|
2016-04-06 13:41:59 +02:00
|
|
|
|
2013-05-28 09:32:06 +02:00
|
|
|
G1RemSetSummary _prev_period_summary;
|
2015-11-09 11:26:15 +01:00
|
|
|
|
2017-06-28 14:15:56 +02:00
|
|
|
// Scan all remembered sets of the collection set for references into the collection
|
|
|
|
// set.
|
2018-04-27 12:06:46 +02:00
|
|
|
void scan_rem_set(G1ParScanThreadState* pss, uint worker_i);
|
2017-06-28 14:15:56 +02:00
|
|
|
|
|
|
|
// Flush remaining refinement buffers for cross-region references to either evacuate references
|
|
|
|
// into the collection set or update the remembered set.
|
2017-07-17 11:37:00 +02:00
|
|
|
void update_rem_set(G1ParScanThreadState* pss, uint worker_i);
|
2017-06-28 14:15:56 +02:00
|
|
|
|
2018-04-18 11:36:48 +02:00
|
|
|
G1CollectedHeap* _g1h;
|
2017-07-04 09:16:26 +02:00
|
|
|
size_t _num_conc_refined_cards; // Number of cards refined concurrently to the mutator.
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2018-02-26 09:34:12 +01:00
|
|
|
G1CardTable* _ct;
|
2016-03-18 15:20:43 +01:00
|
|
|
G1Policy* _g1p;
|
2016-05-02 12:07:58 -04:00
|
|
|
G1HotCardCache* _hot_card_cache;
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
public:
|
2015-12-22 11:02:04 +01:00
|
|
|
// Gives an approximation on how many threads can be expected to add records to
|
|
|
|
// a remembered set in parallel. This can be used for sizing data structures to
|
|
|
|
// decrease performance losses due to data structure sharing.
|
|
|
|
// Examples for quantities that influence this value are the maximum number of
|
|
|
|
// mutator threads, maximum number of concurrent refinement or GC threads.
|
|
|
|
static uint num_par_rem_sets();
|
|
|
|
|
|
|
|
// Initialize data that depends on the heap size being known.
|
2016-04-06 13:41:59 +02:00
|
|
|
void initialize(size_t capacity, uint max_regions);
|
2015-12-22 11:02:04 +01:00
|
|
|
|
2018-04-18 11:36:48 +02:00
|
|
|
G1RemSet(G1CollectedHeap* g1h,
|
2018-02-26 09:34:12 +01:00
|
|
|
G1CardTable* ct,
|
2016-05-02 12:07:58 -04:00
|
|
|
G1HotCardCache* hot_card_cache);
|
2010-10-12 09:36:48 -07:00
|
|
|
~G1RemSet();
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2017-06-28 10:58:19 +02:00
|
|
|
// Process all oops in the collection set from the cards in the refinement buffers and
|
|
|
|
// remembered sets using pss.
|
2013-08-15 10:52:18 +02:00
|
|
|
//
|
2017-06-28 10:58:19 +02:00
|
|
|
// Further applies heap_region_codeblobs on the oops of the unmarked nmethods on the strong code
|
|
|
|
// roots list for each region in the collection set.
|
2018-04-27 12:06:46 +02:00
|
|
|
void oops_into_collection_set_do(G1ParScanThreadState* pss, uint worker_i);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2010-10-12 09:36:48 -07:00
|
|
|
// Prepare for and cleanup after an oops_into_collection_set_do
|
|
|
|
// call. Must call each of these once before and after (in sequential
|
2017-06-28 14:15:56 +02:00
|
|
|
// code) any thread calls oops_into_collection_set_do.
|
2008-06-05 15:57:56 -07:00
|
|
|
void prepare_for_oops_into_collection_set_do();
|
|
|
|
void cleanup_after_oops_into_collection_set_do();
|
2010-10-12 09:36:48 -07:00
|
|
|
|
2016-04-18 16:51:14 +02:00
|
|
|
G1RemSetScanState* scan_state() const { return _scan_state; }
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2017-06-28 14:15:56 +02:00
|
|
|
// Refine the card corresponding to "card_ptr". Safe to be called concurrently
|
|
|
|
// to the mutator.
|
2017-06-02 13:47:54 +02:00
|
|
|
void refine_card_concurrently(jbyte* card_ptr,
|
|
|
|
uint worker_i);
|
|
|
|
|
2017-06-28 14:15:56 +02:00
|
|
|
// Refine the card corresponding to "card_ptr", applying the given closure to
|
2017-07-17 11:37:00 +02:00
|
|
|
// all references found. Must only be called during gc.
|
2017-08-09 17:27:42 +02:00
|
|
|
// Returns whether the card has been scanned.
|
|
|
|
bool refine_card_during_gc(jbyte* card_ptr, G1ScanObjsDuringUpdateRSClosure* update_rs_cl);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2013-05-28 09:32:06 +02:00
|
|
|
// Print accumulated summary info from the start of the VM.
|
2017-02-27 12:41:41 -05:00
|
|
|
void print_summary_info();
|
2010-10-12 09:36:48 -07:00
|
|
|
|
2013-05-28 09:32:06 +02:00
|
|
|
// Print accumulated summary info from the last time called.
|
2017-02-27 12:41:41 -05:00
|
|
|
void print_periodic_summary_info(const char* header, uint period_count);
|
2013-05-28 09:32:06 +02:00
|
|
|
|
2017-07-04 09:16:26 +02:00
|
|
|
size_t num_conc_refined_cards() const { return _num_conc_refined_cards; }
|
2016-04-06 13:41:59 +02:00
|
|
|
|
2018-03-26 16:51:43 +02:00
|
|
|
// Rebuilds the remembered set by scanning from bottom to TARS for all regions
|
|
|
|
// using the given work gang.
|
|
|
|
void rebuild_rem_set(G1ConcurrentMark* cm, WorkGang* workers, uint worker_id_offset);
|
2008-06-05 15:57:56 -07:00
|
|
|
};
|
|
|
|
|
2017-06-28 14:15:56 +02:00
|
|
|
class G1ScanRSForRegionClosure : public HeapRegionClosure {
|
2018-04-27 12:06:46 +02:00
|
|
|
G1CollectedHeap* _g1h;
|
|
|
|
G1CardTable *_ct;
|
|
|
|
|
|
|
|
G1ParScanThreadState* _pss;
|
|
|
|
G1ScanObjsDuringScanRSClosure* _scan_objs_on_card_cl;
|
|
|
|
|
2016-04-18 16:51:14 +02:00
|
|
|
G1RemSetScanState* _scan_state;
|
|
|
|
|
2018-12-07 13:54:45 +01:00
|
|
|
G1GCPhaseTimes::GCParPhases _phase;
|
|
|
|
|
2018-04-27 12:06:46 +02:00
|
|
|
uint _worker_i;
|
|
|
|
|
2017-06-14 11:26:44 +02:00
|
|
|
size_t _cards_scanned;
|
|
|
|
size_t _cards_claimed;
|
|
|
|
size_t _cards_skipped;
|
|
|
|
|
2018-04-27 12:06:46 +02:00
|
|
|
Tickspan _rem_set_root_scan_time;
|
|
|
|
Tickspan _rem_set_trim_partially_time;
|
2015-10-19 16:21:35 +02:00
|
|
|
|
2018-04-27 12:06:46 +02:00
|
|
|
Tickspan _strong_code_root_scan_time;
|
|
|
|
Tickspan _strong_code_trim_partially_time;
|
2015-10-19 16:21:35 +02:00
|
|
|
|
2017-07-06 12:11:20 +02:00
|
|
|
void claim_card(size_t card_index, const uint region_idx_for_card);
|
|
|
|
void scan_card(MemRegion mr, uint region_idx_for_card);
|
2018-04-27 12:06:46 +02:00
|
|
|
|
|
|
|
void scan_rem_set_roots(HeapRegion* r);
|
2016-04-18 16:51:14 +02:00
|
|
|
void scan_strong_code_roots(HeapRegion* r);
|
2015-10-19 16:21:35 +02:00
|
|
|
public:
|
2017-06-28 14:15:56 +02:00
|
|
|
G1ScanRSForRegionClosure(G1RemSetScanState* scan_state,
|
|
|
|
G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
|
2018-04-27 12:06:46 +02:00
|
|
|
G1ParScanThreadState* pss,
|
2018-12-07 13:54:45 +01:00
|
|
|
G1GCPhaseTimes::GCParPhases phase,
|
2017-06-28 14:15:56 +02:00
|
|
|
uint worker_i);
|
2015-10-19 16:21:35 +02:00
|
|
|
|
2018-02-09 13:09:55 +01:00
|
|
|
bool do_heap_region(HeapRegion* r);
|
2015-10-19 16:21:35 +02:00
|
|
|
|
2018-04-27 12:06:46 +02:00
|
|
|
Tickspan rem_set_root_scan_time() const { return _rem_set_root_scan_time; }
|
|
|
|
Tickspan rem_set_trim_partially_time() const { return _rem_set_trim_partially_time; }
|
|
|
|
|
|
|
|
Tickspan strong_code_root_scan_time() const { return _strong_code_root_scan_time; }
|
|
|
|
Tickspan strong_code_root_trim_partially_time() const { return _strong_code_trim_partially_time; }
|
2016-04-18 16:51:14 +02:00
|
|
|
|
2017-06-14 11:26:44 +02:00
|
|
|
size_t cards_scanned() const { return _cards_scanned; }
|
|
|
|
size_t cards_claimed() const { return _cards_claimed; }
|
|
|
|
size_t cards_skipped() const { return _cards_skipped; }
|
2015-10-19 16:21:35 +02:00
|
|
|
};
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#endif // SHARE_VM_GC_G1_G1REMSET_HPP
|