Mercurial > hg > truffle
comparison graal/com.oracle.max.cri/src/com/oracle/max/cri/ri/RiRuntime.java @ 4199:aaac4894175c
Renamed cri packages from sun to oracle.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Tue, 03 Jan 2012 16:29:28 +0100 |
parents | graal/com.oracle.max.cri/src/com/sun/cri/ri/RiRuntime.java@ae261db78f68 |
children | 744dade427b8 |
comparison
equal
deleted
inserted
replaced
4198:8c9c0e1eaab1 | 4199:aaac4894175c |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.max.cri.ri; | |
24 | |
25 import java.lang.reflect.*; | |
26 | |
27 import com.oracle.max.cri.ci.*; | |
28 | |
29 /** | |
30 * Encapsulates the main functionality of the runtime for the compiler, including access | |
31 * to constant pools, OSR frames, inlining requirements, and runtime calls such as checkcast. | |
32 s */ | |
33 public interface RiRuntime { | |
34 | |
35 /** | |
36 * Offset of the lock within the lock object on the stack. | |
37 | |
38 * Note: superseded by sizeOfLockData() in Graal. | |
39 * | |
40 * @return the offset in bytes | |
41 */ | |
42 int basicObjectLockOffsetInBytes(); | |
43 | |
44 /** | |
45 * Get the size in bytes of a lock object on the stack. | |
46 * | |
47 * Note: superseded by sizeOfLockData() in Graal. | |
48 */ | |
49 int sizeOfBasicObjectLock(); | |
50 | |
51 /** | |
52 * Get the size in bytes for locking information on the stack. | |
53 */ | |
54 int sizeOfLockData(); | |
55 | |
56 /** | |
57 * The offset of the normal entry to the code. The compiler inserts NOP instructions to satisfy this constraint. | |
58 * | |
59 * @return the code offset in bytes | |
60 */ | |
61 int codeOffset(); | |
62 | |
63 /** | |
64 * Returns the disassembly of the given code bytes. Used for debugging purposes only. | |
65 * | |
66 * @param code the code bytes that should be disassembled | |
67 * @param address an address at which the bytes are located. This can be used for an address prefix per line of disassembly. | |
68 * @return the disassembly. This will be of length 0 if the runtime does not support disassembling. | |
69 */ | |
70 String disassemble(byte[] code, long address); | |
71 | |
72 /** | |
73 * Returns the disassembly of the given code bytes. Used for debugging purposes only. | |
74 * | |
75 * @param targetMethod the {@link CiTargetMethod} containing the code bytes that should be disassembled | |
76 * @return the disassembly. This will be of length 0 if the runtime does not support disassembling. | |
77 */ | |
78 String disassemble(CiTargetMethod targetMethod); | |
79 | |
80 /** | |
81 * Returns the disassembly of the given method in a {@code javap}-like format. | |
82 * Used for debugging purposes only. | |
83 * | |
84 * @param method the method that should be disassembled | |
85 * @return the disassembly. This will be of length 0 if the runtime does not support disassembling. | |
86 */ | |
87 String disassemble(RiResolvedMethod method); | |
88 | |
89 /** | |
90 * Registers the given compiler stub and returns an object that can be used to identify it in the relocation | |
91 * information. | |
92 * | |
93 * @param targetMethod the target method representing the code of the compiler stub | |
94 * @param name the name of the stub, used for debugging purposes only | |
95 * @return the identification object | |
96 */ | |
97 Object registerCompilerStub(CiTargetMethod targetMethod, String name); | |
98 | |
99 /** | |
100 * Returns the RiType object representing the base type for the given kind. | |
101 */ | |
102 RiResolvedType asRiType(CiKind kind); | |
103 | |
104 /** | |
105 * Returns the type of the given constant object. | |
106 * | |
107 * @return {@code null} if {@code constant.isNull() || !constant.kind.isObject()} | |
108 */ | |
109 RiResolvedType getTypeOf(CiConstant constant); | |
110 | |
111 | |
112 RiResolvedType getType(Class<?> clazz); | |
113 | |
114 /** | |
115 * Returns true if the given type is a subtype of java/lang/Throwable. | |
116 */ | |
117 boolean isExceptionType(RiResolvedType type); | |
118 | |
119 /** | |
120 * Used by the canonicalizer to compare objects, since a given runtime might not want to expose the real objects to the compiler. | |
121 * | |
122 * @return true if the two parameters represent the same runtime object, false otherwise | |
123 */ | |
124 boolean areConstantObjectsEqual(CiConstant x, CiConstant y); | |
125 | |
126 /** | |
127 * Gets the register configuration to use when compiling a given method. | |
128 * | |
129 * @param method the top level method of a compilation | |
130 */ | |
131 RiRegisterConfig getRegisterConfig(RiMethod method); | |
132 | |
133 /** | |
134 * Custom area on the stack of each compiled method that the VM can use for its own purposes. | |
135 * @return the size of the custom area in bytes | |
136 */ | |
137 int getCustomStackAreaSize(); | |
138 | |
139 /** | |
140 * Minimum size of the stack area reserved for outgoing parameters. This area is reserved in all cases, even when | |
141 * the compiled method has no regular call instructions. | |
142 * @return the minimum size of the outgoing parameter area in bytes | |
143 */ | |
144 int getMinimumOutgoingSize(); | |
145 | |
146 /** | |
147 * Gets the length of the array that is wrapped in a CiConstant object. | |
148 */ | |
149 int getArrayLength(CiConstant array); | |
150 | |
151 /** | |
152 * Converts the given CiConstant object to a object. | |
153 * | |
154 * @return {@code null} if the conversion is not possible <b>OR</b> {@code c.isNull() == true} | |
155 */ | |
156 Object asJavaObject(CiConstant c); | |
157 | |
158 /** | |
159 * Converts the given CiConstant object to a {@link Class} object. | |
160 * | |
161 * @return {@code null} if the conversion is not possible. | |
162 */ | |
163 Class<?> asJavaClass(CiConstant c); | |
164 | |
165 /** | |
166 * Performs any runtime-specific conversion on the object used to describe the target of a call. | |
167 */ | |
168 Object asCallTarget(Object target); | |
169 | |
170 /** | |
171 * Returns the maximum absolute offset of a runtime call target from any position in the code cache or -1 | |
172 * when not known or not applicable. Intended for determining the required size of address/offset fields. | |
173 */ | |
174 long getMaxCallTargetOffset(CiRuntimeCall rtcall); | |
175 | |
176 /** | |
177 * Provides the {@link RiMethod} for a {@link Method} obtained via reflection. | |
178 */ | |
179 RiResolvedMethod getRiMethod(Method reflectionMethod); | |
180 | |
181 /** | |
182 * Installs some given machine code as the implementation of a given method. | |
183 * | |
184 * @param method a method whose executable code is being modified | |
185 * @param code the code to be executed when {@code method} is called | |
186 */ | |
187 void installMethod(RiMethod method, CiTargetMethod code); | |
188 | |
189 /** | |
190 * Adds the given machine code as an implementation of the given method without making it the default implementation. | |
191 * @param method a method to which the executable code is begin added | |
192 * @param code the code to be added | |
193 * @return a reference to the compiled and ready-to-run code | |
194 */ | |
195 RiCompiledMethod addMethod(RiResolvedMethod method, CiTargetMethod code); | |
196 } |