2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2017-10-03 16:42:04 -04:00
|
|
|
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00: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.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#ifndef SHARE_VM_GC_SHARED_CARDTABLERS_HPP
|
|
|
|
#define SHARE_VM_GC_SHARED_CARDTABLERS_HPP
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2015-07-22 00:37:01 -04:00
|
|
|
#include "gc/shared/cardTableModRefBSForCTRS.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/memRegion.hpp"
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
class Space;
|
|
|
|
class OopsInGenClosure;
|
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
// Helper to remember modified oops in all clds.
|
|
|
|
class CLDRemSet {
|
2015-10-14 09:33:45 +02:00
|
|
|
bool _accumulate_modified_oops;
|
|
|
|
public:
|
2017-10-03 16:42:04 -04:00
|
|
|
CLDRemSet() : _accumulate_modified_oops(false) {}
|
2015-10-14 09:33:45 +02:00
|
|
|
void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; }
|
|
|
|
bool accumulate_modified_oops() { return _accumulate_modified_oops; }
|
|
|
|
bool mod_union_is_clear();
|
|
|
|
void clear_mod_union();
|
|
|
|
};
|
|
|
|
|
|
|
|
// This RemSet uses a card table both as shared data structure
|
2007-12-01 00:00:00 +00:00
|
|
|
// for a mod ref barrier set and for the rem set information.
|
|
|
|
|
2015-10-14 09:33:45 +02:00
|
|
|
class CardTableRS: public CHeapObj<mtGC> {
|
2007-12-01 00:00:00 +00:00
|
|
|
friend class VMStructs;
|
|
|
|
// Below are private classes used in impl.
|
|
|
|
friend class VerifyCTSpaceClosure;
|
|
|
|
friend class ClearNoncleanCardWrapper;
|
|
|
|
|
|
|
|
static jbyte clean_card_val() {
|
2015-07-22 00:37:01 -04:00
|
|
|
return CardTableModRefBSForCTRS::clean_card;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2012-03-14 12:49:27 +01:00
|
|
|
static intptr_t clean_card_row() {
|
2015-07-22 00:37:01 -04:00
|
|
|
return CardTableModRefBSForCTRS::clean_card_row;
|
2012-03-14 12:49:27 +01:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
static bool
|
|
|
|
card_is_dirty_wrt_gen_iter(jbyte cv) {
|
2015-07-22 00:37:01 -04:00
|
|
|
return CardTableModRefBSForCTRS::card_is_dirty_wrt_gen_iter(cv);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
CLDRemSet _cld_rem_set;
|
2015-10-14 09:33:45 +02:00
|
|
|
BarrierSet* _bs;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-10-14 09:33:45 +02:00
|
|
|
CardTableModRefBSForCTRS* _ct_bs;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void verify_space(Space* s, HeapWord* gen_start);
|
|
|
|
|
|
|
|
enum ExtendedCardValue {
|
2015-07-22 00:37:01 -04:00
|
|
|
youngergen_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 1,
|
2007-12-01 00:00:00 +00:00
|
|
|
// These are for parallel collection.
|
|
|
|
// There are three P (parallel) youngergen card values. In general, this
|
|
|
|
// needs to be more than the number of generations (including the perm
|
|
|
|
// gen) that might have younger_refs_do invoked on them separately. So
|
|
|
|
// if we add more gens, we have to add more values.
|
2015-07-22 00:37:01 -04:00
|
|
|
youngergenP1_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 2,
|
|
|
|
youngergenP2_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 3,
|
|
|
|
youngergenP3_card = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 4,
|
2007-12-01 00:00:00 +00:00
|
|
|
cur_youngergen_and_prev_nonclean_card =
|
2015-07-22 00:37:01 -04:00
|
|
|
CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 5
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// An array that contains, for each generation, the card table value last
|
|
|
|
// used as the current value for a younger_refs_do iteration of that
|
2015-06-17 14:44:54 +02:00
|
|
|
// portion of the table. The perm gen is index 0. The young gen is index 1,
|
|
|
|
// but will always have the value "clean_card". The old gen is index 2.
|
2007-12-01 00:00:00 +00:00
|
|
|
jbyte* _last_cur_val_in_gen;
|
|
|
|
|
|
|
|
jbyte _cur_youngergen_card_val;
|
|
|
|
|
2014-11-18 10:36:42 +01:00
|
|
|
// Number of generations, plus one for lingering PermGen issues in CardTableRS.
|
|
|
|
static const int _regions_to_iterate = 3;
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
jbyte cur_youngergen_card_val() {
|
|
|
|
return _cur_youngergen_card_val;
|
|
|
|
}
|
|
|
|
void set_cur_youngergen_card_val(jbyte v) {
|
|
|
|
_cur_youngergen_card_val = v;
|
|
|
|
}
|
|
|
|
bool is_prev_youngergen_card_val(jbyte v) {
|
|
|
|
return
|
|
|
|
youngergen_card <= v &&
|
|
|
|
v < cur_youngergen_and_prev_nonclean_card &&
|
|
|
|
v != _cur_youngergen_card_val;
|
|
|
|
}
|
|
|
|
// Return a youngergen_card_value that is not currently in use.
|
|
|
|
jbyte find_unused_youngergenP_card_value();
|
|
|
|
|
|
|
|
public:
|
2014-11-18 10:36:42 +01:00
|
|
|
CardTableRS(MemRegion whole_heap);
|
2013-05-14 09:41:12 -07:00
|
|
|
~CardTableRS();
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-10-14 09:33:45 +02:00
|
|
|
// Return the barrier set associated with "this."
|
|
|
|
BarrierSet* bs() { return _bs; }
|
|
|
|
|
|
|
|
// Set the barrier set.
|
|
|
|
void set_bs(BarrierSet* bs) { _bs = bs; }
|
|
|
|
|
2017-10-03 16:42:04 -04:00
|
|
|
CLDRemSet* cld_rem_set() { return &_cld_rem_set; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-07-22 00:37:01 -04:00
|
|
|
CardTableModRefBSForCTRS* ct_bs() { return _ct_bs; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-10-14 09:33:45 +02:00
|
|
|
void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl, uint n_threads);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Override.
|
|
|
|
void prepare_for_younger_refs_iterate(bool parallel);
|
|
|
|
|
|
|
|
// Card table entries are cleared before application; "blk" is
|
|
|
|
// responsible for dirtying if the oop is still older-to-younger after
|
|
|
|
// closure application.
|
2015-05-21 09:35:38 +02:00
|
|
|
void younger_refs_iterate(Generation* g, OopsInGenClosure* blk, uint n_threads);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
void inline_write_ref_field_gc(void* field, oop new_val) {
|
2008-06-05 15:57:56 -07:00
|
|
|
jbyte* byte = _ct_bs->byte_for(field);
|
2007-12-01 00:00:00 +00:00
|
|
|
*byte = youngergen_card;
|
|
|
|
}
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
void write_ref_field_gc_work(void* field, oop new_val) {
|
2007-12-01 00:00:00 +00:00
|
|
|
inline_write_ref_field_gc(field, new_val);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Override. Might want to devirtualize this in the same fashion as
|
|
|
|
// above. Ensures that the value of the card for field says that it's
|
|
|
|
// a younger card in the current collection.
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
virtual void write_ref_field_gc_par(void* field, oop new_val);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void resize_covered_region(MemRegion new_region);
|
|
|
|
|
|
|
|
bool is_aligned(HeapWord* addr) {
|
2008-06-05 15:57:56 -07:00
|
|
|
return _ct_bs->is_card_aligned(addr);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void verify();
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
void clear(MemRegion mr) { _ct_bs->clear(mr); }
|
2013-08-15 10:05:50 +02:00
|
|
|
void clear_into_younger(Generation* old_gen);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-11-24 16:48:22 +03:00
|
|
|
void invalidate(MemRegion mr) {
|
|
|
|
_ct_bs->invalidate(mr);
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
2013-08-15 10:05:50 +02:00
|
|
|
void invalidate_or_clear(Generation* old_gen);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
static uintx ct_max_alignment_constraint() {
|
2015-07-22 00:37:01 -04:00
|
|
|
return CardTableModRefBSForCTRS::ct_max_alignment_constraint();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
jbyte* byte_for(void* p) { return _ct_bs->byte_for(p); }
|
|
|
|
jbyte* byte_after(void* p) { return _ct_bs->byte_after(p); }
|
|
|
|
HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
bool is_prev_nonclean_card_val(jbyte v) {
|
|
|
|
return
|
|
|
|
youngergen_card <= v &&
|
|
|
|
v <= cur_youngergen_and_prev_nonclean_card &&
|
|
|
|
v != _cur_youngergen_card_val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool youngergen_may_have_been_dirty(jbyte cv) {
|
|
|
|
return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2011-04-20 19:19:30 -07:00
|
|
|
class ClearNoncleanCardWrapper: public MemRegionClosure {
|
2011-05-10 00:33:21 -07:00
|
|
|
DirtyCardToOopClosure* _dirty_card_closure;
|
2011-04-20 19:19:30 -07:00
|
|
|
CardTableRS* _ct;
|
|
|
|
bool _is_par;
|
|
|
|
private:
|
|
|
|
// Clears the given card, return true if the corresponding card should be
|
|
|
|
// processed.
|
|
|
|
inline bool clear_card(jbyte* entry);
|
|
|
|
// Work methods called by the clear_card()
|
|
|
|
inline bool clear_card_serial(jbyte* entry);
|
|
|
|
inline bool clear_card_parallel(jbyte* entry);
|
2012-03-14 12:49:27 +01:00
|
|
|
// check alignment of pointer
|
|
|
|
bool is_word_aligned(jbyte* entry);
|
2011-04-20 19:19:30 -07:00
|
|
|
|
|
|
|
public:
|
2015-05-21 09:35:38 +02:00
|
|
|
ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct, bool is_par);
|
2011-04-20 19:19:30 -07:00
|
|
|
void do_MemRegion(MemRegion mr);
|
|
|
|
};
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#endif // SHARE_VM_GC_SHARED_CARDTABLERS_HPP
|