-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8284848: C2: Compiler blackhole arguments should be treated as global…
…ly escaping Reviewed-by: kvn Backport-of: 5629c7555f9bb779c57f45dfb071abbb1d87bb7d
- Loading branch information
Showing
6 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
test/hotspot/jtreg/compiler/c2/irTests/blackhole/BlackholeStoreStoreEATest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2022, 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 8284848 | ||
* @requires vm.compiler2.enabled | ||
* @summary Blackhole arguments are globally escaping, thus preventing advanced EA optimizations | ||
* @library /test/lib / | ||
* @run driver compiler.c2.irTests.blackhole.BlackholeStoreStoreEATest | ||
*/ | ||
|
||
package compiler.c2.irTests.blackhole; | ||
|
||
import compiler.lib.ir_framework.*; | ||
import jdk.test.lib.Asserts; | ||
|
||
public class BlackholeStoreStoreEATest { | ||
|
||
public static void main(String[] args) { | ||
TestFramework.runWithFlags( | ||
"-XX:+UnlockExperimentalVMOptions", | ||
"-XX:CompileCommand=blackhole,compiler.c2.irTests.blackhole.BlackholeStoreStoreEATest::blackhole" | ||
); | ||
} | ||
|
||
/* | ||
* Negative test is not possible: the StoreStore barrier is still in, even if we just do dontinline. | ||
* Positive test: check that blackhole keeps the StoreStore barrier in. | ||
*/ | ||
|
||
@Test | ||
@IR(counts = {IRNode.MEMBAR_STORESTORE, "1"}) | ||
static void testBlackholed() { | ||
Object o = new Object(); | ||
blackhole(o); | ||
} | ||
|
||
static void blackhole(Object o) {} | ||
|
||
@Run(test = "testBlackholed") | ||
static void runBlackholed() { | ||
testBlackholed(); | ||
} | ||
|
||
} |
87 changes: 87 additions & 0 deletions
87
test/hotspot/jtreg/compiler/c2/irTests/blackhole/BlackholeSyncEATest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) 2022, 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 8284848 | ||
* @requires vm.compiler2.enabled | ||
* @summary Blackhole arguments are globally escaping, thus preventing advanced EA optimizations | ||
* @library /test/lib / | ||
* @run driver compiler.c2.irTests.blackhole.BlackholeSyncEATest | ||
*/ | ||
|
||
package compiler.c2.irTests.blackhole; | ||
|
||
import compiler.lib.ir_framework.*; | ||
import jdk.test.lib.Asserts; | ||
|
||
public class BlackholeSyncEATest { | ||
|
||
public static void main(String[] args) { | ||
TestFramework.runWithFlags( | ||
"-XX:+UnlockExperimentalVMOptions", | ||
"-XX:CompileCommand=blackhole,compiler.c2.irTests.blackhole.BlackholeSyncEATest::blackhole", | ||
"-XX:CompileCommand=dontinline,compiler.c2.irTests.blackhole.BlackholeSyncEATest::dontinline" | ||
); | ||
} | ||
|
||
/* | ||
* Negative test: check that dontinline method still allows EA to eliminate the synchronization. | ||
*/ | ||
|
||
@Test | ||
@IR(failOn = {IRNode.FAST_LOCK, IRNode.FAST_UNLOCK}) | ||
static void testDontline() { | ||
Object o = new Object(); | ||
synchronized (o) {} | ||
dontinline(o); | ||
} | ||
|
||
static void dontinline(Object o) {} | ||
|
||
@Run(test = "testDontline") | ||
static void runDontinline() { | ||
testDontline(); | ||
} | ||
|
||
/* | ||
* Positive test: check that blackhole keeps the synchronization in. | ||
*/ | ||
|
||
@Test | ||
@IR(counts = {IRNode.FAST_LOCK, "1"}) | ||
@IR(counts = {IRNode.FAST_UNLOCK, "1"}) | ||
static void testBlackholed() { | ||
Object o = new Object(); | ||
synchronized (o) {} | ||
blackhole(o); | ||
} | ||
|
||
static void blackhole(Object o) {} | ||
|
||
@Run(test = "testBlackholed") | ||
static void runBlackholed() { | ||
testBlackholed(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31eefe5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues