--- old/src/share/vm/gc/parallel/psPromotionManager.inline.hpp 2016-10-04 18:58:59.000000000 +0900 +++ new/src/share/vm/gc/parallel/psPromotionManager.inline.hpp 2016-10-04 18:58:59.000000000 +0900 @@ -211,7 +211,7 @@ Copy::aligned_disjoint_words((HeapWord*)o, (HeapWord*)new_obj, new_obj_size); // Now we have to CAS in the header. - if (o->cas_forward_to(new_obj, test_mark)) { + if (o->cas_forward_to(new_obj, test_mark, memory_order_relaxed)) { // We won any races, we "own" this object. assert(new_obj == o->forwardee(), "Sanity"); @@ -238,6 +238,15 @@ // we'll just push its contents push_contents(new_obj); } + + // This code must come after the CAS test, or it will print incorrect + // information. + if (log_develop_is_enabled(Trace, gc, scavenge)) { + log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", + should_scavenge(&new_obj) ? "copying" : "tenuring", + new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), + new_obj->size()) + } } else { // We lost, someone else "owns" this object guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); @@ -255,18 +264,27 @@ // don't update this before the unallocation! new_obj = o->forwardee(); + + // fields in new_obj may not be synchronized. + if (log_develop_is_enabled(Trace, gc, scavenge)) { + log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT "}", + should_scavenge(&new_obj) ? "copying" : "tenuring", + o->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj)); + } + new_obj = NULL; } } else { assert(o->is_forwarded(), "Sanity"); new_obj = o->forwardee(); + // fields in new_obj may not be synchronized. + if (log_develop_is_enabled(Trace, gc, scavenge)) { + log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT "}", + should_scavenge(&new_obj) ? "copying" : "tenuring", + o->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj)); + } + new_obj = NULL; } - // This code must come after the CAS test, or it will print incorrect - // information. - log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", - should_scavenge(&new_obj) ? "copying" : "tenuring", - new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); - return new_obj; } @@ -278,16 +296,16 @@ assert(should_scavenge(p, true), "revisiting object?"); oop o = oopDesc::load_decode_heap_oop_not_null(p); - oop new_obj = o->is_forwarded() - ? o->forwardee() - : copy_to_survivor_space(o); - - // This code must come after the CAS test, or it will print incorrect - // information. - if (log_develop_is_enabled(Trace, gc, scavenge) && o->is_forwarded()) { - log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", - "forwarding", - new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); + + if (!o->is_forwarded()) { + copy_to_survivor_space(o); + } + oop new_obj = o->forwardee(); + assert(forwardee != NULL, "forwardee should not be NULL"); + // This code must come after the CAS test, or it will print incorrect information. + if (log_develop_is_enabled(Trace, gc, scavenge)) { + log_develop_trace(gc, scavenge)("{forwarding %s " PTR_FORMAT " -> " PTR_FORMAT "}", + o->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj)); } oopDesc::encode_store_heap_oop_not_null(p, new_obj);