2015-10-08 22:49:30 +00:00
|
|
|
/*
|
2022-07-08 15:55:14 +00:00
|
|
|
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
2015-10-08 22:49:30 +00:00
|
|
|
* 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
|
2018-01-31 00:48:53 +00:00
|
|
|
*
|
2019-06-07 20:57:08 +00:00
|
|
|
* @requires vm.jvmci & vm.compMode == "Xmixed"
|
2018-01-31 00:48:53 +00:00
|
|
|
* @requires vm.opt.final.EliminateAllocations == true
|
|
|
|
*
|
|
|
|
* @comment no "-Xcomp -XX:-TieredCompilation" combination allowed until JDK-8140018 is resolved
|
2019-06-07 20:57:08 +00:00
|
|
|
* @requires vm.opt.TieredCompilation == null | vm.opt.TieredCompilation == true
|
2018-01-31 00:48:53 +00:00
|
|
|
*
|
2016-08-19 14:06:30 +00:00
|
|
|
* @library / /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
|
2017-02-16 23:46:09 +00:00
|
|
|
* jdk.internal.vm.ci/jdk.vm.ci.hotspot
|
|
|
|
* jdk.internal.vm.ci/jdk.vm.ci.code
|
2018-03-08 03:32:54 +00:00
|
|
|
* jdk.internal.vm.ci/jdk.vm.ci.code.stack
|
2017-02-16 23:46:09 +00:00
|
|
|
* jdk.internal.vm.ci/jdk.vm.ci.meta
|
2016-07-08 18:26:02 +00:00
|
|
|
*
|
2022-07-08 15:55:14 +00:00
|
|
|
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper jdk.test.whitebox.WhiteBox
|
|
|
|
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
|
2019-06-07 20:57:08 +00:00
|
|
|
* @run main/othervm -Xbatch -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
|
2017-02-15 14:40:44 +00:00
|
|
|
* -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
|
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
|
2018-08-31 09:43:06 +00:00
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
|
2016-07-20 16:29:10 +00:00
|
|
|
* -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
|
2017-02-15 14:40:44 +00:00
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true
|
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
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
|
|
|
|
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
|
2019-06-07 20:57:08 +00:00
|
|
|
* @run main/othervm -Xbatch -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
|
2017-02-15 14:40:44 +00:00
|
|
|
* -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
|
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
|
2018-08-31 09:43:06 +00:00
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
|
2016-07-20 16:29:10 +00:00
|
|
|
* -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
|
2017-02-15 14:40:44 +00:00
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false
|
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
|
|
|
|
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
|
2019-06-07 20:57:08 +00:00
|
|
|
* @run main/othervm -Xbatch -Xbootclasspath/a:.
|
2017-02-15 14:40:44 +00:00
|
|
|
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
|
|
|
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
|
|
|
|
* -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
|
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
|
2018-08-31 09:43:06 +00:00
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
|
2017-02-15 14:40:44 +00:00
|
|
|
* -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
|
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true
|
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
|
|
|
|
* compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
|
2019-06-07 20:57:08 +00:00
|
|
|
* @run main/othervm -Xbatch -Xbootclasspath/a:.
|
2017-02-15 14:40:44 +00:00
|
|
|
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
|
|
|
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
|
|
|
|
* -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
|
|
|
|
* -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
|
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
|
2018-08-31 09:43:06 +00:00
|
|
|
* -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
|
2017-02-15 14:40:44 +00:00
|
|
|
* -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
|
|
|
|
* -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false
|
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
|
|
|
* -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;
|
2018-03-08 03:32:54 +00:00
|
|
|
import jdk.vm.ci.code.stack.InspectedFrame;
|
2016-07-12 15:24:48 +00:00
|
|
|
import jdk.vm.ci.hotspot.CompilerToVMHelper;
|
|
|
|
import jdk.vm.ci.hotspot.HotSpotStackFrameReference;
|
|
|
|
import jdk.vm.ci.meta.ResolvedJavaMethod;
|
2018-08-02 21:40:55 +00:00
|
|
|
import jtreg.SkippedException;
|
2022-07-08 15:55:14 +00:00
|
|
|
import jdk.test.whitebox.WhiteBox;
|
2015-10-08 22:49:30 +00:00
|
|
|
|
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;
|
|
|
|
private static final boolean INVALIDATE;
|
2016-05-23 14:33:39 +00:00
|
|
|
private static final int COMPILE_THRESHOLD;
|
2017-02-15 14:40:44 +00:00
|
|
|
private static final Method MATERIALIZED_METHOD;
|
|
|
|
private static final Method NOT_MATERIALIZED_METHOD;
|
2018-08-31 09:43:06 +00:00
|
|
|
private static final Method FRAME3_METHOD;
|
2017-02-15 14:40:44 +00:00
|
|
|
private static final ResolvedJavaMethod MATERIALIZED_RESOLVED;
|
|
|
|
private static final ResolvedJavaMethod NOT_MATERIALIZED_RESOLVED;
|
2018-08-31 09:43:06 +00:00
|
|
|
private static final ResolvedJavaMethod FRAME2_RESOLVED;
|
|
|
|
private static final ResolvedJavaMethod FRAME3_RESOLVED;
|
2017-02-15 14:40:44 +00:00
|
|
|
private static final boolean MATERIALIZE_FIRST;
|
2015-10-08 22:49:30 +00:00
|
|
|
|
|
|
|
static {
|
2017-02-15 14:40:44 +00:00
|
|
|
Method method1;
|
|
|
|
Method method2;
|
2016-05-16 13:54:09 +00:00
|
|
|
WB = WhiteBox.getWhiteBox();
|
2015-10-08 22:49:30 +00:00
|
|
|
try {
|
2017-02-15 14:40:44 +00:00
|
|
|
method1 = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame",
|
|
|
|
String.class, int.class);
|
|
|
|
method2 = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame2",
|
|
|
|
String.class, int.class);
|
2018-08-31 09:43:06 +00:00
|
|
|
FRAME3_METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame3",
|
|
|
|
Helper.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);
|
|
|
|
}
|
2017-02-15 14:40:44 +00:00
|
|
|
ResolvedJavaMethod resolved1;
|
|
|
|
resolved1 = CTVMUtilities.getResolvedMethod(method1);
|
2018-08-31 09:43:06 +00:00
|
|
|
FRAME2_RESOLVED = CTVMUtilities.getResolvedMethod(method2);
|
|
|
|
FRAME3_RESOLVED = CTVMUtilities.getResolvedMethod(FRAME3_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");
|
2021-01-28 20:51:12 +00:00
|
|
|
COMPILE_THRESHOLD = CompilerWhiteBoxTest.THRESHOLD;
|
2017-02-15 14:40:44 +00:00
|
|
|
MATERIALIZE_FIRST = Boolean.getBoolean(
|
|
|
|
"compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst");
|
2018-08-31 09:43:06 +00:00
|
|
|
MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? resolved1 : FRAME2_RESOLVED;
|
|
|
|
NOT_MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? FRAME2_RESOLVED : resolved1;
|
2017-02-15 14:40:44 +00:00
|
|
|
MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method1 : method2;
|
|
|
|
NOT_MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method2 : method1;
|
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) {
|
2018-08-02 21:40:55 +00:00
|
|
|
throw new SkippedException("Test needs compilation level 4");
|
2015-10-14 23:46:51 +00:00
|
|
|
}
|
2018-08-02 21:40:55 +00:00
|
|
|
|
|
|
|
new MaterializeVirtualObjectTest().test();
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
2015-10-14 23:46:51 +00:00
|
|
|
private static String getName() {
|
2017-02-15 14:40:44 +00:00
|
|
|
return "CASE: invalidate=" + INVALIDATE + ", materializedMethod="
|
|
|
|
+ (MATERIALIZE_FIRST ? "testFrame" : "testFrame2")
|
|
|
|
+ ", notMaterializedMethod="
|
|
|
|
+ (MATERIALIZE_FIRST ? "testFrame2" : "testFrame");
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void test() {
|
2015-10-14 23:46:51 +00:00
|
|
|
System.out.println(getName());
|
2017-02-15 14:40:44 +00:00
|
|
|
Asserts.assertFalse(WB.isMethodCompiled(MATERIALIZED_METHOD),
|
|
|
|
getName() + " : materialized method is compiled");
|
|
|
|
Asserts.assertFalse(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
|
|
|
|
getName() + " : not materialized method is compiled");
|
|
|
|
for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
|
2016-05-16 13:54:09 +00:00
|
|
|
testFrame("someString", i);
|
|
|
|
}
|
2017-02-15 14:40:44 +00:00
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName()
|
|
|
|
+ " : materialized method not compiled");
|
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
|
|
|
|
getName() + " : not materialized method not compiled");
|
|
|
|
testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD);
|
2018-08-31 09:43:06 +00:00
|
|
|
|
|
|
|
// run second test types
|
|
|
|
for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
|
|
|
|
testFrame("someString", i);
|
|
|
|
}
|
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName()
|
|
|
|
+ " : materialized method not compiled");
|
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
|
|
|
|
getName() + " : not materialized method not compiled");
|
|
|
|
testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD + 1);
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
2016-05-16 13:54:09 +00:00
|
|
|
private void testFrame(String str, int iteration) {
|
2017-02-15 14:40:44 +00:00
|
|
|
Helper helper = new Helper(str);
|
|
|
|
testFrame2(str, iteration);
|
|
|
|
Asserts.assertTrue((helper.string != null) && (this != null)
|
|
|
|
&& (helper != null), String.format("%s : some locals are null", getName()));
|
2018-08-31 09:43:06 +00:00
|
|
|
}
|
2017-02-15 14:40:44 +00:00
|
|
|
|
|
|
|
private void testFrame2(String str, int iteration) {
|
2015-10-08 22:49:30 +00:00
|
|
|
Helper helper = new Helper(str);
|
2018-08-31 09:43:06 +00:00
|
|
|
Helper helper2 = new Helper("bar");
|
|
|
|
testFrame3(helper, iteration);
|
|
|
|
Asserts.assertTrue((helper.string != null) && (this != null) && helper.string == str
|
2017-02-15 14:40:44 +00:00
|
|
|
&& (helper != null), String.format("%s : some locals are null", getName()));
|
2018-08-31 09:43:06 +00:00
|
|
|
Asserts.assertTrue((helper2.string != null) && (this != null)
|
|
|
|
&& (helper2 != null), String.format("%s : some locals are null", getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
private void testFrame3(Helper outerHelper, int iteration) {
|
|
|
|
Helper innerHelper = new Helper("foo");
|
|
|
|
recurse(2, iteration);
|
|
|
|
Asserts.assertTrue((innerHelper.string != null) && (this != null)
|
|
|
|
&& (innerHelper != null), String.format("%s : some locals are null", getName()));
|
|
|
|
Asserts.assertTrue((outerHelper.string != null) && (this != null)
|
|
|
|
&& (outerHelper != null), String.format("%s : some locals are null", getName()));
|
2017-01-30 18:30:24 +00:00
|
|
|
}
|
2017-02-15 14:40:44 +00:00
|
|
|
|
2017-01-30 18:30:24 +00:00
|
|
|
private void recurse(int depth, int iteration) {
|
|
|
|
if (depth == 0) {
|
|
|
|
check(iteration);
|
|
|
|
} else {
|
|
|
|
Integer s = new Integer(depth);
|
|
|
|
recurse(depth - 1, iteration);
|
2017-02-15 14:40:44 +00:00
|
|
|
Asserts.assertEQ(s.intValue(), depth,
|
|
|
|
String.format("different values: %s != %s", s.intValue(), depth));
|
2017-01-30 18:30:24 +00:00
|
|
|
}
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
|
2018-08-31 09:43:06 +00:00
|
|
|
private void checkStructure(boolean materialize) {
|
|
|
|
boolean[] framesSeen = new boolean[2];
|
|
|
|
Object[] helpers = new Object[1];
|
|
|
|
CompilerToVMHelper.iterateFrames(
|
|
|
|
new ResolvedJavaMethod[] {FRAME3_RESOLVED},
|
|
|
|
null, /* any */
|
|
|
|
0,
|
|
|
|
f -> {
|
|
|
|
if (!framesSeen[1]) {
|
|
|
|
Asserts.assertTrue(f.isMethod(FRAME3_RESOLVED),
|
|
|
|
"Expected testFrame3 first");
|
|
|
|
framesSeen[1] = true;
|
|
|
|
Asserts.assertTrue(f.getLocal(0) != null, "this should not be null");
|
|
|
|
Asserts.assertTrue(f.getLocal(1) != null, "outerHelper should not be null");
|
|
|
|
Asserts.assertTrue(f.getLocal(3) != null, "innerHelper should not be null");
|
|
|
|
Asserts.assertEQ(((Helper) f.getLocal(3)).string, "foo", "innerHelper.string should be foo");
|
|
|
|
helpers[0] = f.getLocal(1);
|
|
|
|
if (materialize) {
|
|
|
|
f.materializeVirtualObjects(false);
|
|
|
|
}
|
|
|
|
return null; //continue
|
|
|
|
} else {
|
|
|
|
Asserts.assertFalse(framesSeen[0], "frame3 can not have been seen");
|
|
|
|
Asserts.assertTrue(f.isMethod(FRAME2_RESOLVED),
|
|
|
|
"Expected testFrame2 second");
|
|
|
|
framesSeen[0] = true;
|
|
|
|
Asserts.assertTrue(f.getLocal(0) != null, "this should not be null");
|
|
|
|
Asserts.assertTrue(f.getLocal(1) != null, "str should not be null");
|
|
|
|
Asserts.assertTrue(f.getLocal(3) != null, "helper should not be null");
|
|
|
|
Asserts.assertTrue(f.getLocal(4) != null, "helper2 should not be null");
|
|
|
|
Asserts.assertEQ(((Helper) f.getLocal(3)).string, f.getLocal(1), "helper.string should be the same as str");
|
|
|
|
Asserts.assertEQ(((Helper) f.getLocal(4)).string, "bar", "helper2.string should be foo");
|
|
|
|
if (!materialize) {
|
|
|
|
Asserts.assertEQ(f.getLocal(3), helpers[0], "helper should be the same as frame3's outerHelper");
|
|
|
|
}
|
|
|
|
return f; // stop
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Asserts.assertTrue(framesSeen[1], "frame3 should have been seen");
|
|
|
|
Asserts.assertTrue(framesSeen[0], "frame2 should have been seen");
|
|
|
|
}
|
|
|
|
|
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) {
|
2017-02-15 14:40:44 +00:00
|
|
|
// get frames and check not-null
|
2018-03-08 03:32:54 +00:00
|
|
|
HotSpotStackFrameReference materialized = CompilerToVMHelper.iterateFrames(
|
|
|
|
new ResolvedJavaMethod[] {MATERIALIZED_RESOLVED},
|
|
|
|
null /* any */,
|
|
|
|
0,
|
|
|
|
f -> (HotSpotStackFrameReference) f);
|
2017-02-15 14:40:44 +00:00
|
|
|
Asserts.assertNotNull(materialized, getName()
|
|
|
|
+ " : got null frame for materialized method");
|
2018-03-08 03:32:54 +00:00
|
|
|
Asserts.assertTrue(materialized.isMethod(MATERIALIZED_RESOLVED),
|
|
|
|
"Expected materialized method but got " + materialized);
|
|
|
|
InspectedFrame notMaterialized = CompilerToVMHelper.iterateFrames(
|
|
|
|
new ResolvedJavaMethod[] {NOT_MATERIALIZED_RESOLVED},
|
|
|
|
null /* any */,
|
|
|
|
0,
|
|
|
|
f -> f);
|
2017-02-15 14:40:44 +00:00
|
|
|
Asserts.assertNE(materialized, notMaterialized,
|
|
|
|
"Got same frame pointer for both tested frames");
|
2018-03-08 03:32:54 +00:00
|
|
|
Asserts.assertTrue(notMaterialized.isMethod(NOT_MATERIALIZED_RESOLVED),
|
|
|
|
"Expected notMaterialized method but got " + notMaterialized);
|
2017-02-15 14:40:44 +00:00
|
|
|
Asserts.assertNotNull(notMaterialized, getName()
|
|
|
|
+ " : got null frame for not materialized method");
|
2018-03-08 03:32:54 +00:00
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName()
|
|
|
|
+ " : materialized method not compiled");
|
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
|
|
|
|
getName() + " : not materialized method not compiled");
|
2017-02-15 14:40:44 +00:00
|
|
|
// check that frames has virtual objects before materialization stage
|
|
|
|
Asserts.assertTrue(materialized.hasVirtualObjects(), getName()
|
|
|
|
+ ": materialized frame has no virtual object before materialization");
|
|
|
|
Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName()
|
|
|
|
+ ": notMaterialized frame has no virtual object before materialization");
|
|
|
|
// materialize
|
|
|
|
CompilerToVMHelper.materializeVirtualObjects(materialized, INVALIDATE);
|
|
|
|
// check that only not materialized frame has virtual objects
|
|
|
|
Asserts.assertFalse(materialized.hasVirtualObjects(), getName()
|
|
|
|
+ " : materialized has virtual object after materialization");
|
|
|
|
Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName()
|
|
|
|
+ " : notMaterialized has no virtual object after materialization");
|
|
|
|
// check that materialized frame was deoptimized in case invalidate=true
|
|
|
|
Asserts.assertEQ(WB.isMethodCompiled(MATERIALIZED_METHOD), !INVALIDATE, getName()
|
|
|
|
+ " : materialized method has unexpected compiled status");
|
|
|
|
// check that not materialized frame wasn't deoptimized
|
|
|
|
Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), getName()
|
|
|
|
+ " : not materialized method has unexpected compiled status");
|
2018-08-31 09:43:06 +00:00
|
|
|
} else if (iteration == COMPILE_THRESHOLD + 1) {
|
|
|
|
checkStructure(false);
|
|
|
|
checkStructure(true);
|
2015-10-08 22:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class Helper {
|
|
|
|
public String string;
|
|
|
|
|
|
|
|
public Helper(String s) {
|
|
|
|
this.string = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|