# HG changeset patch # User Doug Simon # Date 1443468132 -7200 # Node ID bec9cd4e731ae36000b5eb0110b849b9775e28d6 # Parent 111882d99400aae882d0a8caebb53733646ded8b added CompilationRequest to package up a compilation request and be able to add VM specific context diff -r 111882d99400 -r bec9cd4e731a jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/CompilationRequest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.internal.jvmci.code/src/jdk/internal/jvmci/code/CompilationRequest.java Mon Sep 28 21:22:12 2015 +0200 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.jvmci.code; + +import jdk.internal.jvmci.meta.ResolvedJavaMethod; + +/** + * Represents a request to compile a method. + */ +public class CompilationRequest { + + private final ResolvedJavaMethod method; + + private final int entryBCI; + + /** + * Creates a compilation request. + * + * @param method the method to be compiled + * @param entryBCI the bytecode index (BCI) at which to start compiling + */ + public CompilationRequest(ResolvedJavaMethod method, int entryBCI) { + this.method = method; + this.entryBCI = entryBCI; + } + + /** + * Gets the method to be compiled. + */ + public ResolvedJavaMethod getMethod() { + return method; + } + + /** + * Gets the bytecode index (BCI) at which to start compiling where -1 denotes a non-OSR + * compilation request and all other values denote an on stack replacement (OSR) compilation + * request + */ + public int getEntryBCI() { + return entryBCI; + } +} diff -r 111882d99400 -r bec9cd4e731a jvmci/jdk.internal.jvmci.compiler/src/jdk/internal/jvmci/compiler/Compiler.java --- a/jvmci/jdk.internal.jvmci.compiler/src/jdk/internal/jvmci/compiler/Compiler.java Mon Sep 28 17:09:29 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.compiler/src/jdk/internal/jvmci/compiler/Compiler.java Mon Sep 28 21:22:12 2015 +0200 @@ -22,7 +22,7 @@ */ package jdk.internal.jvmci.compiler; -import jdk.internal.jvmci.meta.ResolvedJavaMethod; +import jdk.internal.jvmci.code.CompilationRequest; import jdk.internal.jvmci.options.Option; import jdk.internal.jvmci.options.OptionType; import jdk.internal.jvmci.options.OptionValue; @@ -39,14 +39,8 @@ @Option(help = "", type = OptionType.Debug) OptionValue PrintStackTraceOnException = new OptionValue<>(false); /** - * Request the compilation of a method by this JVMCI compiler. The compiler should compile the - * method to machine code and install it in the code cache if the compilation is successful. - * - * @param method the method that should be compiled - * @param entryBCI the BCI at which to start compiling where -1 denotes a non-OSR compilation - * request and all other values denote an OSR compilation request - * @param jvmciEnv pointer to native {@code JVMCIEnv} object - * @param id a unique identifier for this compilation + * Services a compilation request. This object should compile the method to machine code and + * install it in the code cache if the compilation is successful. */ - void compileMethod(ResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id); + void compileMethod(CompilationRequest request); } diff -r 111882d99400 -r bec9cd4e731a jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotCompilationRequest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotCompilationRequest.java Mon Sep 28 21:22:12 2015 +0200 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.jvmci.hotspot; + +import jdk.internal.jvmci.code.CompilationRequest; + +/** + * A compilation request with extra HotSpot specific context such as a compilation identifier and + * the address of a {@code JVMCIEnv} object that provides extra native level context for a + * compilation. + */ +public class HotSpotCompilationRequest extends CompilationRequest { + private final long jvmciEnv; + private final int id; + + public HotSpotCompilationRequest(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { + super(method, entryBCI); + this.jvmciEnv = jvmciEnv; + this.id = id; + } + + @Override + public HotSpotResolvedJavaMethod getMethod() { + return (HotSpotResolvedJavaMethod) super.getMethod(); + } + + /** + * Gets the address of the native {@code JVMCIEnv} object or 0L if no such object exists. + */ + public long getJvmciEnv() { + return jvmciEnv; + } + + /** + * Gets the VM allocated identifier for this compilation. + */ + public int getId() { + return id; + } + +} diff -r 111882d99400 -r bec9cd4e731a jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCICompilerConfig.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCICompilerConfig.java Mon Sep 28 17:09:29 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCICompilerConfig.java Mon Sep 28 21:22:12 2015 +0200 @@ -22,10 +22,10 @@ */ package jdk.internal.jvmci.hotspot; +import jdk.internal.jvmci.code.CompilationRequest; import jdk.internal.jvmci.common.JVMCIError; import jdk.internal.jvmci.compiler.Compiler; import jdk.internal.jvmci.compiler.CompilerFactory; -import jdk.internal.jvmci.meta.ResolvedJavaMethod; import jdk.internal.jvmci.runtime.JVMCIRuntime; import jdk.internal.jvmci.service.Services; @@ -33,7 +33,7 @@ private static class DummyCompilerFactory implements CompilerFactory, Compiler { - public void compileMethod(ResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { + public void compileMethod(CompilationRequest request) { throw new JVMCIError("no JVMCI compiler selected"); } diff -r 111882d99400 -r bec9cd4e731a jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java --- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java Mon Sep 28 17:09:29 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotJVMCIRuntime.java Mon Sep 28 21:22:12 2015 +0200 @@ -244,7 +244,7 @@ */ @SuppressWarnings({"unused"}) private void compileMethod(HotSpotResolvedJavaMethod method, int entryBCI, long jvmciEnv, int id) { - compiler.compileMethod(method, entryBCI, jvmciEnv, id); + compiler.compileMethod(new HotSpotCompilationRequest(method, entryBCI, jvmciEnv, id)); } /**