2008-06-05 15:57:56 -07:00
|
|
|
/*
|
2018-01-10 22:48:27 +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_G1SATBCARDTABLEMODREFBS_HPP
|
|
|
|
#define SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_HPP
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/g1/g1RegionToSpaceMapper.hpp"
|
|
|
|
#include "gc/shared/cardTableModRefBS.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "memory/memRegion.hpp"
|
2015-02-13 14:37:35 +01:00
|
|
|
#include "oops/oop.hpp"
|
2013-01-23 13:02:39 -05:00
|
|
|
#include "utilities/macros.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
class DirtyCardQueueSet;
|
2014-08-19 14:09:10 +02:00
|
|
|
class G1SATBCardTableLoggingModRefBS;
|
2008-06-05 15:57:56 -07:00
|
|
|
|
|
|
|
// This barrier is specialized to use a logging barrier to support
|
|
|
|
// snapshot-at-the-beginning marking.
|
|
|
|
|
2014-12-18 13:26:37 -05:00
|
|
|
class G1SATBCardTableModRefBS: public CardTableModRefBS {
|
2015-10-08 12:49:30 -10:00
|
|
|
friend class VMStructs;
|
2013-10-08 17:35:51 +02:00
|
|
|
protected:
|
|
|
|
enum G1CardValues {
|
|
|
|
g1_young_gen = CT_MR_BS_last_reserved << 1
|
|
|
|
};
|
|
|
|
|
2015-02-27 19:52:48 -05:00
|
|
|
G1SATBCardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti);
|
2015-01-27 13:50:31 -05:00
|
|
|
~G1SATBCardTableModRefBS() { }
|
|
|
|
|
2011-04-07 09:53:20 -07:00
|
|
|
public:
|
2013-10-08 17:35:51 +02:00
|
|
|
static int g1_young_card_val() { return g1_young_gen; }
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
// Add "pre_val" to a set of objects that may have been disconnected from the
|
|
|
|
// pre-marking object graph.
|
|
|
|
static void enqueue(oop pre_val);
|
|
|
|
|
2018-01-10 22:43:42 +01:00
|
|
|
static void enqueue_if_weak_or_archive(DecoratorSet decorators, oop value);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2009-07-14 15:40:39 -07:00
|
|
|
template <class T> void write_ref_array_pre_work(T* dst, int count);
|
2014-06-26 13:20:18 +02:00
|
|
|
virtual void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized);
|
|
|
|
virtual void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized);
|
2013-09-24 14:46:29 +02:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
template <DecoratorSet decorators, typename T>
|
|
|
|
void write_ref_field_pre(T* field);
|
|
|
|
|
2013-09-24 14:46:29 +02:00
|
|
|
/*
|
|
|
|
Claimed and deferred bits are used together in G1 during the evacuation
|
|
|
|
pause. These bits can have the following state transitions:
|
|
|
|
1. The claimed bit can be put over any other card state. Except that
|
|
|
|
the "dirty -> dirty and claimed" transition is checked for in
|
|
|
|
G1 code and is not used.
|
|
|
|
2. Deferred bit can be set only if the previous state of the card
|
|
|
|
was either clean or claimed. mark_card_deferred() is wait-free.
|
|
|
|
We do not care if the operation is be successful because if
|
|
|
|
it does not it will only result in duplicate entry in the update
|
|
|
|
buffer because of the "cache-miss". So it's not worth spinning.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool is_card_claimed(size_t card_index) {
|
|
|
|
jbyte val = _byte_map[card_index];
|
|
|
|
return (val & (clean_card_mask_val() | claimed_card_val())) == claimed_card_val();
|
|
|
|
}
|
|
|
|
|
2016-01-18 10:25:41 +01:00
|
|
|
inline void set_card_claimed(size_t card_index);
|
2013-09-24 14:46:29 +02:00
|
|
|
|
2013-10-08 17:35:51 +02:00
|
|
|
void verify_g1_young_region(MemRegion mr) PRODUCT_RETURN;
|
|
|
|
void g1_mark_as_young(const MemRegion& mr);
|
|
|
|
|
2013-09-24 14:46:29 +02:00
|
|
|
bool mark_card_deferred(size_t card_index);
|
|
|
|
|
|
|
|
bool is_card_deferred(size_t card_index) {
|
|
|
|
jbyte val = _byte_map[card_index];
|
|
|
|
return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val();
|
|
|
|
}
|
2018-01-10 22:48:27 +01:00
|
|
|
|
|
|
|
virtual bool is_in_young(oop obj) const;
|
2014-08-19 14:09:10 +02:00
|
|
|
};
|
|
|
|
|
2015-02-27 19:52:48 -05:00
|
|
|
template<>
|
|
|
|
struct BarrierSet::GetName<G1SATBCardTableModRefBS> {
|
|
|
|
static const BarrierSet::Name value = BarrierSet::G1SATBCT;
|
|
|
|
};
|
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
template<>
|
|
|
|
struct BarrierSet::GetType<BarrierSet::G1SATBCT> {
|
|
|
|
typedef G1SATBCardTableModRefBS type;
|
|
|
|
};
|
|
|
|
|
2014-08-19 14:09:10 +02:00
|
|
|
class G1SATBCardTableLoggingModRefBSChangedListener : public G1MappingChangedListener {
|
|
|
|
private:
|
|
|
|
G1SATBCardTableLoggingModRefBS* _card_table;
|
|
|
|
public:
|
|
|
|
G1SATBCardTableLoggingModRefBSChangedListener() : _card_table(NULL) { }
|
|
|
|
|
|
|
|
void set_card_table(G1SATBCardTableLoggingModRefBS* card_table) { _card_table = card_table; }
|
2013-09-24 14:46:29 +02:00
|
|
|
|
2014-10-09 11:40:11 +02:00
|
|
|
virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
|
2008-06-05 15:57:56 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// Adds card-table logging to the post-barrier.
|
|
|
|
// Usual invariant: all dirty cards are logged in the DirtyCardQueueSet.
|
|
|
|
class G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS {
|
2014-08-19 14:09:10 +02:00
|
|
|
friend class G1SATBCardTableLoggingModRefBSChangedListener;
|
2008-06-05 15:57:56 -07:00
|
|
|
private:
|
2014-08-19 14:09:10 +02:00
|
|
|
G1SATBCardTableLoggingModRefBSChangedListener _listener;
|
2008-06-05 15:57:56 -07:00
|
|
|
DirtyCardQueueSet& _dcqs;
|
2015-09-02 11:41:42 -04:00
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
public:
|
2014-08-19 14:09:10 +02:00
|
|
|
static size_t compute_size(size_t mem_region_size_in_words) {
|
|
|
|
size_t number_of_slots = (mem_region_size_in_words / card_size_in_words);
|
|
|
|
return ReservedSpace::allocation_align_size_up(number_of_slots);
|
|
|
|
}
|
|
|
|
|
2015-04-27 10:04:26 +02:00
|
|
|
// Returns how many bytes of the heap a single byte of the Card Table corresponds to.
|
|
|
|
static size_t heap_map_factor() {
|
|
|
|
return CardTableModRefBS::card_size;
|
|
|
|
}
|
|
|
|
|
2014-11-18 10:36:42 +01:00
|
|
|
G1SATBCardTableLoggingModRefBS(MemRegion whole_heap);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2014-08-19 14:09:10 +02:00
|
|
|
virtual void initialize() { }
|
|
|
|
virtual void initialize(G1RegionToSpaceMapper* mapper);
|
|
|
|
|
|
|
|
virtual void resize_covered_region(MemRegion new_region) { ShouldNotReachHere(); }
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
// NB: if you do a whole-heap invalidation, the "usual invariant" defined
|
|
|
|
// above no longer applies.
|
2016-11-24 16:48:22 +03:00
|
|
|
void invalidate(MemRegion mr);
|
2008-06-05 15:57:56 -07:00
|
|
|
|
2018-01-10 22:48:27 +01:00
|
|
|
void write_region(MemRegion mr) { invalidate(mr); }
|
2008-06-05 15:57:56 -07:00
|
|
|
void write_ref_array_work(MemRegion mr) { invalidate(mr); }
|
2017-11-20 13:07:44 +01:00
|
|
|
|
|
|
|
template <DecoratorSet decorators, typename T>
|
|
|
|
void write_ref_field_post(T* field, oop new_val);
|
|
|
|
void write_ref_field_post_slow(volatile jbyte* byte);
|
|
|
|
|
2018-01-10 22:48:27 +01:00
|
|
|
virtual void flush_deferred_barriers(JavaThread* thread);
|
|
|
|
|
|
|
|
virtual bool card_mark_must_follow_store() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
// Callbacks for runtime accesses.
|
|
|
|
template <DecoratorSet decorators, typename BarrierSetT = G1SATBCardTableLoggingModRefBS>
|
|
|
|
class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {
|
|
|
|
typedef ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> ModRef;
|
|
|
|
typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Needed for loads on non-heap weak references
|
|
|
|
template <typename T>
|
|
|
|
static oop oop_load_not_in_heap(T* addr);
|
|
|
|
|
|
|
|
// Needed for non-heap stores
|
|
|
|
template <typename T>
|
|
|
|
static void oop_store_not_in_heap(T* addr, oop new_value);
|
|
|
|
|
|
|
|
// Needed for weak references
|
|
|
|
static oop oop_load_in_heap_at(oop base, ptrdiff_t offset);
|
|
|
|
|
|
|
|
// Defensive: will catch weak oops at addresses in heap
|
|
|
|
template <typename T>
|
|
|
|
static oop oop_load_in_heap(T* addr);
|
|
|
|
};
|
2008-06-05 15:57:56 -07:00
|
|
|
};
|
|
|
|
|
2015-02-27 19:52:48 -05:00
|
|
|
template<>
|
|
|
|
struct BarrierSet::GetName<G1SATBCardTableLoggingModRefBS> {
|
|
|
|
static const BarrierSet::Name value = BarrierSet::G1SATBCTLogging;
|
|
|
|
};
|
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
template<>
|
|
|
|
struct BarrierSet::GetType<BarrierSet::G1SATBCTLogging> {
|
|
|
|
typedef G1SATBCardTableLoggingModRefBS type;
|
|
|
|
};
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#endif // SHARE_VM_GC_G1_G1SATBCARDTABLEMODREFBS_HPP
|