test/hotspot/jtreg/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java
author iignatyev
Tue, 30 Jan 2018 16:48:53 -0800
changeset 53497 2134c512a525
parent 51606 18afb2097ada
child 55295 14283f280695
permissions -rw-r--r--
8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     1
/*
53497
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 51606
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
/*
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    25
 * @test
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
 * @bug 8136421
53497
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 51606
diff changeset
    27
 *
42607
acd91f1875d4 8170227: use vm.jvmci property in compiler/jvmci tests
iignatyev
parents: 40631
diff changeset
    28
 * @requires vm.jvmci
53497
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 51606
diff changeset
    29
 * @requires vm.opt.final.EliminateAllocations == true
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 51606
diff changeset
    30
 *
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 51606
diff changeset
    31
 * @comment no "-Xcomp -XX:-TieredCompilation" combination allowed until JDK-8140018 is resolved
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 51606
diff changeset
    32
 * @requires vm.compMode != "Xcomp" | vm.opt.TieredCompilation == null | vm.opt.TieredCompilation == true
2134c512a525 8167276: jvmci/compilerToVM/MaterializeVirtualObjectTest.java fails with -XX:-EliminateAllocations
iignatyev
parents: 51606
diff changeset
    33
 *
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40076
diff changeset
    34
 * @library / /test/lib
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    35
 * @library ../common/patches
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 36508
diff changeset
    36
 * @modules java.base/jdk.internal.misc
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    37
 * @modules java.base/jdk.internal.org.objectweb.asm
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    38
 *          java.base/jdk.internal.org.objectweb.asm.tree
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 43961
diff changeset
    39
 *          jdk.internal.vm.ci/jdk.vm.ci.hotspot
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 43961
diff changeset
    40
 *          jdk.internal.vm.ci/jdk.vm.ci.code
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
    41
 *          jdk.internal.vm.ci/jdk.vm.ci.code.stack
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 43961
diff changeset
    42
 *          jdk.internal.vm.ci/jdk.vm.ci.meta
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 39291
diff changeset
    43
 *
43972
1ade39b8381b 8174879: Rename jdk.vm.ci to jdk.internal.vm.ci
kvn
parents: 43961
diff changeset
    44
 * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox
40053
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 39291
diff changeset
    45
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
b3617982544e 8160657: Compiler HotSpot tests should use the "run driver" directive where applicable
iignatyev
parents: 39291
diff changeset
    46
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    47
 * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:.
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    48
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    49
 *                   -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    50
 *                   -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    51
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    52
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    53
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
    54
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    55
 *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    56
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    57
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    58
 *                   compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    59
 * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    60
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    61
 *                   -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    62
 *                   -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    63
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    64
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    65
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
    66
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
40076
1e283716fd17 8161508: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before materialization
dpochepk
parents: 40059
diff changeset
    67
 *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    68
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    69
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=false
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    70
 *                   compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    71
 * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    72
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    73
 *                   -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    74
 *                   -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    75
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    76
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    77
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
    78
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
40076
1e283716fd17 8161508: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before materialization
dpochepk
parents: 40059
diff changeset
    79
 *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    80
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=true
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    81
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    82
 *                   compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    83
 * @run main/othervm -Xmixed -Xbatch -Xbootclasspath/a:.
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    84
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    85
 *                   -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    86
 *                   -XX:CompileCommand=exclude,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::check
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    87
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    88
 *                   -XX:CompileCommand=dontinline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame2
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    89
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::recurse
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
    90
 *                   -XX:CompileCommand=inline,compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest::testFrame3
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    91
 *                   -XX:+DoEscapeAnalysis -XX:-UseCounterDecay
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
    92
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst=false
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    93
 *                   -Dcompiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate=true
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    94
 *                   compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    95
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    96
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    97
package compiler.jvmci.compilerToVM;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    98
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33191
diff changeset
    99
import compiler.jvmci.common.CTVMUtilities;
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33191
diff changeset
   100
import compiler.testlibrary.CompilerUtils;
38688
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   101
import compiler.whitebox.CompilerWhiteBoxTest;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
   102
import jdk.test.lib.Asserts;
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   103
import jdk.vm.ci.code.stack.InspectedFrame;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
   104
import jdk.vm.ci.hotspot.CompilerToVMHelper;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
   105
import jdk.vm.ci.hotspot.HotSpotStackFrameReference;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
   106
import jdk.vm.ci.meta.ResolvedJavaMethod;
51287
7b1ddbafa134 8208655: use JTreg skipped status in hotspot tests
iignatyev
parents: 49358
diff changeset
   107
import jtreg.SkippedException;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
   108
import sun.hotspot.WhiteBox;
33632
038347770a9e 8139170: JVMCI refresh
twisti
parents: 33191
diff changeset
   109
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40053
diff changeset
   110
import java.lang.reflect.Method;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   111
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   112
public class MaterializeVirtualObjectTest {
38688
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   113
    private static final WhiteBox WB;
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   114
    private static final boolean INVALIDATE;
38700
6aa6444c1b48 8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents: 38688
diff changeset
   115
    private static final int COMPILE_THRESHOLD;
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   116
    private static final Method MATERIALIZED_METHOD;
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   117
    private static final Method NOT_MATERIALIZED_METHOD;
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   118
    private static final Method FRAME3_METHOD;
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   119
    private static final ResolvedJavaMethod MATERIALIZED_RESOLVED;
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   120
    private static final ResolvedJavaMethod NOT_MATERIALIZED_RESOLVED;
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   121
    private static final ResolvedJavaMethod FRAME2_RESOLVED;
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   122
    private static final ResolvedJavaMethod FRAME3_RESOLVED;
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   123
    private static final boolean MATERIALIZE_FIRST;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   124
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   125
    static {
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   126
        Method method1;
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   127
        Method method2;
38688
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   128
        WB = WhiteBox.getWhiteBox();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   129
        try {
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   130
            method1 = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame",
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   131
                    String.class, int.class);
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   132
            method2 = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame2",
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   133
                    String.class, int.class);
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   134
            FRAME3_METHOD = MaterializeVirtualObjectTest.class.getDeclaredMethod("testFrame3",
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   135
                    Helper.class, int.class);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   136
        } catch (NoSuchMethodException e) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   137
            throw new Error("Can't get executable for test method", e);
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   138
        }
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   139
        ResolvedJavaMethod resolved1;
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   140
        resolved1 = CTVMUtilities.getResolvedMethod(method1);
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   141
        FRAME2_RESOLVED = CTVMUtilities.getResolvedMethod(method2);
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   142
        FRAME3_RESOLVED = CTVMUtilities.getResolvedMethod(FRAME3_METHOD);
38688
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   143
        INVALIDATE = Boolean.getBoolean(
38700
6aa6444c1b48 8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents: 38688
diff changeset
   144
                "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.invalidate");
6aa6444c1b48 8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents: 38688
diff changeset
   145
        COMPILE_THRESHOLD = WB.getBooleanVMFlag("TieredCompilation")
6aa6444c1b48 8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents: 38688
diff changeset
   146
                ? CompilerWhiteBoxTest.THRESHOLD
6aa6444c1b48 8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents: 38688
diff changeset
   147
                : CompilerWhiteBoxTest.THRESHOLD * 2;
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   148
        MATERIALIZE_FIRST = Boolean.getBoolean(
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   149
                "compiler.jvmci.compilerToVM.MaterializeVirtualObjectTest.materializeFirst");
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   150
        MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? resolved1 : FRAME2_RESOLVED;
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   151
        NOT_MATERIALIZED_RESOLVED = MATERIALIZE_FIRST ? FRAME2_RESOLVED : resolved1;
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   152
        MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method1 : method2;
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   153
        NOT_MATERIALIZED_METHOD = MATERIALIZE_FIRST ? method2 : method1;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   154
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   155
33184
db796ab93ba7 8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents: 33160
diff changeset
   156
    public static void main(String[] args) {
db796ab93ba7 8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents: 33160
diff changeset
   157
        int levels[] = CompilerUtils.getAvailableCompilationLevels();
db796ab93ba7 8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents: 33160
diff changeset
   158
        // we need compilation level 4 to use EscapeAnalysis
db796ab93ba7 8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents: 33160
diff changeset
   159
        if (levels.length < 1 || levels[levels.length - 1] != 4) {
51287
7b1ddbafa134 8208655: use JTreg skipped status in hotspot tests
iignatyev
parents: 49358
diff changeset
   160
            throw new SkippedException("Test needs compilation level 4");
33184
db796ab93ba7 8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents: 33160
diff changeset
   161
        }
51287
7b1ddbafa134 8208655: use JTreg skipped status in hotspot tests
iignatyev
parents: 49358
diff changeset
   162
7b1ddbafa134 8208655: use JTreg skipped status in hotspot tests
iignatyev
parents: 49358
diff changeset
   163
        new MaterializeVirtualObjectTest().test();
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   164
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   165
33184
db796ab93ba7 8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents: 33160
diff changeset
   166
    private static String getName() {
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   167
        return "CASE: invalidate=" + INVALIDATE + ", materializedMethod="
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   168
                + (MATERIALIZE_FIRST ? "testFrame" : "testFrame2")
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   169
                + ", notMaterializedMethod="
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   170
                + (MATERIALIZE_FIRST ? "testFrame2" : "testFrame");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   171
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   172
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   173
    private void test() {
33184
db796ab93ba7 8139438: [TESTBUG] JVMCI test fails with RuntimeException: Has no virtual object before materialization
dpochepk
parents: 33160
diff changeset
   174
        System.out.println(getName());
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   175
        Asserts.assertFalse(WB.isMethodCompiled(MATERIALIZED_METHOD),
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   176
                getName() + " : materialized method is compiled");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   177
        Asserts.assertFalse(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   178
                getName() + " : not materialized method is compiled");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   179
        for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
38688
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   180
            testFrame("someString", i);
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   181
        }
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   182
        Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   183
                + " : materialized method not compiled");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   184
        Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   185
                getName() + " : not materialized method not compiled");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   186
        testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD);
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   187
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   188
        // run second test types
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   189
        for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   190
            testFrame("someString", i);
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   191
        }
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   192
        Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName()
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   193
                + " : materialized method not compiled");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   194
        Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   195
                getName() + " : not materialized method not compiled");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   196
        testFrame("someString", /* materialize */ CompilerWhiteBoxTest.THRESHOLD + 1);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   197
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   198
38688
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   199
    private void testFrame(String str, int iteration) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   200
        Helper helper = new Helper(str);
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   201
        testFrame2(str, iteration);
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   202
        Asserts.assertTrue((helper.string != null) && (this != null)
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   203
                && (helper != null), String.format("%s : some locals are null", getName()));
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   204
    }
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   205
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   206
    private void testFrame2(String str, int iteration) {
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   207
        Helper helper = new Helper(str);
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   208
        Helper helper2 = new Helper("bar");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   209
        testFrame3(helper, iteration);
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   210
        Asserts.assertTrue((helper.string != null) && (this != null) && helper.string == str
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   211
                && (helper != null), String.format("%s : some locals are null", getName()));
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   212
        Asserts.assertTrue((helper2.string != null) && (this != null)
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   213
                && (helper2 != null), String.format("%s : some locals are null", getName()));
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   214
    }
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   215
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   216
    private void testFrame3(Helper outerHelper, int iteration) {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   217
        Helper innerHelper = new Helper("foo");
43672
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   218
        recurse(2, iteration);
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   219
        Asserts.assertTrue((innerHelper.string != null) && (this != null)
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   220
                && (innerHelper != null), String.format("%s : some locals are null", getName()));
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   221
        Asserts.assertTrue((outerHelper.string != null) && (this != null)
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   222
                && (outerHelper != null), String.format("%s : some locals are null", getName()));
43672
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   223
    }
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   224
43672
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   225
    private void recurse(int depth, int iteration) {
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   226
        if (depth == 0) {
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   227
            check(iteration);
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   228
        } else {
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   229
            Integer s = new Integer(depth);
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   230
            recurse(depth - 1, iteration);
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   231
            Asserts.assertEQ(s.intValue(), depth,
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   232
                    String.format("different values: %s != %s", s.intValue(), depth));
43672
b188841d7ac8 8173584: Add unit test for 8173309
never
parents: 42607
diff changeset
   233
        }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   234
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   235
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   236
    private void checkStructure(boolean materialize) {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   237
        boolean[] framesSeen = new boolean[2];
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   238
        Object[] helpers = new Object[1];
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   239
        CompilerToVMHelper.iterateFrames(
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   240
            new ResolvedJavaMethod[] {FRAME3_RESOLVED},
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   241
            null, /* any */
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   242
            0,
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   243
            f -> {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   244
                if (!framesSeen[1]) {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   245
                    Asserts.assertTrue(f.isMethod(FRAME3_RESOLVED),
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   246
                            "Expected testFrame3 first");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   247
                    framesSeen[1] = true;
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   248
                    Asserts.assertTrue(f.getLocal(0) != null, "this should not be null");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   249
                    Asserts.assertTrue(f.getLocal(1) != null, "outerHelper should not be null");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   250
                    Asserts.assertTrue(f.getLocal(3) != null, "innerHelper should not be null");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   251
                    Asserts.assertEQ(((Helper) f.getLocal(3)).string, "foo", "innerHelper.string should be foo");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   252
                    helpers[0] = f.getLocal(1);
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   253
                    if (materialize) {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   254
                        f.materializeVirtualObjects(false);
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   255
                    }
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   256
                    return null; //continue
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   257
                } else {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   258
                    Asserts.assertFalse(framesSeen[0], "frame3 can not have been seen");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   259
                    Asserts.assertTrue(f.isMethod(FRAME2_RESOLVED),
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   260
                            "Expected testFrame2 second");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   261
                    framesSeen[0] = true;
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   262
                    Asserts.assertTrue(f.getLocal(0) != null, "this should not be null");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   263
                    Asserts.assertTrue(f.getLocal(1) != null, "str should not be null");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   264
                    Asserts.assertTrue(f.getLocal(3) != null, "helper should not be null");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   265
                    Asserts.assertTrue(f.getLocal(4) != null, "helper2 should not be null");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   266
                    Asserts.assertEQ(((Helper) f.getLocal(3)).string, f.getLocal(1), "helper.string should be the same as str");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   267
                    Asserts.assertEQ(((Helper) f.getLocal(4)).string, "bar", "helper2.string should be foo");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   268
                    if (!materialize) {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   269
                        Asserts.assertEQ(f.getLocal(3), helpers[0], "helper should be the same as frame3's outerHelper");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   270
                    }
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   271
                    return f; // stop
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   272
                }
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   273
            });
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   274
        Asserts.assertTrue(framesSeen[1], "frame3 should have been seen");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   275
        Asserts.assertTrue(framesSeen[0], "frame2 should have been seen");
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   276
    }
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   277
38688
ad115177801f 8139703: [TESTBUG] compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest fails using -Xcomp
dpochepk
parents: 38152
diff changeset
   278
    private void check(int iteration) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   279
        // Materialize virtual objects on last invocation
38700
6aa6444c1b48 8157438: JVMCI: MaterializeVirtualObjectTest fails w/ "CASE: invalidate=true: has no virtual object before"
dpochepk
parents: 38688
diff changeset
   280
        if (iteration == COMPILE_THRESHOLD) {
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   281
            // get frames and check not-null
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   282
            HotSpotStackFrameReference materialized = CompilerToVMHelper.iterateFrames(
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   283
                new ResolvedJavaMethod[] {MATERIALIZED_RESOLVED},
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   284
                null /* any */,
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   285
                0,
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   286
                f -> (HotSpotStackFrameReference) f);
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   287
            Asserts.assertNotNull(materialized, getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   288
                    + " : got null frame for materialized method");
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   289
            Asserts.assertTrue(materialized.isMethod(MATERIALIZED_RESOLVED),
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   290
                "Expected materialized method but got " + materialized);
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   291
            InspectedFrame notMaterialized = CompilerToVMHelper.iterateFrames(
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   292
                new ResolvedJavaMethod[] {NOT_MATERIALIZED_RESOLVED},
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   293
                null /* any */,
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   294
                0,
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   295
                f -> f);
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   296
            Asserts.assertNE(materialized, notMaterialized,
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   297
                    "Got same frame pointer for both tested frames");
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   298
            Asserts.assertTrue(notMaterialized.isMethod(NOT_MATERIALIZED_RESOLVED),
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   299
                "Expected notMaterialized method but got " + notMaterialized);
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   300
            Asserts.assertNotNull(notMaterialized, getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   301
                    + " : got null frame for not materialized method");
49358
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   302
            Asserts.assertTrue(WB.isMethodCompiled(MATERIALIZED_METHOD), getName()
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   303
                + " : materialized method not compiled");
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   304
            Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD),
0dc249f5c260 8194490: [JVMCI] Move `iterateFrames` to C++
gdub
parents: 47216
diff changeset
   305
                getName() + " : not materialized method not compiled");
43961
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   306
            // check that frames has virtual objects before materialization stage
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   307
            Asserts.assertTrue(materialized.hasVirtualObjects(), getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   308
                    + ": materialized frame has no virtual object before materialization");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   309
            Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   310
                    + ": notMaterialized frame has no virtual object before materialization");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   311
            // materialize
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   312
            CompilerToVMHelper.materializeVirtualObjects(materialized, INVALIDATE);
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   313
            // check that only not materialized frame has virtual objects
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   314
            Asserts.assertFalse(materialized.hasVirtualObjects(), getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   315
                    + " : materialized has virtual object after materialization");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   316
            Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   317
                    + " : notMaterialized has no virtual object after materialization");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   318
            // check that materialized frame was deoptimized in case invalidate=true
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   319
            Asserts.assertEQ(WB.isMethodCompiled(MATERIALIZED_METHOD), !INVALIDATE, getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   320
                    + " : materialized method has unexpected compiled status");
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   321
            // check that not materialized frame wasn't deoptimized
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   322
            Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), getName()
441de9600d40 8138799: improve tests for CompilerToVM::MaterializeVirtualObjectTest
dpochepk
parents: 43672
diff changeset
   323
                    + " : not materialized method has unexpected compiled status");
51606
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   324
        } else if (iteration == COMPILE_THRESHOLD + 1) {
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   325
            checkStructure(false);
18afb2097ada 8210066: [JVMCI] iterateFrames uses wrong GrowableArray API for appending
dnsimon
parents: 51287
diff changeset
   326
            checkStructure(true);
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   327
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   328
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   329
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   330
    private class Helper {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   331
        public String string;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   332
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   333
        public Helper(String s) {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   334
            this.string = s;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   335
        }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   336
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
   337
}