2015-10-08 22:49:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015, 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
|
|
|
|
* 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 8136421
|
2016-06-17 10:07:27 +00:00
|
|
|
* @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
|
2015-10-29 19:04:04 +00:00
|
|
|
* @library / /testlibrary /test/lib
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
* @library ../common/patches
|
2016-05-01 09:47:00 +00:00
|
|
|
* @modules java.base/jdk.internal.misc
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
* @modules java.base/jdk.internal.org.objectweb.asm
|
|
|
|
* java.base/jdk.internal.org.objectweb.asm.tree
|
|
|
|
* jdk.vm.ci/jdk.vm.ci.hotspot
|
|
|
|
* jdk.vm.ci/jdk.vm.ci.code
|
|
|
|
* jdk.vm.ci/jdk.vm.ci.meta
|
2016-07-08 18:26:02 +00:00
|
|
|
*
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
|
|
|
|
* @build compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
|
|
|
|
* @build sun.hotspot.WhiteBox
|
2016-07-08 18:26:02 +00:00
|
|
|
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
|
|
|
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
2016-05-16 13:54:09 +00:00
|
|
|
* @run main/othervm -Xmixed -Xbootclasspath/a:.
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
|
|
|
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
|
|
|
|
* -XX:CompileCommand=exclude,*::check
|
|
|
|
* -XX:+DoEscapeAnalysis
|
|
|
|
* -Xbatch
|
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
|
|
|
|
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
|
2016-05-16 13:54:09 +00:00
|
|
|
* @run main/othervm -Xmixed -Xbootclasspath/a:.
|
8142968: Module System implementation
Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282
Co-authored-by: Alex Buckley <alex.buckley@oracle.com>
Co-authored-by: Jonathan Gibbons <jonathan.gibbons@oracle.com>
Co-authored-by: Karen Kinnear <karen.kinnear@oracle.com>
Co-authored-by: Mandy Chung <mandy.chung@oracle.com>
Co-authored-by: Mark Reinhold <mark.reinhold@oracle.com>
Co-authored-by: Harold Seigel <harold.seigel@oracle.com>
Co-authored-by: Lois Foltan <lois.foltan@oracle.com>
Co-authored-by: Calvin Cheung <calvin.cheung@oracle.com>
Co-authored-by: Christian Tornqvist <christian.tornqvist@oracle.com>
Co-authored-by: Erik Joelsson <erik.joelsson@oracle.com>
Co-authored-by: George Triantafillou <george.triantafillou@oracle.com>
Co-authored-by: Igor Ignatyev <igor.ignatyev@oracle.com>
Co-authored-by: Ioi Lam <ioi.lam@oracle.com>
Co-authored-by: James Laskey <james.laskey@oracle.com>
Co-authored-by: Jean-Francois Denise <jean-francois.denise@oracle.com>
Co-authored-by: Jiangli Zhou <jiangli.zhou@oracle.com>
Co-authored-by: Markus Gronlund <markus.gronlund@oracle.com>
Co-authored-by: Serguei Spitsyn <serguei.spitsyn@oracle.com>
Co-authored-by: Staffan Larsen <staffan.larsen@oracle.com>
Co-authored-by: Sundararajan Athijegannathan <sundararajan.athijegannathan@oracle.com>
Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen
2016-03-17 19:04:01 +00:00
|
|
|
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
|
|
|
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
|
|
|
|
* -XX:CompileCommand=exclude,*::check
|
|
|
|
* -XX:+DoEscapeAnalysis
|
|
|
|
* -Xbatch
|
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
|
|
|
|
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
|
2015-10-08 22:49:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
package compiler.jvmci.compilerToVM;
|
|
|
|
|
2015-11-04 17:23:23 +00:00
|
|
|
import compiler.jvmci.common.CTVMUtilities;
|
|
|
|
import compiler.testlibrary.CompilerUtils;
|
2016-05-16 13:54:09 +00:00
|
|
|
import compiler.whitebox.CompilerWhiteBoxTest;
|
2016-07-12 15:24:48 +00:00
|
|
|
import jdk.test.lib.Asserts;
|
|
|
|
import jdk.vm.ci.hotspot.CompilerToVMHelper;
|
|
|
|
import jdk.vm.ci.hotspot.HotSpotStackFrameReference;
|
|
|
|
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
2015-10-08 22:49:30 +00:00
|
|
|
import sun.hotspot.WhiteBox;
|
|
|
|
|
2016-07-12 15:24:48 +00:00
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
2015-10-08 22:49:30 +00:00
|
|
|
public class MaterializeVirtualObjectTest {
|
2016-05-16 13:54:09 +00:00
|
|
|
private static final WhiteBox WB;
|
2015-10-08 22:49:30 +00:00
|
|
|
private static final Method METHOD;
|
2015-11-04 17:23:23 +00:00
|
|
|
private static final ResolvedJavaMethod RESOLVED_METHOD;
|
2016-05-16 13:54:09 +00:00
|
|
|
private static final boolean INVALIDATE;
|
2016-05-23 14:33:39 +00:00
|
|
|
private static final int COMPILE_THRESHOLD;
|
2015-10-08 22:49:30 +00:00
|
|
|
|
|
|
|
static {
|
2016-05-16 13:54:09 +00:00
|
|
|
WB = WhiteBox.getWhiteBox();
|
2015-10-08 22:49:30 +00:00
|
|
|
try {
|
|
|
|
METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod(
|
2016-05-16 13:54:09 +00:00
|
|
|
"testFrame", String.class, int.class);
|
2015-10-08 22:49:30 +00:00
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
throw new Error("Can't get executable for test method", e);
|
|
|
|
}
|
|
|
|
RESOLVED_METHOD = CTVMUtilities.getResolvedMethod(METHOD);
|
2016-05-16 13:54:09 +00:00
|
|
|
INVALIDATE = Boolean.getBoolean(
|
2016-05-23 14:33:39 +00:00
|
|
|
"compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate");
|
|
|
|
COMPILE_THRESHOLD = WB.getBooleanVMFlag("TieredCompilation")
|
|
|
|
? CompilerWhiteBoxTest.THRESHOLD
|
|
|
|
: CompilerWhiteBoxTest.THRESHOLD * 2;
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
2015-10-14 23:46:51 +00:00
|
|
|
public static void main(String[] args) {
|
|
|
|
int levels[] = CompilerUtils.getAvailableCompilationLevels();
|
|
|
|
// we need compilation level 4 to use EscapeAnalysis
|
|
|
|
if (levels.length < 1 || levels[levels.length - 1] != 4) {
|
|
|
|
System.out.println("INFO: Test needs compilation level 4 to"
|
|
|
|
+ " be available. Skipping.");
|
|
|
|
} else {
|
|
|
|
new MaterializeVirtualObjectTest().test();
|
|
|
|
}
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
2015-10-14 23:46:51 +00:00
|
|
|
private static String getName() {
|
|
|
|
return "CASE: invalidate=" + INVALIDATE;
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void test() {
|
2015-10-14 23:46:51 +00:00
|
|
|
System.out.println(getName());
|
|
|
|
Asserts.assertFalse(WB.isMethodCompiled(METHOD), getName()
|
|
|
|
+ " : method unexpectedly compiled");
|
2016-05-16 13:54:09 +00:00
|
|
|
/* need to trigger compilation by multiple method invocations
|
|
|
|
in order to have method profile data to be gathered */
|
|
|
|
for (int i = 0; i < COMPILE_THRESHOLD; i++) {
|
|
|
|
testFrame("someString", i);
|
|
|
|
}
|
2015-10-14 23:46:51 +00:00
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName()
|
|
|
|
+ "Method unexpectedly not compiled");
|
2016-05-23 14:33:39 +00:00
|
|
|
testFrame("someString", COMPILE_THRESHOLD);
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 13:54:09 +00:00
|
|
|
private void testFrame(String str, int iteration) {
|
2015-10-08 22:49:30 +00:00
|
|
|
Helper helper = new Helper(str);
|
2016-05-16 13:54:09 +00:00
|
|
|
check(iteration);
|
2015-10-08 22:49:30 +00:00
|
|
|
Asserts.assertTrue((helper.string != null) && (this != null)
|
2015-10-14 23:46:51 +00:00
|
|
|
&& (helper != null), getName() + " : some locals are null");
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 13:54:09 +00:00
|
|
|
private void check(int iteration) {
|
2015-10-08 22:49:30 +00:00
|
|
|
// Materialize virtual objects on last invocation
|
2016-05-23 14:33:39 +00:00
|
|
|
if (iteration == COMPILE_THRESHOLD) {
|
2015-10-08 22:49:30 +00:00
|
|
|
HotSpotStackFrameReference hsFrame = CompilerToVMHelper
|
|
|
|
.getNextStackFrame(/* topmost frame */ null,
|
2015-11-04 17:23:23 +00:00
|
|
|
new ResolvedJavaMethod[]{
|
2015-10-08 22:49:30 +00:00
|
|
|
RESOLVED_METHOD}, /* don't skip any */ 0);
|
2015-10-14 23:46:51 +00:00
|
|
|
Asserts.assertNotNull(hsFrame, getName() + " : got null frame");
|
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(METHOD), getName()
|
|
|
|
+ "Test method should be compiled");
|
|
|
|
Asserts.assertTrue(hsFrame.hasVirtualObjects(), getName()
|
|
|
|
+ ": has no virtual object before materialization");
|
|
|
|
CompilerToVMHelper.materializeVirtualObjects(hsFrame, INVALIDATE);
|
|
|
|
Asserts.assertFalse(hsFrame.hasVirtualObjects(), getName()
|
|
|
|
+ " : has virtual object after materialization");
|
|
|
|
Asserts.assertEQ(WB.isMethodCompiled(METHOD), !INVALIDATE, getName()
|
|
|
|
+ " : unexpected compiled status");
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class Helper {
|
|
|
|
public String string;
|
|
|
|
|
|
|
|
public Helper(String s) {
|
|
|
|
this.string = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|