--- old/src/hotspot/share/gc/z/zBarrier.cpp 2019-12-09 11:24:58.559820324 +0100 +++ new/src/hotspot/share/gc/z/zBarrier.cpp 2019-12-09 11:24:57.324779623 +0100 @@ -84,6 +84,17 @@ ZHeap::heap()->mark_object(good_addr); } + if (finalizable) { + // Make the oop finalizable marked/good, instead of normal marked/good. + // This is needed because an object might first becomes finalizable + // marked by the GC, and then loaded by a mutator thread. In this case, + // the mutator thread must be able to tell that the object needs to be + // strongly marked. The finalizable bit in the oop exists to make sure + // that a load of a finalizable marked oop will fall into the barrier + // slow path so that we can mark the object as strongly reachable. + return ZAddress::finalizable_good(good_addr); + } + return good_addr; } @@ -166,25 +177,17 @@ // Mark barrier // uintptr_t ZBarrier::mark_barrier_on_oop_slow_path(uintptr_t addr) { + assert(during_mark(), "Invalid phase"); + + // Mark return mark(addr); } uintptr_t ZBarrier::mark_barrier_on_finalizable_oop_slow_path(uintptr_t addr) { - const uintptr_t good_addr = mark(addr); - if (ZAddress::is_good(addr)) { - // If the oop was already strongly marked/good, then we do - // not want to downgrade it to finalizable marked/good. - return good_addr; - } + assert(during_mark(), "Invalid phase"); - // Make the oop finalizable marked/good, instead of normal marked/good. - // This is needed because an object might first becomes finalizable - // marked by the GC, and then loaded by a mutator thread. In this case, - // the mutator thread must be able to tell that the object needs to be - // strongly marked. The finalizable bit in the oop exists to make sure - // that a load of a finalizable marked oop will fall into the barrier - // slow path so that we can mark the object as strongly reachable. - return ZAddress::finalizable_good(good_addr); + // Mark + return mark(addr); } uintptr_t ZBarrier::mark_barrier_on_root_oop_slow_path(uintptr_t addr) {