2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2018-01-10 22:48:27 +01:00
|
|
|
* Copyright (c) 2000, 2018, 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_MODREFBARRIERSET_HPP
|
|
|
|
#define SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/barrierSet.hpp"
|
2017-11-20 13:07:44 +01:00
|
|
|
#include "memory/memRegion.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2017-11-20 13:07:44 +01:00
|
|
|
class Klass;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
class ModRefBarrierSet: public BarrierSet {
|
|
|
|
protected:
|
2018-03-21 14:38:32 +01:00
|
|
|
ModRefBarrierSet(BarrierSetAssembler* barrier_set_assembler,
|
2018-04-26 20:42:43 +02:00
|
|
|
BarrierSetC1* barrier_set_c1,
|
2018-05-18 14:51:06 +02:00
|
|
|
BarrierSetC2* barrier_set_c2,
|
2018-03-21 14:38:32 +01:00
|
|
|
const BarrierSet::FakeRtti& fake_rtti)
|
|
|
|
: BarrierSet(barrier_set_assembler,
|
2018-04-26 20:42:43 +02:00
|
|
|
barrier_set_c1,
|
2018-05-18 14:51:06 +02:00
|
|
|
barrier_set_c2,
|
2018-03-21 14:38:32 +01:00
|
|
|
fake_rtti.add_tag(BarrierSet::ModRef)) { }
|
2015-01-27 13:50:31 -05:00
|
|
|
~ModRefBarrierSet() { }
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
public:
|
2017-11-20 13:07:44 +01:00
|
|
|
template <DecoratorSet decorators, typename T>
|
|
|
|
inline void write_ref_field_pre(T* addr) {}
|
|
|
|
|
|
|
|
template <DecoratorSet decorators, typename T>
|
|
|
|
inline void write_ref_field_post(T *addr, oop new_value) {}
|
|
|
|
|
2016-11-24 16:48:22 +03:00
|
|
|
// Causes all refs in "mr" to be assumed to be modified.
|
|
|
|
virtual void invalidate(MemRegion mr) = 0;
|
2018-01-10 22:48:27 +01:00
|
|
|
virtual void write_region(MemRegion mr) = 0;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2018-03-21 14:38:32 +01:00
|
|
|
// Operations on arrays, or general regions (e.g., for "clone") may be
|
|
|
|
// optimized by some barriers.
|
|
|
|
|
|
|
|
// Below length is the # array elements being written
|
|
|
|
virtual void write_ref_array_pre(oop* dst, size_t length,
|
|
|
|
bool dest_uninitialized = false) {}
|
|
|
|
virtual void write_ref_array_pre(narrowOop* dst, size_t length,
|
|
|
|
bool dest_uninitialized = false) {}
|
|
|
|
// Below count is the # array elements being written, starting
|
|
|
|
// at the address "start", which may not necessarily be HeapWord-aligned
|
|
|
|
inline void write_ref_array(HeapWord* start, size_t count);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void write_ref_array_work(MemRegion mr) = 0;
|
|
|
|
|
|
|
|
public:
|
2017-11-20 13:07:44 +01:00
|
|
|
// The ModRef abstraction introduces pre and post barriers
|
|
|
|
template <DecoratorSet decorators, typename BarrierSetT>
|
|
|
|
class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
|
|
|
|
typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
|
|
|
|
|
|
|
|
public:
|
|
|
|
template <typename T>
|
|
|
|
static void oop_store_in_heap(T* addr, oop value);
|
|
|
|
template <typename T>
|
|
|
|
static oop oop_atomic_cmpxchg_in_heap(oop new_value, T* addr, oop compare_value);
|
|
|
|
template <typename T>
|
|
|
|
static oop oop_atomic_xchg_in_heap(oop new_value, T* addr);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static bool oop_arraycopy_in_heap(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
|
|
|
|
|
|
|
|
static void clone_in_heap(oop src, oop dst, size_t size);
|
|
|
|
|
|
|
|
static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value) {
|
|
|
|
oop_store_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static oop oop_atomic_xchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset) {
|
|
|
|
return oop_atomic_xchg_in_heap(new_value, AccessInternal::oop_field_addr<decorators>(base, offset));
|
|
|
|
}
|
|
|
|
|
|
|
|
static oop oop_atomic_cmpxchg_in_heap_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
|
|
|
|
return oop_atomic_cmpxchg_in_heap(new_value, AccessInternal::oop_field_addr<decorators>(base, offset), compare_value);
|
|
|
|
}
|
|
|
|
};
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2015-02-27 19:52:48 -05:00
|
|
|
template<>
|
|
|
|
struct BarrierSet::GetName<ModRefBarrierSet> {
|
|
|
|
static const BarrierSet::Name value = BarrierSet::ModRef;
|
|
|
|
};
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#endif // SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
|