hotspot/test/compiler/profiling/unloadingconflict/TestProfileConflictClassUnloading.java
author vdeshpande
Fri, 26 Aug 2016 12:20:09 -0700
changeset 41362 e09e871860a7
parent 40059 c2304140ed64
permissions -rw-r--r--
8154122: Intrinsify fused mac operations Summary: added FMA intrinsics on x86 Reviewed-by: kvn, aph, darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21581
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     1
/*
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     4
 *
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     8
 *
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    13
 * accompanied this code).
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    14
 *
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    18
 *
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    21
 * questions.
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    22
 */
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    23
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    24
/*
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    25
 * @test
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    26
 * @bug 8027572
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    27
 * @summary class unloading resets profile, method compiled after the profile is
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    28
 * first set and before class loading sets unknown bit with not recorded class
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    29
 * @library /
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    30
 * @build compiler.profiling.unloadingconflict.B
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    31
 * @run main/othervm -XX:TypeProfileLevel=222 -XX:-BackgroundCompilation
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    32
 *                   compiler.profiling.unloadingconflict.TestProfileConflictClassUnloading
21581
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    33
 *
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    34
 */
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    35
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    36
package compiler.profiling.unloadingconflict;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    37
21581
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    38
import java.net.MalformedURLException;
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    39
import java.net.URL;
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    40
import java.net.URLClassLoader;
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    41
import java.nio.file.Paths;
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    42
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    43
public class TestProfileConflictClassUnloading {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    44
    static class A {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    45
    }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    46
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    47
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    48
    static void m1(Object o) {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    49
    }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    50
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    51
    static void m2(Object o) {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    52
        m1(o);
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    53
    }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    54
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    55
    static void m3(A a, boolean do_call) {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    56
        if (!do_call) {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    57
            return;
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    58
        }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    59
        m2(a);
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    60
    }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    61
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    62
    public static ClassLoader newClassLoader() {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    63
        try {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    64
            return new URLClassLoader(new URL[] {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    65
                    Paths.get(System.getProperty("test.classes",".")).toUri().toURL(),
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    66
            }, null);
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    67
        } catch (MalformedURLException e){
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    68
            throw new RuntimeException("Unexpected URL conversion failure", e);
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    69
        }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    70
    }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    71
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    72
    public static void main(String[] args) throws Exception {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    73
        ClassLoader loader = newClassLoader();
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21581
diff changeset
    74
        Object o = loader.loadClass("compiler.profiling.unloadingconflict.B").newInstance();
21581
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    75
        // collect conflicting profiles
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    76
        for (int i = 0; i < 5000; i++) {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    77
            m2(o);
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    78
        }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    79
        // prepare for conflict
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    80
        A a = new A();
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    81
        for (int i = 0; i < 5000; i++) {
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    82
            m3(a, false);
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    83
        }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    84
        // unload class in profile
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    85
        o = null;
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    86
        loader = null;
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    87
        System.gc();
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    88
        // record the conflict
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    89
        m3(a, true);
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    90
        // trigger another GC
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    91
        System.gc();
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    92
    }
73584c201e2d 8027572: assert(r != 0) failed: invalid
roland
parents:
diff changeset
    93
}