SynchronizedMethodDeoptimizationTest.java revision 12651:6ef01bd40ce2
1229430Spfg/* 2229430Spfg * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3229430Spfg * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4229430Spfg * 5229430Spfg * This code is free software; you can redistribute it and/or modify it 6229430Spfg * under the terms of the GNU General Public License version 2 only, as 7229430Spfg * published by the Free Software Foundation. 8229430Spfg * 9229430Spfg * This code is distributed in the hope that it will be useful, but WITHOUT 10229430Spfg * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11229430Spfg * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12229430Spfg * version 2 for more details (a copy is included in the LICENSE file that 13229430Spfg * accompanied this code). 14229430Spfg * 15229430Spfg * You should have received a copy of the GNU General Public License version 16229430Spfg * 2 along with this work; if not, write to the Free Software Foundation, 17229430Spfg * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18229430Spfg * 19229430Spfg * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20229430Spfg * or visit www.oracle.com if you need additional information or have any 21229430Spfg * questions. 22229430Spfg */ 23229430Spfgpackage org.graalvm.compiler.core.test.deopt; 24229430Spfg 25229430Spfgimport org.junit.Test; 26229430Spfg 27229430Spfgimport org.graalvm.compiler.core.test.GraalCompilerTest; 28229430Spfgimport org.graalvm.compiler.core.test.ea.EATestBase.TestClassObject; 29229430Spfg 30229430Spfg/** 31229430Spfg * In the following tests, we try to deoptimize out of synchronized methods. 32229430Spfg */ 33229430Spfgpublic class SynchronizedMethodDeoptimizationTest extends GraalCompilerTest { 34229430Spfg 35229430Spfg public static final TestClassObject testObject = null; 36229430Spfg 37229430Spfg public static synchronized Object testMethodSynchronized(Object o) { 38229430Spfg if (o == null) { 39229430Spfg // this branch will always deoptimize 40229430Spfg return testObject.x; 41229430Spfg } 42229430Spfg return o; 43229430Spfg } 44229430Spfg 45229430Spfg @Test 46229430Spfg public void test1() { 47229430Spfg test("testMethodSynchronized", "test"); 48229430Spfg test("testMethodSynchronized", (Object) null); 49229430Spfg } 50229430Spfg} 51229430Spfg