001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Eclipse Public License (EPL);
005 * You may not use this file except in compliance with the License. You
006 * may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.jikesrvm.compilers.opt.inlining;
014
015 import org.jikesrvm.classloader.RVMMethod;
016 import org.jikesrvm.classloader.NormalMethod;
017 import org.jikesrvm.compilers.common.CompiledMethod;
018 import org.jikesrvm.compilers.opt.OptOptions;
019 import org.jikesrvm.compilers.opt.ir.Call;
020 import org.jikesrvm.compilers.opt.ir.Instruction;
021
022 /**
023 * This class holds miscellaneous information regarding the state of
024 * a compilation
025 */
026 public final class CompilationState {
027
028 /*
029 * Implementation
030 */
031 private final Instruction call;
032 private final boolean isExtant;
033 private final OptOptions options;
034 private final CompiledMethod cm;
035 private final int realBCI;
036
037 /*
038 * Interface
039 */
040
041 /**
042 * @param call the call instruction being considered for inlining.
043 * @param isExtant is the receiver of a virtual call an extant object?
044 * @param options controlling compiler options
045 * @param cm compiled method of the IR object being compiled
046 * @param realBCI the real bytecode index of the call instruction, not adjusted because of OSR
047 */
048 public CompilationState(Instruction call, boolean isExtant, OptOptions options, CompiledMethod cm, int realBCI) {
049 this.call = call;
050 this.isExtant = isExtant;
051 this.options = options;
052 this.cm = cm;
053 this.realBCI = realBCI;
054 }
055
056 /**
057 * Does this state represent an invokeinterface call?
058 *
059 * @return <code>true</code> if it is an interface call
060 * or <code>false</code> if it is not.
061 */
062 public boolean isInvokeInterface() {
063 return Call.getMethod(call).isInterface();
064 }
065
066 /**
067 * Return the depth of inlining so far.
068 */
069 public int getInlineDepth() {
070 return call.position.getInlineDepth();
071 }
072
073 /**
074 * Return the call instruction being considered for inlining
075 */
076 public Instruction getCallInstruction() {
077 return call;
078 }
079
080 /**
081 * Obtain the target method from the compilation state.
082 * If a computed target is present, use it.
083 */
084 public RVMMethod obtainTarget() {
085 return Call.getMethod(call).getTarget();
086 }
087
088 /**
089 * Return the controlling compiler options
090 */
091 public OptOptions getOptions() {
092 return options;
093 }
094
095 /**
096 * Return whether or not the receiving object is extant
097 */
098 public boolean getIsExtant() {
099 return isExtant;
100 }
101
102 /**
103 * Return whether or not the target is precise (ie needs no guard)
104 */
105 public boolean getHasPreciseTarget() {
106 return Call.getMethod(call).hasPreciseTarget();
107 }
108
109 /**
110 * Return the root method of the compilation
111 */
112 public NormalMethod getRootMethod() {
113 return call.position.getRootMethod();
114 }
115
116 /**
117 * Return the method being compiled
118 */
119 public NormalMethod getMethod() {
120 return call.position.getMethod();
121 }
122
123 /**
124 * Return the real bytecode index associated with this call
125 */
126 public int getRealBytecodeIndex() {
127 return realBCI;
128 }
129
130 /**
131 * Return the inlining sequence
132 */
133 public InlineSequence getSequence() {
134 return call.position;
135 }
136
137 /**
138 * Return the compiled method
139 */
140 public CompiledMethod getCompiledMethod() {
141 return cm;
142 }
143 }