1 /*
2 * Copyright (c) 2012, 2018, 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 */
261
262 /**
263 * @return the compilation id plus a trailing '%' if the compilation is an OSR to match
264 * PrintCompilation style output
265 */
266 public String getIdString() {
267 if (getEntryBCI() != JVMCICompiler.INVOCATION_ENTRY_BCI) {
268 return getId() + "%";
269 } else {
270 return Integer.toString(getId());
271 }
272 }
273
274 public HotSpotInstalledCode getInstalledCode() {
275 return installedCode;
276 }
277
278 /**
279 * Time spent in compilation.
280 */
281 private static final TimerKey CompilationTime = DebugContext.timer("CompilationTime").doc("Time spent in compilation and code installation.");
282
283 /**
284 * Counts the number of compiled {@linkplain CompilationResult#getBytecodeSize() bytecodes}.
285 */
286 private static final CounterKey CompiledBytecodes = DebugContext.counter("CompiledBytecodes");
287
288 /**
289 * Counts the number of compiled {@linkplain CompilationResult#getBytecodeSize() bytecodes} for
290 * which {@linkplain CompilationResult#getTargetCode()} code was installed.
291 */
292 private static final CounterKey CompiledAndInstalledBytecodes = DebugContext.counter("CompiledAndInstalledBytecodes");
293
294 /**
295 * Counts the number of installed {@linkplain CompilationResult#getTargetCodeSize()} bytes.
296 */
297 private static final CounterKey InstalledCodeSize = DebugContext.counter("InstalledCodeSize");
298
299 /**
300 * Time spent in code installation.
301 */
302 public static final TimerKey CodeInstallationTime = DebugContext.timer("CodeInstallation");
303
304 public HotSpotCompilationRequestResult runCompilation(OptionValues initialOptions) {
305 OptionValues options = filterOptions(initialOptions);
306 SnippetReflectionProvider snippetReflection = compiler.getGraalRuntime().getHostProviders().getSnippetReflection();
307 try (DebugContext debug = DebugContext.create(options, new GraalDebugHandlersFactory(snippetReflection))) {
308 return runCompilation(debug);
309 }
310 }
311
312 @SuppressWarnings("try")
313 public HotSpotCompilationRequestResult runCompilation(DebugContext debug) {
314 HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
315 GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
316 int entryBCI = getEntryBCI();
317 boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
318 HotSpotResolvedJavaMethod method = getMethod();
319
320 if (installAsDefault || isOSR) {
321 // If there is already compiled code for this method on our level we simply return.
322 // JVMCI compiles are always at the highest compile level, even in non-tiered mode so we
323 // only need to check for that value.
324 if (method.hasCodeAtLevel(entryBCI, config.compilationLevelFullOptimization)) {
325 return HotSpotCompilationRequestResult.failure("Already compiled", false);
326 }
327 if (HotSpotGraalCompilerFactory.shouldExclude(method)) {
|
1 /*
2 * Copyright (c) 2012, 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 */
261
262 /**
263 * @return the compilation id plus a trailing '%' if the compilation is an OSR to match
264 * PrintCompilation style output
265 */
266 public String getIdString() {
267 if (getEntryBCI() != JVMCICompiler.INVOCATION_ENTRY_BCI) {
268 return getId() + "%";
269 } else {
270 return Integer.toString(getId());
271 }
272 }
273
274 public HotSpotInstalledCode getInstalledCode() {
275 return installedCode;
276 }
277
278 /**
279 * Time spent in compilation.
280 */
281 public static final TimerKey CompilationTime = DebugContext.timer("CompilationTime").doc("Time spent in compilation and code installation.");
282
283 /**
284 * Counts the number of compiled {@linkplain CompilationResult#getBytecodeSize() bytecodes}.
285 */
286 private static final CounterKey CompiledBytecodes = DebugContext.counter("CompiledBytecodes");
287
288 /**
289 * Counts the number of compiled {@linkplain CompilationResult#getBytecodeSize() bytecodes} for
290 * which {@linkplain CompilationResult#getTargetCode()} code was installed.
291 */
292 public static final CounterKey CompiledAndInstalledBytecodes = DebugContext.counter("CompiledAndInstalledBytecodes");
293
294 /**
295 * Counts the number of installed {@linkplain CompilationResult#getTargetCodeSize()} bytes.
296 */
297 private static final CounterKey InstalledCodeSize = DebugContext.counter("InstalledCodeSize");
298
299 /**
300 * Time spent in code installation.
301 */
302 public static final TimerKey CodeInstallationTime = DebugContext.timer("CodeInstallation");
303
304 public HotSpotCompilationRequestResult runCompilation(OptionValues initialOptions) {
305 OptionValues options = filterOptions(initialOptions);
306 HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
307 try (DebugContext debug = graalRuntime.openDebugContext(options, compilationId, getMethod(), compiler.getDebugHandlersFactories(), DebugContext.DEFAULT_LOG_STREAM)) {
308 return runCompilation(debug);
309 }
310 }
311
312 @SuppressWarnings("try")
313 public HotSpotCompilationRequestResult runCompilation(DebugContext debug) {
314 HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
315 GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
316 int entryBCI = getEntryBCI();
317 boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
318 HotSpotResolvedJavaMethod method = getMethod();
319
320 if (installAsDefault || isOSR) {
321 // If there is already compiled code for this method on our level we simply return.
322 // JVMCI compiles are always at the highest compile level, even in non-tiered mode so we
323 // only need to check for that value.
324 if (method.hasCodeAtLevel(entryBCI, config.compilationLevelFullOptimization)) {
325 return HotSpotCompilationRequestResult.failure("Already compiled", false);
326 }
327 if (HotSpotGraalCompilerFactory.shouldExclude(method)) {
|