2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2015-05-13 15:16:06 +02:00
|
|
|
* Copyright (c) 2001, 2015, 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-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/cardTableModRefBS.hpp"
|
|
|
|
#include "gc/shared/genRemSet.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;
|
|
|
|
|
|
|
|
// This kind of "GenRemSet" uses a card table both as shared data structure
|
|
|
|
// for a mod ref barrier set and for the rem set information.
|
|
|
|
|
|
|
|
class CardTableRS: public GenRemSet {
|
|
|
|
friend class VMStructs;
|
|
|
|
// Below are private classes used in impl.
|
|
|
|
friend class VerifyCTSpaceClosure;
|
|
|
|
friend class ClearNoncleanCardWrapper;
|
|
|
|
|
|
|
|
static jbyte clean_card_val() {
|
|
|
|
return CardTableModRefBS::clean_card;
|
|
|
|
}
|
|
|
|
|
2012-03-14 12:49:27 +01:00
|
|
|
static intptr_t clean_card_row() {
|
|
|
|
return CardTableModRefBS::clean_card_row;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
static bool
|
|
|
|
card_is_dirty_wrt_gen_iter(jbyte cv) {
|
|
|
|
return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv);
|
|
|
|
}
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
CardTableModRefBSForCTRS* _ct_bs;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-05-21 09:35:38 +02:00
|
|
|
virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl, uint n_threads);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void verify_space(Space* s, HeapWord* gen_start);
|
|
|
|
|
|
|
|
enum ExtendedCardValue {
|
|
|
|
youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1,
|
|
|
|
// 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.
|
|
|
|
youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2,
|
|
|
|
youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3,
|
|
|
|
youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4,
|
|
|
|
cur_youngergen_and_prev_nonclean_card =
|
|
|
|
CardTableModRefBS::CT_MR_BS_last_reserved + 5
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// portion of the table. (The perm gen is index 0; other gens are at
|
|
|
|
// their level plus 1. They youngest gen is in the table, but will
|
|
|
|
// always have the value "clean_card".)
|
|
|
|
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
|
|
|
|
|
|
|
// *** GenRemSet functions.
|
|
|
|
CardTableRS* as_CardTableRS() { return this; }
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
CardTableModRefBS* ct_bs() { return _ct_bs; }
|
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
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
void invalidate(MemRegion mr, bool whole_heap = false) {
|
|
|
|
_ct_bs->invalidate(mr, whole_heap);
|
|
|
|
}
|
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() {
|
|
|
|
return CardTableModRefBS::ct_max_alignment_constraint();
|
|
|
|
}
|
|
|
|
|
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
|