--- old/src/share/vm/gc/parallel/psPromotionManager.inline.hpp 2016-10-03 22:57:56.000000000 +0900 +++ new/src/share/vm/gc/parallel/psPromotionManager.inline.hpp 2016-10-03 22:57:56.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,13 @@ // we'll just push its contents push_contents(new_obj); } + + // 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()); } else { // We lost, someone else "owns" this object guarantee(o->is_forwarded(), "Object must be forwarded if the cas failed."); @@ -255,18 +262,21 @@ // don't update this before the unallocation! new_obj = o->forwardee(); + + // fields in new_obj may not be synchronized. + 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)); } } else { assert(o->is_forwarded(), "Sanity"); new_obj = o->forwardee(); + // fields in new_obj may not be synchronized. + 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)); } - // 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 +288,26 @@ 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()); + oop new_obj; + + if (o->is_forwarded()) { + new_obj = o->forwardee(); + // fields in new_obj may not be synchronized. + if (log_develop_is_enabled(Trace, gc, scavenge) && o->is_forwarded()) { + log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT "}", + "forwarding", + o->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj)); + } + } else { + new_obj = 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()); + } } oopDesc::encode_store_heap_oop_not_null(p, new_obj);