Path: blob/master/test/hotspot/jtreg/compiler/profiling/TestUnexpectedProfilingMismatch.java
41149 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 802763126* @summary profiling of arguments at calls cannot rely on signature of callee for types27*28* @run main/othervm -XX:-BackgroundCompilation -XX:TieredStopAtLevel=3 -XX:TypeProfileLevel=11129* -XX:Tier3InvocationThreshold=200 -XX:Tier0InvokeNotifyFreqLog=730* compiler.profiling.TestUnexpectedProfilingMismatch31*/3233package compiler.profiling;3435import java.lang.invoke.MethodHandle;36import java.lang.invoke.MethodHandles;37import java.lang.invoke.MethodType;3839public class TestUnexpectedProfilingMismatch {4041static class A {42}4344static class B {45}4647static void mA(A a) {48}4950static void mB(B b) {51}5253static final MethodHandle mhA;54static final MethodHandle mhB;55static {56MethodHandles.Lookup lookup = MethodHandles.lookup();57MethodType mt = MethodType.methodType(void.class, A.class);58MethodHandle res = null;59try {60res = lookup.findStatic(TestUnexpectedProfilingMismatch.class, "mA", mt);61} catch(NoSuchMethodException ex) {62} catch(IllegalAccessException ex) {63}64mhA = res;65mt = MethodType.methodType(void.class, B.class);66try {67res = lookup.findStatic(TestUnexpectedProfilingMismatch.class, "mB", mt);68} catch(NoSuchMethodException ex) {69} catch(IllegalAccessException ex) {70}71mhB = res;72}7374void m1(A a, boolean doit) throws Throwable {75if (doit) {76mhA.invoke(a);77}78}7980void m2(B b) throws Throwable {81mhB.invoke(b);82}8384static public void main(String[] args) {85TestUnexpectedProfilingMismatch tih = new TestUnexpectedProfilingMismatch();86A a = new A();87B b = new B();88try {89for (int i = 0; i < 256 - 1; i++) {90tih.m1(a, true);91}92// Will trigger the compilation but will also run once93// more interpreted with a non null MDO which it will94// update. Make it skip the body of the method.95tih.m1(a, false);96// Compile this one as well and do the profiling97for (int i = 0; i < 256; i++) {98tih.m2(b);99}100// Will run and see a conflict101tih.m1(a, true);102} catch(Throwable ex) {103ex.printStackTrace();104}105System.out.println("TEST PASSED");106}107}108109110