GraalOSRTest.java revision 12657:6ef01bd40ce2
1279377Simp/* 2279377Simp * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3279377Simp * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4279377Simp * 5279377Simp * This code is free software; you can redistribute it and/or modify it 6279377Simp * under the terms of the GNU General Public License version 2 only, as 7279377Simp * published by the Free Software Foundation. 8279377Simp * 9279377Simp * This code is distributed in the hope that it will be useful, but WITHOUT 10279377Simp * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11279377Simp * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12279377Simp * version 2 for more details (a copy is included in the LICENSE file that 13279377Simp * accompanied this code). 14279377Simp * 15279377Simp * You should have received a copy of the GNU General Public License version 16279377Simp * 2 along with this work; if not, write to the Free Software Foundation, 17279377Simp * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18279377Simp * 19279377Simp * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20279377Simp * or visit www.oracle.com if you need additional information or have any 21279377Simp * questions. 22279377Simp */ 23279377Simppackage org.graalvm.compiler.hotspot.test; 24279377Simp 25279377Simpimport org.junit.Test; 26279377Simp 27279377Simpimport org.graalvm.compiler.api.directives.GraalDirectives; 28279377Simp 29279377Simp/** 30279377Simp * Test on-stack-replacement with Graal. The test manually triggers a Graal OSR-compilation which is 31279377Simp * later invoked when hitting the backedge counter overflow. 32279377Simp */ 33279377Simppublic class GraalOSRTest extends GraalOSRTestBase { 34279377Simp 35279377Simp @Test 36279377Simp public void testOSR() { 37279377Simp testOSR("test"); 38279377Simp } 39279377Simp 40279377Simp static int limit = 10000; 41279377Simp 42279377Simp public static ReturnValue test() { 43279377Simp for (int i = 0; i < limit * limit; i++) { 44279377Simp GraalDirectives.blackhole(i); 45279377Simp if (GraalDirectives.inCompiledCode()) { 46279377Simp return ReturnValue.SUCCESS; 47279377Simp } 48279377Simp } 49279377Simp return ReturnValue.FAILURE; 50279377Simp } 51279377Simp 52279377Simp} 53279377Simp