8166836: Elimination of clone's ArrayCopyNode may make compilation fail silently
Reviewed-by: vlivanov
This commit is contained in:
parent
7cc1fb0747
commit
a8c02b10fd
@ -439,12 +439,6 @@ Node* PhaseMacroExpand::make_arraycopy_load(ArrayCopyNode* ac, intptr_t offset,
|
|||||||
Node* adr = _igvn.transform(new AddPNode(base, base, MakeConX(offset)));
|
Node* adr = _igvn.transform(new AddPNode(base, base, MakeConX(offset)));
|
||||||
const TypePtr* adr_type = _igvn.type(base)->is_ptr()->add_offset(offset);
|
const TypePtr* adr_type = _igvn.type(base)->is_ptr()->add_offset(offset);
|
||||||
Node* m = ac->in(TypeFunc::Memory);
|
Node* m = ac->in(TypeFunc::Memory);
|
||||||
while (m->is_MergeMem()) {
|
|
||||||
m = m->as_MergeMem()->memory_at(C->get_alias_index(adr_type));
|
|
||||||
if (m->is_Proj() && m->in(0)->is_MemBar()) {
|
|
||||||
m = m->in(0)->in(TypeFunc::Memory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res = LoadNode::make(_igvn, ctl, m, adr, adr_type, type, bt, MemNode::unordered, LoadNode::Pinned);
|
res = LoadNode::make(_igvn, ctl, m, adr, adr_type, type, bt, MemNode::unordered, LoadNode::Pinned);
|
||||||
} else {
|
} else {
|
||||||
if (ac->modifies(offset, offset, &_igvn, true)) {
|
if (ac->modifies(offset, offset, &_igvn, true)) {
|
||||||
@ -978,6 +972,17 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray <Sa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void disconnect_projections(MultiNode* n, PhaseIterGVN& igvn) {
|
||||||
|
Node* ctl_proj = n->proj_out(TypeFunc::Control);
|
||||||
|
Node* mem_proj = n->proj_out(TypeFunc::Memory);
|
||||||
|
if (ctl_proj != NULL) {
|
||||||
|
igvn.replace_node(ctl_proj, n->in(0));
|
||||||
|
}
|
||||||
|
if (mem_proj != NULL) {
|
||||||
|
igvn.replace_node(mem_proj, n->in(TypeFunc::Memory));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Process users of eliminated allocation.
|
// Process users of eliminated allocation.
|
||||||
void PhaseMacroExpand::process_users_of_allocation(CallNode *alloc) {
|
void PhaseMacroExpand::process_users_of_allocation(CallNode *alloc) {
|
||||||
Node* res = alloc->result_cast();
|
Node* res = alloc->result_cast();
|
||||||
@ -1008,13 +1013,13 @@ void PhaseMacroExpand::process_users_of_allocation(CallNode *alloc) {
|
|||||||
// Disconnect ArrayCopy node
|
// Disconnect ArrayCopy node
|
||||||
ArrayCopyNode* ac = n->as_ArrayCopy();
|
ArrayCopyNode* ac = n->as_ArrayCopy();
|
||||||
assert(ac->is_clonebasic(), "unexpected array copy kind");
|
assert(ac->is_clonebasic(), "unexpected array copy kind");
|
||||||
Node* ctl_proj = ac->proj_out(TypeFunc::Control);
|
Node* membar_after = ac->proj_out(TypeFunc::Control)->unique_ctrl_out();
|
||||||
Node* mem_proj = ac->proj_out(TypeFunc::Memory);
|
disconnect_projections(ac, _igvn);
|
||||||
if (ctl_proj != NULL) {
|
assert(alloc->in(0)->is_Proj() && alloc->in(0)->in(0)->Opcode() == Op_MemBarCPUOrder, "mem barrier expected before allocation");
|
||||||
_igvn.replace_node(ctl_proj, n->in(0));
|
Node* membar_before = alloc->in(0)->in(0);
|
||||||
}
|
disconnect_projections(membar_before->as_MemBar(), _igvn);
|
||||||
if (mem_proj != NULL) {
|
if (membar_after->is_MemBar()) {
|
||||||
_igvn.replace_node(mem_proj, n->in(TypeFunc::Memory));
|
disconnect_projections(membar_after->as_MemBar(), _igvn);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
eliminate_card_mark(n);
|
eliminate_card_mark(n);
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, Red Hat, Inc. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 8166836
|
||||||
|
* @summary Elimination of clone's ArrayCopyNode may make compilation fail silently
|
||||||
|
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:CompileCommand=dontinline,TestEliminatedCloneBadMemEdge::not_inlined TestEliminatedCloneBadMemEdge
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TestEliminatedCloneBadMemEdge implements Cloneable {
|
||||||
|
|
||||||
|
int f1;
|
||||||
|
int f2;
|
||||||
|
int f3;
|
||||||
|
int f4;
|
||||||
|
int f5;
|
||||||
|
int f6;
|
||||||
|
int f7;
|
||||||
|
int f8;
|
||||||
|
int f9;
|
||||||
|
|
||||||
|
static void not_inlined() {}
|
||||||
|
|
||||||
|
static void test(TestEliminatedCloneBadMemEdge o1) throws CloneNotSupportedException {
|
||||||
|
TestEliminatedCloneBadMemEdge o2 = (TestEliminatedCloneBadMemEdge)o1.clone();
|
||||||
|
not_inlined();
|
||||||
|
o2.f1 = 0x42;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public void main(String[] args) throws CloneNotSupportedException {
|
||||||
|
TestEliminatedCloneBadMemEdge o1 = new TestEliminatedCloneBadMemEdge();
|
||||||
|
for (int i = 0; i < 20000; i++) {
|
||||||
|
test(o1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user