Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperIRL committed Jul 7, 2020
2 parents 8170244 + 653af30 commit e584237
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 26 deletions.
24 changes: 24 additions & 0 deletions src/hotspot/share/opto/cfgnode.cpp
Expand Up @@ -1334,6 +1334,30 @@ Node* PhiNode::Identity(PhaseGVN* phase) {
if (id != NULL) return id;
}

// Looking for phis with identical inputs. If we find one that has
// type TypePtr::BOTTOM, replace the current phi with the bottom phi.
if (phase->is_IterGVN() && type() == Type::MEMORY && adr_type() !=
TypePtr::BOTTOM && !adr_type()->is_known_instance()) {
uint phi_len = req();
Node* phi_reg = region();
for (DUIterator_Fast imax, i = phi_reg->fast_outs(imax); i < imax; i++) {
Node* u = phi_reg->fast_out(i);
if (u->is_Phi() && u->as_Phi()->type() == Type::MEMORY &&
u->adr_type() == TypePtr::BOTTOM && u->in(0) == phi_reg &&
u->req() == phi_len) {
for (uint j = 1; j < phi_len; j++) {
if (in(j) != u->in(j)) {
u = NULL;
break;
}
}
if (u != NULL) {
return u;
}
}
}
}

return this; // No identity
}

Expand Down
18 changes: 0 additions & 18 deletions src/hotspot/share/opto/memnode.cpp
Expand Up @@ -4601,24 +4601,6 @@ Node *MergeMemNode::Ideal(PhaseGVN *phase, bool can_reshape) {
}
// else preceding memory was not a MergeMem

// replace equivalent phis (unfortunately, they do not GVN together)
if (new_mem != NULL && new_mem != new_base &&
new_mem->req() == phi_len && new_mem->in(0) == phi_reg) {
if (new_mem->is_Phi()) {
PhiNode* phi_mem = new_mem->as_Phi();
for (uint i = 1; i < phi_len; i++) {
if (phi_base->in(i) != phi_mem->in(i)) {
phi_mem = NULL;
break;
}
}
if (phi_mem != NULL) {
// equivalent phi nodes; revert to the def
new_mem = new_base;
}
}
}

// maybe store down a new value
Node* new_in = new_mem;
if (new_in == new_base) new_in = empty_mem;
Expand Down
Expand Up @@ -231,10 +231,11 @@ private void initClasspath(Map<String, ? super Object> params)
if (inputDir == null) {
classPath = Collections.emptyList();
} else {
try (Stream<Path> walk = Files.walk(inputDir, 1)) {
try (Stream<Path> walk = Files.walk(inputDir, Integer.MAX_VALUE)) {
Set<Path> jars = walk.filter(Files::isRegularFile)
.filter(file -> file.toString().endsWith(".jar"))
.map(Path::getFileName)
.map(p -> inputDir.toAbsolutePath()
.relativize(p.toAbsolutePath()))
.collect(Collectors.toSet());
jars.remove(mainJarName);
classPath = jars.stream().sorted().collect(Collectors.toList());
Expand Down
77 changes: 77 additions & 0 deletions test/hotspot/jtreg/compiler/c2/TestReplaceEquivPhis.java
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2020, Huawei Technologies Co. Ltd. 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 8243670
* @summary Unexpected test result caused by C2 MergeMemNode::Ideal
*
* @run main/othervm -Xcomp -XX:-SplitIfBlocks
* -XX:CompileOnly=compiler.c2.TestReplaceEquivPhis::test
* -XX:-BackgroundCompilation compiler.c2.TestReplaceEquivPhis
*/

package compiler.c2;

public class TestReplaceEquivPhis {

public static final int N = 400;
public static volatile int instanceCount = 0;
public int iFld = 0;
public static int iArrFld[] = new int[N];

public int test() {
int v = 0;
boolean bArr[] = new boolean[N];

for (int i = 1; i < 344; i++) {
iFld = i;
for (int j = 2; j <177 ; j++) {
v = iFld;
iFld = TestReplaceEquivPhis.instanceCount;
TestReplaceEquivPhis.iArrFld[i] = 0;
iFld += TestReplaceEquivPhis.instanceCount;
TestReplaceEquivPhis.iArrFld[i] = 0;
bArr[j] = false;
TestReplaceEquivPhis.instanceCount = 1;

for (int k = 1; k < 3; k++) {
// do nothing
}
}
}
return v;
}

public static void main(String[] args) {
TestReplaceEquivPhis obj = new TestReplaceEquivPhis();
for (int i = 0; i < 5; i++) {
int result = obj.test();
if (result != 2) {
throw new RuntimeException("Test failed.");
}
}
System.out.println("Test passed.");
}

}
Expand Up @@ -72,7 +72,7 @@

/*
* @test
* @requires vm.gc.Z
* @requires vm.gc.Z & !vm.graal.enabled
* @summary Test of diagnostic command GC.heap_dump with gzipped output (Z GC)
* @library /test/lib
* @modules java.base/jdk.internal.misc
Expand All @@ -84,7 +84,7 @@

/*
* @test
* @requires vm.gc.Shenandoah
* @requires vm.gc.Shenandoah & !vm.graal.enabled
* @summary Test of diagnostic command GC.heap_dump with gzipped output (Shenandoah GC)
* @library /test/lib
* @modules java.base/jdk.internal.misc
Expand All @@ -96,7 +96,7 @@

/*
* @test
* @requires vm.gc.Epsilon
* @requires vm.gc.Epsilon & !vm.graal.enabled
* @summary Test of diagnostic command GC.heap_dump with gzipped output (Epsilon GC)
* @library /test/lib
* @modules java.base/jdk.internal.misc
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/TEST.ROOT
Expand Up @@ -24,7 +24,7 @@ javax/management sun/awt sun/java2d javax/xml/jaxp/testng/validation java/lang/P
# Tests that cannot run concurrently
exclusiveAccess.dirs=java/math/BigInteger/largeMemory \
java/rmi/Naming java/util/prefs sun/management/jmxremote \
sun/tools/jstatd sun/tools/jcmd sun/tools/jhsdb sun/tools/jhsdb/heapconfig \
sun/tools/jstatd sun/tools/jcmd \
sun/tools/jinfo sun/tools/jmap sun/tools/jps sun/tools/jstack sun/tools/jstat \
com/sun/tools/attach sun/security/mscapi java/util/stream java/util/Arrays/largeMemory \
java/util/BitSet/stream javax/rmi
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/security/SecureRandom/ThreadSafe.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. 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
Expand Down Expand Up @@ -87,7 +87,7 @@ protected void engineNextBytes(byte[] bytes) {
}
inCall = true;
try {
Thread.sleep(100);
Thread.sleep(500);
} catch (Exception e) {
// OK
}
Expand Down

0 comments on commit e584237

Please sign in to comment.