001/* 002 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.jtt.backend; 024 025import static com.oracle.graal.api.directives.GraalDirectives.*; 026 027import java.lang.reflect.*; 028 029import jdk.internal.jvmci.options.*; 030import jdk.internal.jvmci.options.OptionValue.OverrideScope; 031 032import org.junit.*; 033 034import com.oracle.graal.compiler.common.*; 035import com.oracle.graal.jtt.*; 036 037public class ConstantPhiTest extends JTTTest { 038 039 public static int test(int i, int x) throws Throwable { 040 int r; 041 if (injectBranchProbability(LIKELY_PROBABILITY, i < 0)) { 042 r = 42; 043 } else { 044 r = x; 045 } 046 destroyCallerSavedValues(); 047 return r; 048 } 049 050 protected static void destroyCallerSavedValues() throws Throwable { 051 Class<ConstantPhiTest> c = ConstantPhiTest.class; 052 Method m = c.getMethod("destroyCallerSavedValues0"); 053 m.invoke(null); 054 } 055 056 public static void destroyCallerSavedValues0() { 057 } 058 059 @Test 060 public void run0() { 061 try (OverrideScope os = OptionValue.override(GraalOptions.MaximumInliningSize, -1)) { 062 runTest("test", 0, 0xDEADDEAD); 063 } 064 } 065 066 @Test 067 public void run1() { 068 try (OverrideScope os = OptionValue.override(GraalOptions.MaximumInliningSize, -1)) { 069 runTest("test", -1, 0xDEADDEAD); 070 } 071 } 072 073 @Test 074 public void run2() { 075 try (OverrideScope os = OptionValue.override(GraalOptions.MaximumInliningSize, -1)) { 076 runTest("test", 1, 0xDEADDEAD); 077 } 078 } 079}