--- old/src/hotspot/share/opto/valuetypenode.cpp 2020-02-21 02:14:43.127730558 -0800 +++ new/src/hotspot/share/opto/valuetypenode.cpp 2020-02-21 02:14:42.685265655 -0800 @@ -399,6 +399,7 @@ // Do not let stores that initialize this buffer be reordered with a subsequent // store that would make this buffer accessible by other threads. + // FIXME: coordinate with ready_to_publish(kit, alloc_oop) AllocateNode* alloc = AllocateNode::Ideal_allocation(alloc_oop, &kit->gvn()); assert(alloc != NULL, "must have an allocation node"); kit->insert_mem_bar(Op_MemBarStoreStore, alloc->proj_out_or_null(AllocateNode::RawAddress)); @@ -627,6 +628,7 @@ Node* mark = kit->make_load(NULL, mark_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered); mark = kit->gvn().transform(new AndXNode(mark, kit->MakeConX(~markWord::larval_mask_in_place))); kit->store_to_memory(kit->control(), mark_addr, mark, TypeX_X->basic_type(), kit->gvn().type(mark_addr)->is_ptr(), MemNode::unordered); + ready_to_publish(kit, obj); // Do not let stores that initialize this buffer be reordered with a subsequent // store that would make this buffer accessible by other threads. @@ -641,6 +643,17 @@ return res; } +void ValueTypeBaseNode::ready_to_publish(GraphKit* kit, Node* base) const { + // Do not let stores that initialize this buffer be reordered with + // a subsequent store that would make it accessible by other threads. + // Required for correct non-flat array element publication. + // (See jtreg test ValueTearing.java.) + Node* raw_address_proj = NULL; //FIXME + kit->insert_mem_bar(Op_MemBarStoreStore, raw_address_proj); + // Fails to prevent array element tearing: + //kit->insert_mem_bar_volatile(Op_MemBarStoreStore, Compile::AliasIdxRaw, raw_address_proj); +} + Node* ValueTypeNode::is_loaded(PhaseGVN* phase, ciValueKlass* vk, Node* base, int holder_offset) { if (vk == NULL) { vk = value_klass();