author | darcy |
Wed, 23 Oct 2019 13:01:40 -0700 | |
changeset 58766 | 54ffb15c4839 |
parent 54669 | ad45b3802d4e |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. |
43972 | 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 jdk.vm.ci.code; |
|
24 |
||
25 |
import jdk.vm.ci.code.site.Call; |
|
26 |
import jdk.vm.ci.code.site.Mark; |
|
27 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
28 |
import jdk.vm.ci.meta.SpeculationLog; |
|
29 |
||
30 |
/** |
|
31 |
* Access to code cache related details and requirements. |
|
32 |
*/ |
|
33 |
public interface CodeCacheProvider { |
|
34 |
||
35 |
/** |
|
36 |
* Installs code for a given method based on a given compilation result without making it the |
|
37 |
* default implementation of the method. |
|
38 |
* |
|
39 |
* @param method a method implemented by the installed code |
|
40 |
* @param compiledCode the compiled code to be added |
|
41 |
* @param log the speculation log to be used |
|
42 |
* @param installedCode a predefined {@link InstalledCode} object to use as a reference to the |
|
43 |
* installed code. If {@code null}, a new {@link InstalledCode} object will be |
|
44 |
* created. |
|
45 |
* @return a reference to the ready-to-run code |
|
46 |
* @throws BailoutException if the code installation failed |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
47216
diff
changeset
|
47 |
* @throws IllegalArgumentException if {@code installedCode != null} and this object does not |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
47216
diff
changeset
|
48 |
* support a predefined {@link InstalledCode} object |
43972 | 49 |
*/ |
50 |
default InstalledCode addCode(ResolvedJavaMethod method, CompiledCode compiledCode, SpeculationLog log, InstalledCode installedCode) { |
|
51 |
return installCode(method, compiledCode, installedCode, log, false); |
|
52 |
} |
|
53 |
||
54 |
/** |
|
55 |
* Installs code for a given method based on a given compilation result and makes it the default |
|
56 |
* implementation of the method. |
|
57 |
* |
|
58 |
* @param method a method implemented by the installed code and for which the installed code |
|
59 |
* becomes the default implementation |
|
60 |
* @param compiledCode the compiled code to be added |
|
61 |
* @return a reference to the ready-to-run code |
|
62 |
* @throws BailoutException if the code installation failed |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
47216
diff
changeset
|
63 |
* @throws IllegalArgumentException if {@code installedCode != null} and this object does not |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
47216
diff
changeset
|
64 |
* support a predefined {@link InstalledCode} object |
43972 | 65 |
*/ |
66 |
default InstalledCode setDefaultCode(ResolvedJavaMethod method, CompiledCode compiledCode) { |
|
67 |
return installCode(method, compiledCode, null, null, true); |
|
68 |
} |
|
69 |
||
70 |
/** |
|
71 |
* Installs code based on a given compilation result. |
|
72 |
* |
|
73 |
* @param method the method compiled to produce {@code compiledCode} or {@code null} if the |
|
74 |
* input to {@code compResult} was not a {@link ResolvedJavaMethod} |
|
75 |
* @param compiledCode the compiled code to be added |
|
76 |
* @param installedCode a pre-allocated {@link InstalledCode} object to use as a reference to |
|
77 |
* the installed code. If {@code null}, a new {@link InstalledCode} object will be |
|
78 |
* created. |
|
79 |
* @param log the speculation log to be used |
|
80 |
* @param isDefault specifies if the installed code should be made the default implementation of |
|
81 |
* {@code compRequest.getMethod()}. The default implementation for a method is the |
|
82 |
* code executed for standard calls to the method. This argument is ignored if |
|
83 |
* {@code compRequest == null}. |
|
84 |
* @return a reference to the compiled and ready-to-run installed code |
|
85 |
* @throws BailoutException if the code installation failed |
|
86 |
*/ |
|
87 |
InstalledCode installCode(ResolvedJavaMethod method, CompiledCode compiledCode, InstalledCode installedCode, SpeculationLog log, boolean isDefault); |
|
88 |
||
89 |
/** |
|
90 |
* Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be |
|
91 |
* raised the next time {@code installedCode} is |
|
92 |
* {@linkplain InstalledCode#executeVarargs(Object...) executed}. |
|
93 |
*/ |
|
94 |
void invalidateInstalledCode(InstalledCode installedCode); |
|
95 |
||
96 |
/** |
|
97 |
* Gets a name for a {@link Mark} mark. |
|
98 |
*/ |
|
99 |
default String getMarkName(Mark mark) { |
|
100 |
return String.valueOf(mark.id); |
|
101 |
} |
|
102 |
||
103 |
/** |
|
104 |
* Gets a name for the {@linkplain Call#target target} of a {@link Call}. |
|
105 |
*/ |
|
106 |
default String getTargetName(Call call) { |
|
107 |
return String.valueOf(call.target); |
|
108 |
} |
|
109 |
||
110 |
/** |
|
111 |
* Gets the register configuration to use when compiling a given method. |
|
112 |
*/ |
|
113 |
RegisterConfig getRegisterConfig(); |
|
114 |
||
115 |
/** |
|
116 |
* Minimum size of the stack area reserved for outgoing parameters. This area is reserved in all |
|
117 |
* cases, even when the compiled method has no regular call instructions. |
|
118 |
* |
|
119 |
* @return the minimum size of the outgoing parameter area in bytes |
|
120 |
*/ |
|
121 |
int getMinimumOutgoingSize(); |
|
122 |
||
123 |
/** |
|
124 |
* Gets a description of the target architecture. |
|
125 |
*/ |
|
126 |
TargetDescription getTarget(); |
|
127 |
||
128 |
/** |
|
129 |
* Create a new speculation log for the target runtime. |
|
130 |
*/ |
|
131 |
SpeculationLog createSpeculationLog(); |
|
132 |
||
133 |
/** |
|
134 |
* Returns the maximum absolute offset of a PC relative call to a given address from any |
|
135 |
* position in the code cache or -1 when not applicable. Intended for determining the required |
|
136 |
* size of address/offset fields. |
|
137 |
*/ |
|
138 |
long getMaxCallTargetOffset(long address); |
|
139 |
||
140 |
/** |
|
141 |
* Determines if debug info should also be emitted at non-safepoint locations. |
|
142 |
*/ |
|
143 |
boolean shouldDebugNonSafepoints(); |
|
144 |
} |