< prev index next >

src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp

Print this page
rev 13055 : Implement barriers for maintaining connection matrix.

*** 26,35 **** --- 26,36 ---- #include "gc/shared/cmBitMap.inline.hpp" #include "gc/shared/threadLocalAllocBuffer.inline.hpp" #include "gc/shenandoah/brooksPointer.inline.hpp" #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp" + #include "gc/shenandoah/shenandoahConnectionMatrix.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" #include "gc/shenandoah/shenandoahHeapRegionSet.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp"
*** 174,183 **** --- 175,189 ---- } #endif assert(is_in(heap_oop), "only ever call this on objects in the heap"); if (in_collection_set(heap_oop)) { oop forwarded_oop = ShenandoahBarrierSet::resolve_oop_static_not_null(heap_oop); // read brooks ptr + if (oopDesc::unsafe_equals(forwarded_oop, heap_oop)) { + // E.g. during evacuation. + return forwarded_oop; + } + assert(! oopDesc::unsafe_equals(forwarded_oop, heap_oop) || is_full_gc_in_progress(), "expect forwarded object"); log_develop_trace(gc)("Updating old ref: "PTR_FORMAT" pointing to "PTR_FORMAT" to new ref: "PTR_FORMAT, p2i(p), p2i(heap_oop), p2i(forwarded_oop));
*** 223,232 **** --- 229,272 ---- } else { return NULL; } } + class UpdateMatrixClosure : public ExtendedOopClosure { + + private: + uint _from_idx; + ShenandoahHeap* _heap; + ShenandoahConnectionMatrix* _matrix; + + template <class T> + inline void do_oop_nv(T* o) { + T t = oopDesc::load_heap_oop(o); + if (! oopDesc::is_null(t)) { + oop obj = oopDesc::decode_heap_oop_not_null(t); + uint to_idx = _heap->heap_region_index_containing(obj); + _matrix->set_connected(_from_idx, to_idx, true); + } + } + + public: + + UpdateMatrixClosure(uint from_idx) : + _from_idx(from_idx), + _heap(ShenandoahHeap::heap()), + _matrix(ShenandoahHeap::heap()->connection_matrix()) { + } + + void do_oop(oop* o) { + do_oop_nv(o); + } + + void do_oop(narrowOop* o) { + do_oop_nv(o); + } + }; + inline void ShenandoahHeap::copy_object(oop p, HeapWord* s, size_t words) { assert(s != NULL, "allocation of brooks pointer must not fail"); HeapWord* copy = s + BrooksPointer::word_size(); guarantee(copy != NULL, "allocation of copy object must not fail");
*** 308,317 **** --- 348,361 ---- #ifdef ASSERT assert(return_val->is_oop(), "expect oop"); assert(p->klass() == return_val->klass(), "Should have the same class p: "PTR_FORMAT", copy: "PTR_FORMAT, p2i((HeapWord*) p), p2i((HeapWord*) copy)); + + uint from_idx = heap_region_index_containing(copy_val); + UpdateMatrixClosure cl(from_idx); + copy_val->oop_iterate(&cl); #endif } else { if (alloc_from_gclab) { thread->gclab().rollback(required); }
< prev index next >