< prev index next >
src/share/vm/gc/shared/modRefBarrierSet.hpp
Print this page
rev 12906 : [mq]: gc_interface
@@ -24,79 +24,99 @@
#ifndef SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
#define SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
#include "gc/shared/barrierSet.hpp"
+#include "memory/memRegion.hpp"
-// This kind of "BarrierSet" allows a "CollectedHeap" to detect and
-// enumerate ref fields that have been modified (since the last
-// enumeration), using a card table.
-
-class OopClosure;
-class Generation;
+class Klass;
class ModRefBarrierSet: public BarrierSet {
+protected:
+ ModRefBarrierSet(const BarrierSet::FakeRtti& fake_rtti)
+ : BarrierSet(fake_rtti.add_tag(BarrierSet::ModRef)) { }
+ ~ModRefBarrierSet() { }
+
+ virtual void write_ref_array_region(MemRegion mr) = 0;
+
+ // These methods serve the only purpose of speeding up build times by reducing
+ // included files
+ static Klass* bound_for_array(oop obj);
+ static bool is_bounded_by(oop obj, Klass* klass);
+
public:
+ // Causes all refs in "mr" to be assumed to be modified.
+ virtual void invalidate(MemRegion mr) = 0;
- // Barriers only on ref writes.
- bool has_read_ref_barrier() { return false; }
- bool has_read_prim_barrier() { return false; }
- bool has_write_ref_barrier() { return true; }
- bool has_write_prim_barrier() { return false; }
-
- bool read_ref_needs_barrier(void* field) { return false; }
- bool read_prim_needs_barrier(HeapWord* field, size_t bytes) { return false; }
- bool write_prim_needs_barrier(HeapWord* field, size_t bytes,
- juint val1, juint val2) { return false; }
+ // Operations on arrays, or general regions (e.g., for "clone") may be
+ // optimized by some barriers.
- void write_prim_field(oop obj, size_t offset, size_t bytes,
- juint val1, juint val2) {}
+ // Below length is the # array elements being written
+ virtual void write_ref_array_pre(oop* dst, int length,
+ bool dest_uninitialized = false) {}
+ virtual void write_ref_array_pre(narrowOop* dst, int 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);
- void read_ref_field(void* field) {}
- void read_prim_field(HeapWord* field, size_t bytes) {}
+ // Static versions, suitable for calling from generated code;
+ // count is # array elements being written, starting with "start",
+ // which may not necessarily be HeapWord-aligned.
+ static void static_write_ref_array_pre(HeapWord* start, size_t count);
+ static void static_write_ref_array_post(HeapWord* start, size_t count);
-protected:
+ template <DecoratorSet decorators>
+ inline void write_ref_field_pre(void* addr) {}
- ModRefBarrierSet(const BarrierSet::FakeRtti& fake_rtti)
- : BarrierSet(fake_rtti.add_tag(BarrierSet::ModRef)) { }
- ~ModRefBarrierSet() { }
+ template <DecoratorSet decorators>
+ inline void write_ref_field_post(void *addr, oop new_value) {}
-public:
- void write_prim_field(HeapWord* field, size_t bytes,
- juint val1, juint val2) {}
+ // barriers used by klass_oop_store
+ void klass_update_barrier_set_pre(Klass* klass, oop* p) {}
+ void klass_update_barrier_set(Klass* klass, oop* p, oop v);
- bool has_read_ref_array_opt() { return false; }
- bool has_read_prim_array_opt() { return false; }
- bool has_write_prim_array_opt() { return false; }
+ template <DecoratorSet decorators, typename BarrierSetT>
+ class AccessBarrier: public BarrierSet::AccessBarrier<decorators> {
+ typedef BarrierSet::AccessBarrier<decorators> Basic;
- bool has_read_region_opt() { return false; }
+ public:
+ typedef Basic SuperAccessBarrier;
+ static void oop_store(void* addr, oop value);
- // These operations should assert false unless the corresponding operation
- // above returns true.
- void read_ref_array(MemRegion mr) {
- assert(false, "can't call");
- }
- void read_prim_array(MemRegion mr) {
- assert(false, "can't call");
- }
- void write_prim_array(MemRegion mr) {
- assert(false, "can't call");
- }
- void read_region(MemRegion mr) {
- assert(false, "can't call");
+ static oop oop_cas(oop new_value, void* addr, oop compare_value);
+
+ static oop oop_swap(oop new_value, void* addr);
+
+ template <typename T>
+ static bool oop_copy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
+
+ static void clone(oop src, oop dst, size_t size);
+
+ static inline void oop_store_at(oop base, ptrdiff_t offset, oop value) {
+ oop_store(Basic::field_addr(base, offset), value);
}
- // Causes all refs in "mr" to be assumed to be modified.
- virtual void invalidate(MemRegion mr) = 0;
+ static inline void oop_store_at(Klass* base, ptrdiff_t offset, oop value);
+
+ static inline oop oop_swap_at(oop new_value, oop base, ptrdiff_t offset) {
+ return oop_swap(new_value, Basic::field_addr(base, offset));
+ }
- // The caller guarantees that "mr" contains no references. (Perhaps it's
- // objects have been moved elsewhere.)
- virtual void clear(MemRegion mr) = 0;
+ static inline oop oop_cas_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
+ return oop_cas(new_value, Basic::field_addr(base, offset), compare_value);
+ }
+ };
};
template<>
-struct BarrierSet::GetName<ModRefBarrierSet> {
+struct BSTypeToName<ModRefBarrierSet> {
static const BarrierSet::Name value = BarrierSet::ModRef;
};
+template<>
+struct BSNameToType<BarrierSet::ModRef> {
+ typedef ModRefBarrierSet type;
+};
+
#endif // SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
< prev index next >