# HG changeset patch # User stefank # Date 1426521911 -3600 # Mon Mar 16 17:05:11 2015 +0100 # Node ID d3924995db63cb9b9e79eb1c8df1915244e8f62e # Parent 077aecb1cbee43ea50b2fabf72f58f86a4874186 imported patch moveClaimForward diff --git a/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp --- a/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp +++ b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.cpp @@ -226,6 +226,8 @@ } assert(obj_ptr != NULL, "when we get here, allocation should have succeeded"); + assert(_g1h->is_in_reserved(obj_ptr), "Allocated memory should be in the heap"); + #ifndef PRODUCT // Should this evacuation fail? if (_g1h->evacuation_should_fail()) { diff --git a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -1126,14 +1126,6 @@ return forward_ptr; } -#ifdef ASSERT -bool ParNewGeneration::is_legal_forward_ptr(oop p) { - return - (p == ClaimedForwardPtr) - || Universe::heap()->is_in_reserved(p); -} -#endif - void ParNewGeneration::preserve_mark_if_necessary(oop obj, markOop m) { if (m->must_be_preserved_for_promotion_failure(obj)) { // We should really have separate per-worker stacks, rather @@ -1208,6 +1200,7 @@ } else { // Is in to-space; do copying ourselves. Copy::aligned_disjoint_words((HeapWord*)old, (HeapWord*)new_obj, sz); + assert(Universe::heap()->is_in_reserved(new_obj), "illegal forwarding pointer value."); forward_ptr = old->forward_to_atomic(new_obj); // Restore the mark word copied above. new_obj->set_mark(m); diff --git a/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp b/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.hpp @@ -419,8 +419,6 @@ } static oop real_forwardee(oop obj); - - DEBUG_ONLY(static bool is_legal_forward_ptr(oop p);) }; #endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARNEWGENERATION_HPP diff --git a/src/share/vm/oops/oop.inline.hpp b/src/share/vm/oops/oop.inline.hpp --- a/src/share/vm/oops/oop.inline.hpp +++ b/src/share/vm/oops/oop.inline.hpp @@ -630,6 +630,30 @@ return cas_set_mark(m, compare) == compare; } +#if INCLUDE_ALL_GCS +inline oop oopDesc::forward_to_atomic(oop p) { + markOop oldMark = mark(); + markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p); + markOop curMark; + + assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable"); + assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this."); + + while (!oldMark->is_marked()) { + curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark); + assert(is_forwarded(), "object should have been forwarded"); + if (curMark == oldMark) { + return NULL; + } + // If the CAS was unsuccessful then curMark->is_marked() + // should return true as another thread has CAS'd in another + // forwarding pointer. + oldMark = curMark; + } + return forwardee(); +} +#endif + // Note that the forwardee is not the same thing as the displaced_mark. // The forwardee is used when copying during scavenge and mark-sweep. // It does need to clear the low two locking- and GC-related bits. diff --git a/src/share/vm/oops/oop.pcgc.inline.hpp b/src/share/vm/oops/oop.pcgc.inline.hpp --- a/src/share/vm/oops/oop.pcgc.inline.hpp +++ b/src/share/vm/oops/oop.pcgc.inline.hpp @@ -54,28 +54,4 @@ klass()->oop_follow_contents(cm, this); } -inline oop oopDesc::forward_to_atomic(oop p) { - assert(ParNewGeneration::is_legal_forward_ptr(p), - "illegal forwarding pointer value."); - markOop oldMark = mark(); - markOop forwardPtrMark = markOopDesc::encode_pointer_as_mark(p); - markOop curMark; - - assert(forwardPtrMark->decode_pointer() == p, "encoding must be reversable"); - assert(sizeof(markOop) == sizeof(intptr_t), "CAS below requires this."); - - while (!oldMark->is_marked()) { - curMark = (markOop)Atomic::cmpxchg_ptr(forwardPtrMark, &_mark, oldMark); - assert(is_forwarded(), "object should have been forwarded"); - if (curMark == oldMark) { - return NULL; - } - // If the CAS was unsuccessful then curMark->is_marked() - // should return true as another thread has CAS'd in another - // forwarding pointer. - oldMark = curMark; - } - return forwardee(); -} - #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP