--- old/src/hotspot/share/opto/memnode.cpp 2018-06-08 19:45:33.128678566 +0200 +++ new/src/hotspot/share/opto/memnode.cpp 2018-06-08 19:45:32.857666808 +0200 @@ -44,7 +44,11 @@ #include "opto/regmask.hpp" #include "utilities/align.hpp" #include "utilities/copy.hpp" +#include "utilities/macros.hpp" #include "utilities/vmError.hpp" +#if INCLUDE_ZGC +#include "gc/z/c2/zBarrierSetC2.hpp" +#endif // Portions of code courtesy of Clifford Click @@ -891,6 +895,14 @@ // a load node that reads from the source array so we may be able to // optimize out the ArrayCopy node later. Node* LoadNode::can_see_arraycopy_value(Node* st, PhaseGVN* phase) const { +#if INCLUDE_ZGC + if (UseZGC) { + if (bottom_type()->make_oopptr() != NULL) { + return NULL; + } + } +#endif + Node* ld_adr = in(MemNode::Address); intptr_t ld_off = 0; AllocateNode* ld_alloc = AllocateNode::Ideal_allocation(ld_adr, phase, ld_off); @@ -1574,7 +1586,7 @@ // Is there a dominating load that loads the same value? Leave // anything that is not a load of a field/array element (like // barriers etc.) alone - if (in(0) != NULL && adr_type() != TypeRawPtr::BOTTOM && can_reshape) { + if (in(0) != NULL && !adr_type()->isa_rawptr() && can_reshape) { for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) { Node *use = mem->fast_out(i); if (use != this && @@ -2968,6 +2980,16 @@ return NULL; } +#if INCLUDE_ZGC + if (UseZGC) { + if (req() == (Precedent+1) && in(MemBarNode::Precedent)->in(0) != NULL && in(MemBarNode::Precedent)->in(0)->is_LoadBarrier()) { + Node* load_node = in(MemBarNode::Precedent)->in(0)->in(LoadBarrierNode::Oop); + set_req(MemBarNode::Precedent, load_node); + return this; + } + } +#endif + bool progress = false; // Eliminate volatile MemBars for scalar replaced objects. if (can_reshape && req() == (Precedent+1)) {