test/compiler/whitebox/MakeMethodNotCompilableTest.java

Tue, 16 Apr 2013 10:04:01 -0700

author
iignatyev
date
Tue, 16 Apr 2013 10:04:01 -0700
changeset 4951
4b2eebe03f93
parent 4908
b84fd7d73702
child 5032
d1c9384eecb4
permissions
-rw-r--r--

8011971: WB API doesn't accept j.l.reflect.Constructor
Reviewed-by: kvn, vlivanov

iignatyev@4592 1 /*
iignatyev@4592 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
iignatyev@4592 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
iignatyev@4592 4 *
iignatyev@4592 5 * This code is free software; you can redistribute it and/or modify it
iignatyev@4592 6 * under the terms of the GNU General Public License version 2 only, as
iignatyev@4592 7 * published by the Free Software Foundation.
iignatyev@4592 8 *
iignatyev@4592 9 * This code is distributed in the hope that it will be useful, but WITHOUT
iignatyev@4592 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
iignatyev@4592 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
iignatyev@4592 12 * version 2 for more details (a copy is included in the LICENSE file that
iignatyev@4592 13 * accompanied this code).
iignatyev@4592 14 *
iignatyev@4592 15 * You should have received a copy of the GNU General Public License version
iignatyev@4592 16 * 2 along with this work; if not, write to the Free Software Foundation,
iignatyev@4592 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
iignatyev@4592 18 *
iignatyev@4592 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
iignatyev@4592 20 * or visit www.oracle.com if you need additional information or have any
iignatyev@4592 21 * questions.
iignatyev@4592 22 */
iignatyev@4592 23
iignatyev@4592 24 /*
iignatyev@4592 25 * @test MakeMethodNotCompilableTest
mgerdin@4637 26 * @library /testlibrary /testlibrary/whitebox
mgerdin@4637 27 * @build MakeMethodNotCompilableTest
mgerdin@4637 28 * @run main ClassFileInstaller sun.hotspot.WhiteBox
mgerdin@4637 29 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI MakeMethodNotCompilableTest
iignatyev@4951 30 * @summary testing of WB::makeMethodNotCompilable()
iignatyev@4592 31 * @author igor.ignatyev@oracle.com
iignatyev@4592 32 */
iignatyev@4592 33 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest {
iignatyev@4592 34
iignatyev@4592 35 public static void main(String[] args) throws Exception {
iignatyev@4951 36 if (args.length == 0) {
iignatyev@4951 37 for (TestCase test : TestCase.values()) {
iignatyev@4951 38 new MakeMethodNotCompilableTest(test).runTest();
iignatyev@4951 39 }
iignatyev@4951 40 } else {
iignatyev@4951 41 for (String name : args) {
iignatyev@4951 42 new MakeMethodNotCompilableTest(
iignatyev@4951 43 TestCase.valueOf(name)).runTest();
iignatyev@4951 44 }
iignatyev@4951 45 }
iignatyev@4592 46 }
iignatyev@4592 47
iignatyev@4951 48 public MakeMethodNotCompilableTest(TestCase testCase) {
iignatyev@4951 49 super(testCase);
iignatyev@4951 50 // to prevent inlining of #method
iignatyev@4951 51 WHITE_BOX.testSetDontInlineMethod(method, true);
iignatyev@4951 52 }
iignatyev@4951 53
iignatyev@4951 54 /**
iignatyev@4951 55 * Tests {@code WB::makeMethodNotCompilable()} by calling it before
iignatyev@4951 56 * compilation and checking that method isn't compiled. Also
iignatyev@4951 57 * checks that WB::clearMethodState() clears no-compilable flags. For
iignatyev@4951 58 * tiered, additional checks for all available levels are conducted.
iignatyev@4951 59 *
iignatyev@4951 60 * @throws Exception if one of the checks fails.
iignatyev@4951 61 */
iignatyev@4951 62 @Override
iignatyev@4951 63 protected void test() throws Exception {
iignatyev@4951 64 checkNotCompiled();
iignatyev@4951 65 if (!WHITE_BOX.isMethodCompilable(method)) {
iignatyev@4951 66 throw new RuntimeException(method + " must be compilable");
iignatyev@4592 67 }
iignatyev@4951 68
iignatyev@4951 69 if (TIERED_COMPILATION) {
iignatyev@4951 70 for (int i = 1, n = TIERED_STOP_AT_LEVEL + 1; i < n; ++i) {
iignatyev@4951 71 WHITE_BOX.makeMethodNotCompilable(method, i);
iignatyev@4951 72 if (WHITE_BOX.isMethodCompilable(method, i)) {
iignatyev@4951 73 throw new RuntimeException(method
iignatyev@4951 74 + " must be not compilable at level" + i);
iignatyev@4951 75 }
iignatyev@4951 76 WHITE_BOX.enqueueMethodForCompilation(method, i);
iignatyev@4951 77 checkNotCompiled();
iignatyev@4951 78
iignatyev@4951 79 if (!WHITE_BOX.isMethodCompilable(method)) {
iignatyev@4951 80 System.out.println(method
iignatyev@4951 81 + " is not compilable after level " + i);
iignatyev@4951 82 }
iignatyev@4951 83 }
iignatyev@4951 84
iignatyev@4951 85 // WB.clearMethodState() must reset no-compilable flags
iignatyev@4951 86 WHITE_BOX.clearMethodState(method);
iignatyev@4951 87 if (!WHITE_BOX.isMethodCompilable(method)) {
iignatyev@4951 88 throw new RuntimeException(method
iignatyev@4951 89 + " is not compilable after clearMethodState()");
iignatyev@4951 90 }
iignatyev@4951 91 }
iignatyev@4951 92 WHITE_BOX.makeMethodNotCompilable(method);
iignatyev@4951 93 if (WHITE_BOX.isMethodCompilable(method)) {
iignatyev@4951 94 throw new RuntimeException(method + " must be not compilable");
iignatyev@4951 95 }
iignatyev@4951 96
iignatyev@4951 97 compile();
iignatyev@4951 98 checkNotCompiled();
iignatyev@4951 99 if (WHITE_BOX.isMethodCompilable(method)) {
iignatyev@4951 100 throw new RuntimeException(method + " must be not compilable");
iignatyev@4951 101 }
iignatyev@4951 102 // WB.clearMethodState() must reset no-compilable flags
iignatyev@4951 103 WHITE_BOX.clearMethodState(method);
iignatyev@4951 104 if (!WHITE_BOX.isMethodCompilable(method)) {
iignatyev@4951 105 throw new RuntimeException(method
iignatyev@4951 106 + " is not compilable after clearMethodState()");
iignatyev@4592 107 }
iignatyev@4592 108 compile();
iignatyev@4951 109 checkCompiled();
iignatyev@4592 110 }
iignatyev@4592 111 }

mercurial