001/* 002 * Copyright (c) 2013, 2014, 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.phases.common.inlining.info; 024 025import java.util.*; 026 027import jdk.internal.jvmci.meta.*; 028 029import com.oracle.graal.graph.*; 030import com.oracle.graal.nodes.*; 031import com.oracle.graal.phases.common.inlining.info.elem.*; 032import com.oracle.graal.phases.util.*; 033 034/** 035 * Represents an inlining opportunity where the compiler can statically determine a monomorphic 036 * target method and therefore is able to determine the called method exactly. 037 */ 038public class ExactInlineInfo extends AbstractInlineInfo { 039 040 protected final ResolvedJavaMethod concrete; 041 private Inlineable inlineableElement; 042 private boolean suppressNullCheck; 043 044 public ExactInlineInfo(Invoke invoke, ResolvedJavaMethod concrete) { 045 super(invoke); 046 this.concrete = concrete; 047 assert concrete != null; 048 } 049 050 public void suppressNullCheck() { 051 suppressNullCheck = true; 052 } 053 054 @Override 055 public Collection<Node> inline(Providers providers) { 056 return inline(invoke, concrete, inlineableElement, !suppressNullCheck); 057 } 058 059 @Override 060 public void tryToDevirtualizeInvoke(Providers providers) { 061 // nothing todo, can already be bound statically 062 } 063 064 @Override 065 public int numberOfMethods() { 066 return 1; 067 } 068 069 @Override 070 public ResolvedJavaMethod methodAt(int index) { 071 assert index == 0; 072 return concrete; 073 } 074 075 @Override 076 public double probabilityAt(int index) { 077 assert index == 0; 078 return 1.0; 079 } 080 081 @Override 082 public double relevanceAt(int index) { 083 assert index == 0; 084 return 1.0; 085 } 086 087 @Override 088 public String toString() { 089 return "exact " + concrete.format("%H.%n(%p):%r"); 090 } 091 092 @Override 093 public Inlineable inlineableElementAt(int index) { 094 assert index == 0; 095 return inlineableElement; 096 } 097 098 @Override 099 public void setInlinableElement(int index, Inlineable inlineableElement) { 100 assert index == 0; 101 this.inlineableElement = inlineableElement; 102 } 103 104 public boolean shouldInline() { 105 return concrete.shouldBeInlined(); 106 } 107}