1 /*
2 * Copyright (c) 2009, 2014, 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 */
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
47 */
48 default InstalledCode addCode(ResolvedJavaMethod method, CompiledCode compiledCode, SpeculationLog log, InstalledCode installedCode) {
49 return installCode(method, compiledCode, installedCode, log, false);
50 }
51
52 /**
53 * Installs code for a given method based on a given compilation result and makes it the default
54 * implementation of the method.
55 *
56 * @param method a method implemented by the installed code and for which the installed code
57 * becomes the default implementation
58 * @param compiledCode the compiled code to be added
59 * @return a reference to the ready-to-run code
60 * @throws BailoutException if the code installation failed
61 */
62 default InstalledCode setDefaultCode(ResolvedJavaMethod method, CompiledCode compiledCode) {
63 return installCode(method, compiledCode, null, null, true);
64 }
65
66 /**
67 * Installs code based on a given compilation result.
68 *
69 * @param method the method compiled to produce {@code compiledCode} or {@code null} if the
70 * input to {@code compResult} was not a {@link ResolvedJavaMethod}
71 * @param compiledCode the compiled code to be added
72 * @param installedCode a pre-allocated {@link InstalledCode} object to use as a reference to
73 * the installed code. If {@code null}, a new {@link InstalledCode} object will be
74 * created.
75 * @param log the speculation log to be used
76 * @param isDefault specifies if the installed code should be made the default implementation of
77 * {@code compRequest.getMethod()}. The default implementation for a method is the
78 * code executed for standard calls to the method. This argument is ignored if
79 * {@code compRequest == null}.
80 * @return a reference to the compiled and ready-to-run installed code
|
1 /*
2 * Copyright (c) 2009, 2019, 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 */
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
47 * @throws IllegalArgumentException if {@code installedCode != null} and this object does not
48 * support a predefined {@link InstalledCode} object
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
63 * @throws IllegalArgumentException if {@code installedCode != null} and this object does not
64 * support a predefined {@link InstalledCode} object
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
|