8075249: Cleanup forward_to_atomic and ClaimedForwardPtr

Reviewed-by: kbarrett, brutisso
This commit is contained in:
Stefan Karlsson 2015-03-17 15:53:55 +01:00
parent 366bf9ff09
commit 28adfbf0be
5 changed files with 29 additions and 36 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -226,6 +226,8 @@ oop G1ParScanThreadState::copy_to_survivor_space(InCSetState const state,
} }
assert(obj_ptr != NULL, "when we get here, allocation should have succeeded"); 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 #ifndef PRODUCT
// Should this evacuation fail? // Should this evacuation fail?
if (_g1h->evacuation_should_fail()) { if (_g1h->evacuation_should_fail()) {

View file

@ -1122,14 +1122,6 @@ oop ParNewGeneration::real_forwardee_slow(oop obj) {
return forward_ptr; 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) { void ParNewGeneration::preserve_mark_if_necessary(oop obj, markOop m) {
if (m->must_be_preserved_for_promotion_failure(obj)) { if (m->must_be_preserved_for_promotion_failure(obj)) {
// We should really have separate per-worker stacks, rather // We should really have separate per-worker stacks, rather
@ -1204,6 +1196,7 @@ oop ParNewGeneration::copy_to_survivor_space(
} else { } else {
// Is in to-space; do copying ourselves. // Is in to-space; do copying ourselves.
Copy::aligned_disjoint_words((HeapWord*)old, (HeapWord*)new_obj, sz); 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); forward_ptr = old->forward_to_atomic(new_obj);
// Restore the mark word copied above. // Restore the mark word copied above.
new_obj->set_mark(m); new_obj->set_mark(m);

View file

@ -419,8 +419,6 @@ class ParNewGeneration: public DefNewGeneration {
} }
static oop real_forwardee(oop obj); static oop real_forwardee(oop obj);
DEBUG_ONLY(static bool is_legal_forward_ptr(oop p);)
}; };
#endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARNEWGENERATION_HPP #endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARNEWGENERATION_HPP

View file

@ -630,6 +630,30 @@ inline bool oopDesc::cas_forward_to(oop p, markOop compare) {
return cas_set_mark(m, compare) == compare; 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. // Note that the forwardee is not the same thing as the displaced_mark.
// The forwardee is used when copying during scavenge and mark-sweep. // The forwardee is used when copying during scavenge and mark-sweep.
// It does need to clear the low two locking- and GC-related bits. // It does need to clear the low two locking- and GC-related bits.

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -54,28 +54,4 @@ inline void oopDesc::follow_contents(ParCompactionManager* cm) {
klass()->oop_follow_contents(cm, this); 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 #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP