Mercurial > hg > graal-compiler
changeset 21559:be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.api.replacements/src/com/oracle/graal/api/replacements/SnippetReflectionProvider.java Thu May 28 15:36:48 2015 +0200 @@ -31,7 +31,6 @@ import java.lang.reflect.*; import java.util.*; - /** * Reflection operations on values represented as {@linkplain JavaConstant constants} for the * processing of snippets. Snippets need a direct access to the value of object constants, which is @@ -93,7 +92,7 @@ try { return Class.forName(type.toClassName()); } catch (ClassNotFoundException e) { - // Support for -XX:-UseGraalClassLoader + // Support for -XX:-UseJVMCIClassLoader return Class.forName(type.toClassName(), false, ClassLoader.getSystemClassLoader()); } }
--- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Thu May 28 15:36:48 2015 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.api.runtime; +import java.io.*; import java.util.*; import sun.reflect.*; @@ -42,11 +43,24 @@ rt = factory.getRuntime(); } if (rt != null) { + updateGraalVersionProperty(); return rt; } return new InvalidGraalRuntime(); } + private static void updateGraalVersionProperty() { + try { + InputStream s = Graal.class.getResourceAsStream("graal.version"); + byte[] buf = new byte[s.available()]; + new DataInputStream(s).readFully(buf); + String version = new String(buf); + System.setProperty("graal.version", version); + } catch (IOException e) { + throw new InternalError(e); + } + } + /** * Gets the singleton {@link GraalRuntime} instance available to the application. */
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCounterOp.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCounterOp.java Thu May 28 15:36:48 2015 +0200 @@ -73,7 +73,7 @@ } // address for counters array - AMD64Address countersArrayAddr = new AMD64Address(thread, config.graalCountersThreadOffset); + AMD64Address countersArrayAddr = new AMD64Address(thread, config.jvmciCountersThreadOffset); Register countersArrayReg = scratch; // backup scratch register
--- a/graal/com.oracle.graal.hotspot.loader/src/com/oracle/graal/hotspot/loader/Factory.java Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2014, 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 com.oracle.graal.hotspot.loader; - -import java.io.*; -import java.net.*; -import java.util.*; - -/** - * Utility to create and register a separate class loader for loading Graal classes (i.e., those in - * found in lib/graal/graal*.jar). - */ -public class Factory { - - /** - * Copy of the {@code UseGraalClassLoader} VM option. Set by the VM before the static - * initializer is called. - */ - private static boolean useGraalClassLoader; - - /** - * Registers the Graal class loader in the VM. - */ - private static native void init(ClassLoader loader); - - static { - init(useGraalClassLoader ? newClassLoader() : null); - } - - /** - * Creates a new class loader for loading graal classes. - */ - private static ClassLoader newClassLoader() { - URL[] urls = getGraalJarsUrls(); - ClassLoader parent = null; - return URLClassLoader.newInstance(urls, parent); - } - - /** - * Gets the URLs for lib/graal/graal*.jar. - */ - private static URL[] getGraalJarsUrls() { - File javaHome = new File(System.getProperty("java.home")); - File lib = new File(javaHome, "lib"); - File graal = new File(lib, "graal"); - if (!graal.exists()) { - throw new InternalError(graal + " does not exist"); - } - - List<URL> urls = new ArrayList<>(); - for (String fileName : graal.list()) { - if (fileName.startsWith("graal") && fileName.endsWith(".jar")) { - File file = new File(graal, fileName); - if (file.isDirectory()) { - continue; - } - try { - urls.add(file.toURI().toURL()); - } catch (MalformedURLException e) { - throw new InternalError(e); - } - } - } - - return urls.toArray(new URL[urls.size()]); - } -}
--- a/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sourcegen/src/com/oracle/graal/hotspot/sourcegen/GenGraalRuntimeInlineHpp.java Thu May 28 15:36:48 2015 +0200 @@ -100,8 +100,8 @@ } /** - * Generates code for {@code GraalRuntime::set_option()} and - * {@code GraalRuntime::set_option_bool()}. + * Generates code for {@code JVMCIRuntime::set_option()} and + * {@code JVMCIRuntime::set_option_bool()}. */ private static void genSetOption(PrintStream out) throws Exception { SortedMap<String, OptionDescriptor> options = getOptions(); @@ -112,12 +112,12 @@ } lengths.add("PrintFlags".length()); - out.println("bool GraalRuntime::set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS) {"); + out.println("bool JVMCIRuntime::set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS) {"); out.println(" bool check_only = hotSpotOptionsClass.is_null();"); genMatchers(out, lengths, options, true); out.println(" return false;"); out.println("}"); - out.println("bool GraalRuntime::set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS) {"); + out.println("bool JVMCIRuntime::set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS) {"); out.println(" bool check_only = hotSpotOptionsClass.is_null();"); genMatchers(out, lengths, options, false); out.println(" return false;");
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCounterOp.java Thu May 28 15:36:48 2015 +0200 @@ -60,7 +60,7 @@ TargetDescription target = crb.target; // address for counters array - SPARCAddress countersArrayAddr = new SPARCAddress(thread, config.graalCountersThreadOffset); + SPARCAddress countersArrayAddr = new SPARCAddress(thread, config.jvmciCountersThreadOffset); try (ScratchRegister scratch = masm.getScratchRegister()) { Register countersArrayReg = scratch.getRegister();
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Thu May 28 15:36:48 2015 +0200 @@ -43,13 +43,13 @@ * To benchmark: * * <pre> - * mx vm -XX:-UseGraalClassLoader -cp @com.oracle.graal.hotspot.test com.oracle.graal.hotspot.test.MemoryUsageBenchmark + * mx vm -XX:-UseJVMCIClassLoader -cp @com.oracle.graal.hotspot.test com.oracle.graal.hotspot.test.MemoryUsageBenchmark * </pre> * * Memory analysis for a {@link CompileTheWorld} execution can also be performed. For example: * * <pre> - * mx --vm server vm -XX:-UseGraalClassLoader -G:CompileTheWorldClasspath=$HOME/SPECjvm2008/SPECjvm2008.jar -cp @com.oracle.graal.hotspot.test com.oracle.graal.hotspot.test.MemoryUsageBenchmark + * mx --vm server vm -XX:-UseJVMCIClassLoader -G:CompileTheWorldClasspath=$HOME/SPECjvm2008/SPECjvm2008.jar -cp @com.oracle.graal.hotspot.test com.oracle.graal.hotspot.test.MemoryUsageBenchmark * </pre> */ public class MemoryUsageBenchmark extends HotSpotGraalCompilerTest {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu May 28 15:36:48 2015 +0200 @@ -301,7 +301,7 @@ } if (graalEnv != 0) { - long ctask = unsafe.getAddress(graalEnv + config.graalEnvTaskOffset); + long ctask = unsafe.getAddress(graalEnv + config.jvmciEnvTaskOffset); assert ctask != 0L; unsafe.putInt(ctask + config.compileTaskNumInlinedBytecodesOffset, compiledBytecodes); } @@ -324,7 +324,7 @@ if (config.ciTime || config.ciTimeEach || CompiledBytecodes.isEnabled()) { return false; } - if (graalEnv == 0 || unsafe.getByte(graalEnv + config.graalEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0) { + if (graalEnv == 0 || unsafe.getByte(graalEnv + config.jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset) != 0) { return false; } return true;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java Thu May 28 15:36:48 2015 +0200 @@ -139,7 +139,7 @@ } } assert counter.group.equals(group) : "mismatching groups: " + counter.group + " vs. " + group; - int countersSize = config.graalCountersSize; + int countersSize = config.jvmciCountersSize; if (counter.index >= countersSize) { throw new JVMCIError("too many counters, reduce number of counters or increase -XX:GraalCounterSize=... (current value: " + countersSize + ")"); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.hotspot.loader/src/com/oracle/jvmci/hotspot/loader/Factory.java Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2014, 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 com.oracle.jvmci.hotspot.loader; + +import java.io.*; +import java.net.*; +import java.util.*; + +/** + * Utility to create and register a separate class loader for loading JVMCI classes (i.e., those in + * found in lib/jvmci/*.jar). + */ +public class Factory { + + /** + * Copy of the {@code UseJVMCIClassLoader} VM option. Set by the VM before the static + * initializer is called. + */ + private static boolean useJVMCIClassLoader; + + /** + * Registers the JVMCI class loader in the VM. + */ + private static native void init(ClassLoader loader); + + static { + init(useJVMCIClassLoader ? newClassLoader() : null); + } + + /** + * Creates a new class loader for loading JVMCI classes. + */ + private static ClassLoader newClassLoader() { + URL[] urls = getJVMCIJarsUrls(); + ClassLoader parent = null; + return URLClassLoader.newInstance(urls, parent); + } + + /** + * Gets the URLs for lib/jvmci/*.jar. + */ + private static URL[] getJVMCIJarsUrls() { + File javaHome = new File(System.getProperty("java.home")); + File lib = new File(javaHome, "lib"); + File jvmci = new File(lib, "jvmci"); + if (!jvmci.exists()) { + throw new InternalError(jvmci + " does not exist"); + } + + List<URL> urls = new ArrayList<>(); + for (String fileName : jvmci.list()) { + if (fileName.endsWith(".jar")) { + File file = new File(jvmci, fileName); + if (file.isDirectory()) { + continue; + } + try { + urls.add(file.toURI().toURL()); + } catch (MalformedURLException e) { + throw new InternalError(e); + } + } + } + + return urls.toArray(new URL[urls.size()]); + } +}
--- a/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotVMConfig.java Wed May 27 13:43:27 2015 +0200 +++ b/graal/com.oracle.jvmci.hotspot/src/com/oracle/jvmci/hotspot/HotSpotVMConfig.java Thu May 28 15:36:48 2015 +0200 @@ -715,7 +715,7 @@ @HotSpotVMFlag(name = "DontCompileHugeMethods") @Stable public boolean dontCompileHugeMethods; @HotSpotVMFlag(name = "HugeMethodLimit") @Stable public int hugeMethodLimit; @HotSpotVMFlag(name = "PrintInlining") @Stable public boolean printInlining; - @HotSpotVMFlag(name = "GraalUseFastLocking") @Stable public boolean useFastLocking; + @HotSpotVMFlag(name = "JVMCIUseFastLocking") @Stable public boolean useFastLocking; @HotSpotVMFlag(name = "ForceUnreachable") @Stable public boolean forceUnreachable; @HotSpotVMFlag(name = "UseTLAB") @Stable public boolean useTLAB; @@ -744,8 +744,8 @@ return universeCollectedHeap + collectedHeapTotalCollectionsOffset; } - @HotSpotVMFlag(name = "GraalDeferredInitBarriers") @Stable public boolean useDeferredInitBarriers; - @HotSpotVMFlag(name = "GraalHProfEnabled") @Stable public boolean useHeapProfiler; + @HotSpotVMFlag(name = "JVMCIDeferredInitBarriers") @Stable public boolean useDeferredInitBarriers; + @HotSpotVMFlag(name = "JVMCIHProfEnabled") @Stable public boolean useHeapProfiler; // Compressed Oops related values. @HotSpotVMFlag(name = "UseCompressedOops") @Stable public boolean useCompressedOops; @@ -902,7 +902,7 @@ @HotSpotVMField(name = "JavaThread::_is_method_handle_return", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int threadIsMethodHandleReturnOffset; @HotSpotVMField(name = "JavaThread::_satb_mark_queue", type = "ObjPtrQueue", get = HotSpotVMField.Type.OFFSET) @Stable public int javaThreadSatbMarkQueueOffset; @HotSpotVMField(name = "JavaThread::_vm_result", type = "oop", get = HotSpotVMField.Type.OFFSET) @Stable public int threadObjectResultOffset; - @HotSpotVMValue(expression = "in_bytes(JavaThread::graal_counters_offset())") @Stable public int graalCountersThreadOffset; + @HotSpotVMValue(expression = "in_bytes(JavaThread::jvmci_counters_offset())") @Stable public int jvmciCountersThreadOffset; /** * An invalid value for {@link #rtldDefault}. @@ -1053,8 +1053,8 @@ @HotSpotVMConstant(name = "JVM_ACC_MONITOR_MATCH") @Stable public int jvmAccMonitorMatch; @HotSpotVMConstant(name = "JVM_ACC_HAS_MONITOR_BYTECODES") @Stable public int jvmAccHasMonitorBytecodes; - @HotSpotVMField(name = "GraalEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvTaskOffset; - @HotSpotVMField(name = "GraalEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int graalEnvJvmtiCanHotswapOrPostBreakpointOffset; + @HotSpotVMField(name = "JVMCIEnv::_task", type = "CompileTask*", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvTaskOffset; + @HotSpotVMField(name = "JVMCIEnv::_jvmti_can_hotswap_or_post_breakpoint", type = "bool", get = HotSpotVMField.Type.OFFSET) @Stable public int jvmciEnvJvmtiCanHotswapOrPostBreakpointOffset; @HotSpotVMField(name = "CompileTask::_num_inlined_bytecodes", type = "int", get = HotSpotVMField.Type.OFFSET) @Stable public int compileTaskNumInlinedBytecodesOffset; /** @@ -1384,29 +1384,29 @@ @HotSpotVMField(name = "StubRoutines::_unsafe_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long unsafeArraycopy; @HotSpotVMField(name = "StubRoutines::_generic_arraycopy", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long genericArraycopy; - @HotSpotVMValue(expression = "GraalRuntime::new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newInstanceAddress; - @HotSpotVMValue(expression = "GraalRuntime::new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newArrayAddress; - @HotSpotVMValue(expression = "GraalRuntime::new_multi_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newMultiArrayAddress; - @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewArrayAddress; - @HotSpotVMValue(expression = "GraalRuntime::dynamic_new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewInstanceAddress; - @HotSpotVMValue(expression = "GraalRuntime::thread_is_interrupted", get = HotSpotVMValue.Type.ADDRESS) @Stable public long threadIsInterruptedAddress; - @HotSpotVMValue(expression = "GraalRuntime::vm_message", signature = "(unsigned char, long, long, long, long)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmMessageAddress; - @HotSpotVMValue(expression = "GraalRuntime::identity_hash_code", get = HotSpotVMValue.Type.ADDRESS) @Stable public long identityHashCodeAddress; - @HotSpotVMValue(expression = "GraalRuntime::exception_handler_for_pc", signature = "(JavaThread*)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForPcAddress; - @HotSpotVMValue(expression = "GraalRuntime::monitorenter", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorenterAddress; - @HotSpotVMValue(expression = "GraalRuntime::monitorexit", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorexitAddress; - @HotSpotVMValue(expression = "GraalRuntime::create_null_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createNullPointerExceptionAddress; - @HotSpotVMValue(expression = "GraalRuntime::create_out_of_bounds_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createOutOfBoundsExceptionAddress; - @HotSpotVMValue(expression = "GraalRuntime::log_primitive", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrimitiveAddress; - @HotSpotVMValue(expression = "GraalRuntime::log_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logObjectAddress; - @HotSpotVMValue(expression = "GraalRuntime::log_printf", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrintfAddress; - @HotSpotVMValue(expression = "GraalRuntime::vm_error", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmErrorAddress; - @HotSpotVMValue(expression = "GraalRuntime::load_and_clear_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long loadAndClearExceptionAddress; - @HotSpotVMValue(expression = "GraalRuntime::write_barrier_pre", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPreAddress; - @HotSpotVMValue(expression = "GraalRuntime::write_barrier_post", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPostAddress; - @HotSpotVMValue(expression = "GraalRuntime::validate_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long validateObject; + @HotSpotVMValue(expression = "JVMCIRuntime::new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newInstanceAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newArrayAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::new_multi_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long newMultiArrayAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::dynamic_new_array", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewArrayAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::dynamic_new_instance", get = HotSpotVMValue.Type.ADDRESS) @Stable public long dynamicNewInstanceAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::thread_is_interrupted", get = HotSpotVMValue.Type.ADDRESS) @Stable public long threadIsInterruptedAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::vm_message", signature = "(unsigned char, long, long, long, long)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmMessageAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::identity_hash_code", get = HotSpotVMValue.Type.ADDRESS) @Stable public long identityHashCodeAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::exception_handler_for_pc", signature = "(JavaThread*)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForPcAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::monitorenter", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorenterAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::monitorexit", get = HotSpotVMValue.Type.ADDRESS) @Stable public long monitorexitAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::create_null_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createNullPointerExceptionAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::create_out_of_bounds_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long createOutOfBoundsExceptionAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::log_primitive", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrimitiveAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::log_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logObjectAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::log_printf", get = HotSpotVMValue.Type.ADDRESS) @Stable public long logPrintfAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::vm_error", get = HotSpotVMValue.Type.ADDRESS) @Stable public long vmErrorAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::load_and_clear_exception", get = HotSpotVMValue.Type.ADDRESS) @Stable public long loadAndClearExceptionAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::write_barrier_pre", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPreAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::write_barrier_post", get = HotSpotVMValue.Type.ADDRESS) @Stable public long writeBarrierPostAddress; + @HotSpotVMValue(expression = "JVMCIRuntime::validate_object", get = HotSpotVMValue.Type.ADDRESS) @Stable public long validateObject; - @HotSpotVMValue(expression = "GraalRuntime::test_deoptimize_call_int", get = HotSpotVMValue.Type.ADDRESS) @Stable public long testDeoptimizeCallInt; + @HotSpotVMValue(expression = "JVMCIRuntime::test_deoptimize_call_int", get = HotSpotVMValue.Type.ADDRESS) @Stable public long testDeoptimizeCallInt; @HotSpotVMValue(expression = "SharedRuntime::register_finalizer", get = HotSpotVMValue.Type.ADDRESS) @Stable public long registerFinalizerAddress; @HotSpotVMValue(expression = "SharedRuntime::exception_handler_for_return_address", get = HotSpotVMValue.Type.ADDRESS) @Stable public long exceptionHandlerForReturnAddressAddress; @@ -1422,7 +1422,7 @@ @HotSpotVMValue(expression = "SharedRuntime::dlog10", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticLog10Address; @HotSpotVMValue(expression = "SharedRuntime::dpow", get = HotSpotVMValue.Type.ADDRESS) @Stable public long arithmeticPowAddress; - @HotSpotVMValue(expression = "(jint) GraalCounterSize") @Stable public int graalCountersSize; + @HotSpotVMValue(expression = "(jint) JVMCICounterSize") @Stable public int jvmciCountersSize; @HotSpotVMValue(expression = "Deoptimization::fetch_unroll_info", signature = "(JavaThread*)", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationFetchUnrollInfo; @HotSpotVMValue(expression = "Deoptimization::uncommon_trap", get = HotSpotVMValue.Type.ADDRESS) @Stable public long deoptimizationUncommonTrap; @@ -1478,11 +1478,11 @@ @HotSpotVMConstant(name = "vmIntrinsics::_linkToSpecial") @Stable public int vmIntrinsicLinkToSpecial; @HotSpotVMConstant(name = "vmIntrinsics::_linkToInterface") @Stable public int vmIntrinsicLinkToInterface; - @HotSpotVMConstant(name = "GraalEnv::ok") @Stable public int codeInstallResultOk; - @HotSpotVMConstant(name = "GraalEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; - @HotSpotVMConstant(name = "GraalEnv::dependencies_invalid") @Stable public int codeInstallResultDependenciesInvalid; - @HotSpotVMConstant(name = "GraalEnv::cache_full") @Stable public int codeInstallResultCacheFull; - @HotSpotVMConstant(name = "GraalEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge; + @HotSpotVMConstant(name = "JVMCIEnv::ok") @Stable public int codeInstallResultOk; + @HotSpotVMConstant(name = "JVMCIEnv::dependencies_failed") @Stable public int codeInstallResultDependenciesFailed; + @HotSpotVMConstant(name = "JVMCIEnv::dependencies_invalid") @Stable public int codeInstallResultDependenciesInvalid; + @HotSpotVMConstant(name = "JVMCIEnv::cache_full") @Stable public int codeInstallResultCacheFull; + @HotSpotVMConstant(name = "JVMCIEnv::code_too_large") @Stable public int codeInstallResultCodeTooLarge; public String getCodeInstallResultDescription(int codeInstallResult) { if (codeInstallResult == codeInstallResultOk) {
--- a/hotspot/.cproject Wed May 27 13:43:27 2015 +0200 +++ b/hotspot/.cproject Thu May 28 15:36:48 2015 +0200 @@ -42,9 +42,9 @@ <listOptionValue builtIn="false" value="TARGET_OS_FAMILY_linux=1"/> <listOptionValue builtIn="false" value="TARGET_OS_ARCH_linux_x86=1"/> <listOptionValue builtIn="false" value="TARGET_ARCH_MODEL_x86_64=1"/> - <listOptionValue builtIn="false" value="GRAAL=1"/> + <listOptionValue builtIn="false" value="JVMCI=1"/> <listOptionValue builtIn="false" value="COMPILER2=1"/> - <listOptionValue builtIn="false" value="COMPILERGRAAL=1"/> + <listOptionValue builtIn="false" value="COMPILERJVMCI=1"/> </option> <option id="gnu.cpp.compiler.option.preprocessor.undef.2137486146" name="Undefined symbols (-U)" superClass="gnu.cpp.compiler.option.preprocessor.undef"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.866181452" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> @@ -96,7 +96,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="hotspot" buildProperties="" description="Server VM with graal enabled (Tiered)" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.1958236162" name="Server" parent="org.eclipse.cdt.build.core.emptycfg"> + <configuration artifactName="hotspot" buildProperties="" description="Server VM with JVMCI enabled (Tiered)" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.1958236162" name="Server" parent="org.eclipse.cdt.build.core.emptycfg"> <folderInfo id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.1958236162." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.base.1741231788" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base"> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.1058861512" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> @@ -124,7 +124,7 @@ <listOptionValue builtIn="false" value="TARGET_OS_FAMILY_linux=1"/> <listOptionValue builtIn="false" value="TARGET_OS_ARCH_linux_x86=1"/> <listOptionValue builtIn="false" value="TARGET_ARCH_MODEL_x86_64=1"/> - <listOptionValue builtIn="false" value="GRAAL=1"/> + <listOptionValue builtIn="false" value="JVMCI=1"/> <listOptionValue builtIn="false" value="COMPILER2=1"/> </option> <option id="gnu.cpp.compiler.option.preprocessor.undef.553556482" name="Undefined symbols (-U)" superClass="gnu.cpp.compiler.option.preprocessor.undef"/> @@ -177,7 +177,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="hotspot" buildProperties="" description="Client VM with Graal enabled" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.982312162" name="Client" parent="org.eclipse.cdt.build.core.emptycfg"> + <configuration artifactName="hotspot" buildProperties="" description="Client VM with JVMCI enabled" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.982312162" name="Client" parent="org.eclipse.cdt.build.core.emptycfg"> <folderInfo id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.982312162." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.base.1944635494" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base"> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.760397453" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> @@ -205,7 +205,7 @@ <listOptionValue builtIn="false" value="TARGET_OS_FAMILY_linux=1"/> <listOptionValue builtIn="false" value="TARGET_OS_ARCH_linux_x86=1"/> <listOptionValue builtIn="false" value="TARGET_ARCH_MODEL_x86_64=1"/> - <listOptionValue builtIn="false" value="GRAAL=1"/> + <listOptionValue builtIn="false" value="JVMCI=1"/> </option> <option id="gnu.cpp.compiler.option.preprocessor.undef.2019710410" name="Undefined symbols (-U)" superClass="gnu.cpp.compiler.option.preprocessor.undef"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.931461388" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> @@ -245,7 +245,7 @@ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> </cconfiguration> <cconfiguration id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.2116626004"> - <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.2116626004" moduleId="org.eclipse.cdt.core.settings" name="Graal"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.2116626004" moduleId="org.eclipse.cdt.core.settings" name="JVMCI"> <externalSettings/> <extensions> <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> @@ -257,7 +257,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="hotspot" buildProperties="" description="Graal VM (Tiered)" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.2116626004" name="Graal" parent="org.eclipse.cdt.build.core.emptycfg"> + <configuration artifactName="hotspot" buildProperties="" description="Graal VM (Tiered)" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.2116626004" name="JVMCI" parent="org.eclipse.cdt.build.core.emptycfg"> <folderInfo id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.2116626004." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.base.1790873354" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base"> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.2087199731" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> @@ -285,8 +285,8 @@ <listOptionValue builtIn="false" value="TARGET_OS_FAMILY_linux=1"/> <listOptionValue builtIn="false" value="TARGET_OS_ARCH_linux_x86=1"/> <listOptionValue builtIn="false" value="TARGET_ARCH_MODEL_x86_64=1"/> - <listOptionValue builtIn="false" value="GRAAL=1"/> - <listOptionValue builtIn="false" value="COMPILERGRAAL=1"/> + <listOptionValue builtIn="false" value="JVMCI=1"/> + <listOptionValue builtIn="false" value="COMPILERJVMCI=1"/> </option> <option id="gnu.cpp.compiler.option.preprocessor.undef.1682796822" name="Undefined symbols (-U)" superClass="gnu.cpp.compiler.option.preprocessor.undef"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1552002453" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> @@ -326,7 +326,7 @@ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> </cconfiguration> <cconfiguration id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.500153051"> - <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.500153051" moduleId="org.eclipse.cdt.core.settings" name="Server no Graal"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.500153051" moduleId="org.eclipse.cdt.core.settings" name="Server no JVMCI"> <externalSettings/> <extensions> <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> @@ -338,7 +338,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="hotspot" buildProperties="" description="Server VM without Graal extentions (Tiered)" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.500153051" name="Server no Graal" parent="org.eclipse.cdt.build.core.emptycfg"> + <configuration artifactName="hotspot" buildProperties="" description="Server VM without JVMCI extentions (Tiered)" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.500153051" name="Server no JVMCI" parent="org.eclipse.cdt.build.core.emptycfg"> <folderInfo id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.500153051." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.base.264813073" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base"> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.555589372" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> @@ -406,7 +406,7 @@ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> </cconfiguration> <cconfiguration id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.915924225"> - <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.915924225" moduleId="org.eclipse.cdt.core.settings" name="Client no Graal"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.915924225" moduleId="org.eclipse.cdt.core.settings" name="Client no JVMCI"> <externalSettings/> <extensions> <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> @@ -418,7 +418,7 @@ </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="hotspot" buildProperties="" description="Client VM without Graal extentions" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.915924225" name="Client no Graal" parent="org.eclipse.cdt.build.core.emptycfg"> + <configuration artifactName="hotspot" buildProperties="" description="Client VM without JVMCI extentions" id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.915924225" name="Client no JVMCI" parent="org.eclipse.cdt.build.core.emptycfg"> <folderInfo id="cdt.managedbuild.toolchain.gnu.solaris.base.945602881.915924225." name="/" resourcePath=""> <toolChain id="cdt.managedbuild.toolchain.gnu.base.237868264" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base"> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.819675926" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/> @@ -475,7 +475,7 @@ </toolChain> </folderInfo> <sourceEntries> - <entry excluding="cpu/vm/templateTable_x86_32.cpp|cpu/vm/templateInterpreter_x86_32.cpp|cpu/vm/stubRoutines_x86_32.cpp|cpu/vm/stubGenerator_x86_32.cpp|cpu/vm/sharedRuntime_x86_32.cpp|cpu/vm/jniFastGetField_x86_32.cpp|cpu/vm/interpreterRT_x86_32.cpp|cpu/vm/interpreter_x86_32.cpp|cpu/vm/interp_masm_x86_32.cpp|cpu/vm/vtableStubs_x86_32.cpp|shared/vm/opto|shared/vm/graal" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/> + <entry excluding="cpu/vm/templateTable_x86_32.cpp|cpu/vm/templateInterpreter_x86_32.cpp|cpu/vm/stubRoutines_x86_32.cpp|cpu/vm/stubGenerator_x86_32.cpp|cpu/vm/sharedRuntime_x86_32.cpp|cpu/vm/jniFastGetField_x86_32.cpp|cpu/vm/interpreterRT_x86_32.cpp|cpu/vm/interpreter_x86_32.cpp|cpu/vm/interp_masm_x86_32.cpp|cpu/vm/vtableStubs_x86_32.cpp|shared/vm/opto|shared/vm/jvmci" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/> </sourceEntries> </configuration> </storageModule>
--- a/hotspot/.project Wed May 27 13:43:27 2015 +0200 +++ b/hotspot/.project Thu May 28 15:36:48 2015 +0200 @@ -106,9 +106,9 @@ <locationURI>PARENT-1-PROJECT_LOC/build/linux/linux_amd64_compiler2/generated</locationURI> </link> <link> - <name>generated_graal</name> + <name>generated_jvmci</name> <type>2</type> - <locationURI>PARENT-1-PROJECT_LOC/build/linux/linux_amd64_graal/generated</locationURI> + <locationURI>PARENT-1-PROJECT_LOC/build/linux/linux_amd64_jvmci/generated</locationURI> </link> <link> <name>generated_java_processor</name>
--- a/make/Makefile Wed May 27 13:43:27 2015 +0200 +++ b/make/Makefile Thu May 28 15:36:48 2015 +0200 @@ -84,7 +84,7 @@ ALT_OUT= endif -# Directory for shared code (e.g. graal.jar) +# Directory for shared code (e.g. jvmci.jar) SHARED_DIR=$(OUTPUTDIR)/shared # Typical C1/C2 targets made available with this Makefile @@ -94,7 +94,7 @@ ZERO_VM_TARGETS=productzero fastdebugzero optimizedzero debugzero SHARK_VM_TARGETS=productshark fastdebugshark optimizedshark debugshark MINIMAL1_VM_TARGETS=productminimal1 fastdebugminimal1 debugminimal1 -GRAAL_VM_TARGETS=productgraal fastdebuggraal optimizedgraal debuggraal +JVMCI_VM_TARGETS=productjvmci fastdebugjvmci optimizedjvmci debugjvmci COMMON_VM_PRODUCT_TARGETS=product product1 docs export_product COMMON_VM_FASTDEBUG_TARGETS=fastdebug fastdebug1 docs export_fastdebug @@ -149,11 +149,11 @@ all_debugcore: debugcore docs export_debug all_optimizedcore: optimizedcore docs export_optimized -allgraal: all_productgraal all_fastdebuggraal -all_productgraal: productgraal docs export_product -all_fastdebuggraal: fastdebuggraal docs export_fastdebug -all_debuggraal: debuggraal docs export_debug -all_optimizedgraal: optimizedgraal docs export_optimized +alljvmci: all_productjvmci all_fastdebugjvmci +all_productjvmci: productjvmci docs export_product +all_fastdebugjvmci: fastdebugjvmci docs export_fastdebug +all_debugjvmci: debugjvmci docs export_debug +all_optimizedjvmci: optimizedjvmci docs export_optimized # Do everything world: all create_jdk @@ -174,11 +174,11 @@ C1_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1 C2_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2 CORE_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_core -GRAAL_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_graal +JVMCI_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_jvmci MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1 ZERO_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_zero SHARK_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_shark -GRAAL_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_graal +JVMCI_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_jvmci # Build variation of hotspot $(C1_VM_TARGETS): @@ -205,9 +205,9 @@ $(CD) $(GAMMADIR)/make; \ $(MAKE) BUILD_DIR=$(MINIMAL1_DIR) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ generic_buildminimal1 $(ALT_OUT) -$(GRAAL_VM_TARGETS): +$(JVMCI_VM_TARGETS): $(CD) $(GAMMADIR)/make; \ - $(MAKE) BUILD_DIR=$(GRAAL_DIR) BUILD_FLAVOR=$(@:%graal=%) VM_TARGET=$@ INCLUDE_GRAAL=true generic_buildgraal $(ALT_OUT) + $(MAKE) BUILD_DIR=$(JVMCI_DIR) BUILD_FLAVOR=$(@:%jvmci=%) VM_TARGET=$@ INCLUDE_JVMCI=true generic_buildjvmci $(ALT_OUT) # Install hotspot script in build directory HOTSPOT_SCRIPT=$(BUILD_DIR)/$(BUILD_FLAVOR)/hotspot @@ -301,7 +301,7 @@ @$(ECHO) "Error: trying to build a minimal target but JVM_VARIANT_MINIMAL1 is not true." endif -generic_buildgraal: $(HOTSPOT_SCRIPT) buildshared +generic_buildjvmci: $(HOTSPOT_SCRIPT) buildshared $(MKDIR) -p $(OUTPUTDIR) $(CD) $(OUTPUTDIR); \ $(MAKE) -f $(ABS_OS_MAKEFILE) \ @@ -350,7 +350,7 @@ C1_BUILD_DIR =$(C1_DIR)/$(BUILD_FLAVOR) C2_BUILD_DIR =$(C2_DIR)/$(BUILD_FLAVOR) CORE_BUILD_DIR =$(CORE_DIR)/$(BUILD_FLAVOR) -GRAAL_BUILD_DIR =$(GRAAL_DIR)/$(BUILD_FLAVOR) +JVMCI_BUILD_DIR =$(JVMCI_DIR)/$(BUILD_FLAVOR) MINIMAL1_BUILD_DIR=$(MINIMAL1_DIR)/$(BUILD_FLAVOR) ZERO_BUILD_DIR =$(ZERO_DIR)/$(BUILD_FLAVOR) SHARK_BUILD_DIR =$(SHARK_DIR)/$(BUILD_FLAVOR) @@ -404,52 +404,52 @@ $(EXPORT_SERVER_DIR)/%.dSYM: $(C2_BUILD_DIR)/%.dSYM $(install-dir) -# Graal +# JVMCI # Common -$(EXPORT_SERVER_DIR)/%.diz: $(GRAAL_BUILD_DIR)/%.diz +$(EXPORT_SERVER_DIR)/%.diz: $(JVMCI_BUILD_DIR)/%.diz $(install-file) -$(EXPORT_LIB_DIR)/%.jar: $(GRAAL_BUILD_DIR)/../generated/%.jar +$(EXPORT_LIB_DIR)/%.jar: $(JVMCI_BUILD_DIR)/../generated/%.jar $(install-file) -$(EXPORT_INCLUDE_DIR)/%: $(GRAAL_BUILD_DIR)/../generated/jvmtifiles/% +$(EXPORT_INCLUDE_DIR)/%: $(JVMCI_BUILD_DIR)/../generated/jvmtifiles/% $(install-file) # Windows -$(EXPORT_SERVER_DIR)/%.dll: $(GRAAL_BUILD_DIR)/%.dll +$(EXPORT_SERVER_DIR)/%.dll: $(JVMCI_BUILD_DIR)/%.dll $(install-file) -$(EXPORT_SERVER_DIR)/%.pdb: $(GRAAL_BUILD_DIR)/%.pdb +$(EXPORT_SERVER_DIR)/%.pdb: $(JVMCI_BUILD_DIR)/%.pdb $(install-file) -$(EXPORT_SERVER_DIR)/%.map: $(GRAAL_BUILD_DIR)/%.map +$(EXPORT_SERVER_DIR)/%.map: $(JVMCI_BUILD_DIR)/%.map $(install-file) -$(EXPORT_LIB_DIR)/%.lib: $(GRAAL_BUILD_DIR)/%.lib +$(EXPORT_LIB_DIR)/%.lib: $(JVMCI_BUILD_DIR)/%.lib $(install-file) -$(EXPORT_JRE_BIN_DIR)/%.diz: $(GRAAL_BUILD_DIR)/%.diz +$(EXPORT_JRE_BIN_DIR)/%.diz: $(JVMCI_BUILD_DIR)/%.diz $(install-file) -$(EXPORT_JRE_BIN_DIR)/%.dll: $(GRAAL_BUILD_DIR)/%.dll +$(EXPORT_JRE_BIN_DIR)/%.dll: $(JVMCI_BUILD_DIR)/%.dll $(install-file) -$(EXPORT_JRE_BIN_DIR)/%.pdb: $(GRAAL_BUILD_DIR)/%.pdb +$(EXPORT_JRE_BIN_DIR)/%.pdb: $(JVMCI_BUILD_DIR)/%.pdb $(install-file) -$(EXPORT_JRE_BIN_DIR)/%.map: $(GRAAL_BUILD_DIR)/%.map +$(EXPORT_JRE_BIN_DIR)/%.map: $(JVMCI_BUILD_DIR)/%.map $(install-file) # Unix -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(GRAAL_BUILD_DIR)/%.$(LIBRARY_SUFFIX) +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(JVMCI_BUILD_DIR)/%.$(LIBRARY_SUFFIX) $(install-file) -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(GRAAL_BUILD_DIR)/%.$(LIBRARY_SUFFIX) +$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(JVMCI_BUILD_DIR)/%.$(LIBRARY_SUFFIX) $(install-file) -$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX): $(GRAAL_BUILD_DIR)/%.$(LIBRARY_SUFFIX) +$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX): $(JVMCI_BUILD_DIR)/%.$(LIBRARY_SUFFIX) $(install-file) -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(GRAAL_BUILD_DIR)/%.debuginfo +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: $(JVMCI_BUILD_DIR)/%.debuginfo $(install-file) -$(EXPORT_SERVER_DIR)/%.debuginfo: $(GRAAL_BUILD_DIR)/%.debuginfo +$(EXPORT_SERVER_DIR)/%.debuginfo: $(JVMCI_BUILD_DIR)/%.debuginfo $(install-file) -$(EXPORT_SERVER_DIR)/64/%.debuginfo: $(GRAAL_BUILD_DIR)/%.debuginfo +$(EXPORT_SERVER_DIR)/64/%.debuginfo: $(JVMCI_BUILD_DIR)/%.debuginfo $(install-file) -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(GRAAL_BUILD_DIR)/%.diz +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: $(JVMCI_BUILD_DIR)/%.diz $(install-file) -$(EXPORT_SERVER_DIR)/64/%.diz: $(GRAAL_BUILD_DIR)/%.diz +$(EXPORT_SERVER_DIR)/64/%.diz: $(JVMCI_BUILD_DIR)/%.diz $(install-file) # MacOS X -$(EXPORT_JRE_LIB_ARCH_DIR)/%.dSYM: $(GRAAL_BUILD_DIR)/%.dSYM +$(EXPORT_JRE_LIB_ARCH_DIR)/%.dSYM: $(JVMCI_BUILD_DIR)/%.dSYM $(install-dir) -$(EXPORT_SERVER_DIR)/%.dSYM: $(GRAAL_BUILD_DIR)/%.dSYM +$(EXPORT_SERVER_DIR)/%.dSYM: $(JVMCI_BUILD_DIR)/%.dSYM $(install-dir) endif @@ -632,10 +632,10 @@ $(EXPORT_JRE_LIB_EXT_DIR)/%.jar: $(SHARED_DIR)/%.jar $(install-file) -$(EXPORT_JRE_LIB_GRAAL_DIR)/%.jar: $(SHARED_DIR)/%.jar +$(EXPORT_JRE_LIB_JVMCI_DIR)/%.jar: $(SHARED_DIR)/%.jar $(install-file) -$(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/%: $(SHARED_DIR)/services/% +$(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/%: $(SHARED_DIR)/services/% $(install-file) $(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/code/% @@ -680,7 +680,7 @@ $(RM) -r $(C1_DIR) $(RM) -r $(C2_DIR) $(RM) -r $(CORE_DIR) - $(RM) -r $(GRAAL_DIR) + $(RM) -r $(JVMCI_DIR) $(RM) -r $(ZERO_DIR) $(RM) -r $(SHARK_DIR) $(RM) -r $(MINIMAL1_DIR) @@ -944,7 +944,7 @@ jvmgshark: warn_jvmg_deprecated debugshark -jvmggraal: warn_jvmg_deprecated debuggraal +jvmgjvmci: warn_jvmg_deprecated debugjvmci # JPRT rule to build this workspace include $(GAMMADIR)/make/jprt.gmk
--- a/make/bsd/Makefile Wed May 27 13:43:27 2015 +0200 +++ b/make/bsd/Makefile Thu May 28 15:36:48 2015 +0200 @@ -192,7 +192,7 @@ SUBDIRS_ZERO = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS)) SUBDIRS_SHARK = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS)) SUBDIRS_MINIMAL1 = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS)) -SUBDIRS_GRAAL = $(addprefix $(OSNAME)_$(BUILDARCH)_graal/,$(TARGETS)) +SUBDIRS_JVMCI = $(addprefix $(OSNAME)_$(BUILDARCH)_jvmci/,$(TARGETS)) TARGETS_C2 = $(TARGETS) TARGETS_C1 = $(addsuffix 1,$(TARGETS)) @@ -201,7 +201,7 @@ TARGETS_ZERO = $(addsuffix zero,$(TARGETS)) TARGETS_SHARK = $(addsuffix shark,$(TARGETS)) TARGETS_MINIMAL1 = $(addsuffix minimal1,$(TARGETS)) -TARGETS_GRAAL = $(addsuffix graal,$(TARGETS)) +TARGETS_JVMCI = $(addsuffix jvmci,$(TARGETS)) BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) LIBRARY_SUFFIX=$(LIBRARY_SUFFIX) @@ -221,7 +221,7 @@ @echo " $(TARGETS_ZERO)" @echo " $(TARGETS_SHARK)" @echo " $(TARGETS_MINIMAL1)" - @echo " $(TARGETS_GRAAL)" + @echo " $(TARGETS_JVMCI)" checks: check_os_version check_j2se_version @@ -284,9 +284,9 @@ $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks $(BUILDTREE) VARIANT=minimal1 -$(SUBDIRS_GRAAL): $(BUILDTREE_MAKE) +$(SUBDIRS_JVMCI): $(BUILDTREE_MAKE) $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - $(BUILDTREE) VARIANT=graal + $(BUILDTREE) VARIANT=jvmci platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in $(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@ @@ -335,10 +335,10 @@ cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install endif -$(TARGETS_GRAAL): $(SUBDIRS_GRAAL) - cd $(OSNAME)_$(BUILDARCH)_graal/$(patsubst %graal,%,$@) && $(MAKE) $(MFLAGS) +$(TARGETS_JVMCI): $(SUBDIRS_JVMCI) + cd $(OSNAME)_$(BUILDARCH)_jvmci/$(patsubst %jvmci,%,$@) && $(MAKE) $(MFLAGS) ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_graal/$(patsubst %graal,%,$@) && $(MAKE) $(MFLAGS) install + cd $(OSNAME)_$(BUILDARCH)_jvmci/$(patsubst %jvmci,%,$@) && $(MAKE) $(MFLAGS) install endif # Just build the tree, and nothing else: @@ -348,7 +348,7 @@ treezero: $(SUBDIRS_ZERO) treeshark: $(SUBDIRS_SHARK) treeminimal1: $(SUBDIRS_MINIMAL1) -treegraal: $(SUBDIRS_GRAAL) +treejvmci: $(SUBDIRS_JVMCI) # Doc target. This is the same for all build options. # Hence create a docs directory beside ...$(ARCH)_[...] @@ -400,9 +400,9 @@ #------------------------------------------------------------------------------- -.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1) $(TARGETS_GRAAL) -.PHONY: tree tree1 treecore treezero treeshark treegraal -.PHONY: all compiler1 compiler2 core zero shark graal -.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs clean_graal +.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1) $(TARGETS_JVMCI) +.PHONY: tree tree1 treecore treezero treeshark treejvmci +.PHONY: all compiler1 compiler2 core zero shark jvmci +.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs clean_jvmci .PHONY: checks check_os_version check_j2se_version .PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
--- a/make/bsd/makefiles/compiler1.make Wed May 27 13:43:27 2015 +0200 +++ b/make/bsd/makefiles/compiler1.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER1 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = client-nograal + VM_SUBDIR = client-nojvmci endif \ No newline at end of file
--- a/make/bsd/makefiles/compiler2.make Wed May 27 13:43:27 2015 +0200 +++ b/make/bsd/makefiles/compiler2.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER2 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = server-nograal + VM_SUBDIR = server-nojvmci endif \ No newline at end of file
--- a/make/bsd/makefiles/gcc.make Wed May 27 13:43:27 2015 +0200 +++ b/make/bsd/makefiles/gcc.make Thu May 28 15:36:48 2015 +0200 @@ -149,7 +149,7 @@ PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH) - PCH_FLAG/graalCompilerToVM.o = $(PCH_FLAG/NO_PCH) + PCH_FLAG/jvmciCompilerToVM.o = $(PCH_FLAG/NO_PCH) endif else # ($(USE_CLANG), true)
--- a/make/bsd/makefiles/graal.make Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2008, 2010 Red Hat, Inc. -# 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. -# -# - -# Sets make macros for making Graal version of VM - -TYPE = GRAAL - -VM_SUBDIR = graal - -# To make a non-tiered Graal build, remove the -DCOMPILER1 below and -# in vm.make remove COMPILER1_PATHS from Src_Dirs/GRAAL and add -# COMPILER1_SPECIFIC_FILES to Src_Files_EXCLUDE/GRAAL -CFLAGS += -DCOMPILERGRAAL -DGRAAL -DCOMPILER1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bsd/makefiles/jvmci.make Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,35 @@ +# +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2008, 2010 Red Hat, Inc. +# 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. +# +# + +# Sets make macros for making JVMCI version of VM + +TYPE = JVMCI + +VM_SUBDIR = jvmci + +# To make a non-tiered JVMCI build, remove the -DCOMPILER1 below and +# in vm.make remove COMPILER1_PATHS from Src_Dirs/JVMCI and add +# COMPILER1_SPECIFIC_FILES to Src_Files_EXCLUDE/JVMCI +CFLAGS += -DCOMPILERJVMCI -DJVMCI -DCOMPILER1
--- a/make/bsd/makefiles/tiered.make Wed May 27 13:43:27 2015 +0200 +++ b/make/bsd/makefiles/tiered.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER2 -DCOMPILER1 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = server-nograal + VM_SUBDIR = server-nojvmci endif
--- a/make/bsd/makefiles/vm.make Wed May 27 13:43:27 2015 +0200 +++ b/make/bsd/makefiles/vm.make Thu May 28 15:36:48 2015 +0200 @@ -111,10 +111,6 @@ CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\"" endif -ifeq ($(INCLUDE_GRAAL), true) - CXXFLAGS += -DGRAAL_VERSION="\"$(GRAAL_VERSION)\"" -endif - # CFLAGS_WARN holds compiler options to suppress/enable warnings. CFLAGS += $(CFLAGS_WARN/BYFILE) @@ -171,7 +167,7 @@ LIBJVM_DIZ = lib$(JVM).diz endif -SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt graal +SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt jvmci SOURCE_PATHS=\ $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ @@ -201,17 +197,17 @@ SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark -GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/graal) -GRAAL_PATHS += $(HS_COMMON_SRC)/share/vm/graal +JVMCI_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/jvmci) +JVMCI_PATHS += $(HS_COMMON_SRC)/share/vm/jvmci # Include dirs per type. Src_Dirs/CORE := $(CORE_PATHS) -Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) $(GRAAL_PATHS) -Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) $(GRAAL_PATHS) -Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) $(GRAAL_PATHS) +Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) $(JVMCI_PATHS) +Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) $(JVMCI_PATHS) +Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) $(JVMCI_PATHS) Src_Dirs/ZERO := $(CORE_PATHS) Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) -Src_Dirs/GRAAL := $(CORE_PATHS) $(COMPILER1_PATHS) $(GRAAL_PATHS) +Src_Dirs/JVMCI := $(CORE_PATHS) $(COMPILER1_PATHS) $(JVMCI_PATHS) Src_Dirs := $(Src_Dirs/$(TYPE)) COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* @@ -219,10 +215,10 @@ SHARK_SPECIFIC_FILES := shark ZERO_SPECIFIC_FILES := zero -ifneq ($(INCLUDE_GRAAL), true) - GRAAL_SPECIFIC_FILES := graal\* +ifneq ($(INCLUDE_JVMCI), true) + JVMCI_SPECIFIC_FILES := jvmci\* else - GRAAL_SPECIFIC_FILES := + JVMCI_SPECIFIC_FILES := Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.jvmci.hotspot/src_gen/hotspot endif @@ -230,13 +226,13 @@ Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp # Exclude per type. -Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/GRAAL := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/JVMCI := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE))
--- a/make/defs.make Wed May 27 13:43:27 2015 +0200 +++ b/make/defs.make Thu May 28 15:36:48 2015 +0200 @@ -341,8 +341,8 @@ EXPORT_JRE_BIN_DIR = $(EXPORT_JRE_DIR)/bin EXPORT_JRE_LIB_DIR = $(EXPORT_JRE_DIR)/lib EXPORT_JRE_LIB_EXT_DIR = $(EXPORT_JRE_LIB_DIR)/ext -EXPORT_JRE_LIB_GRAAL_DIR = $(EXPORT_JRE_LIB_DIR)/graal -EXPORT_JRE_LIB_GRAAL_SERVICES_DIR = $(EXPORT_JRE_LIB_GRAAL_DIR)/services +EXPORT_JRE_LIB_JVMCI_DIR = $(EXPORT_JRE_LIB_DIR)/jvmci +EXPORT_JRE_LIB_JVMCI_SERVICES_DIR = $(EXPORT_JRE_LIB_JVMCI_DIR)/services EXPORT_JRE_LIB_ARCH_DIR = $(EXPORT_JRE_LIB_DIR)/$(LIBARCH) # non-universal macosx builds need to appear universal @@ -358,21 +358,22 @@ EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h -EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/graal-loader.jar +EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/jvmci-loader.jar EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/truffle.jar -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/graal.jar -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/graal-truffle.jar +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/graal.jar +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/graal-truffle.jar -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.compiler.match.MatchStatementSet -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.hotspot.HotSpotBackendFactory -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.nodes.spi.ReplacementsProvider -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.phases.tiers.CompilerConfiguration -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.truffle.hotspot.nfi.RawNativeCallNodeFactory -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.truffle.OptimizedCallTargetInstrumentationFactory -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.graal.api.runtime.GraalRuntimeFactory -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.jvmci.hotspot.HotSpotJVMCIBackendFactory -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.jvmci.hotspot.HotSpotVMEventListener -EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/com.oracle.jvmci.runtime.OptionsParsed +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.hotspot.HotSpotJVMCIBackendFactory +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.hotspot.HotSpotVMEventListener +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.jvmci.runtime.OptionsParsed + +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.api.runtime.GraalRuntimeFactory +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.compiler.match.MatchStatementSet +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.hotspot.HotSpotBackendFactory +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.nodes.spi.ReplacementsProvider +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.phases.tiers.CompilerConfiguration +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.truffle.hotspot.nfi.RawNativeCallNodeFactory +EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/com.oracle.graal.truffle.OptimizedCallTargetInstrumentationFactory .PHONY: $(HS_ALT_MAKE)/defs.make
--- a/make/linux/Makefile Wed May 27 13:43:27 2015 +0200 +++ b/make/linux/Makefile Thu May 28 15:36:48 2015 +0200 @@ -195,7 +195,7 @@ SUBDIRS_ZERO = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS)) SUBDIRS_SHARK = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS)) SUBDIRS_MINIMAL1 = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS)) -SUBDIRS_GRAAL = $(addprefix $(OSNAME)_$(BUILDARCH)_graal/,$(TARGETS)) +SUBDIRS_JVMCI = $(addprefix $(OSNAME)_$(BUILDARCH)_jvmci/,$(TARGETS)) TARGETS_C2 = $(TARGETS) TARGETS_C1 = $(addsuffix 1,$(TARGETS)) @@ -204,7 +204,7 @@ TARGETS_ZERO = $(addsuffix zero,$(TARGETS)) TARGETS_SHARK = $(addsuffix shark,$(TARGETS)) TARGETS_MINIMAL1 = $(addsuffix minimal1,$(TARGETS)) -TARGETS_GRAAL = $(addsuffix graal,$(TARGETS)) +TARGETS_JVMCI = $(addsuffix jvmci,$(TARGETS)) BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) @@ -224,7 +224,7 @@ @echo " $(TARGETS_ZERO)" @echo " $(TARGETS_SHARK)" @echo " $(TARGETS_MINIMAL1)" - @echo " $(TARGETS_GRAAL)" + @echo " $(TARGETS_JVMCI)" checks: check_os_version check_j2se_version @@ -286,9 +286,9 @@ $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks $(BUILDTREE) VARIANT=minimal1 -$(SUBDIRS_GRAAL): $(BUILDTREE_MAKE) +$(SUBDIRS_JVMCI): $(BUILDTREE_MAKE) $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - $(BUILDTREE) VARIANT=graal + $(BUILDTREE) VARIANT=jvmci platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in $(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@ @@ -337,10 +337,10 @@ cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install endif -$(TARGETS_GRAAL): $(SUBDIRS_GRAAL) - cd $(OSNAME)_$(BUILDARCH)_graal/$(patsubst %graal,%,$@) && $(MAKE) $(MFLAGS) +$(TARGETS_JVMCI): $(SUBDIRS_JVMCI) + cd $(OSNAME)_$(BUILDARCH)_jvmci/$(patsubst %jvmci,%,$@) && $(MAKE) $(MFLAGS) ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_graal/$(patsubst %graal,%,$@) && $(MAKE) $(MFLAGS) install + cd $(OSNAME)_$(BUILDARCH)_jvmci/$(patsubst %jvmci,%,$@) && $(MAKE) $(MFLAGS) install endif # Just build the tree, and nothing else: @@ -350,7 +350,7 @@ treezero: $(SUBDIRS_ZERO) treeshark: $(SUBDIRS_SHARK) treeminimal1: $(SUBDIRS_MINIMAL1) -treegraal: $(SUBDIRS_GRAAL) +treejvmci: $(SUBDIRS_JVMCI) # Doc target. This is the same for all build options. # Hence create a docs directory beside ...$(ARCH)_[...] @@ -388,10 +388,10 @@ clean_docs: rm -rf $(SUBDIR_DOCS) -clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_graal clean_minimal1: +clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_jvmci clean_minimal1: rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@) -clean: clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_graal clean_docs +clean: clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_jvmci clean_docs include $(GAMMADIR)/make/cscope.make @@ -402,9 +402,9 @@ #------------------------------------------------------------------------------- -.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1) $(TARGETS_GRAAL) -.PHONY: tree tree1 treecore treezero treeshark treegraal -.PHONY: all compiler1 compiler2 core zero shark graal -.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs clean_graal +.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1) $(TARGETS_JVMCI) +.PHONY: tree tree1 treecore treezero treeshark treejvmci +.PHONY: all compiler1 compiler2 core zero shark jvmci +.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs clean_jvmci .PHONY: checks check_os_version check_j2se_version .PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make
--- a/make/linux/makefiles/compiler1.make Wed May 27 13:43:27 2015 +0200 +++ b/make/linux/makefiles/compiler1.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER1 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = client-nograal + VM_SUBDIR = client-nojvmci endif \ No newline at end of file
--- a/make/linux/makefiles/compiler2.make Wed May 27 13:43:27 2015 +0200 +++ b/make/linux/makefiles/compiler2.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER2 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = server-nograal + VM_SUBDIR = server-nojvmci endif \ No newline at end of file
--- a/make/linux/makefiles/graal.make Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2008, 2010 Red Hat, Inc. -# 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. -# -# - -# Sets make macros for making Graal version of VM - -TYPE = GRAAL - -VM_SUBDIR = graal - -# To make a non-tiered Graal build, remove the -DCOMPILER1 below and -# in vm.make remove COMPILER1_PATHS from Src_Dirs/GRAAL and add -# COMPILER1_SPECIFIC_FILES to Src_Files_EXCLUDE/GRAAL -CFLAGS += -DCOMPILERGRAAL -DGRAAL -DCOMPILER1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/linux/makefiles/jvmci.make Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,35 @@ +# +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2008, 2010 Red Hat, Inc. +# 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. +# +# + +# Sets make macros for making JVMCI version of VM + +TYPE = JVMCI + +VM_SUBDIR = jvmci + +# To make a non-tiered JVMCI build, remove the -DCOMPILER1 below and +# in vm.make remove COMPILER1_PATHS from Src_Dirs/JVMCI and add +# COMPILER1_SPECIFIC_FILES to Src_Files_EXCLUDE/JVMCI +CFLAGS += -DCOMPILERJVMCI -DJVMCI -DCOMPILER1
--- a/make/linux/makefiles/tiered.make Wed May 27 13:43:27 2015 +0200 +++ b/make/linux/makefiles/tiered.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER2 -DCOMPILER1 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = server-nograal + VM_SUBDIR = server-nojvmci endif \ No newline at end of file
--- a/make/linux/makefiles/vm.make Wed May 27 13:43:27 2015 +0200 +++ b/make/linux/makefiles/vm.make Thu May 28 15:36:48 2015 +0200 @@ -113,10 +113,6 @@ CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64 endif # ifneq ($(LP64), 1) -ifeq ($(INCLUDE_GRAAL), true) - CXXFLAGS += -DGRAAL_VERSION="\"$(GRAAL_VERSION)\"" -endif - # CFLAGS_WARN holds compiler options to suppress/enable warnings. CFLAGS += $(CFLAGS_WARN/BYFILE) @@ -151,7 +147,7 @@ LIBJVM_DEBUGINFO = lib$(JVM).debuginfo LIBJVM_DIZ = lib$(JVM).diz -SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt graal +SPECIAL_PATHS:=adlc c1 gc_implementation opto shark libadt jvmci SOURCE_PATHS=\ $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ @@ -181,17 +177,17 @@ SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark -GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/graal) -GRAAL_PATHS += $(HS_COMMON_SRC)/share/vm/graal +JVMCI_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/jvmci) +JVMCI_PATHS += $(HS_COMMON_SRC)/share/vm/jvmci # Include dirs per type. Src_Dirs/CORE := $(CORE_PATHS) -Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) $(GRAAL_PATHS) -Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) $(GRAAL_PATHS) -Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) $(GRAAL_PATHS) +Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) $(JVMCI_PATHS) +Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) $(JVMCI_PATHS) +Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) $(JVMCI_PATHS) Src_Dirs/ZERO := $(CORE_PATHS) Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) -Src_Dirs/GRAAL := $(CORE_PATHS) $(COMPILER1_PATHS) $(GRAAL_PATHS) +Src_Dirs/JVMCI := $(CORE_PATHS) $(COMPILER1_PATHS) $(JVMCI_PATHS) Src_Dirs := $(Src_Dirs/$(TYPE)) COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* @@ -199,10 +195,10 @@ SHARK_SPECIFIC_FILES := shark ZERO_SPECIFIC_FILES := zero -ifneq ($(INCLUDE_GRAAL), true) - GRAAL_SPECIFIC_FILES := graal\* +ifneq ($(INCLUDE_JVMCI), true) + JVMCI_SPECIFIC_FILES := jvmci\* else - GRAAL_SPECIFIC_FILES := + JVMCI_SPECIFIC_FILES := Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.jvmci.hotspot/src_gen/hotspot endif @@ -210,13 +206,13 @@ Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp # Exclude per type. -Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/GRAAL := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/JVMCI := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE))
--- a/make/solaris/Makefile Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/Makefile Thu May 28 15:36:48 2015 +0200 @@ -149,13 +149,13 @@ SUBDIRS_C2 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS)) SUBDIRS_TIERED = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS)) SUBDIRS_CORE = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS)) -SUBDIRS_GRAAL = $(addprefix $(OSNAME)_$(BUILDARCH)_graal/,$(TARGETS)) +SUBDIRS_JVMCI = $(addprefix $(OSNAME)_$(BUILDARCH)_jvmci/,$(TARGETS)) TARGETS_C2 = $(TARGETS) TARGETS_C1 = $(addsuffix 1,$(TARGETS)) TARGETS_TIERED = $(addsuffix tiered,$(TARGETS)) TARGETS_CORE = $(addsuffix core,$(TARGETS)) -TARGETS_GRAAL = $(addsuffix graal,$(TARGETS)) +TARGETS_JVMCI = $(addsuffix jvmci,$(TARGETS)) BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) ARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) @@ -173,7 +173,7 @@ @echo " $(TARGETS_C2)" @echo " $(TARGETS_C1)" @echo " $(TARGETS_CORE)" - @echo " $(TARGETS_GRAAL)" + @echo " $(TARGETS_JVMCI)" checks: check_os_version check_j2se_version @@ -223,9 +223,9 @@ $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks $(BUILDTREE) VARIANT=core -$(SUBDIRS_GRAAL): $(BUILDTREE_MAKE) +$(SUBDIRS_JVMCI): $(BUILDTREE_MAKE) $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - $(BUILDTREE) VARIANT=graal + $(BUILDTREE) VARIANT=jvmci # Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME @@ -253,17 +253,17 @@ cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install endif -$(TARGETS_GRAAL): $(SUBDIRS_GRAAL) - cd $(OSNAME)_$(BUILDARCH)_graal/$(patsubst %graal,%,$@) && $(MAKE) $(MFLAGS) +$(TARGETS_JVMCI): $(SUBDIRS_JVMCI) + cd $(OSNAME)_$(BUILDARCH)_jvmci/$(patsubst %jvmci,%,$@) && $(MAKE) $(MFLAGS) ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_graal/$(patsubst %graal,%,$@) && $(MAKE) $(MFLAGS) install + cd $(OSNAME)_$(BUILDARCH)_jvmci/$(patsubst %jvmci,%,$@) && $(MAKE) $(MFLAGS) install endif # Just build the tree, and nothing else: tree: $(SUBDIRS_C2) tree1: $(SUBDIRS_C1) treecore: $(SUBDIRS_CORE) -treegraal: $(SUBDIRS_GRAAL) +treejvmci: $(SUBDIRS_JVMCI) # Doc target. This is the same for all build options. # Hence create a docs directory beside ...$(ARCH)_[...] @@ -293,17 +293,17 @@ clean_docs: rm -rf $(SUBDIR_DOCS) -clean_compiler1 clean_compiler2 clean_core clean_graal: +clean_compiler1 clean_compiler2 clean_core clean_jvmci: rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@) -clean: clean_compiler2 clean_compiler1 clean_core clean_docs clean_graal +clean: clean_compiler2 clean_compiler1 clean_core clean_docs clean_jvmci include $(GAMMADIR)/make/cscope.make #------------------------------------------------------------------------------- .PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) -.PHONY: tree tree1 treecore treegraal -.PHONY: all compiler1 compiler2 core graal -.PHONY: clean clean_compiler1 clean_compiler2 clean_core docs clean_docs clean_graal +.PHONY: tree tree1 treecore treejvmci +.PHONY: all compiler1 compiler2 core jvmci +.PHONY: clean clean_compiler1 clean_compiler2 clean_core docs clean_docs clean_jvmci .PHONY: checks check_os_version check_j2se_version
--- a/make/solaris/makefiles/compiler1.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/compiler1.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER1 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = client-nograal + VM_SUBDIR = client-nojvmci endif
--- a/make/solaris/makefiles/compiler2.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/compiler2.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER2 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = server-nograal + VM_SUBDIR = server-nojvmci endif
--- a/make/solaris/makefiles/debug.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/debug.make Thu May 28 15:36:48 2015 +0200 @@ -46,8 +46,8 @@ # Linker mapfiles MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \ $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug -#ifdef GRAAL -MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-GRAAL +#ifdef JVMCI +MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-JVMCI #endif # This mapfile is only needed when compiling with dtrace support,
--- a/make/solaris/makefiles/fastdebug.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/fastdebug.make Thu May 28 15:36:48 2015 +0200 @@ -117,8 +117,8 @@ # Linker mapfiles MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \ $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug -#ifdef GRAAL -MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-GRAAL +#ifdef JVMCI +MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-JVMCI #endif # This mapfile is only needed when compiling with dtrace support,
--- a/make/solaris/makefiles/graal.make Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2008, 2010 Red Hat, Inc. -# 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. -# -# - -# Sets make macros for making Graal version of VM - -TYPE = GRAAL - -VM_SUBDIR = graal - -# To make a non-tiered Graal build, remove the -DCOMPILER1 below and -# in vm.make remove COMPILER1_PATHS from Src_Dirs/GRAAL and add -# COMPILER1_SPECIFIC_FILES to Src_Files_EXCLUDE/GRAAL -CFLAGS += -DCOMPILERGRAAL -DGRAAL -DCOMPILER1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/solaris/makefiles/jvmci.make Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,35 @@ +# +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2008, 2010 Red Hat, Inc. +# 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. +# +# + +# Sets make macros for making JVMCI version of VM + +TYPE = JVMCI + +VM_SUBDIR = jvmci + +# To make a non-tiered JVMCI build, remove the -DCOMPILER1 below and +# in vm.make remove COMPILER1_PATHS from Src_Dirs/JVMCI and add +# COMPILER1_SPECIFIC_FILES to Src_Files_EXCLUDE/JVMCI +CFLAGS += -DCOMPILERJVMCI -DJVMCI -DCOMPILER1
--- a/make/solaris/makefiles/optimized.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/optimized.make Thu May 28 15:36:48 2015 +0200 @@ -54,8 +54,8 @@ # Linker mapfiles MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers -#ifdef GRAAL -MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-GRAAL +#ifdef JVMCI +MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-JVMCI #endif # This mapfile is only needed when compiling with dtrace support,
--- a/make/solaris/makefiles/product.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/product.make Thu May 28 15:36:48 2015 +0200 @@ -66,8 +66,8 @@ # Linker mapfiles MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers -ifdef GRAAL -MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-GRAAL +ifdef JVMCI +MAPFILE += $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-JVMCI endif ifndef USE_GCC
--- a/make/solaris/makefiles/tiered.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/tiered.make Thu May 28 15:36:48 2015 +0200 @@ -30,8 +30,8 @@ CFLAGS += -DCOMPILER2 -DCOMPILER1 -ifeq ($(INCLUDE_GRAAL), true) - CFLAGS += -DGRAAL +ifeq ($(INCLUDE_JVMCI), true) + CFLAGS += -DJVMCI else - VM_SUBDIR = server-nograal + VM_SUBDIR = server-nojvmci endif
--- a/make/solaris/makefiles/vm.make Wed May 27 13:43:27 2015 +0200 +++ b/make/solaris/makefiles/vm.make Thu May 28 15:36:48 2015 +0200 @@ -100,10 +100,6 @@ CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64 endif # ifneq ($(LP64), 1) -ifeq ($(INCLUDE_GRAAL), true) - CXXFLAGS += -DGRAAL_VERSION="\"$(GRAAL_VERSION)\"" -endif - # CFLAGS_WARN holds compiler options to suppress/enable warnings. CFLAGS += $(CFLAGS_WARN) @@ -165,7 +161,7 @@ LIBJVM_DEBUGINFO = lib$(JVM).debuginfo LIBJVM_DIZ = lib$(JVM).diz -SPECIAL_PATHS:=adlc c1 dist gc_implementation opto shark libadt graal +SPECIAL_PATHS:=adlc c1 dist gc_implementation opto shark libadt jvmci SOURCE_PATHS=\ $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ @@ -193,17 +189,17 @@ COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt COMPILER2_PATHS += $(GENERATED)/adfiles -GRAAL_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/graal) -GRAAL_PATHS += $(HS_COMMON_SRC)/share/vm/graal +JVMCI_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/jvmci) +JVMCI_PATHS += $(HS_COMMON_SRC)/share/vm/jvmci # Include dirs per type. Src_Dirs/CORE := $(CORE_PATHS) -Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) $(GRAAL_PATHS) -Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) $(GRAAL_PATHS) -Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) $(GRAAL_PATHS) +Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) $(JVMCI_PATHS) +Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) $(JVMCI_PATHS) +Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) $(JVMCI_PATHS) Src_Dirs/ZERO := $(CORE_PATHS) Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) -Src_Dirs/GRAAL := $(CORE_PATHS) $(COMPILER1_PATHS) $(GRAAL_PATHS) +Src_Dirs/JVMCI := $(CORE_PATHS) $(COMPILER1_PATHS) $(JVMCI_PATHS) Src_Dirs := $(Src_Dirs/$(TYPE)) COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* @@ -211,10 +207,10 @@ SHARK_SPECIFIC_FILES := shark ZERO_SPECIFIC_FILES := zero -ifneq ($(INCLUDE_GRAAL), true) - GRAAL_SPECIFIC_FILES := graal\* +ifneq ($(INCLUDE_JVMCI), true) + JVMCI_SPECIFIC_FILES := jvmci\* else - GRAAL_SPECIFIC_FILES := + JVMCI_SPECIFIC_FILES := Src_Dirs_I += $(HS_COMMON_SRC)/../graal/com.oracle.jvmci.hotspot/src_gen/hotspot endif @@ -222,13 +218,13 @@ Src_Files_EXCLUDE := dtrace jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp # Exclude per type. -Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(GRAAL_SPECIFIC_FILES) -Src_Files_EXCLUDE/GRAAL := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) ciTypeFlow.cpp +Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(JVMCI_SPECIFIC_FILES) +Src_Files_EXCLUDE/JVMCI := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE))
--- a/make/windows/build.make Wed May 27 13:43:27 2015 +0200 +++ b/make/windows/build.make Thu May 28 15:36:48 2015 +0200 @@ -110,8 +110,8 @@ !endif !elseif "$(Variant)" == "tiered" VARIANT_TEXT=Tiered -!elseif "$(Variant)" == "graal" -VARIANT_TEXT=Graal +!elseif "$(Variant)" == "jvmci" +VARIANT_TEXT=JVMCI !endif ######################################################################### @@ -308,9 +308,9 @@ checks: checkVariant checkWorkSpace checkSA checkVariant: - @ if "$(Variant)"=="" echo Need to specify "Variant=[graal|tiered|compiler2|compiler1|core]" && false - @ if "$(Variant)" NEQ "graal" if "$(Variant)" NEQ "tiered" if "$(Variant)" NEQ "compiler2" if "$(Variant)" NEQ "compiler1" if "$(Variant)" NEQ "core" \ - echo Need to specify "Variant=[graal|tiered|compiler2|compiler1|core]" && false + @ if "$(Variant)"=="" echo Need to specify "Variant=[jvmci|tiered|compiler2|compiler1|core]" && false + @ if "$(Variant)" NEQ "jvmci" if "$(Variant)" NEQ "tiered" if "$(Variant)" NEQ "compiler2" if "$(Variant)" NEQ "compiler1" if "$(Variant)" NEQ "core" \ + echo Need to specify "Variant=[jvmci|tiered|compiler2|compiler1|core]" && false checkWorkSpace: @ if "$(WorkSpace)"=="" echo Need to specify "WorkSpace=..." && false
--- a/make/windows/create.bat Wed May 27 13:43:27 2015 +0200 +++ b/make/windows/create.bat Thu May 28 15:36:48 2015 +0200 @@ -159,7 +159,7 @@ REM This is now safe to do. :copyfiles -for /D %%i in (graal, compiler1, compiler2, tiered) do ( +for /D %%i in (jvmci, compiler1, compiler2, tiered) do ( if NOT EXIST %HotSpotBuildSpace%\%%i\generated mkdir %HotSpotBuildSpace%\%%i\generated copy %HotSpotWorkSpace%\make\windows\projectfiles\%%i\* %HotSpotBuildSpace%\%%i\generated > NUL ) @@ -167,7 +167,7 @@ REM force regneration of ProjectFile if exist %ProjectFile% del %ProjectFile% -for /D %%i in (graal, compiler1, compiler2, tiered) do ( +for /D %%i in (jvmci, compiler1, compiler2, tiered) do ( echo -- %%i -- echo # Generated file! > %HotSpotBuildSpace%\%%i\local.make echo # Changing a variable below and then deleting %ProjectFile% will cause >> %HotSpotBuildSpace%\%%i\local.make
--- a/make/windows/makefiles/projectcreator.make Wed May 27 13:43:27 2015 +0200 +++ b/make/windows/makefiles/projectcreator.make Thu May 28 15:36:48 2015 +0200 @@ -56,7 +56,7 @@ -relativeInclude src\os\windows\vm \ -relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \ -relativeInclude src\cpu\$(Platform_arch)\vm \ - -relativeInclude graal\com.oracle.graal.hotspot\src_gen\hotspot \ + -relativeInclude graal\com.oracle.jvmci.hotspot\src_gen\hotspot \ -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \ -relativeSrcInclude src \ -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \ @@ -150,10 +150,10 @@ -ignorePath_TARGET tiered \ -ignorePath_TARGET c1_ -ProjectCreatorIDEOptionsIgnoreGraal=\ - -ignorePath_TARGET src/share/vm/graal \ - -ignorePath_TARGET graal\com.oracle.graal.hotspot\src_gen\hotspot \ - -ignorePath_TARGET vm/graal +ProjectCreatorIDEOptionsIgnoreJVMCI=\ + -ignorePath_TARGET src/share/vm/jvmci \ + -ignorePath_TARGET graal\com.oracle.jvmci.hotspot\src_gen\hotspot \ + -ignorePath_TARGET vm/jvmci ProjectCreatorIDEOptionsIgnoreCompiler2=\ -ignorePath_TARGET compiler2 \ @@ -175,17 +175,17 @@ ################################################## ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ -define_compiler1 COMPILER1 \ - -define_compiler1 GRAAL \ + -define_compiler1 JVMCI \ $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1) ################################################## -# Graal compiler specific options +# JVMCI compiler specific options ################################################## ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ - -define_graal COMPILER1 \ - -define_graal COMPILERGRAAL \ - -define_graal GRAAL \ - $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=graal) + -define_jvmci COMPILER1 \ + -define_jvmci COMPILERJVMCI \ + -define_jvmci JVMCI \ + $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=jvmci) ################################################## # Server(C2) compiler specific options @@ -194,7 +194,7 @@ ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ -define_compiler2 COMPILER1 \ -define_compiler2 COMPILER2 \ - -define_compiler2 GRAAL \ + -define_compiler2 JVMCI \ -additionalFile_compiler2 $(Platform_arch_model).ad \ -additionalFile_compiler2 ad_$(Platform_arch_model).cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model).hpp \
--- a/make/windows/makefiles/vm.make Wed May 27 13:43:27 2015 +0200 +++ b/make/windows/makefiles/vm.make Thu May 28 15:36:48 2015 +0200 @@ -48,8 +48,8 @@ CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER1" /D "COMPILER2" !endif -!if "$(Variant)" == "graal" -CXX_FLAGS=$(CXX_FLAGS) /D "GRAAL" /D "COMPILERGRAAL" /D "COMPILER1" +!if "$(Variant)" == "jvmci" +CXX_FLAGS=$(CXX_FLAGS) /D "JVMCI" /D "COMPILERJVMCI" /D "COMPILER1" !endif !if "$(BUILDARCH)" == "i486" @@ -71,10 +71,6 @@ # Define that so jni.h is on correct side CXX_FLAGS=$(CXX_FLAGS) /D "_JNI_IMPLEMENTATION_" -!if "$(INCLUDE_GRAAL)" == "true" - CXX_FLAGS=$(CXX_FLAGS) /D "GRAAL_VERSION=\"$(GRAAL_VERSION)\"" -!endif - !if "$(BUILDARCH)" == "ia64" STACK_SIZE="/STACK:1048576,262144" !else @@ -150,7 +146,7 @@ VM_PATH=$(VM_PATH);../generated/jvmtifiles VM_PATH=$(VM_PATH);../generated/tracefiles VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/c1 -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/graal +VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/jvmci VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/compiler VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/code VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/interpreter
--- a/mx/mx_graal.py Wed May 27 13:43:27 2015 +0200 +++ b/mx/mx_graal.py Thu May 28 15:36:48 2015 +0200 @@ -48,11 +48,11 @@ """ The VMs that can be built and run along with an optional description. Only VMs with a description are listed in the dialogue for setting the default VM (see _get_vm()). """ _vmChoices = { - 'graal' : 'Normal compilation is performed with a tiered system (C1 + Graal), Truffle compilation is performed with Graal.', + 'jvmci' : 'Normal compilation is performed with a tiered system (C1 + Graal), Truffle compilation is performed with Graal.', 'server' : 'Normal compilation is performed with a tiered system (C1 + C2), Truffle compilation is performed with Graal. Use this for optimal Truffle performance.', 'client' : None, # normal compilation with client compiler, explicit compilation (e.g., by Truffle) with Graal - 'server-nograal' : None, # all compilation with tiered system (i.e., client + server), Graal omitted - 'client-nograal' : None, # all compilation with client compiler, Graal omitted + 'server-nojvmci' : None, # all compilation with tiered system (i.e., client + server), JVMCI omitted + 'client-nojvmci' : None, # all compilation with client compiler, JVMCI omitted 'original' : None, # default VM copied from bootstrap JDK } @@ -88,16 +88,16 @@ _untilVersion = None class JDKDeployedDist: - def __init__(self, name, isExtension=False, isGraalClassLoader=False): + def __init__(self, name, isExtension=False, usesJVMCIClassLoader=False): self.name = name self.isExtension = isExtension - self.isGraalClassLoader = isGraalClassLoader + self.usesJVMCIClassLoader = usesJVMCIClassLoader _jdkDeployedDists = [ JDKDeployedDist('TRUFFLE'), - JDKDeployedDist('GRAAL_LOADER'), - JDKDeployedDist('GRAAL', isGraalClassLoader=True), - JDKDeployedDist('GRAAL_TRUFFLE', isGraalClassLoader=True) + JDKDeployedDist('JVMCI_LOADER'), + JDKDeployedDist('GRAAL', usesJVMCIClassLoader=True), + JDKDeployedDist('GRAAL_TRUFFLE', usesJVMCIClassLoader=True) ] JDK_UNIX_PERMISSIONS_DIR = 0755 @@ -168,7 +168,7 @@ os.path.walk(dirname, _chmodDir, chmodFlagsDir) def clean(args): - """clean the GraalVM source tree""" + """clean the source tree""" opts = mx.clean(args, parser=ArgumentParser(prog='mx clean')) if opts.native: @@ -187,7 +187,7 @@ os.unlink(name) rmIfExists(join(_graal_home, 'build')) - rmIfExists(join(_graal_home, 'build-nograal')) + rmIfExists(join(_graal_home, 'build-nojvmci')) rmIfExists(_jdksDir()) def export(args): @@ -500,13 +500,13 @@ return jdk -def _updateInstalledGraalOptionsFile(jdk): - graalOptions = join(_graal_home, 'graal.options') +def _updateInstalledJVMCIOptionsFile(jdk): + jvmciOptions = join(_graal_home, 'jvmci.options') jreLibDir = join(jdk, 'jre', 'lib') - if exists(graalOptions): - shutil.copy(graalOptions, join(jreLibDir, 'graal.options')) + if exists(jvmciOptions): + shutil.copy(jvmciOptions, join(jreLibDir, 'jvmci.options')) else: - toDelete = join(jreLibDir, 'graal.options') + toDelete = join(jreLibDir, 'jvmci.options') if exists(toDelete): os.unlink(toDelete) @@ -552,7 +552,7 @@ # Add SHA1 to end of graalRuntime.inline.hpp print >> tmp, '' - print >> tmp, 'const char* GraalRuntime::_generated_sources_sha1 = "' + sha1 + '";' + print >> tmp, 'const char* JVMCIRuntime::_generated_sources_sha1 = "' + sha1 + '";' mx.update_file(graalRuntime_inline_hpp, tmp.getvalue()) @@ -600,14 +600,14 @@ return className[:className.index('<')] return className -def _classifyGraalServices(classNames, graalJars): +def _classifyJVMCIServices(classNames, jvmciJars): classification = {} if not classNames: return classification for className in classNames: classification[className] = None javap = mx.java().javap - output = subprocess.check_output([javap, '-cp', os.pathsep.join(graalJars)] + classNames, stderr=subprocess.STDOUT) + output = subprocess.check_output([javap, '-cp', os.pathsep.join(jvmciJars)] + classNames, stderr=subprocess.STDOUT) lines = output.split(os.linesep) for line in lines: if line.startswith('public interface '): @@ -654,11 +654,11 @@ classification[className] = [] classification[className].extend(newClassification[superInterface]) -def _filterGraalService(classNames, graalJars): - classification = _classifyGraalServices(classNames, graalJars) +def _filterJVMCIService(classNames, jvmciJars): + classification = _classifyJVMCIServices(classNames, jvmciJars) needClassification = _extractMaybes(classification) while needClassification: - _mergeClassification(classification, _classifyGraalServices(needClassification, graalJars)) + _mergeClassification(classification, _classifyJVMCIServices(needClassification, jvmciJars)) needClassification = _extractMaybes(classification) filtered = [] for className in classNames: @@ -666,13 +666,13 @@ filtered.append(className) return filtered -def _extractGraalServiceFiles(graalJars, destination, cleanDestination=True): +def _extractJVMCIServiceFiles(jvmciJars, destination, cleanDestination=True): if cleanDestination: if exists(destination): shutil.rmtree(destination) os.makedirs(destination) servicesMap = {} - for jar in graalJars: + for jar in jvmciJars: if os.path.isfile(jar): with zipfile.ZipFile(jar) as zf: for member in zf.namelist(): @@ -687,8 +687,8 @@ line = line.strip() if line: serviceImpls.append(line) - graalServices = _filterGraalService(servicesMap.keys(), graalJars) - for serviceName in graalServices: + jvmciServices = _filterJVMCIService(servicesMap.keys(), jvmciJars) + for serviceName in jvmciServices: serviceImpls = servicesMap[serviceName] fd, tmp = tempfile.mkstemp(prefix=serviceName) f = os.fdopen(fd, 'w+') @@ -699,24 +699,28 @@ shutil.move(tmp, target) if mx.get_os() != 'windows': os.chmod(target, JDK_UNIX_PERMISSIONS_FILE) - return graalServices - -def _updateGraalServiceFiles(jdkDir): - jreGraalDir = join(jdkDir, 'jre', 'lib', 'graal') - graalJars = [join(jreGraalDir, e) for e in os.listdir(jreGraalDir) if e.startswith('graal') and e.endswith('.jar')] - jreGraalServicesDir = join(jreGraalDir, 'services') - _extractGraalServiceFiles(graalJars, jreGraalServicesDir) + return jvmciServices + +def _updateJVMCIServiceFiles(jdkDir): + jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci') + jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if (e.startswith('jvmci') or e.startswith('graal')) and e.endswith('.jar')] + jreJVMCIServicesDir = join(jreJVMCIDir, 'services') + _extractJVMCIServiceFiles(jvmciJars, jreJVMCIServicesDir) def _installDistInJdks(deployableDist): """ - Installs the jar(s) for a given Distribution into all existing Graal JDKs + Installs the jar(s) for a given Distribution into all existing JVMCI JDKs """ dist = mx.distribution(deployableDist.name) - if dist.name == 'GRAAL_TRUFFLE': + if dist.name == 'GRAAL': + zf = zipfile.ZipFile(dist.path, 'a') + zf.writestr('com/oracle/graal/api/runtime/graal.version', graal_version()) + zf.close() + elif dist.name == 'GRAAL_TRUFFLE': # The content in graalRuntime.inline.hpp is generated from Graal # classes that contain com.oracle.jvmci.options.Option annotated fields. # Since GRAAL_TRUFFLE is the leaf most distribution containing @@ -732,8 +736,8 @@ if exists(jreLibDir): if deployableDist.isExtension: targetDir = join(jreLibDir, 'ext') - elif deployableDist.isGraalClassLoader: - targetDir = join(jreLibDir, 'graal') + elif deployableDist.usesJVMCIClassLoader: + targetDir = join(jreLibDir, 'jvmci') else: targetDir = jreLibDir if not exists(targetDir): @@ -741,9 +745,9 @@ _copyToJdk(dist.path, targetDir) if dist.sourcesPath: _copyToJdk(dist.sourcesPath, jdkDir) - if deployableDist.isGraalClassLoader: + if deployableDist.usesJVMCIClassLoader: # deploy service files - _updateGraalServiceFiles(jdkDir) + _updateJVMCIServiceFiles(jdkDir) # run a command in the windows SDK Debug Shell def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None): @@ -890,7 +894,7 @@ # Call mx.build to compile the Java sources parser = AP() - parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>') + parser.add_argument('--export-dir', help='directory to which JVMCI and Graal jars and jvmci.options will be copied', metavar='<path>') parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') opts2 = mx.build(['--source', '1.7'] + args, parser=parser) assert len(opts2.remainder) == 0 @@ -904,28 +908,28 @@ defsPath = join(_graal_home, 'make', 'defs.make') with open(defsPath) as fp: defs = fp.read() - graalJars = [] + jvmciJars = [] for jdkDist in _jdkDeployedDists: dist = mx.distribution(jdkDist.name) defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) if jdkDist.isExtension: defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_EXT_DIR)/' + basename(dist.path) - elif jdkDist.isGraalClassLoader: - defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_DIR)/' + basename(dist.path) - graalJars.append(dist.path) + elif jdkDist.usesJVMCIClassLoader: + defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/' + basename(dist.path) + jvmciJars.append(dist.path) else: defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) if defLine not in defs: mx.abort('Missing following line in ' + defsPath + '\n' + defLine) shutil.copy(dist.path, opts2.export_dir) - services = _extractGraalServiceFiles(graalJars, join(opts2.export_dir, 'services')) + services = _extractJVMCIServiceFiles(jvmciJars, join(opts2.export_dir, 'services')) for service in services: - defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_GRAAL_SERVICES_DIR)/' + service + defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/' + service if defLine not in defs: mx.abort('Missing following line in ' + defsPath + ' for service from ' + dist.name + '\n' + defLine) - graalOptions = join(_graal_home, 'graal.options') - if exists(graalOptions): - shutil.copy(graalOptions, opts2.export_dir) + jvmciOptions = join(_graal_home, 'jvmci.options') + if exists(jvmciOptions): + shutil.copy(jvmciOptions, opts2.export_dir) if not _vmSourcesAvailable or not opts2.native: return @@ -951,8 +955,8 @@ elif vm.startswith('client'): buildSuffix = '1' else: - assert vm == 'graal', vm - buildSuffix = 'graal' + assert vm == 'jvmci', vm + buildSuffix = 'jvmci' if _installed_jdks and _installed_jdks != _graal_home: if not mx.ask_yes_no("Warning: building while --installed-jdks is set (" + _installed_jdks + ") is not recommanded - are you sure you want to continue", 'n'): @@ -1051,14 +1055,13 @@ setMakeVar('ALT_BOOTDIR', mx.java().jdk, env=env) setMakeVar('MAKE_VERBOSE', 'y' if mx._opts.verbose else '') - if vm.endswith('nograal'): - setMakeVar('INCLUDE_GRAAL', 'false') - setMakeVar('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os()), env=env) + if vm.endswith('nojvmci'): + setMakeVar('INCLUDE_JVMCI', 'false') + setMakeVar('ALT_OUTPUTDIR', join(_graal_home, 'build-nojvmci', mx.get_os()), env=env) else: version = graal_version() - setMakeVar('USER_RELEASE_SUFFIX', 'graal-' + version) - setMakeVar('GRAAL_VERSION', version) - setMakeVar('INCLUDE_GRAAL', 'true') + setMakeVar('USER_RELEASE_SUFFIX', 'jvmci-' + version) + setMakeVar('INCLUDE_JVMCI', 'true') setMakeVar('INSTALL', 'y', env=env) if mx.get_os() == 'darwin' and platform.mac_ver()[0] != '': # Force use of clang on MacOS @@ -1150,7 +1153,7 @@ build = vmbuild if vmbuild else _vmbuild if _vmSourcesAvailable else 'product' jdk = _jdk(build, vmToCheck=vm, installJars=False) - _updateInstalledGraalOptionsFile(jdk) + _updateInstalledJVMCIOptionsFile(jdk) mx.expand_project_in_args(args) if _make_eclipse_launch: mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) @@ -1338,7 +1341,7 @@ def harness(projectsCp, vmArgs): - if _get_vm() != 'graal': + if _get_vm() != 'jvmci': prefixArgs = ['-esa', '-ea'] else: prefixArgs = ['-XX:-BootstrapGraal', '-esa', '-ea'] @@ -1351,13 +1354,13 @@ # run the VM in a mode where application/test classes can # access core Graal classes. cp = prefixCp + coreCp + os.pathsep + projectsCp - if isGraalEnabled(_get_vm()): + if isJVMCIEnabled(_get_vm()): excluded = set() for jdkDist in _jdkDeployedDists: dist = mx.distribution(jdkDist.name) excluded.update([d.output_dir() for d in dist.sorted_deps()]) cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded]) - vmArgs = ['-XX:-UseGraalClassLoader'] + vmArgs + vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs # suppress menubar and dock when running on Mac vmArgs = ['-Djava.awt.headless=true'] + vmArgs @@ -1556,8 +1559,8 @@ build(check_dists_args) if not args.no_check: vmargs = ['-version'] - if v == 'graal': - vmargs.insert(0, '-XX:-BootstrapGraal') + if v == 'jvmci': + vmargs.insert(0, '-XX:-BootstrapJVMCI') vm(vmargs, vm=v, vmbuild=vmbuild) allDuration = datetime.timedelta(seconds=time.time() - allStart) mx.log('TOTAL TIME: ' + '[' + str(allDuration) + ']') @@ -1604,7 +1607,7 @@ defaultCtwopts = '-Inline' parser = ArgumentParser(prog='mx ctw') - parser.add_argument('--ctwopts', action='store', help='space separated Graal options used for CTW compilations (default: --ctwopts="' + defaultCtwopts + '")', default=defaultCtwopts, metavar='<options>') + parser.add_argument('--ctwopts', action='store', help='space separated JVMCI options used for CTW compilations (default: --ctwopts="' + defaultCtwopts + '")', default=defaultCtwopts, metavar='<options>') parser.add_argument('--jar', action='store', help='jar of classes to compiled instead of rt.jar', metavar='<path>') args, vmargs = parser.parse_known_args(args) @@ -1620,9 +1623,9 @@ vmargs += ['-XX:+CompileTheWorld'] vm_ = _get_vm() - if isGraalEnabled(vm_): - if vm_ == 'graal': - vmargs += ['-XX:+BootstrapGraal'] + if isJVMCIEnabled(vm_): + if vm_ == 'jvmci': + vmargs += ['-XX:+BootstrapJVMCI'] vmargs += ['-G:CompileTheWorldClasspath=' + jar] else: vmargs += ['-Xbootclasspath/p:' + jar] @@ -1633,81 +1636,81 @@ vm(vmargs) def _basic_gate_body(args, tasks): - # Build server-hosted-graal now so we can run the unit tests - with Task('BuildHotSpotGraalHosted: product', tasks) as t: + # Build server-hosted-jvmci now so we can run the unit tests + with Task('BuildHotSpotJVMCIHosted: product', tasks) as t: if t: buildvms(['--vms', 'server', '--builds', 'product', '--check-distributions']) - # Run unit tests on server-hosted-graal + # Run unit tests on server-hosted-jvmci with VM('server', 'product'): with Task('UnitTests:hosted-product', tasks) as t: if t: unittest(['--enable-timing', '--verbose', '--fail-fast']) - # Run ctw against rt.jar on server-hosted-graal + # Run ctw against rt.jar on server-hosted-jvmci with VM('server', 'product'): with Task('CTW:hosted-product', tasks) as t: if t: ctw(['--ctwopts', '-Inline +ExitVMOnException', '-esa', '-G:+CompileTheWorldMultiThreaded', '-G:-CompileTheWorldVerbose']) # Build the other VM flavors with Task('BuildHotSpotGraalOthers: fastdebug,product', tasks) as t: - if t: buildvms(['--vms', 'graal,server', '--builds', 'fastdebug,product', '--check-distributions']) - - with VM('graal', 'fastdebug'): + if t: buildvms(['--vms', 'jvmci,server', '--builds', 'fastdebug,product', '--check-distributions']) + + with VM('jvmci', 'fastdebug'): with Task('BootstrapWithSystemAssertions:fastdebug', tasks) as t: if t: vm(['-esa', '-XX:-TieredCompilation', '-version']) - with VM('graal', 'fastdebug'): + with VM('jvmci', 'fastdebug'): with Task('BootstrapEconomyWithSystemAssertions:fastdebug', tasks) as t: if t: vm(['-esa', '-XX:-TieredCompilation', '-G:CompilerConfiguration=economy', '-version']) - with VM('graal', 'fastdebug'): + with VM('jvmci', 'fastdebug'): with Task('BootstrapWithSystemAssertionsNoCoop:fastdebug', tasks) as t: if t: vm(['-esa', '-XX:-TieredCompilation', '-XX:-UseCompressedOops', '-version']) - with VM('graal', 'fastdebug'): + with VM('jvmci', 'fastdebug'): with Task('BootstrapWithExceptionEdges:fastdebug', tasks) as t: if t: vm(['-esa', '-XX:-TieredCompilation', '-G:+StressInvokeWithExceptionNode', '-version']) - with VM('graal', 'product'): + with VM('jvmci', 'product'): with Task('BootstrapWithGCVerification:product', tasks) as t: if t: out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) - with VM('graal', 'product'): + with VM('jvmci', 'product'): with Task('BootstrapWithG1GCVerification:product', tasks) as t: if t: out = mx.DuplicateSuppressingStream(['VerifyAfterGC:', 'VerifyBeforeGC:']).write vm(['-XX:-TieredCompilation', '-XX:+UnlockDiagnosticVMOptions', '-XX:-UseSerialGC', '-XX:+UseG1GC', '-XX:+VerifyBeforeGC', '-XX:+VerifyAfterGC', '-version'], out=out) - with VM('graal', 'product'): + with VM('jvmci', 'product'): with Task('BootstrapWithRegisterPressure:product', tasks) as t: if t: registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if platform.processor() == 'sparc' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14' vm(['-XX:-TieredCompilation', '-G:RegisterPressure=' + registers, '-esa', '-version']) - with VM('graal', 'product'): + with VM('jvmci', 'product'): with Task('BootstrapSSAWithRegisterPressure:product', tasks) as t: if t: registers = 'o0,o1,o2,o3,f8,f9,d32,d34' if platform.processor() == 'sparc' else 'rbx,r11,r10,r14,xmm3,xmm11,xmm14' vm(['-XX:-TieredCompilation', '-G:+SSA_LIR', '-G:RegisterPressure=' + registers, '-esa', '-version']) - with VM('graal', 'product'): + with VM('jvmci', 'product'): with Task('BootstrapWithImmutableCode:product', tasks) as t: if t: vm(['-XX:-TieredCompilation', '-G:+ImmutableCode', '-G:+VerifyPhases', '-esa', '-version']) for vmbuild in ['fastdebug', 'product']: for test in sanitycheck.getDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild) + sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Gate, gateBuildLevel=vmbuild): with Task(str(test) + ':' + vmbuild, tasks) as t: - if t and not test.test('graal'): + if t and not test.test('jvmci'): t.abort(test.name + ' Failed') # ensure -Xbatch still works - with VM('graal', 'product'): + with VM('jvmci', 'product'): with Task('DaCapo_pmd:BatchMode:product', tasks) as t: if t: dacapo(['-Xbatch', 'pmd']) # ensure -Xcomp still works - with VM('graal', 'product'): + with VM('jvmci', 'product'): with Task('XCompMode:product', tasks) as t: if t: vm(['-Xcomp', '-version']) @@ -1728,7 +1731,7 @@ if t: buildvms(['--vms', 'client,server', '--builds', 'fastdebug,product']) if mx.get_os() not in ['windows', 'cygwin']: - buildvms(['--vms', 'server-nograal', '--builds', 'product,optimized']) + buildvms(['--vms', 'server-nojvmci', '--builds', 'product,optimized']) for vmbuild in ['product', 'fastdebug']: for theVm in ['client', 'server']: @@ -1740,7 +1743,7 @@ if t: dacapo(['pmd']) with Task('UnitTests:' + theVm + ':' + vmbuild, tasks) as t: - if t: unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api']) + if t: unittest(['-XX:CompileCommand=exclude,*::run*', 'graal.api', 'java.test']) def gate(args, gate_body=_basic_gate_body): @@ -1753,7 +1756,7 @@ parser.add_argument('-j', '--omit-java-clean', action='store_false', dest='cleanJava', help='omit cleaning Java native code') parser.add_argument('-n', '--omit-native-clean', action='store_false', dest='cleanNative', help='omit cleaning and building native code') parser.add_argument('-i', '--omit-ide-clean', action='store_false', dest='cleanIde', help='omit cleaning the ide project files') - parser.add_argument('-g', '--only-build-graalvm', action='store_false', dest='buildNonGraal', help='only build the Graal VM') + parser.add_argument('-g', '--only-build-jvmci', action='store_false', dest='buildNonJVMCI', help='only build the JVMCI VM') parser.add_argument('-t', '--task-filter', help='comma separated list of substrings to select subset of tasks to be run') parser.add_argument('--jacocout', help='specify the output directory for jacoco report') @@ -1853,7 +1856,7 @@ Task.filters = None def deoptalot(args): - """bootstrap a fastdebug Graal VM with DeoptimizeALot and VerifyOops on + """bootstrap a fastdebug JVMCI VM with DeoptimizeALot and VerifyOops on If the first argument is a number, the process will be repeated this number of times. All other arguments are passed to the VM.""" @@ -2151,7 +2154,7 @@ buildOutput.append(x) env = os.environ.copy() env['JAVA_HOME'] = _jdk(vmToCheck='server') - env['MAVEN_OPTS'] = '-server -XX:-UseGraalClassLoader' + env['MAVEN_OPTS'] = '-server -XX:-UseJVMCIClassLoader' mx.log("Building benchmarks...") cmd = ['mvn'] if args.settings: @@ -2177,8 +2180,8 @@ mx.abort(1) vmArgs, benchmarksAndJsons = _extract_VM_args(args) - if isGraalEnabled(_get_vm()) and '-XX:-UseGraalClassLoader' not in vmArgs: - vmArgs = ['-XX:-UseGraalClassLoader'] + vmArgs + if isJVMCIEnabled(_get_vm()) and '-XX:-UseJVMCIClassLoader' not in vmArgs: + vmArgs = ['-XX:-UseJVMCIClassLoader'] + vmArgs benchmarks = [b for b in benchmarksAndJsons if not b.startswith('{')] jmhArgJsons = [b for b in benchmarksAndJsons if b.startswith('{')] @@ -2382,7 +2385,7 @@ elif len(args) > 1: mx.abort('jacocoreport takes only one argument : an output directory') - includes = ['com.oracle.graal'] + includes = ['com.oracle.graal', 'com.oracle.jvmci'] for p in mx.projects(): projsetting = getattr(p, 'jacoco', '') if projsetting == 'include': @@ -2409,8 +2412,8 @@ vmArgs, slArgs = _extract_VM_args(args) vm(vmArgs + ['-cp', mx.classpath(["TRUFFLE", "com.oracle.truffle.sl"]), "com.oracle.truffle.sl.SLMain"] + slArgs) -def isGraalEnabled(vm): - return vm != 'original' and not vm.endswith('nograal') +def isJVMCIEnabled(vm): + return vm != 'original' and not vm.endswith('nojvmci') def jol(args): """Java Object Layout""" @@ -2479,7 +2482,7 @@ complt += '\t\t\t(vm | vmg | vmfg | unittest | jmh | dacapo | scaladacapo | specjvm2008 | specjbb2013 | specjbb2005)\n' complt += '\t\t\t\tnoglob \\\n' complt += '\t\t\t\t\t_arguments -s -S \\\n' - complt += _appendOptions("graal", r"G\:") + complt += _appendOptions("jvmci", r"G\:") # TODO: fix -XX:{-,+}Use* flags complt += _appendOptions("hotspot", r"XX\:") complt += '\t\t\t\t\t"-version" && ret=0 \n' @@ -2541,10 +2544,10 @@ 'optDoc' : '<optDoc>', })) - # gather graal options + # gather JVMCI options output = StringIO.StringIO() - vm(['-XX:-BootstrapGraal', '-XX:+UnlockDiagnosticVMOptions', '-G:+PrintFlags' if optionType == "graal" else '-XX:+PrintFlagsWithComments'], - vm="graal", + vm(['-XX:-BootstrapJVMCI', '-XX:+UnlockDiagnosticVMOptions', '-G:+PrintFlags' if optionType == "jvmci" else '-XX:+PrintFlagsWithComments'], + vm="jvmci", vmbuild="optimized", nonZeroIsFatal=False, out=output.write,
--- a/mx/sanitycheck.py Wed May 27 13:43:27 2015 +0200 +++ b/mx/sanitycheck.py Thu May 28 15:36:48 2015 +0200 @@ -278,10 +278,10 @@ args = ['-XX:+CompileTheWorld', '-Xbootclasspath/p:' + rtjar] - if vm == 'graal': + if vm == 'jvmci': args += ['-XX:+BootstrapGraal'] if mode >= CTWMode.NoInline: - if not mx_graal.isGraalEnabled(vm): + if not mx_graal.isJVMCIEnabled(vm): args.append('-XX:-Inline') else: args.append('-G:CompileTheWordConfig=-Inline') @@ -380,7 +380,7 @@ parser.addMatcher(scoreMatcher) if self.benchmarkCompilationRate: - if vm == 'graal': + if vm == 'jvmci': bps = re.compile(r"ParsedBytecodesPerSecond@final: (?P<rate>[0-9]+)") ibps = re.compile(r"InlinedBytecodesPerSecond@final: (?P<rate>[0-9]+)") parser.addMatcher(ValuesMatcher(bps, {'group' : 'ParsedBytecodesPerSecond', 'name' : self.name, 'score' : '<rate>'}))
--- a/mx/suite.py Wed May 27 13:43:27 2015 +0200 +++ b/mx/suite.py Thu May 28 15:36:48 2015 +0200 @@ -339,7 +339,7 @@ "workingSets" : "Graal,HotSpot", }, - "com.oracle.graal.hotspot.loader" : { + "com.oracle.jvmci.hotspot.loader" : { "subDir" : "graal", "sourceDirs" : ["src"], "dependencies" : [], @@ -1191,11 +1191,11 @@ "exclude" : ["FINDBUGS"], }, - "GRAAL_LOADER" : { - "path" : "build/graal-loader.jar", + "JVMCI_LOADER" : { + "path" : "build/jvmci-loader.jar", "subDir" : "graal", - "sourcesPath" : "build/graal-loader.src.zip", - "dependencies" : ["com.oracle.graal.hotspot.loader"], + "sourcesPath" : "build/jvmci-loader.src.zip", + "dependencies" : ["com.oracle.jvmci.hotspot.loader"], }, "TRUFFLE" : {
--- a/src/cpu/ppc/vm/graalGlobals_ppc.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000, 2012, 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. - * - */ - -#ifndef CPU_PPC_VM_GRAALGLOBALS_PPC_HPP -#define CPU_PPC_VM_GRAALGLOBALS_PPC_HPP - -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" - -// Sets the default values for platform dependent flags used by the Graal compiler. -// (see graalGlobals.hpp) - -#ifdef COMPILERGRAAL -#error Unimplemented -#endif // COMPILERGRAAL - -#endif // CPU_PPC_VM_GRAALGLOBALS_PPC_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cpu/ppc/vm/jvmciGlobals_ppc.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2000, 2012, 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. + * + */ + +#ifndef CPU_PPC_VM_GRAALGLOBALS_PPC_HPP +#define CPU_PPC_VM_GRAALGLOBALS_PPC_HPP + +#include "utilities/globalDefinitions.hpp" +#include "utilities/macros.hpp" + +// Sets the default values for platform dependent flags used by the Graal compiler. +// (see graalGlobals.hpp) + +#ifdef COMPILERGRAAL +#error Unimplemented +#endif // COMPILERGRAAL + +#endif // CPU_PPC_VM_GRAALGLOBALS_PPC_HPP
--- a/src/cpu/sparc/vm/compiledIC_sparc.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/sparc/vm/compiledIC_sparc.cpp Thu May 28 15:36:48 2015 +0200 @@ -102,7 +102,7 @@ void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) { address stub = find_stub(); -#ifdef GRAAL +#ifdef JVMCI if (stub == NULL) { set_destination_mt_safe(entry); return; @@ -159,7 +159,7 @@ // Verify stub. address stub = find_stub(); -#ifndef GRAAL +#ifndef JVMCI assert(stub != NULL, "no stub found for static call"); // Creation also verifies the object. NativeMovConstReg* method_holder = nativeMovConstReg_at(stub);
--- a/src/cpu/sparc/vm/graalCodeInstaller_sparc.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2013, 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. - */ - -#include "graal/graalCodeInstaller.hpp" -#include "graal/graalRuntime.hpp" -#include "graal/graalCompilerToVM.hpp" -#include "graal/graalJavaAccess.hpp" -#include "vmreg_sparc.inline.hpp" - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { - if (inst->is_call() || inst->is_jump()) { - return pc_offset + NativeCall::instruction_size; - } else if (inst->is_call_reg()) { - return pc_offset + NativeCallReg::instruction_size; - } else if (inst->is_sethi()) { - return pc_offset + NativeFarCall::instruction_size; - } else { - fatal("unsupported type of instruction for call site"); - return 0; - } -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) { - address pc = _instructions->start() + pc_offset; - Handle obj = HotSpotObjectConstantImpl::object(constant); - jobject value = JNIHandles::make_local(obj()); - if (HotSpotObjectConstantImpl::compressed(constant)) { -#ifdef _LP64 - int oop_index = _oop_recorder->find_index(value); - RelocationHolder rspec = oop_Relocation::spec(oop_index); - _instructions->relocate(pc, rspec, 1); -#else - fatal("compressed oop on 32bit"); -#endif - } else { - NativeMovConstReg* move = nativeMovConstReg_at(pc); - move->set_data((intptr_t) value); - - // We need two relocations: one on the sethi and one on the add. - int oop_index = _oop_recorder->find_index(value); - RelocationHolder rspec = oop_Relocation::spec(oop_index); - _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); - _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); - } -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) { - address pc = _instructions->start() + pc_offset; - address const_start = _constants->start(); - address dest = _constants->start() + data_offset; - - _instructions->relocate(pc + NativeMovConstReg::sethi_offset, internal_word_Relocation::spec((address) dest)); - _instructions->relocate(pc + NativeMovConstReg::add_offset, internal_word_Relocation::spec((address) dest)); - TRACE_graal_3("relocating at %p with destination at %p (%d)", pc, dest, data_offset); -} - -void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { - fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp"); -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { - address pc = (address) inst; - if (inst->is_call()) { - NativeCall* call = nativeCall_at(pc); - call->set_destination((address) foreign_call_destination); - _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); - } else if (inst->is_sethi()) { - NativeJump* jump = nativeJump_at(pc); - jump->set_jump_destination((address) foreign_call_destination); - _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); - } else { - fatal(err_msg("unknown call or jump instruction at %p", pc)); - } - TRACE_graal_3("relocating (foreign call) at %p", inst); -} - -void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { -#ifdef ASSERT - Method* method = NULL; - // we need to check, this might also be an unresolved method - if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) { - method = getMethodFromHotSpotMethod(hotspot_method); - } -#endif - switch (_next_call_type) { - case INLINE_INVOKE: - break; - case INVOKEVIRTUAL: - case INVOKEINTERFACE: { - assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); - NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); - _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); - break; - } - case INVOKESTATIC: { - assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); - NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_static_call_stub()); - _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); - break; - } - case INVOKESPECIAL: { - assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); - NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); - _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); - break; - } - default: - fatal("invalid _next_call_type value"); - break; - } -} - -void CodeInstaller::pd_relocate_poll(address pc, jint mark) { - switch (mark) { - case POLL_NEAR: - fatal("unimplemented"); - break; - case POLL_FAR: - _instructions->relocate(pc, relocInfo::poll_type); - break; - case POLL_RETURN_NEAR: - fatal("unimplemented"); - break; - case POLL_RETURN_FAR: - _instructions->relocate(pc, relocInfo::poll_return_type); - break; - default: - fatal("invalid mark value"); - break; - } -} - -// convert Graal register indices (as used in oop maps) to HotSpot registers -VMReg CodeInstaller::get_hotspot_reg(jint graal_reg) { - if (graal_reg < RegisterImpl::number_of_registers) { - return as_Register(graal_reg)->as_VMReg(); - } else { - jint floatRegisterNumber = graal_reg - RegisterImpl::number_of_registers; - floatRegisterNumber += MAX2(0, floatRegisterNumber-32); // Beginning with f32, only every second register is going to be addressed - if (floatRegisterNumber < FloatRegisterImpl::number_of_registers) { - return as_FloatRegister(floatRegisterNumber)->as_VMReg(); - } - ShouldNotReachHere(); - return NULL; - } -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return !hotspotRegister->is_FloatRegister(); -}
--- a/src/cpu/sparc/vm/graalGlobals_sparc.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2000, 2012, 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. - * - */ - -#ifndef CPU_SPARC_VM_GRAALGLOBALS_SPARC_HPP -#define CPU_SPARC_VM_GRAALGLOBALS_SPARC_HPP - -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" - -// Sets the default values for platform dependent flags used by the Graal compiler. -// (see graalGlobals.hpp) - -#ifdef COMPILERGRAAL -define_pd_global(bool, BackgroundCompilation, true ); -define_pd_global(bool, UseTLAB, true ); -define_pd_global(bool, ResizeTLAB, true ); -define_pd_global(bool, InlineIntrinsics, true ); -define_pd_global(bool, PreferInterpreterNativeStubs, false); -define_pd_global(bool, TieredCompilation, trueInTiered); -define_pd_global(intx, BackEdgeThreshold, 100000); - -define_pd_global(intx, OnStackReplacePercentage, 933 ); -define_pd_global(intx, FreqInlineSize, 325 ); -define_pd_global(intx, NewSizeThreadIncrease, 4*K ); -define_pd_global(uintx,MetaspaceSize, 12*M ); -define_pd_global(bool, NeverActAsServerClassMachine, false); -define_pd_global(uint64_t,MaxRAM, 128ULL*G); -define_pd_global(bool, CICompileOSR, true ); -define_pd_global(bool, ProfileTraps, true ); -define_pd_global(bool, UseOnStackReplacement, true ); -define_pd_global(intx, CompileThreshold, 10000); -define_pd_global(intx, InitialCodeCacheSize, 16*M ); -define_pd_global(intx, ReservedCodeCacheSize, 64*M ); -define_pd_global(bool, ProfileInterpreter, true ); -define_pd_global(intx, CodeCacheExpansionSize, 64*K ); -define_pd_global(uintx,CodeCacheMinBlockLength, 4); -define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(intx, TypeProfileWidth, 8); -define_pd_global(intx, MethodProfileWidth, 0); -#endif // COMPILERGRAAL - -define_pd_global(intx, MaxVectorSize, 8); - -#endif // CPU_SPARC_VM_GRAALGLOBALS_SPARC_HPP
--- a/src/cpu/sparc/vm/interp_masm_sparc.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/sparc/vm/interp_masm_sparc.cpp Thu May 28 15:36:48 2015 +0200 @@ -1644,7 +1644,7 @@ bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. -#ifdef GRAAL +#ifdef JVMCI if (MethodProfileWidth == 0) { update_mdp_by_constant(in_bytes(VirtualCallData::virtual_call_data_size())); } @@ -1655,7 +1655,7 @@ } } -#ifdef GRAAL +#ifdef JVMCI void InterpreterMacroAssembler::profile_called_method(Register method, Register scratch) { assert_different_registers(method, scratch); if (ProfileInterpreter && MethodProfileWidth > 0) { @@ -1681,17 +1681,17 @@ if (is_virtual_call) { increment_mdp_data_at(in_bytes(CounterData::count_offset()), scratch); } -#ifdef GRAAL +#ifdef JVMCI else { increment_mdp_data_at(in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset()), scratch); } #endif } else { - bool use_non_profiled_counter = !is_virtual_call || IS_GRAAL_DEFINED; + bool use_non_profiled_counter = !is_virtual_call || IS_JVMCI_DEFINED; int non_profiled_offset = -1; if (use_non_profiled_counter) { non_profiled_offset = in_bytes(CounterData::count_offset()); - #ifdef GRAAL + #ifdef JVMCI if (!is_virtual_call) { non_profiled_offset = in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset()); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2013, 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. + */ + +#include "jvmci/jvmciCodeInstaller.hpp" +#include "jvmci/jvmciRuntime.hpp" +#include "jvmci/jvmciCompilerToVM.hpp" +#include "jvmci/jvmciJavaAccess.hpp" +#include "vmreg_sparc.inline.hpp" + +jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { + if (inst->is_call() || inst->is_jump()) { + return pc_offset + NativeCall::instruction_size; + } else if (inst->is_call_reg()) { + return pc_offset + NativeCallReg::instruction_size; + } else if (inst->is_sethi()) { + return pc_offset + NativeFarCall::instruction_size; + } else { + fatal("unsupported type of instruction for call site"); + return 0; + } +} + +void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) { + address pc = _instructions->start() + pc_offset; + Handle obj = HotSpotObjectConstantImpl::object(constant); + jobject value = JNIHandles::make_local(obj()); + if (HotSpotObjectConstantImpl::compressed(constant)) { +#ifdef _LP64 + int oop_index = _oop_recorder->find_index(value); + RelocationHolder rspec = oop_Relocation::spec(oop_index); + _instructions->relocate(pc, rspec, 1); +#else + fatal("compressed oop on 32bit"); +#endif + } else { + NativeMovConstReg* move = nativeMovConstReg_at(pc); + move->set_data((intptr_t) value); + + // We need two relocations: one on the sethi and one on the add. + int oop_index = _oop_recorder->find_index(value); + RelocationHolder rspec = oop_Relocation::spec(oop_index); + _instructions->relocate(pc + NativeMovConstReg::sethi_offset, rspec); + _instructions->relocate(pc + NativeMovConstReg::add_offset, rspec); + } +} + +void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) { + address pc = _instructions->start() + pc_offset; + address const_start = _constants->start(); + address dest = _constants->start() + data_offset; + + _instructions->relocate(pc + NativeMovConstReg::sethi_offset, internal_word_Relocation::spec((address) dest)); + _instructions->relocate(pc + NativeMovConstReg::add_offset, internal_word_Relocation::spec((address) dest)); + TRACE_jvmci_3("relocating at %p with destination at %p (%d)", pc, dest, data_offset); +} + +void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { + fatal("CodeInstaller::pd_relocate_CodeBlob - sparc unimp"); +} + +void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { + address pc = (address) inst; + if (inst->is_call()) { + NativeCall* call = nativeCall_at(pc); + call->set_destination((address) foreign_call_destination); + _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec()); + } else if (inst->is_sethi()) { + NativeJump* jump = nativeJump_at(pc); + jump->set_jump_destination((address) foreign_call_destination); + _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec()); + } else { + fatal(err_msg("unknown call or jump instruction at %p", pc)); + } + TRACE_jvmci_3("relocating (foreign call) at %p", inst); +} + +void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { +#ifdef ASSERT + Method* method = NULL; + // we need to check, this might also be an unresolved method + if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) { + method = getMethodFromHotSpotMethod(hotspot_method); + } +#endif + switch (_next_call_type) { + case INLINE_INVOKE: + break; + case INVOKEVIRTUAL: + case INVOKEINTERFACE: { + assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); + _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); + break; + } + case INVOKESTATIC: { + assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_static_call_stub()); + _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); + break; + } + case INVOKESPECIAL: { + assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); + _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); + break; + } + default: + fatal("invalid _next_call_type value"); + break; + } +} + +void CodeInstaller::pd_relocate_poll(address pc, jint mark) { + switch (mark) { + case POLL_NEAR: + fatal("unimplemented"); + break; + case POLL_FAR: + _instructions->relocate(pc, relocInfo::poll_type); + break; + case POLL_RETURN_NEAR: + fatal("unimplemented"); + break; + case POLL_RETURN_FAR: + _instructions->relocate(pc, relocInfo::poll_return_type); + break; + default: + fatal("invalid mark value"); + break; + } +} + +// convert JVMCI register indices (as used in oop maps) to HotSpot registers +VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) { + if (jvmci_reg < RegisterImpl::number_of_registers) { + return as_Register(jvmci_reg)->as_VMReg(); + } else { + jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers; + floatRegisterNumber += MAX2(0, floatRegisterNumber-32); // Beginning with f32, only every second register is going to be addressed + if (floatRegisterNumber < FloatRegisterImpl::number_of_registers) { + return as_FloatRegister(floatRegisterNumber)->as_VMReg(); + } + ShouldNotReachHere(); + return NULL; + } +} + +bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { + return !hotspotRegister->is_FloatRegister(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cpu/sparc/vm/jvmciGlobals_sparc.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2000, 2012, 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. + * + */ + +#ifndef CPU_SPARC_VM_JVMCIGLOBALS_SPARC_HPP +#define CPU_SPARC_VM_JVMCIGLOBALS_SPARC_HPP + +#include "utilities/globalDefinitions.hpp" +#include "utilities/macros.hpp" + +// Sets the default values for platform dependent flags used by the JVMCI compiler. +// (see jvmciGlobals.hpp) + +#ifdef COMPILERJVMCI +define_pd_global(bool, BackgroundCompilation, true ); +define_pd_global(bool, UseTLAB, true ); +define_pd_global(bool, ResizeTLAB, true ); +define_pd_global(bool, InlineIntrinsics, true ); +define_pd_global(bool, PreferInterpreterNativeStubs, false); +define_pd_global(bool, TieredCompilation, trueInTiered); +define_pd_global(intx, BackEdgeThreshold, 100000); + +define_pd_global(intx, OnStackReplacePercentage, 933 ); +define_pd_global(intx, FreqInlineSize, 325 ); +define_pd_global(intx, NewSizeThreadIncrease, 4*K ); +define_pd_global(uintx,MetaspaceSize, 12*M ); +define_pd_global(bool, NeverActAsServerClassMachine, false); +define_pd_global(uint64_t,MaxRAM, 128ULL*G); +define_pd_global(bool, CICompileOSR, true ); +define_pd_global(bool, ProfileTraps, true ); +define_pd_global(bool, UseOnStackReplacement, true ); +define_pd_global(intx, CompileThreshold, 10000); +define_pd_global(intx, InitialCodeCacheSize, 16*M ); +define_pd_global(intx, ReservedCodeCacheSize, 64*M ); +define_pd_global(bool, ProfileInterpreter, true ); +define_pd_global(intx, CodeCacheExpansionSize, 64*K ); +define_pd_global(uintx,CodeCacheMinBlockLength, 4); +define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K); +define_pd_global(intx, TypeProfileWidth, 8); +define_pd_global(intx, MethodProfileWidth, 0); +#endif // COMPILERJVMCI + +define_pd_global(intx, MaxVectorSize, 8); + +#endif // CPU_SPARC_VM_JVMCIGLOBALS_SPARC_HPP
--- a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Thu May 28 15:36:48 2015 +0200 @@ -43,8 +43,8 @@ #include "compiler/compileBroker.hpp" #include "shark/sharkCompiler.hpp" #endif -#ifdef GRAAL -#include "graal/graalJavaAccess.hpp" +#ifdef JVMCI +#include "jvmci/jvmciJavaAccess.hpp" #endif #define __ masm-> @@ -995,16 +995,16 @@ // Jump to the compiled code just as if compiled code was doing it. __ ld_ptr(G5_method, in_bytes(Method::from_compiled_offset()), G3); -#ifdef GRAAL +#ifdef JVMCI // check if this call should be routed towards a specific entry point - __ ld(Address(G2_thread, in_bytes(JavaThread::graal_alternate_call_target_offset())), G1); + __ ld(Address(G2_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())), G1); __ cmp(G0, G1); Label no_alternative_target; __ br(Assembler::equal, false, Assembler::pn, no_alternative_target); __ delayed()->nop(); - __ ld_ptr(G2_thread, in_bytes(JavaThread::graal_alternate_call_target_offset()), G3); - __ st(G0, Address(G2_thread, in_bytes(JavaThread::graal_alternate_call_target_offset()))); + __ ld_ptr(G2_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()), G3); + __ st(G0, Address(G2_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); __ bind(no_alternative_target); #endif @@ -3473,8 +3473,8 @@ pad += StackShadowPages*16 + 32; } #endif -#ifdef GRAAL - pad += 1000; // Increase the buffer size when compiling for GRAAL +#ifdef JVMCI + pad += 1000; // Increase the buffer size when compiling for JVMCI #endif #ifdef _LP64 CodeBuffer buffer("deopt_blob", 2100+pad+1000, 512); @@ -3543,10 +3543,10 @@ __ delayed()->mov(Deoptimization::Unpack_deopt, L0deopt_mode); -#ifdef GRAAL - masm->block_comment("BEGIN GRAAL"); +#ifdef JVMCI + masm->block_comment("BEGIN JVMCI"); int implicit_exception_uncommon_trap_offset = __ offset() - start; - __ ld_ptr(G2_thread, in_bytes(JavaThread::graal_implicit_exception_pc_offset()), O7); + __ ld_ptr(G2_thread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()), O7); __ add(O7, -8, O7); int uncommon_trap_offset = __ offset() - start; @@ -3575,8 +3575,8 @@ Label after_fetch_unroll_info_call; __ ba(after_fetch_unroll_info_call); __ delayed()->nop(); // Delay slot - masm->block_comment("END GRAAL"); -#endif // GRAAL + masm->block_comment("END JVMCI"); +#endif // JVMCI int exception_offset = __ offset() - start; @@ -3632,8 +3632,8 @@ // Reexecute entry, similar to c2 uncommon trap // int reexecute_offset = __ offset() - start; -#if defined(COMPILERGRAAL) && !defined(COMPILER1) - // Graal does not use this kind of deoptimization +#if defined(COMPILERJVMCI) && !defined(COMPILER1) + // JVMCI does not use this kind of deoptimization __ should_not_reach_here(); #endif // No need to update oop_map as each call to save_live_registers will produce identical oopmap @@ -3659,7 +3659,7 @@ __ reset_last_Java_frame(); -#ifdef GRAAL +#ifdef JVMCI __ bind(after_fetch_unroll_info_call); #endif // NOTE: we know that only O0/O1 will be reloaded by restore_result_registers @@ -3727,7 +3727,7 @@ masm->flush(); _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_words); _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); -#ifdef GRAAL +#ifdef JVMCI _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset); _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); #endif
--- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp Thu May 28 15:36:48 2015 +0200 @@ -203,7 +203,7 @@ address InterpreterGenerator::generate_deopt_entry_for(TosState state, int step) { address entry = __ pc(); __ get_constant_pool_cache(LcpoolCache); // load LcpoolCache -#ifdef GRAAL +#ifdef JVMCI // Check if we need to take lock at entry of synchronized method. { Label L;
--- a/src/cpu/sparc/vm/templateTable_sparc.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/sparc/vm/templateTable_sparc.cpp Thu May 28 15:36:48 2015 +0200 @@ -2949,7 +2949,7 @@ // get target Method* & entry point __ lookup_virtual_method(Rrecv, Rindex, G5_method); __ profile_arguments_type(G5_method, Rcall, Gargs, true); -#ifdef GRAAL +#ifdef JVMCI __ profile_called_method(G5_method, Rtemp); #endif __ call_from_interpreter(Rcall, Gargs, Rret); @@ -3206,7 +3206,7 @@ assert_different_registers(Rcall, G5_method, Gargs, Rret); __ profile_arguments_type(G5_method, Rcall, Gargs, true); -#ifdef GRAAL +#ifdef JVMCI __ profile_called_method(G5_method, Rscratch); #endif __ call_from_interpreter(Rcall, Gargs, Rret);
--- a/src/cpu/x86/vm/c2_globals_x86.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/c2_globals_x86.hpp Thu May 28 15:36:48 2015 +0200 @@ -86,7 +86,7 @@ define_pd_global(bool, OptoScheduling, false); define_pd_global(bool, OptoBundling, false); -#ifdef GRAAL +#ifdef JVMCI define_pd_global(intx, ReservedCodeCacheSize, 64*M); #else define_pd_global(intx, ReservedCodeCacheSize, 48*M);
--- a/src/cpu/x86/vm/frame_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/frame_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -460,11 +460,11 @@ // This is the sp before any possible extension (adapter/locals). intptr_t* unextended_sp = interpreter_frame_sender_sp(); -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) if (map->update_map()) { update_map_with_saved_link(map, (intptr_t**) addr_at(link_offset)); } -#endif // COMPILER2 || GRAAL +#endif // COMPILER2 || JVMCI return frame(sender_sp, unextended_sp, link(), sender_pc()); }
--- a/src/cpu/x86/vm/globals_x86.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/globals_x86.hpp Thu May 28 15:36:48 2015 +0200 @@ -47,7 +47,7 @@ // the the vep is aligned at CodeEntryAlignment whereas c2 only aligns // the uep and the vep doesn't get real alignment but just slops on by // only assured that the entry instruction meets the 5 byte size requirement. -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) define_pd_global(intx, CodeEntryAlignment, 32); #else define_pd_global(intx, CodeEntryAlignment, 16); @@ -80,8 +80,8 @@ // GC Ergo Flags define_pd_global(uintx, CMSYoungGenPerWorker, 64*M); // default max size of CMS young gen, per GC worker thread -// Disabled in GRAAL until HotSpotMethodData is updated to be aware of the new profiling tags -define_pd_global(uintx, TypeProfileLevel, GRAAL_ONLY(0) NOT_GRAAL(111)); +// Disabled in JVMCI until HotSpotMethodData is updated to be aware of the new profiling tags +define_pd_global(uintx, TypeProfileLevel, JVMCI_ONLY(0) NOT_JVMCI(111)); #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct) \ \
--- a/src/cpu/x86/vm/graalCodeInstaller_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2013, 2014, 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. - */ - -#include "precompiled.hpp" -#include "compiler/disassembler.hpp" -#include "runtime/javaCalls.hpp" -#include "graal/graalEnv.hpp" -#include "graal/graalCodeInstaller.hpp" -#include "graal/graalJavaAccess.hpp" -#include "graal/graalCompilerToVM.hpp" -#include "graal/graalRuntime.hpp" -#include "asm/register.hpp" -#include "classfile/vmSymbols.hpp" -#include "code/vmreg.hpp" -#include "vmreg_x86.inline.hpp" - -jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { - if (inst->is_call() || inst->is_jump()) { - assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size"); - return (pc_offset + NativeCall::instruction_size); - } else if (inst->is_mov_literal64()) { - // mov+call instruction pair - jint offset = pc_offset + NativeMovConstReg::instruction_size; - u_char* call = (u_char*) (_instructions->start() + offset); - if (call[0] == Assembler::REX_B) { - offset += 1; /* prefix byte for extended register R8-R15 */ - call++; - } - assert(call[0] == 0xFF, "expected call"); - offset += 2; /* opcode byte + modrm byte */ - return (offset); - } else if (inst->is_call_reg()) { - // the inlined vtable stub contains a "call register" instruction - assert(method != NULL, "only valid for virtual calls"); - return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset()); - } else if (inst->is_cond_jump()) { - address pc = (address) (inst); - return pc_offset + (jint) (Assembler::locate_next_instruction(pc) - pc); - } else { - fatal("unsupported type of instruction for call site"); - return 0; - } -} - -void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) { - address pc = _instructions->start() + pc_offset; - Handle obj = HotSpotObjectConstantImpl::object(constant); - jobject value = JNIHandles::make_local(obj()); - if (HotSpotObjectConstantImpl::compressed(constant)) { -#ifdef _LP64 - address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); - int oop_index = _oop_recorder->find_index(value); - _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand); - TRACE_graal_3("relocating (narrow oop constant) at %p/%p", pc, operand); -#else - fatal("compressed oop on 32bit"); -#endif - } else { - address operand = Assembler::locate_operand(pc, Assembler::imm_operand); - *((jobject*) operand) = value; - _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); - TRACE_graal_3("relocating (oop constant) at %p/%p", pc, operand); - } -} - -void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) { - address pc = _instructions->start() + pc_offset; - - address operand = Assembler::locate_operand(pc, Assembler::disp32_operand); - address next_instruction = Assembler::locate_next_instruction(pc); - address dest = _constants->start() + data_offset; - - long disp = dest - next_instruction; - assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); - *((jint*) operand) = (jint) disp; - - _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand); - TRACE_graal_3("relocating at %p/%p with destination at %p (%d)", pc, operand, dest, data_offset); -} - -void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { - if (cb->is_nmethod()) { - nmethod* nm = (nmethod*) cb; - nativeJump_at((address)inst)->set_jump_destination(nm->verified_entry_point()); - } else { - nativeJump_at((address)inst)->set_jump_destination(cb->code_begin()); - } - _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand); -} - -void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { - address pc = (address) inst; - if (inst->is_call()) { - // NOTE: for call without a mov, the offset must fit a 32-bit immediate - // see also CompilerToVM.getMaxCallTargetOffset() - NativeCall* call = nativeCall_at(pc); - call->set_destination((address) foreign_call_destination); - _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); - } else if (inst->is_mov_literal64()) { - NativeMovConstReg* mov = nativeMovConstReg_at(pc); - mov->set_data((intptr_t) foreign_call_destination); - _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand); - } else if (inst->is_jump()) { - NativeJump* jump = nativeJump_at(pc); - jump->set_jump_destination((address) foreign_call_destination); - _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); - } else if (inst->is_cond_jump()) { - address old_dest = nativeGeneralJump_at(pc)->jump_destination(); - address disp = Assembler::locate_operand(pc, Assembler::call32_operand); - *(jint*) disp += ((address) foreign_call_destination) - old_dest; - _instructions->relocate(pc, runtime_call_Relocation::spec(), Assembler::call32_operand); - } else { - fatal("unsupported relocation for foreign call"); - } - - TRACE_graal_3("relocating (foreign call) at %p", inst); -} - -void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { -#ifdef ASSERT - Method* method = NULL; - // we need to check, this might also be an unresolved method - if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) { - method = getMethodFromHotSpotMethod(hotspot_method); - } -#endif - switch (_next_call_type) { - case INLINE_INVOKE: - break; - case INVOKEVIRTUAL: - case INVOKEINTERFACE: { - assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); - - NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); - _instructions->relocate(call->instruction_address(), - virtual_call_Relocation::spec(_invoke_mark_pc), - Assembler::call32_operand); - break; - } - case INVOKESTATIC: { - assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); - - NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_static_call_stub()); - _instructions->relocate(call->instruction_address(), - relocInfo::static_call_type, Assembler::call32_operand); - break; - } - case INVOKESPECIAL: { - assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); - NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); - _instructions->relocate(call->instruction_address(), - relocInfo::opt_virtual_call_type, Assembler::call32_operand); - break; - } - default: - break; - } -} - -static void relocate_poll_near(address pc) { - NativeInstruction* ni = nativeInstruction_at(pc); - int32_t* disp = (int32_t*) Assembler::locate_operand(pc, Assembler::disp32_operand); - int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand - intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni; - *disp = (int32_t)new_disp; -} - - -void CodeInstaller::pd_relocate_poll(address pc, jint mark) { - switch (mark) { - case POLL_NEAR: { - relocate_poll_near(pc); - _instructions->relocate(pc, relocInfo::poll_type, Assembler::disp32_operand); - break; - } - case POLL_FAR: - // This is a load from a register so there is no relocatable operand. - // We just have to ensure that the format is not disp32_operand - // so that poll_Relocation::fix_relocation_after_move does the right - // thing (i.e. ignores this relocation record) - _instructions->relocate(pc, relocInfo::poll_type, Assembler::imm_operand); - break; - case POLL_RETURN_NEAR: { - relocate_poll_near(pc); - _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::disp32_operand); - break; - } - case POLL_RETURN_FAR: - // see comment above for POLL_FAR - _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::imm_operand); - break; - default: - fatal("invalid mark value"); - break; - } -} - -// convert Graal register indices (as used in oop maps) to HotSpot registers -VMReg CodeInstaller::get_hotspot_reg(jint graal_reg) { - if (graal_reg < RegisterImpl::number_of_registers) { - return as_Register(graal_reg)->as_VMReg(); - } else { - jint floatRegisterNumber = graal_reg - RegisterImpl::number_of_registers; - if (floatRegisterNumber < XMMRegisterImpl::number_of_registers) { - return as_XMMRegister(floatRegisterNumber)->as_VMReg(); - } - ShouldNotReachHere(); - return NULL; - } -} - -bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { - return !(hotspotRegister->is_FloatRegister() || hotspotRegister->is_XMMRegister()); -}
--- a/src/cpu/x86/vm/graalGlobals_x86.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2000, 2012, 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. - * - */ - -#ifndef CPU_X86_VM_GRAALGLOBALS_X86_HPP -#define CPU_X86_VM_GRAALGLOBALS_X86_HPP - -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" - -// Sets the default values for platform dependent flags used by the Graal compiler. -// (see graalGlobals.hpp) - -#ifdef COMPILERGRAAL -define_pd_global(bool, BackgroundCompilation, true ); -define_pd_global(bool, UseTLAB, true ); -define_pd_global(bool, ResizeTLAB, true ); -define_pd_global(bool, InlineIntrinsics, true ); -define_pd_global(bool, PreferInterpreterNativeStubs, false); -define_pd_global(bool, TieredCompilation, trueInTiered); -define_pd_global(intx, BackEdgeThreshold, 100000); - -define_pd_global(intx, OnStackReplacePercentage, 933 ); -define_pd_global(intx, FreqInlineSize, 325 ); -define_pd_global(intx, NewSizeThreadIncrease, 4*K ); -define_pd_global(uintx,MetaspaceSize, 12*M ); -define_pd_global(bool, NeverActAsServerClassMachine, false); -define_pd_global(uint64_t,MaxRAM, 128ULL*G); -define_pd_global(bool, CICompileOSR, true ); -define_pd_global(bool, ProfileTraps, true ); -define_pd_global(bool, UseOnStackReplacement, true ); -define_pd_global(intx, CompileThreshold, 10000); -define_pd_global(intx, InitialCodeCacheSize, 16*M ); -define_pd_global(intx, ReservedCodeCacheSize, 64*M ); -define_pd_global(bool, ProfileInterpreter, true ); -define_pd_global(intx, CodeCacheExpansionSize, 64*K ); -define_pd_global(uintx,CodeCacheMinBlockLength, 4); -define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K); -define_pd_global(intx, TypeProfileWidth, 8); -define_pd_global(intx, MethodProfileWidth, 0); -#endif // COMPILERGRAAL - -define_pd_global(intx, MaxVectorSize, 32); - -#endif // CPU_X86_VM_GRAALGLOBALS_X86_HPP
--- a/src/cpu/x86/vm/interp_masm_x86_64.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/interp_masm_x86_64.cpp Thu May 28 15:36:48 2015 +0200 @@ -1129,7 +1129,7 @@ bind(skip_receiver_profile); // The method data pointer needs to be updated to reflect the new target. -#ifdef GRAAL +#ifdef JVMCI if (MethodProfileWidth == 0) { update_mdp_by_constant(mdp, in_bytes(VirtualCallData::virtual_call_data_size())); } @@ -1140,7 +1140,7 @@ } } -#ifdef GRAAL +#ifdef JVMCI void InterpreterMacroAssembler::profile_called_method(Register method, Register mdp, Register reg2) { assert_different_registers(method, mdp, reg2); if (ProfileInterpreter && MethodProfileWidth > 0) { @@ -1178,17 +1178,17 @@ if (is_virtual_call) { increment_mdp_data_at(mdp, in_bytes(CounterData::count_offset())); } -#ifdef GRAAL +#ifdef JVMCI else { increment_mdp_data_at(mdp, in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset())); } #endif } else { - bool use_non_profiled_counter = !is_virtual_call || IS_GRAAL_DEFINED; + bool use_non_profiled_counter = !is_virtual_call || IS_JVMCI_DEFINED; int non_profiled_offset = -1; if (use_non_profiled_counter) { non_profiled_offset = in_bytes(CounterData::count_offset()); - #ifdef GRAAL + #ifdef JVMCI if (!is_virtual_call) { non_profiled_offset = in_bytes(ReceiverTypeData::nonprofiled_receiver_count_offset()); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2013, 2014, 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. + */ + +#include "precompiled.hpp" +#include "compiler/disassembler.hpp" +#include "runtime/javaCalls.hpp" +#include "jvmci/jvmciEnv.hpp" +#include "jvmci/jvmciCodeInstaller.hpp" +#include "jvmci/jvmciJavaAccess.hpp" +#include "jvmci/jvmciCompilerToVM.hpp" +#include "jvmci/jvmciRuntime.hpp" +#include "asm/register.hpp" +#include "classfile/vmSymbols.hpp" +#include "code/vmreg.hpp" +#include "vmreg_x86.inline.hpp" + +jint CodeInstaller::pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method) { + if (inst->is_call() || inst->is_jump()) { + assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size"); + return (pc_offset + NativeCall::instruction_size); + } else if (inst->is_mov_literal64()) { + // mov+call instruction pair + jint offset = pc_offset + NativeMovConstReg::instruction_size; + u_char* call = (u_char*) (_instructions->start() + offset); + if (call[0] == Assembler::REX_B) { + offset += 1; /* prefix byte for extended register R8-R15 */ + call++; + } + assert(call[0] == 0xFF, "expected call"); + offset += 2; /* opcode byte + modrm byte */ + return (offset); + } else if (inst->is_call_reg()) { + // the inlined vtable stub contains a "call register" instruction + assert(method != NULL, "only valid for virtual calls"); + return (pc_offset + ((NativeCallReg *) inst)->next_instruction_offset()); + } else if (inst->is_cond_jump()) { + address pc = (address) (inst); + return pc_offset + (jint) (Assembler::locate_next_instruction(pc) - pc); + } else { + fatal("unsupported type of instruction for call site"); + return 0; + } +} + +void CodeInstaller::pd_patch_OopConstant(int pc_offset, Handle& constant) { + address pc = _instructions->start() + pc_offset; + Handle obj = HotSpotObjectConstantImpl::object(constant); + jobject value = JNIHandles::make_local(obj()); + if (HotSpotObjectConstantImpl::compressed(constant)) { +#ifdef _LP64 + address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); + int oop_index = _oop_recorder->find_index(value); + _instructions->relocate(pc, oop_Relocation::spec(oop_index), Assembler::narrow_oop_operand); + TRACE_jvmci_3("relocating (narrow oop constant) at %p/%p", pc, operand); +#else + fatal("compressed oop on 32bit"); +#endif + } else { + address operand = Assembler::locate_operand(pc, Assembler::imm_operand); + *((jobject*) operand) = value; + _instructions->relocate(pc, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); + TRACE_jvmci_3("relocating (oop constant) at %p/%p", pc, operand); + } +} + +void CodeInstaller::pd_patch_DataSectionReference(int pc_offset, int data_offset) { + address pc = _instructions->start() + pc_offset; + + address operand = Assembler::locate_operand(pc, Assembler::disp32_operand); + address next_instruction = Assembler::locate_next_instruction(pc); + address dest = _constants->start() + data_offset; + + long disp = dest - next_instruction; + assert(disp == (jint) disp, "disp doesn't fit in 32 bits"); + *((jint*) operand) = (jint) disp; + + _instructions->relocate(pc, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand); + TRACE_jvmci_3("relocating at %p/%p with destination at %p (%d)", pc, operand, dest, data_offset); +} + +void CodeInstaller::pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst) { + if (cb->is_nmethod()) { + nmethod* nm = (nmethod*) cb; + nativeJump_at((address)inst)->set_jump_destination(nm->verified_entry_point()); + } else { + nativeJump_at((address)inst)->set_jump_destination(cb->code_begin()); + } + _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand); +} + +void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination) { + address pc = (address) inst; + if (inst->is_call()) { + // NOTE: for call without a mov, the offset must fit a 32-bit immediate + // see also CompilerToVM.getMaxCallTargetOffset() + NativeCall* call = nativeCall_at(pc); + call->set_destination((address) foreign_call_destination); + _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); + } else if (inst->is_mov_literal64()) { + NativeMovConstReg* mov = nativeMovConstReg_at(pc); + mov->set_data((intptr_t) foreign_call_destination); + _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand); + } else if (inst->is_jump()) { + NativeJump* jump = nativeJump_at(pc); + jump->set_jump_destination((address) foreign_call_destination); + _instructions->relocate(jump->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand); + } else if (inst->is_cond_jump()) { + address old_dest = nativeGeneralJump_at(pc)->jump_destination(); + address disp = Assembler::locate_operand(pc, Assembler::call32_operand); + *(jint*) disp += ((address) foreign_call_destination) - old_dest; + _instructions->relocate(pc, runtime_call_Relocation::spec(), Assembler::call32_operand); + } else { + fatal("unsupported relocation for foreign call"); + } + + TRACE_jvmci_3("relocating (foreign call) at %p", inst); +} + +void CodeInstaller::pd_relocate_JavaMethod(oop hotspot_method, jint pc_offset) { +#ifdef ASSERT + Method* method = NULL; + // we need to check, this might also be an unresolved method + if (hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass())) { + method = getMethodFromHotSpotMethod(hotspot_method); + } +#endif + switch (_next_call_type) { + case INLINE_INVOKE: + break; + case INVOKEVIRTUAL: + case INVOKEINTERFACE: { + assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); + + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); + _instructions->relocate(call->instruction_address(), + virtual_call_Relocation::spec(_invoke_mark_pc), + Assembler::call32_operand); + break; + } + case INVOKESTATIC: { + assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); + + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_static_call_stub()); + _instructions->relocate(call->instruction_address(), + relocInfo::static_call_type, Assembler::call32_operand); + break; + } + case INVOKESPECIAL: { + assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); + NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); + call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); + _instructions->relocate(call->instruction_address(), + relocInfo::opt_virtual_call_type, Assembler::call32_operand); + break; + } + default: + break; + } +} + +static void relocate_poll_near(address pc) { + NativeInstruction* ni = nativeInstruction_at(pc); + int32_t* disp = (int32_t*) Assembler::locate_operand(pc, Assembler::disp32_operand); + int32_t offset = *disp; // The Java code installed the polling page offset into the disp32 operand + intptr_t new_disp = (intptr_t) (os::get_polling_page() + offset) - (intptr_t) ni; + *disp = (int32_t)new_disp; +} + + +void CodeInstaller::pd_relocate_poll(address pc, jint mark) { + switch (mark) { + case POLL_NEAR: { + relocate_poll_near(pc); + _instructions->relocate(pc, relocInfo::poll_type, Assembler::disp32_operand); + break; + } + case POLL_FAR: + // This is a load from a register so there is no relocatable operand. + // We just have to ensure that the format is not disp32_operand + // so that poll_Relocation::fix_relocation_after_move does the right + // thing (i.e. ignores this relocation record) + _instructions->relocate(pc, relocInfo::poll_type, Assembler::imm_operand); + break; + case POLL_RETURN_NEAR: { + relocate_poll_near(pc); + _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::disp32_operand); + break; + } + case POLL_RETURN_FAR: + // see comment above for POLL_FAR + _instructions->relocate(pc, relocInfo::poll_return_type, Assembler::imm_operand); + break; + default: + fatal("invalid mark value"); + break; + } +} + +// convert JVMCI register indices (as used in oop maps) to HotSpot registers +VMReg CodeInstaller::get_hotspot_reg(jint jvmci_reg) { + if (jvmci_reg < RegisterImpl::number_of_registers) { + return as_Register(jvmci_reg)->as_VMReg(); + } else { + jint floatRegisterNumber = jvmci_reg - RegisterImpl::number_of_registers; + if (floatRegisterNumber < XMMRegisterImpl::number_of_registers) { + return as_XMMRegister(floatRegisterNumber)->as_VMReg(); + } + ShouldNotReachHere(); + return NULL; + } +} + +bool CodeInstaller::is_general_purpose_reg(VMReg hotspotRegister) { + return !(hotspotRegister->is_FloatRegister() || hotspotRegister->is_XMMRegister()); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cpu/x86/vm/jvmciGlobals_x86.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2000, 2012, 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. + * + */ + +#ifndef CPU_X86_VM_JVMCIGLOBALS_X86_HPP +#define CPU_X86_VM_JVMCIGLOBALS_X86_HPP + +#include "utilities/globalDefinitions.hpp" +#include "utilities/macros.hpp" + +// Sets the default values for platform dependent flags used by the JVMCI compiler. +// (see jvmciGlobals.hpp) + +#ifdef COMPILERJVMCI +define_pd_global(bool, BackgroundCompilation, true ); +define_pd_global(bool, UseTLAB, true ); +define_pd_global(bool, ResizeTLAB, true ); +define_pd_global(bool, InlineIntrinsics, true ); +define_pd_global(bool, PreferInterpreterNativeStubs, false); +define_pd_global(bool, TieredCompilation, trueInTiered); +define_pd_global(intx, BackEdgeThreshold, 100000); + +define_pd_global(intx, OnStackReplacePercentage, 933 ); +define_pd_global(intx, FreqInlineSize, 325 ); +define_pd_global(intx, NewSizeThreadIncrease, 4*K ); +define_pd_global(uintx,MetaspaceSize, 12*M ); +define_pd_global(bool, NeverActAsServerClassMachine, false); +define_pd_global(uint64_t,MaxRAM, 128ULL*G); +define_pd_global(bool, CICompileOSR, true ); +define_pd_global(bool, ProfileTraps, true ); +define_pd_global(bool, UseOnStackReplacement, true ); +define_pd_global(intx, CompileThreshold, 10000); +define_pd_global(intx, InitialCodeCacheSize, 16*M ); +define_pd_global(intx, ReservedCodeCacheSize, 64*M ); +define_pd_global(bool, ProfileInterpreter, true ); +define_pd_global(intx, CodeCacheExpansionSize, 64*K ); +define_pd_global(uintx,CodeCacheMinBlockLength, 4); +define_pd_global(uintx, CodeCacheMinimumUseSpace, 400*K); +define_pd_global(intx, TypeProfileWidth, 8); +define_pd_global(intx, MethodProfileWidth, 0); +#endif // COMPILERJVMCI + +define_pd_global(intx, MaxVectorSize, 32); + +#endif // CPU_X86_VM_JVMCIGLOBALS_X86_HPP
--- a/src/cpu/x86/vm/macroAssembler_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/macroAssembler_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -2945,7 +2945,7 @@ } // !defined(COMPILER2) is because of stupid core builds -#if !defined(_LP64) || defined(COMPILER1) || !defined(COMPILER2) || defined(GRAAL) +#if !defined(_LP64) || defined(COMPILER1) || !defined(COMPILER2) || defined(JVMCI) void MacroAssembler::empty_FPU_stack() { if (VM_Version::supports_mmx()) { emms();
--- a/src/cpu/x86/vm/nativeInst_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/nativeInst_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -474,7 +474,7 @@ // // In C2 the 5+ byte sized instruction is enforced by code in MachPrologNode::emit. // In C1 the restriction is enforced by CodeEmitter::method_entry -// In Graal, the restriction is enforced by HotSpotFrameContext.enter(...) +// In JVMCI, the restriction is enforced by HotSpotFrameContext.enter(...) // void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) { // complete jump instruction (to be inserted) is in code_buffer;
--- a/src/cpu/x86/vm/nativeInst_x86.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/nativeInst_x86.hpp Thu May 28 15:36:48 2015 +0200 @@ -566,7 +566,7 @@ if (ubyte_at(0) == NativeTstRegMem::instruction_code_memXregl && ubyte_at(1) == 0x05) { // 00 rax 101 address fault = addr_at(6) + int_at(2); - NOT_GRAAL(assert(!Assembler::is_polling_page_far(), "unexpected poll encoding");) + NOT_JVMCI(assert(!Assembler::is_polling_page_far(), "unexpected poll encoding");) return os::is_poll_address(fault); } // Now try decoding a far safepoint: @@ -576,7 +576,7 @@ (ubyte_at(2) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg) || ubyte_at(0) == NativeTstRegMem::instruction_code_memXregl && (ubyte_at(1) & NativeTstRegMem::modrm_mask) == NativeTstRegMem::modrm_reg) { - NOT_GRAAL(assert(Assembler::is_polling_page_far(), "unexpected poll encoding");) + NOT_JVMCI(assert(Assembler::is_polling_page_far(), "unexpected poll encoding");) return true; } return false;
--- a/src/cpu/x86/vm/relocInfo_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/relocInfo_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -181,7 +181,7 @@ #ifdef _LP64 typedef Assembler::WhichOperand WhichOperand; WhichOperand which = (WhichOperand) format(); -#ifndef GRAAL +#ifndef JVMCI assert((which == Assembler::disp32_operand) == !Assembler::is_polling_page_far(), "format not set correctly"); #endif if (which == Assembler::disp32_operand) {
--- a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Thu May 28 15:36:48 2015 +0200 @@ -40,8 +40,8 @@ #ifdef COMPILER2 #include "opto/runtime.hpp" #endif -#ifdef GRAAL -#include "graal/graalJavaAccess.hpp" +#ifdef JVMCI +#include "jvmci/jvmciJavaAccess.hpp" #endif #define __ masm-> @@ -73,7 +73,7 @@ #define DEF_YMM_HI_OFFS(regnum) ymm_hi ## regnum ## _off = ymm_off + (regnum)*16/BytesPerInt enum layout { fpu_state_off = frame::arg_reg_save_area_bytes/BytesPerInt, // fxsave save area -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) ymm_off = fpu_state_off, // offset in fxsave save area DEF_YMM_HI_OFFS(0), DEF_YMM_HI_OFFS(1), @@ -182,7 +182,7 @@ __ enter(); // rsp becomes 16-byte aligned here __ push_CPU_state(); // Push a multiple of 16 bytes -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) __ subptr(rsp, 256); // Save upper half of YMM registers if (save_vectors) { assert(UseAVX > 0, "256bit vectors are supported only with AVX"); @@ -206,7 +206,7 @@ __ vextractf128h(Address(rsp, ymm_hi15_off * BytesPerInt), xmm15); } #else - assert(!save_vectors, "vectors are generated only by C2 and Graal"); + assert(!save_vectors, "vectors are generated only by C2 and JVMCI"); #endif if (frame::arg_reg_save_area_bytes != 0) { // Allocate argument register save area @@ -257,7 +257,7 @@ map->set_callee_saved(STACK_OFFSET(xmm15_off), xmm15->as_VMReg()); -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) if (save_vectors) { map->set_callee_saved(STACK_OFFSET(ymm_hi0_off ), xmm0->as_VMReg()->next()->next()->next()->next()); map->set_callee_saved(STACK_OFFSET(ymm_hi1_off ), xmm1->as_VMReg()->next()->next()->next()->next()); @@ -321,7 +321,7 @@ // Pop arg register save area __ addptr(rsp, frame::arg_reg_save_area_bytes); } -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) if (restore_vectors) { // Restore upper half of YMM registes. assert(UseAVX > 0, "256bit vectors are supported only with AVX"); @@ -345,7 +345,7 @@ } __ addptr(rsp, 256); #else - assert(!restore_vectors, "vectors are generated only by C2 and Graal"); + assert(!restore_vectors, "vectors are generated only by C2 and JVMCI"); #endif // Recover CPU state __ pop_CPU_state(); @@ -743,7 +743,7 @@ __ block_comment("} verify_i2ce "); } -#ifdef GRAAL +#ifdef JVMCI if (frame_extension_argument != -1) { // The frame_extension_argument is an int that describes the // expected amount of argument space in the caller frame. If that @@ -814,13 +814,13 @@ // Pre-load the register-jump target early, to schedule it better. __ movptr(r11, Address(rbx, in_bytes(Method::from_compiled_offset()))); -#ifdef GRAAL +#ifdef JVMCI // check if this call should be routed towards a specific entry point - __ cmpptr(Address(r15_thread, in_bytes(JavaThread::graal_alternate_call_target_offset())), 0); + __ cmpptr(Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())), 0); Label no_alternative_target; __ jcc(Assembler::equal, no_alternative_target); - __ movptr(r11, Address(r15_thread, in_bytes(JavaThread::graal_alternate_call_target_offset()))); - __ movptr(Address(r15_thread, in_bytes(JavaThread::graal_alternate_call_target_offset())), 0); + __ movptr(r11, Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset()))); + __ movptr(Address(r15_thread, in_bytes(JavaThread::jvmci_alternate_call_target_offset())), 0); __ bind(no_alternative_target); #endif @@ -3428,8 +3428,8 @@ __ jmp(cont); int reexecute_offset = __ pc() - start; -#if defined(COMPILERGRAAL) && !defined(COMPILER1) - // Graal does not use this kind of deoptimization +#if defined(COMPILERJVMCI) && !defined(COMPILER1) + // JVMCI does not use this kind of deoptimization __ should_not_reach_here(); #endif @@ -3442,10 +3442,10 @@ __ movl(r14, Deoptimization::Unpack_reexecute); // callee-saved __ jmp(cont); -#ifdef GRAAL +#ifdef JVMCI int implicit_exception_uncommon_trap_offset = __ pc() - start; - __ pushptr(Address(r15_thread, in_bytes(JavaThread::graal_implicit_exception_pc_offset()))); + __ pushptr(Address(r15_thread, in_bytes(JavaThread::jvmci_implicit_exception_pc_offset()))); int uncommon_trap_offset = __ pc() - start; @@ -3466,7 +3466,7 @@ Label after_fetch_unroll_info_call; __ jmp(after_fetch_unroll_info_call); -#endif // GRAAL +#endif // JVMCI int exception_offset = __ pc() - start; @@ -3553,7 +3553,7 @@ __ reset_last_Java_frame(false, false); -#ifdef GRAAL +#ifdef JVMCI __ bind(after_fetch_unroll_info_call); #endif @@ -3731,7 +3731,7 @@ _deopt_blob = DeoptimizationBlob::create(&buffer, oop_maps, 0, exception_offset, reexecute_offset, frame_size_in_words); _deopt_blob->set_unpack_with_exception_in_tls_offset(exception_in_tls_offset); -#ifdef GRAAL +#ifdef JVMCI _deopt_blob->set_uncommon_trap_offset(uncommon_trap_offset); _deopt_blob->set_implicit_exception_uncommon_trap_offset(implicit_exception_uncommon_trap_offset); #endif
--- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Thu May 28 15:36:48 2015 +0200 @@ -204,7 +204,7 @@ __ movptr(Address(rbp, frame::interpreter_frame_last_sp_offset * wordSize), (int32_t)NULL_WORD); __ restore_bcp(); __ restore_locals(); -#ifdef GRAAL +#ifdef JVMCI // Check if we need to take lock at entry of synchronized method. { Label L;
--- a/src/cpu/x86/vm/templateTable_x86_64.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/templateTable_x86_64.cpp Thu May 28 15:36:48 2015 +0200 @@ -3039,7 +3039,7 @@ // get target Method* & entry point __ lookup_virtual_method(rax, index, method); -#ifdef GRAAL +#ifdef JVMCI // r14: MethodDataPointer (r14 is callee saved) __ profile_called_method(method, r14, r13); #endif @@ -3143,7 +3143,7 @@ __ testptr(rbx, rbx); __ jcc(Assembler::zero, no_such_method); -#ifdef GRAAL +#ifdef JVMCI // r13: MethodDataPointer (r13 is callee saved) __ profile_called_method(rbx, r13, r14); #endif
--- a/src/cpu/x86/vm/vm_version_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/cpu/x86/vm/vm_version_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -668,7 +668,7 @@ } } #endif -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) if (MaxVectorSize > 0) { if (!is_power_of_2(MaxVectorSize)) { warning("MaxVectorSize must be a power of 2");
--- a/src/os/windows/vm/os_windows.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/os/windows/vm/os_windows.cpp Thu May 28 15:36:48 2015 +0200 @@ -2253,7 +2253,7 @@ #elif _M_AMD64 PCONTEXT ctx = exceptionInfo->ContextRecord; address pc = (address)ctx->Rip; -#ifdef GRAAL +#ifdef JVMCI assert(pc[0] >= Assembler::REX && pc[0] <= Assembler::REX_WRXB && pc[1] == 0xF7 || pc[0] == 0xF7, "not an idiv opcode"); if (pc[0] == 0xF7) { // set correct result values and continue after idiv instruction @@ -2271,7 +2271,7 @@ // set correct result values and continue after idiv instruction ctx->Rip = (DWORD)pc + 2; // idiv reg, reg is 2 bytes ctx->Rax = (DWORD)min_jint; // result -#endif // GRAAL +#endif // JVMCI ctx->Rdx = (DWORD)0; // remainder // Continue the execution #else
--- a/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -66,8 +66,8 @@ frame ret_frame(ret_sp, ret_fp, addr.pc()); if (!ret_frame.safe_for_sender(jt)) { -#if defined(COMPILER2) || defined(GRAAL) - // C2 and Graal use ebp as a general register see if NULL fp helps +#if defined(COMPILER2) || defined(JVMCI) + // C2 and JVMCI use ebp as a general register see if NULL fp helps frame ret_frame2(ret_sp, NULL, addr.pc()); if (!ret_frame2.safe_for_sender(jt)) { // nothing else to try if the frame isn't good @@ -77,7 +77,7 @@ #else // nothing else to try if the frame isn't good return false; -#endif /* COMPILER2 || GRAAL*/ +#endif /* COMPILER2 || JVMCI*/ } *fr_addr = ret_frame; return true;
--- a/src/os_cpu/linux_x86/vm/thread_linux_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/os_cpu/linux_x86/vm/thread_linux_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -67,8 +67,8 @@ frame ret_frame(ret_sp, ret_fp, addr.pc()); if (!ret_frame.safe_for_sender(jt)) { -#if defined(COMPILER2) || defined(GRAAL) - // C2 and Graal use ebp as a general register see if NULL fp helps +#if defined(COMPILER2) || defined(JVMCI) + // C2 and JVMCI use ebp as a general register see if NULL fp helps frame ret_frame2(ret_sp, NULL, addr.pc()); if (!ret_frame2.safe_for_sender(jt)) { // nothing else to try if the frame isn't good @@ -78,7 +78,7 @@ #else // nothing else to try if the frame isn't good return false; -#endif /* COMPILER2 || GRAAL */ +#endif /* COMPILER2 || JVMCI */ } *fr_addr = ret_frame; return true;
--- a/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Thu May 28 15:36:48 2015 +0200 @@ -484,14 +484,14 @@ } #endif // COMPILER2 -#ifdef GRAAL +#ifdef JVMCI else if (sig == SIGILL && info->si_trapno == 0x100 + ST_RESERVED_FOR_USER_0) { printf("SIGILL 0x%x 0x%x\n", info->si_trapno, ST_RESERVED_FOR_USER_0); uc->uc_mcontext.gregs[REG_PC] = (greg_t)pc+4; uc->uc_mcontext.gregs[REG_nPC] = (greg_t)npc + 4; return true; } -#endif // GRAAL +#endif // JVMCI else if (sig == SIGSEGV && info->si_code > 0 && !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) { // Determination of interpreter/vtable stub/compiled code null exception
--- a/src/os_cpu/windows_x86/vm/thread_windows_x86.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/os_cpu/windows_x86/vm/thread_windows_x86.cpp Thu May 28 15:36:48 2015 +0200 @@ -74,8 +74,8 @@ frame ret_frame(ret_sp, ret_fp, addr.pc()); if (!ret_frame.safe_for_sender(jt)) { -#if defined(COMPILER2) || defined(GRAAL) - // C2 and Graal use ebp as a general register see if NULL fp helps +#if defined(COMPILER2) || defined(JVMCI) + // C2 and JVMCI use ebp as a general register see if NULL fp helps frame ret_frame2(ret_sp, NULL, addr.pc()); if (!ret_frame2.safe_for_sender(jt)) { // nothing else to try if the frame isn't good @@ -85,7 +85,7 @@ #else // nothing else to try if the frame isn't good return false; -#endif /* COMPILER2 || GRAAL */ +#endif /* COMPILER2 || JVMCI */ } *fr_addr = ret_frame; return true;
--- a/src/share/vm/c1/c1_GraphBuilder.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Thu May 28 15:36:48 2015 +0200 @@ -3560,7 +3560,7 @@ case vmIntrinsics::_updateBytesCRC32: case vmIntrinsics::_updateByteBufferCRC32: if (!UseCRC32Intrinsics) return false; - // GRAAL-409: CRC32 C1 intrinsics cause errors on jdk version earlier than 8 + // JVMCI-409: CRC32 C1 intrinsics cause errors on jdk version earlier than 8 if (!JDK_Version::is_gte_jdk18x_version()) return false; cantrap = false; preserves_state = true;
--- a/src/share/vm/classfile/classFileParser.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/classfile/classFileParser.cpp Thu May 28 15:36:48 2015 +0200 @@ -1791,10 +1791,10 @@ if (_location != _in_method) break; // only allow for methods if (!privileged) break; // only allow in privileged code return _method_LambdaForm_Hidden; -#ifdef GRAAL +#ifdef JVMCI case vmSymbols::VM_SYMBOL_ENUM_NAME(com_oracle_jvmci_hotspot_Stable_signature): if (_location != _in_field) break; // only allow for fields - if (!privileged && loader_data->class_loader() != SystemDictionary::graal_loader()) break; // only allow in privileged code + if (!privileged && loader_data->class_loader() != SystemDictionary::jvmci_loader()) break; // only allow in privileged code return _field_Stable; #endif case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_Stable_signature):
--- a/src/share/vm/classfile/javaClasses.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/classfile/javaClasses.cpp Thu May 28 15:36:48 2015 +0200 @@ -563,8 +563,8 @@ set_init_lock(mirror(), r); // Set protection domain also -#ifdef GRAAL - if (k->class_loader() == SystemDictionary::graal_loader()) { +#ifdef JVMCI + if (k->class_loader() == SystemDictionary::jvmci_loader()) { // Same protection domain as for classes loaded by the boot loader protection_domain = Handle(); }
--- a/src/share/vm/classfile/systemDictionary.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/classfile/systemDictionary.cpp Thu May 28 15:36:48 2015 +0200 @@ -64,8 +64,8 @@ #include "services/threadService.hpp" #include "utilities/macros.hpp" #include "utilities/ticks.hpp" -#ifdef GRAAL -#include "graal/graalRuntime.hpp" +#ifdef JVMCI +#include "jvmci/jvmciRuntime.hpp" #endif #if INCLUDE_TRACE #include "trace/tracing.hpp" @@ -96,15 +96,15 @@ bool SystemDictionary::_has_loadClassInternal = false; bool SystemDictionary::_has_checkPackageAccess = false; -#ifdef GRAAL -oop SystemDictionary::_graal_loader = NULL; - -oop SystemDictionary::graal_loader() { - return _graal_loader; +#ifdef JVMCI +oop SystemDictionary::_jvmci_loader = NULL; + +oop SystemDictionary::jvmci_loader() { + return _jvmci_loader; } -void SystemDictionary::init_graal_loader(oop loader) { - assert(UseGraalClassLoader == (loader != NULL), "must be"); - _graal_loader = loader; +void SystemDictionary::init_jvmci_loader(oop loader) { + assert(UseJVMCIClassLoader == (loader != NULL), "must be"); + _jvmci_loader = loader; } #endif @@ -1728,7 +1728,7 @@ strong->do_oop(&_java_system_loader); strong->do_oop(&_system_loader_lock_obj); CDS_ONLY(SystemDictionaryShared::roots_oops_do(strong);) - GRAAL_ONLY(strong->do_oop(&_graal_loader);) + JVMCI_ONLY(strong->do_oop(&_jvmci_loader);) // Adjust dictionary dictionary()->roots_oops_do(strong, weak); @@ -1741,7 +1741,7 @@ f->do_oop(&_java_system_loader); f->do_oop(&_system_loader_lock_obj); CDS_ONLY(SystemDictionaryShared::oops_do(f);) - GRAAL_ONLY(f->do_oop(&_graal_loader);) + JVMCI_ONLY(f->do_oop(&_jvmci_loader);) // Adjust dictionary dictionary()->oops_do(f); @@ -1865,12 +1865,12 @@ Klass** klassp = &_well_known_klasses[id]; bool must_load = (init_opt < SystemDictionary::Opt); if ((*klassp) == NULL) { -#ifdef GRAAL - bool is_graal = init_opt == SystemDictionary::Graal; - assert(is_graal == (id >= (int)FIRST_GRAAL_WKID && id <= (int)LAST_GRAAL_WKID), - "Graal WKIDs must be contiguous and separate from non-Graal WKIDs"); - if (is_graal) { - (*klassp) = resolve_or_fail(symbol, _graal_loader, Handle(), true, CHECK_0); // load required Graal class +#ifdef JVMCI + bool is_jvmci = init_opt == SystemDictionary::Jvmci; + assert(is_jvmci == (id >= (int)FIRST_JVMCI_WKID && id <= (int)LAST_JVMCI_WKID), + "JVMCI WKIDs must be contiguous and separate from non-JVMCI WKIDs"); + if (is_jvmci) { + (*klassp) = resolve_or_fail(symbol, _jvmci_loader, Handle(), true, CHECK_0); // load required JVMCI class } else #endif if (must_load) { @@ -1950,7 +1950,7 @@ scan = WKID(jsr292_group_end + 1); } - initialize_wk_klasses_until(NOT_GRAAL(WKID_LIMIT) GRAAL_ONLY(FIRST_GRAAL_WKID), scan, CHECK); + initialize_wk_klasses_until(NOT_JVMCI(WKID_LIMIT) JVMCI_ONLY(FIRST_JVMCI_WKID), scan, CHECK); _box_klasses[T_BOOLEAN] = WK_KLASS(Boolean_klass); _box_klasses[T_CHAR] = WK_KLASS(Character_klass);
--- a/src/share/vm/classfile/systemDictionary.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/classfile/systemDictionary.hpp Thu May 28 15:36:48 2015 +0200 @@ -196,62 +196,62 @@ do_klass(Integer_klass, java_lang_Integer, Pre ) \ do_klass(Long_klass, java_lang_Long, Pre ) \ \ - /* Support for Graal */ \ + /* Support for JVMCI */ \ do_klass(BitSet_klass, java_util_BitSet, Opt ) \ - /* Graal classes. These are loaded on-demand. */ \ - GRAAL_ONLY(do_klass(Debug_klass, com_oracle_jvmci_debug_Debug, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompiledCode_klass, com_oracle_jvmci_hotspot_HotSpotCompiledCode, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompiledCode_Comment_klass, com_oracle_jvmci_hotspot_HotSpotCompiledCode_Comment, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompiledNmethod_klass, com_oracle_jvmci_hotspot_HotSpotCompiledNmethod, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotForeignCallTarget_klass, com_oracle_jvmci_hotspot_HotSpotForeignCallTarget, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotReferenceMap_klass, com_oracle_jvmci_hotspot_HotSpotReferenceMap, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotOopMap_klass, com_oracle_jvmci_hotspot_HotSpotReferenceMap_HotSpotOopMap, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotInstalledCode_klass, com_oracle_jvmci_hotspot_HotSpotInstalledCode, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotNmethod_klass, com_oracle_jvmci_hotspot_HotSpotNmethod, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotResolvedJavaMethodImpl_klass, com_oracle_jvmci_hotspot_HotSpotResolvedJavaMethodImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotResolvedObjectTypeImpl_klass, com_oracle_jvmci_hotspot_HotSpotResolvedObjectTypeImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotCompressedNullConstant_klass, com_oracle_jvmci_hotspot_HotSpotCompressedNullConstant, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotObjectConstantImpl_klass, com_oracle_jvmci_hotspot_HotSpotObjectConstantImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotMetaspaceConstantImpl_klass, com_oracle_jvmci_hotspot_HotSpotMetaspaceConstantImpl, Graal)) \ - GRAAL_ONLY(do_klass(HotSpotStackFrameReference_klass, com_oracle_jvmci_hotspot_HotSpotStackFrameReference, Graal)) \ - GRAAL_ONLY(do_klass(CompilationTask_klass, com_oracle_graal_hotspot_CompilationTask, Graal)) \ - GRAAL_ONLY(do_klass(Assumptions_ConcreteMethod_klass, com_oracle_jvmci_meta_Assumptions_ConcreteMethod, Graal)) \ - GRAAL_ONLY(do_klass(Assumptions_NoFinalizableSubclass_klass, com_oracle_jvmci_meta_Assumptions_NoFinalizableSubclass, Graal))\ - GRAAL_ONLY(do_klass(Assumptions_ConcreteSubtype_klass, com_oracle_jvmci_meta_Assumptions_ConcreteSubtype, Graal)) \ - GRAAL_ONLY(do_klass(Assumptions_LeafType_klass, com_oracle_jvmci_meta_Assumptions_LeafType, Graal)) \ - GRAAL_ONLY(do_klass(Assumptions_CallSiteTargetValue_klass, com_oracle_jvmci_meta_Assumptions_CallSiteTargetValue, Graal)) \ - GRAAL_ONLY(do_klass(BytecodePosition_klass, com_oracle_jvmci_code_BytecodePosition, Graal)) \ - GRAAL_ONLY(do_klass(DebugInfo_klass, com_oracle_jvmci_code_DebugInfo, Graal)) \ - GRAAL_ONLY(do_klass(RegisterSaveLayout_klass, com_oracle_jvmci_code_RegisterSaveLayout, Graal)) \ - GRAAL_ONLY(do_klass(BytecodeFrame_klass, com_oracle_jvmci_code_BytecodeFrame, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_klass, com_oracle_jvmci_code_CompilationResult, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_Call_klass, com_oracle_jvmci_code_CompilationResult_Call, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_ConstantReference_klass, com_oracle_jvmci_code_CompilationResult_ConstantReference, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_DataPatch_klass, com_oracle_jvmci_code_CompilationResult_DataPatch, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_DataSectionReference_klass, com_oracle_jvmci_code_CompilationResult_DataSectionReference, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_ExceptionHandler_klass, com_oracle_jvmci_code_CompilationResult_ExceptionHandler, Graal))\ - GRAAL_ONLY(do_klass(CompilationResult_Mark_klass, com_oracle_jvmci_code_CompilationResult_Mark, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_Infopoint_klass, com_oracle_jvmci_code_CompilationResult_Infopoint, Graal)) \ - GRAAL_ONLY(do_klass(CompilationResult_Site_klass, com_oracle_jvmci_code_CompilationResult_Site, Graal)) \ - GRAAL_ONLY(do_klass(InfopointReason_klass, com_oracle_jvmci_code_InfopointReason, Graal)) \ - GRAAL_ONLY(do_klass(InstalledCode_klass, com_oracle_jvmci_code_InstalledCode, Graal)) \ - GRAAL_ONLY(do_klass(code_Register_klass, com_oracle_jvmci_code_Register, Graal)) \ - GRAAL_ONLY(do_klass(RegisterValue_klass, com_oracle_jvmci_code_RegisterValue, Graal)) \ - GRAAL_ONLY(do_klass(RegisterCategory_klass, com_oracle_jvmci_code_Register_RegisterCategory, Graal)) \ - GRAAL_ONLY(do_klass(StackSlot_klass, com_oracle_jvmci_code_StackSlot, Graal)) \ - GRAAL_ONLY(do_klass(StackLockValue_klass, com_oracle_jvmci_code_StackLockValue, Graal)) \ - GRAAL_ONLY(do_klass(VirtualObject_klass, com_oracle_jvmci_code_VirtualObject, Graal)) \ - GRAAL_ONLY(do_klass(SpeculationLog_klass, com_oracle_jvmci_code_SpeculationLog, Graal)) \ - GRAAL_ONLY(do_klass(JavaConstant_klass, com_oracle_jvmci_meta_JavaConstant, Graal)) \ - GRAAL_ONLY(do_klass(PrimitiveConstant_klass, com_oracle_jvmci_meta_PrimitiveConstant, Graal)) \ - GRAAL_ONLY(do_klass(RawConstant_klass, com_oracle_jvmci_meta_RawConstant, Graal)) \ - GRAAL_ONLY(do_klass(NullConstant_klass, com_oracle_jvmci_meta_NullConstant, Graal)) \ - GRAAL_ONLY(do_klass(ExceptionHandler_klass, com_oracle_jvmci_meta_ExceptionHandler, Graal)) \ - GRAAL_ONLY(do_klass(Kind_klass, com_oracle_jvmci_meta_Kind, Graal)) \ - GRAAL_ONLY(do_klass(LIRKind_klass, com_oracle_jvmci_meta_LIRKind, Graal)) \ - GRAAL_ONLY(do_klass(JavaMethod_klass, com_oracle_jvmci_meta_JavaMethod, Graal)) \ - GRAAL_ONLY(do_klass(JavaType_klass, com_oracle_jvmci_meta_JavaType, Graal)) \ - GRAAL_ONLY(do_klass(AbstractValue_klass, com_oracle_jvmci_meta_AbstractValue, Graal)) \ + /* JVMCI classes. These are loaded on-demand. */ \ + JVMCI_ONLY(do_klass(Debug_klass, com_oracle_jvmci_debug_Debug, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotCompiledCode_klass, com_oracle_jvmci_hotspot_HotSpotCompiledCode, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotCompiledCode_Comment_klass, com_oracle_jvmci_hotspot_HotSpotCompiledCode_Comment, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotCompiledNmethod_klass, com_oracle_jvmci_hotspot_HotSpotCompiledNmethod, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotForeignCallTarget_klass, com_oracle_jvmci_hotspot_HotSpotForeignCallTarget, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotReferenceMap_klass, com_oracle_jvmci_hotspot_HotSpotReferenceMap, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotOopMap_klass, com_oracle_jvmci_hotspot_HotSpotReferenceMap_HotSpotOopMap, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotInstalledCode_klass, com_oracle_jvmci_hotspot_HotSpotInstalledCode, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotNmethod_klass, com_oracle_jvmci_hotspot_HotSpotNmethod, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotResolvedJavaMethodImpl_klass, com_oracle_jvmci_hotspot_HotSpotResolvedJavaMethodImpl, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotResolvedObjectTypeImpl_klass, com_oracle_jvmci_hotspot_HotSpotResolvedObjectTypeImpl, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotCompressedNullConstant_klass, com_oracle_jvmci_hotspot_HotSpotCompressedNullConstant, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotObjectConstantImpl_klass, com_oracle_jvmci_hotspot_HotSpotObjectConstantImpl, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotMetaspaceConstantImpl_klass, com_oracle_jvmci_hotspot_HotSpotMetaspaceConstantImpl, Jvmci)) \ + JVMCI_ONLY(do_klass(HotSpotStackFrameReference_klass, com_oracle_jvmci_hotspot_HotSpotStackFrameReference, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationTask_klass, com_oracle_graal_hotspot_CompilationTask, Jvmci)) \ + JVMCI_ONLY(do_klass(Assumptions_ConcreteMethod_klass, com_oracle_jvmci_meta_Assumptions_ConcreteMethod, Jvmci)) \ + JVMCI_ONLY(do_klass(Assumptions_NoFinalizableSubclass_klass, com_oracle_jvmci_meta_Assumptions_NoFinalizableSubclass, Jvmci))\ + JVMCI_ONLY(do_klass(Assumptions_ConcreteSubtype_klass, com_oracle_jvmci_meta_Assumptions_ConcreteSubtype, Jvmci)) \ + JVMCI_ONLY(do_klass(Assumptions_LeafType_klass, com_oracle_jvmci_meta_Assumptions_LeafType, Jvmci)) \ + JVMCI_ONLY(do_klass(Assumptions_CallSiteTargetValue_klass, com_oracle_jvmci_meta_Assumptions_CallSiteTargetValue, Jvmci)) \ + JVMCI_ONLY(do_klass(BytecodePosition_klass, com_oracle_jvmci_code_BytecodePosition, Jvmci)) \ + JVMCI_ONLY(do_klass(DebugInfo_klass, com_oracle_jvmci_code_DebugInfo, Jvmci)) \ + JVMCI_ONLY(do_klass(RegisterSaveLayout_klass, com_oracle_jvmci_code_RegisterSaveLayout, Jvmci)) \ + JVMCI_ONLY(do_klass(BytecodeFrame_klass, com_oracle_jvmci_code_BytecodeFrame, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_klass, com_oracle_jvmci_code_CompilationResult, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_Call_klass, com_oracle_jvmci_code_CompilationResult_Call, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_ConstantReference_klass, com_oracle_jvmci_code_CompilationResult_ConstantReference, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_DataPatch_klass, com_oracle_jvmci_code_CompilationResult_DataPatch, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_DataSectionReference_klass, com_oracle_jvmci_code_CompilationResult_DataSectionReference, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_ExceptionHandler_klass, com_oracle_jvmci_code_CompilationResult_ExceptionHandler, Jvmci))\ + JVMCI_ONLY(do_klass(CompilationResult_Mark_klass, com_oracle_jvmci_code_CompilationResult_Mark, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_Infopoint_klass, com_oracle_jvmci_code_CompilationResult_Infopoint, Jvmci)) \ + JVMCI_ONLY(do_klass(CompilationResult_Site_klass, com_oracle_jvmci_code_CompilationResult_Site, Jvmci)) \ + JVMCI_ONLY(do_klass(InfopointReason_klass, com_oracle_jvmci_code_InfopointReason, Jvmci)) \ + JVMCI_ONLY(do_klass(InstalledCode_klass, com_oracle_jvmci_code_InstalledCode, Jvmci)) \ + JVMCI_ONLY(do_klass(code_Register_klass, com_oracle_jvmci_code_Register, Jvmci)) \ + JVMCI_ONLY(do_klass(RegisterValue_klass, com_oracle_jvmci_code_RegisterValue, Jvmci)) \ + JVMCI_ONLY(do_klass(RegisterCategory_klass, com_oracle_jvmci_code_Register_RegisterCategory, Jvmci)) \ + JVMCI_ONLY(do_klass(StackSlot_klass, com_oracle_jvmci_code_StackSlot, Jvmci)) \ + JVMCI_ONLY(do_klass(StackLockValue_klass, com_oracle_jvmci_code_StackLockValue, Jvmci)) \ + JVMCI_ONLY(do_klass(VirtualObject_klass, com_oracle_jvmci_code_VirtualObject, Jvmci)) \ + JVMCI_ONLY(do_klass(SpeculationLog_klass, com_oracle_jvmci_code_SpeculationLog, Jvmci)) \ + JVMCI_ONLY(do_klass(JavaConstant_klass, com_oracle_jvmci_meta_JavaConstant, Jvmci)) \ + JVMCI_ONLY(do_klass(PrimitiveConstant_klass, com_oracle_jvmci_meta_PrimitiveConstant, Jvmci)) \ + JVMCI_ONLY(do_klass(RawConstant_klass, com_oracle_jvmci_meta_RawConstant, Jvmci)) \ + JVMCI_ONLY(do_klass(NullConstant_klass, com_oracle_jvmci_meta_NullConstant, Jvmci)) \ + JVMCI_ONLY(do_klass(ExceptionHandler_klass, com_oracle_jvmci_meta_ExceptionHandler, Jvmci)) \ + JVMCI_ONLY(do_klass(Kind_klass, com_oracle_jvmci_meta_Kind, Jvmci)) \ + JVMCI_ONLY(do_klass(LIRKind_klass, com_oracle_jvmci_meta_LIRKind, Jvmci)) \ + JVMCI_ONLY(do_klass(JavaMethod_klass, com_oracle_jvmci_meta_JavaMethod, Jvmci)) \ + JVMCI_ONLY(do_klass(JavaType_klass, com_oracle_jvmci_meta_JavaType, Jvmci)) \ + JVMCI_ONLY(do_klass(AbstractValue_klass, com_oracle_jvmci_meta_AbstractValue, Jvmci)) \ /*end*/ @@ -270,9 +270,9 @@ WKID_LIMIT, -#ifdef GRAAL - FIRST_GRAAL_WKID = WK_KLASS_ENUM_NAME(Debug_klass), - LAST_GRAAL_WKID = WK_KLASS_ENUM_NAME(AbstractValue_klass), +#ifdef JVMCI + FIRST_JVMCI_WKID = WK_KLASS_ENUM_NAME(Debug_klass), + LAST_JVMCI_WKID = WK_KLASS_ENUM_NAME(AbstractValue_klass), #endif FIRST_WKID = NO_WKID + 1 @@ -288,8 +288,8 @@ Opt, // preload tried; NULL if not present Opt_Only_JDK14NewRef, // preload tried; use only with NewReflection Opt_Only_JDK15, // preload tried; use only with JDK1.5+ -#ifdef GRAAL - Graal, // preload tried; error if not present, use only with GRAAL +#ifdef JVMCI + Jvmci, // preload tried; error if not present, use only with JVMCI #endif OPTION_LIMIT, CEIL_LG_OPTION_LIMIT = 4 // OPTION_LIMIT <= (1<<CEIL_LG_OPTION_LIMIT) @@ -480,8 +480,8 @@ // despite the optional loading, if you use this it must be present: return check_klass(k); } -#ifdef GRAAL - static Klass* check_klass_Graal(Klass* k) { return k; } +#ifdef JVMCI + static Klass* check_klass_Jvmci(Klass* k) { return k; } #endif static bool initialize_wk_klass(WKID id, int init_opt, TRAPS); @@ -548,12 +548,12 @@ // Returns default system loader static oop java_system_loader(); -#ifdef GRAAL - // Returns the Graal loader. This will be NULL if !UseGraalClassLoader +#ifdef JVMCI + // Returns the JVMCI loader. This will be NULL if !UseJVMCIClassLoader // in which case it's equivalent to the boot loader - static oop graal_loader(); - // Sets the Graal loader. This is called at most once. - static void init_graal_loader(oop loader); + static oop jvmci_loader(); + // Sets the JVMCI loader. This is called at most once. + static void init_jvmci_loader(oop loader); #endif // Compute the default system loader @@ -786,8 +786,8 @@ static Klass* _box_klasses[T_VOID+1]; static oop _java_system_loader; -#ifdef GRAAL - static oop _graal_loader; +#ifdef JVMCI + static oop _jvmci_loader; #endif static bool _has_loadClassInternal;
--- a/src/share/vm/classfile/verifier.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/classfile/verifier.cpp Thu May 28 15:36:48 2015 +0200 @@ -94,7 +94,7 @@ // Methods in Verifier bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) { - return (class_loader == NULL GRAAL_ONLY(|| class_loader == SystemDictionary::graal_loader()) || !should_verify_class) ? + return (class_loader == NULL JVMCI_ONLY(|| class_loader == SystemDictionary::jvmci_loader()) || !should_verify_class) ? BytecodeVerificationLocal : BytecodeVerificationRemote; }
--- a/src/share/vm/classfile/vmSymbols.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Thu May 28 15:36:48 2015 +0200 @@ -298,66 +298,66 @@ LP64_ONLY( do_alias(intptr_signature, long_signature) ) \ template(selectAlternative_signature, "(ZLjava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodHandle;)Ljava/lang/invoke/MethodHandle;") \ \ - /* Support for Graal */ \ + /* Support for JVMCI */ \ template(java_util_BitSet, "java/util/BitSet") \ - GRAAL_ONLY(template(com_oracle_jvmci_debug_Debug, "com/oracle/jvmci/debug/Debug")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompiledCode, "com/oracle/jvmci/hotspot/HotSpotCompiledCode")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompiledCode_Comment, "com/oracle/jvmci/hotspot/HotSpotCompiledCode$Comment")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompiledNmethod, "com/oracle/jvmci/hotspot/HotSpotCompiledNmethod")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotForeignCallTarget, "com/oracle/jvmci/hotspot/HotSpotForeignCallTarget")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotReferenceMap, "com/oracle/jvmci/hotspot/HotSpotReferenceMap")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotReferenceMap_HotSpotOopMap, "com/oracle/jvmci/hotspot/HotSpotReferenceMap$HotSpotOopMap")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_CompilerToVMImpl, "com/oracle/jvmci/hotspot/CompilerToVMImpl")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotInstalledCode, "com/oracle/jvmci/hotspot/HotSpotInstalledCode")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotNmethod, "com/oracle/jvmci/hotspot/HotSpotNmethod")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotResolvedJavaMethodImpl, "com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotResolvedObjectTypeImpl, "com/oracle/jvmci/hotspot/HotSpotResolvedObjectTypeImpl")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompressedNullConstant, "com/oracle/jvmci/hotspot/HotSpotCompressedNullConstant")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotObjectConstantImpl, "com/oracle/jvmci/hotspot/HotSpotObjectConstantImpl")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotMetaspaceConstantImpl, "com/oracle/jvmci/hotspot/HotSpotMetaspaceConstantImpl")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_HotSpotStackFrameReference, "com/oracle/jvmci/hotspot/HotSpotStackFrameReference")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_CompilationTask, "com/oracle/graal/hotspot/CompilationTask")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_JavaConstant, "com/oracle/jvmci/meta/JavaConstant")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_PrimitiveConstant, "com/oracle/jvmci/meta/PrimitiveConstant")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_RawConstant, "com/oracle/jvmci/meta/RawConstant")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_NullConstant, "com/oracle/jvmci/meta/NullConstant")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_ExceptionHandler, "com/oracle/jvmci/meta/ExceptionHandler")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_JavaMethod, "com/oracle/jvmci/meta/JavaMethod")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_JavaType, "com/oracle/jvmci/meta/JavaType")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_Kind, "com/oracle/jvmci/meta/Kind")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_LIRKind, "com/oracle/jvmci/meta/LIRKind")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_AbstractValue, "com/oracle/jvmci/meta/AbstractValue")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_Assumptions_ConcreteSubtype, "com/oracle/jvmci/meta/Assumptions$ConcreteSubtype")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_Assumptions_LeafType, "com/oracle/jvmci/meta/Assumptions$LeafType")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_Assumptions_NoFinalizableSubclass, "com/oracle/jvmci/meta/Assumptions$NoFinalizableSubclass")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_Assumptions_ConcreteMethod, "com/oracle/jvmci/meta/Assumptions$ConcreteMethod")) \ - GRAAL_ONLY(template(com_oracle_jvmci_meta_Assumptions_CallSiteTargetValue, "com/oracle/jvmci/meta/Assumptions$CallSiteTargetValue")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult, "com/oracle/jvmci/code/CompilationResult")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_Call, "com/oracle/jvmci/code/CompilationResult$Call")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_ConstantReference, "com/oracle/jvmci/code/CompilationResult$ConstantReference")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_DataPatch, "com/oracle/jvmci/code/CompilationResult$DataPatch")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_DataSectionReference, "com/oracle/jvmci/code/CompilationResult$DataSectionReference")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_ExceptionHandler, "com/oracle/jvmci/code/CompilationResult$ExceptionHandler")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_Mark, "com/oracle/jvmci/code/CompilationResult$Mark")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_Infopoint, "com/oracle/jvmci/code/CompilationResult$Infopoint")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_CompilationResult_Site, "com/oracle/jvmci/code/CompilationResult$Site")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_InfopointReason, "com/oracle/jvmci/code/InfopointReason")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_InstalledCode, "com/oracle/jvmci/code/InstalledCode")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_BytecodeFrame, "com/oracle/jvmci/code/BytecodeFrame")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_BytecodePosition, "com/oracle/jvmci/code/BytecodePosition")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_DebugInfo, "com/oracle/jvmci/code/DebugInfo")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_Register, "com/oracle/jvmci/code/Register")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_RegisterValue, "com/oracle/jvmci/code/RegisterValue")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_Register_RegisterCategory, "com/oracle/jvmci/code/Register$RegisterCategory")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_StackSlot, "com/oracle/jvmci/code/StackSlot")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_StackLockValue, "com/oracle/jvmci/code/StackLockValue")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_VirtualObject, "com/oracle/jvmci/code/VirtualObject")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_RegisterSaveLayout, "com/oracle/jvmci/code/RegisterSaveLayout")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_InvalidInstalledCodeException, "com/oracle/jvmci/code/InvalidInstalledCodeException")) \ - GRAAL_ONLY(template(com_oracle_jvmci_code_SpeculationLog, "com/oracle/jvmci/code/SpeculationLog")) \ - GRAAL_ONLY(template(compileMetaspaceMethod_name, "compileMetaspaceMethod")) \ - GRAAL_ONLY(template(compileMetaspaceMethod_signature, "(JIJI)V")) \ - GRAAL_ONLY(template(com_oracle_jvmci_hotspot_Stable_signature, "Lcom/oracle/jvmci/hotspot/Stable;")) \ + JVMCI_ONLY(template(com_oracle_jvmci_debug_Debug, "com/oracle/jvmci/debug/Debug")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompiledCode, "com/oracle/jvmci/hotspot/HotSpotCompiledCode")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompiledCode_Comment, "com/oracle/jvmci/hotspot/HotSpotCompiledCode$Comment")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompiledNmethod, "com/oracle/jvmci/hotspot/HotSpotCompiledNmethod")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotForeignCallTarget, "com/oracle/jvmci/hotspot/HotSpotForeignCallTarget")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotReferenceMap, "com/oracle/jvmci/hotspot/HotSpotReferenceMap")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotReferenceMap_HotSpotOopMap, "com/oracle/jvmci/hotspot/HotSpotReferenceMap$HotSpotOopMap")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_CompilerToVMImpl, "com/oracle/jvmci/hotspot/CompilerToVMImpl")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotInstalledCode, "com/oracle/jvmci/hotspot/HotSpotInstalledCode")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotNmethod, "com/oracle/jvmci/hotspot/HotSpotNmethod")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotResolvedJavaMethodImpl, "com/oracle/jvmci/hotspot/HotSpotResolvedJavaMethodImpl")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotResolvedObjectTypeImpl, "com/oracle/jvmci/hotspot/HotSpotResolvedObjectTypeImpl")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotCompressedNullConstant, "com/oracle/jvmci/hotspot/HotSpotCompressedNullConstant")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotObjectConstantImpl, "com/oracle/jvmci/hotspot/HotSpotObjectConstantImpl")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotMetaspaceConstantImpl, "com/oracle/jvmci/hotspot/HotSpotMetaspaceConstantImpl")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_HotSpotStackFrameReference, "com/oracle/jvmci/hotspot/HotSpotStackFrameReference")) \ + JVMCI_ONLY(template(com_oracle_graal_hotspot_CompilationTask, "com/oracle/graal/hotspot/CompilationTask")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_JavaConstant, "com/oracle/jvmci/meta/JavaConstant")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_PrimitiveConstant, "com/oracle/jvmci/meta/PrimitiveConstant")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_RawConstant, "com/oracle/jvmci/meta/RawConstant")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_NullConstant, "com/oracle/jvmci/meta/NullConstant")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_ExceptionHandler, "com/oracle/jvmci/meta/ExceptionHandler")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_JavaMethod, "com/oracle/jvmci/meta/JavaMethod")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_JavaType, "com/oracle/jvmci/meta/JavaType")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_Kind, "com/oracle/jvmci/meta/Kind")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_LIRKind, "com/oracle/jvmci/meta/LIRKind")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_AbstractValue, "com/oracle/jvmci/meta/AbstractValue")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_ConcreteSubtype, "com/oracle/jvmci/meta/Assumptions$ConcreteSubtype")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_LeafType, "com/oracle/jvmci/meta/Assumptions$LeafType")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_NoFinalizableSubclass, "com/oracle/jvmci/meta/Assumptions$NoFinalizableSubclass")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_ConcreteMethod, "com/oracle/jvmci/meta/Assumptions$ConcreteMethod")) \ + JVMCI_ONLY(template(com_oracle_jvmci_meta_Assumptions_CallSiteTargetValue, "com/oracle/jvmci/meta/Assumptions$CallSiteTargetValue")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult, "com/oracle/jvmci/code/CompilationResult")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_Call, "com/oracle/jvmci/code/CompilationResult$Call")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_ConstantReference, "com/oracle/jvmci/code/CompilationResult$ConstantReference")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_DataPatch, "com/oracle/jvmci/code/CompilationResult$DataPatch")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_DataSectionReference, "com/oracle/jvmci/code/CompilationResult$DataSectionReference")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_ExceptionHandler, "com/oracle/jvmci/code/CompilationResult$ExceptionHandler")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_Mark, "com/oracle/jvmci/code/CompilationResult$Mark")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_Infopoint, "com/oracle/jvmci/code/CompilationResult$Infopoint")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_CompilationResult_Site, "com/oracle/jvmci/code/CompilationResult$Site")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_InfopointReason, "com/oracle/jvmci/code/InfopointReason")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_InstalledCode, "com/oracle/jvmci/code/InstalledCode")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_BytecodeFrame, "com/oracle/jvmci/code/BytecodeFrame")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_BytecodePosition, "com/oracle/jvmci/code/BytecodePosition")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_DebugInfo, "com/oracle/jvmci/code/DebugInfo")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_Register, "com/oracle/jvmci/code/Register")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_RegisterValue, "com/oracle/jvmci/code/RegisterValue")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_Register_RegisterCategory, "com/oracle/jvmci/code/Register$RegisterCategory")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_StackSlot, "com/oracle/jvmci/code/StackSlot")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_StackLockValue, "com/oracle/jvmci/code/StackLockValue")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_VirtualObject, "com/oracle/jvmci/code/VirtualObject")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_RegisterSaveLayout, "com/oracle/jvmci/code/RegisterSaveLayout")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_InvalidInstalledCodeException, "com/oracle/jvmci/code/InvalidInstalledCodeException")) \ + JVMCI_ONLY(template(com_oracle_jvmci_code_SpeculationLog, "com/oracle/jvmci/code/SpeculationLog")) \ + JVMCI_ONLY(template(compileMetaspaceMethod_name, "compileMetaspaceMethod")) \ + JVMCI_ONLY(template(compileMetaspaceMethod_signature, "(JIJI)V")) \ + JVMCI_ONLY(template(com_oracle_jvmci_hotspot_Stable_signature, "Lcom/oracle/jvmci/hotspot/Stable;")) \ \ /* common method and field names */ \ template(object_initializer_name, "<init>") \
--- a/src/share/vm/code/codeBlob.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/codeBlob.hpp Thu May 28 15:36:48 2015 +0200 @@ -105,7 +105,7 @@ virtual bool is_compiled_by_c2() const { return false; } virtual bool is_compiled_by_c1() const { return false; } - virtual bool is_compiled_by_graal() const { return false; } + virtual bool is_compiled_by_jvmci() const { return false; } // Casting nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; } @@ -357,8 +357,8 @@ int _unpack_with_exception_in_tls; -#ifdef GRAAL - // (thomaswue) Offset when Graal calls uncommon_trap. +#ifdef JVMCI + // (thomaswue) Offset when JVMCI calls uncommon_trap. int _uncommon_trap_offset; int _implicit_exception_uncommon_trap_offset; #endif @@ -416,8 +416,8 @@ } address unpack_with_exception_in_tls() const { return code_begin() + _unpack_with_exception_in_tls; } -#ifdef GRAAL - // (thomaswue) Offset when Graal calls uncommon_trap. +#ifdef JVMCI + // (thomaswue) Offset when JVMCI calls uncommon_trap. void set_uncommon_trap_offset(int offset) { _uncommon_trap_offset = offset; assert(contains(code_begin() + _uncommon_trap_offset), "must be PC inside codeblob");
--- a/src/share/vm/code/compiledIC.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/compiledIC.cpp Thu May 28 15:36:48 2015 +0200 @@ -273,12 +273,12 @@ // Check that the cached_value is a klass for non-optimized monomorphic calls // This assertion is invalid for compiler1: a call that does not look optimized (no static stub) can be used // for calling directly to vep without using the inline cache (i.e., cached_value == NULL). - // For Graal this occurs because CHA is only used to improve inlining so call sites which could be optimized + // For JVMCI this occurs because CHA is only used to improve inlining so call sites which could be optimized // virtuals because there are no currently loaded subclasses of a type are left as virtual call sites. #ifdef ASSERT CodeBlob* caller = CodeCache::find_blob_unsafe(instruction_address()); - bool is_c1_or_graal_method = caller->is_compiled_by_c1() || caller->is_compiled_by_graal(); - assert( is_c1_or_graal_method || + bool is_c1_or_jvmci_method = caller->is_compiled_by_c1() || caller->is_compiled_by_jvmci(); + assert( is_c1_or_jvmci_method || !is_monomorphic || is_optimized() || (cached_metadata() != NULL && cached_metadata()->is_klass()), "sanity check");
--- a/src/share/vm/code/debugInfoRec.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/debugInfoRec.cpp Thu May 28 15:36:48 2015 +0200 @@ -37,7 +37,7 @@ int _offset; // location in the stream of this scope int _length; // number of bytes in the stream int _hash; // hash of stream bytes (for quicker reuse) -#ifdef GRAAL +#ifdef JVMCI DebugInformationRecorder* _DIR; #endif @@ -54,7 +54,7 @@ DIR_Chunk(int offset, int length, DebugInformationRecorder* dir) { _offset = offset; _length = length; -#ifdef GRAAL +#ifdef JVMCI _DIR = dir; #endif unsigned int hash = 0; @@ -84,7 +84,7 @@ return NULL; } -#ifdef GRAAL +#ifdef JVMCI static int compare(DIR_Chunk* a, DIR_Chunk* b) { if (b->_hash > a->_hash) { return 1; @@ -138,7 +138,7 @@ _oop_recorder = oop_recorder; _all_chunks = new GrowableArray<DIR_Chunk*>(300); -#ifndef GRAAL +#ifndef JVMCI _shared_chunks = new GrowableArray<DIR_Chunk*>(30); #endif _next_chunk = _next_chunk_limit = NULL; @@ -277,7 +277,7 @@ DIR_Chunk* ns = new(this) DIR_Chunk(stream_offset, stream_length, this); -#ifdef GRAAL +#ifdef JVMCI DIR_Chunk* match = _all_chunks->find_insert_binary<DIR_Chunk::compare>(ns); if (match != ns) { // Found an existing chunk
--- a/src/share/vm/code/debugInfoRec.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/debugInfoRec.hpp Thu May 28 15:36:48 2015 +0200 @@ -163,7 +163,7 @@ // Scopes that have been described so far. GrowableArray<DIR_Chunk*>* _all_chunks; -#ifndef GRAAL +#ifndef JVMCI GrowableArray<DIR_Chunk*>* _shared_chunks; #endif DIR_Chunk* _next_chunk;
--- a/src/share/vm/code/dependencies.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/dependencies.cpp Thu May 28 15:36:48 2015 +0200 @@ -52,9 +52,9 @@ _oop_recorder = env->oop_recorder(); _log = env->log(); _dep_seen = new(arena) GrowableArray<int>(arena, 500, 0, 0); -#ifdef GRAAL +#ifdef JVMCI _using_dep_values = false; -#endif // GRAAL +#endif // JVMCI DEBUG_ONLY(_deps[end_marker] = NULL); for (int i = (int)FIRST_TYPE; i < (int)TYPE_LIMIT; i++) { _deps[i] = new(arena) GrowableArray<ciBaseObject*>(arena, 10, 0, 0); @@ -124,7 +124,7 @@ assert_common_2(call_site_target_value, call_site, method_handle); } -#ifdef GRAAL +#ifdef JVMCI Dependencies::Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log) { _oop_recorder = oop_recorder; @@ -180,7 +180,7 @@ void Dependencies::assert_call_site_target_value(oop call_site, oop method_handle) { assert_common_2(call_site_target_value, DepValue(_oop_recorder, JNIHandles::make_local(call_site)), DepValue(_oop_recorder, JNIHandles::make_local(method_handle))); } -#endif // GRAAL +#endif // JVMCI // Helper function. If we are adding a new dep. under ctxk2, @@ -294,7 +294,7 @@ deps->append(x2); } -#ifdef GRAAL +#ifdef JVMCI bool Dependencies::maybe_merge_ctxk(GrowableArray<DepValue>* deps, int ctxk_i, DepValue ctxk2_dv) { Klass* ctxk1 = deps->at(ctxk_i).as_klass(_oop_recorder); @@ -364,7 +364,7 @@ deps->append(x0); deps->append(x1); } -#endif // GRAAL +#endif // JVMCI /// Support for encoding dependencies into an nmethod: @@ -392,7 +392,7 @@ static int sort_dep_arg_3(ciBaseObject** p1, ciBaseObject** p2) { return sort_dep(p1, p2, 3); } -#ifdef GRAAL +#ifdef JVMCI // metadata deps are sorted before object deps static int sort_dep_value(Dependencies::DepValue* p1, Dependencies::DepValue* p2, int narg) { for (int i = 0; i < narg; i++) { @@ -407,10 +407,10 @@ { return sort_dep_value(p1, p2, 2); } static int sort_dep_value_arg_3(Dependencies::DepValue* p1, Dependencies::DepValue* p2) { return sort_dep_value(p1, p2, 3); } -#endif // GRAAL +#endif // JVMCI void Dependencies::sort_all_deps() { -#ifdef GRAAL +#ifdef JVMCI if (_using_dep_values) { for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; @@ -425,7 +425,7 @@ } return; } -#endif // GRAAL +#endif // JVMCI for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; GrowableArray<ciBaseObject*>* deps = _deps[dept]; @@ -441,7 +441,7 @@ size_t Dependencies::estimate_size_in_bytes() { size_t est_size = 100; -#ifdef GRAAL +#ifdef JVMCI if (_using_dep_values) { for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; @@ -450,7 +450,7 @@ } return est_size; } -#endif // GRAAL +#endif // JVMCI for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; GrowableArray<ciBaseObject*>* deps = _deps[dept]; @@ -490,7 +490,7 @@ // cast is safe, no deps can overflow INT_MAX CompressedWriteStream bytes((int)estimate_size_in_bytes()); -#ifdef GRAAL +#ifdef JVMCI if (_using_dep_values) { for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; @@ -520,7 +520,7 @@ } } } else { -#endif // GRAAL +#endif // JVMCI for (int deptv = (int)FIRST_TYPE; deptv < (int)TYPE_LIMIT; deptv++) { DepType dept = (DepType)deptv; GrowableArray<ciBaseObject*>* deps = _deps[dept]; @@ -554,9 +554,9 @@ } } } -#ifdef GRAAL +#ifdef JVMCI } -#endif // GRAAL +#endif // JVMCI // write a sentinel byte to mark the end bytes.write_byte(end_marker);
--- a/src/share/vm/code/dependencies.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/dependencies.hpp Thu May 28 15:36:48 2015 +0200 @@ -200,7 +200,7 @@ static void check_valid_dependency_type(DepType dept); -#ifdef GRAAL +#ifdef JVMCI // A Metadata* or object value recorded in an OopRecorder class DepValue VALUE_OBJ_CLASS_SPEC { private: @@ -249,7 +249,7 @@ // State for writing a new set of dependencies: GrowableArray<int>* _dep_seen; // (seen[h->ident] & (1<<dept)) GrowableArray<ciBaseObject*>* _deps[TYPE_LIMIT]; -#ifdef GRAAL +#ifdef JVMCI bool _using_dep_values; GrowableArray<DepValue>* _dep_values[TYPE_LIMIT]; #endif @@ -271,7 +271,7 @@ return (seen & (1<<dept)) != 0; } -#ifdef GRAAL +#ifdef JVMCI bool note_dep_seen(int dept, DepValue x) { assert(dept < BitsPerInt, "oops"); // place metadata deps at even indexes, object deps at odd indexes @@ -286,7 +286,7 @@ bool maybe_merge_ctxk(GrowableArray<ciBaseObject*>* deps, int ctxk_i, ciKlass* ctxk); -#ifdef GRAAL +#ifdef JVMCI bool maybe_merge_ctxk(GrowableArray<DepValue>* deps, int ctxk_i, DepValue ctxk); #endif @@ -311,9 +311,9 @@ Dependencies(ciEnv* env) { initialize(env); } -#ifdef GRAAL +#ifdef JVMCI Dependencies(Arena* arena, OopRecorder* oop_recorder, CompileLog* log); -#endif // GRAAL +#endif // JVMCI private: // Check for a valid context type. @@ -346,7 +346,7 @@ void assert_has_no_finalizable_subclasses(ciKlass* ctxk); void assert_call_site_target_value(ciCallSite* call_site, ciMethodHandle* method_handle); -#ifdef GRAAL +#ifdef JVMCI private: static void check_ctxk(Klass* ctxk) { assert(ctxk->oop_is_instance(), "java types only"); @@ -365,7 +365,7 @@ void assert_unique_concrete_method(Klass* ctxk, Method* uniqm); void assert_abstract_with_unique_concrete_subtype(Klass* ctxk, Klass* conck); void assert_call_site_target_value(oop callSite, oop methodHandle); -#endif // GRAAL +#endif // JVMCI // Define whether a given method or type is concrete. // These methods define the term "concrete" as used in this module.
--- a/src/share/vm/code/nmethod.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/nmethod.cpp Thu May 28 15:36:48 2015 +0200 @@ -46,8 +46,8 @@ #ifdef SHARK #include "shark/sharkCompiler.hpp" #endif -#ifdef GRAAL -#include "graal/graalJavaAccess.hpp" +#ifdef JVMCI +#include "jvmci/jvmciJavaAccess.hpp" #endif PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -106,10 +106,10 @@ } return compiler()->is_c1(); } -bool nmethod::is_compiled_by_graal() const { +bool nmethod::is_compiled_by_jvmci() const { if (compiler() == NULL || method() == NULL) return false; // can happen during debug printing if (is_native_method()) return false; - return compiler()->is_graal(); + return compiler()->is_jvmci(); } bool nmethod::is_compiled_by_c2() const { if (compiler() == NULL) { @@ -238,8 +238,8 @@ #ifdef COMPILER2 static java_nmethod_stats_struct c2_java_nmethod_stats; #endif -#ifdef GRAAL -static java_nmethod_stats_struct graal_java_nmethod_stats; +#ifdef JVMCI +static java_nmethod_stats_struct jvmci_java_nmethod_stats; #endif #ifdef SHARK static java_nmethod_stats_struct shark_java_nmethod_stats; @@ -264,9 +264,9 @@ c2_java_nmethod_stats.note_nmethod(nm); } else #endif -#ifdef GRAAL - if (nm->is_compiled_by_graal()) { - graal_java_nmethod_stats.note_nmethod(nm); +#ifdef JVMCI + if (nm->is_compiled_by_jvmci()) { + jvmci_java_nmethod_stats.note_nmethod(nm); } else #endif #ifdef SHARK @@ -559,8 +559,8 @@ #if INCLUDE_RTM_OPT _rtm_state = NoRTM; #endif -#ifdef GRAAL - _graal_installed_code = NULL; +#ifdef JVMCI + _jvmci_installed_code = NULL; _speculation_log = NULL; #endif #ifdef HAVE_DTRACE_H @@ -657,7 +657,7 @@ ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, int comp_level -#ifdef GRAAL +#ifdef JVMCI , Handle installed_code, Handle speculationLog #endif @@ -684,7 +684,7 @@ nul_chk_table, compiler, comp_level -#ifdef GRAAL +#ifdef JVMCI , installed_code, speculationLog #endif @@ -920,7 +920,7 @@ ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, int comp_level -#ifdef GRAAL +#ifdef JVMCI , Handle installed_code, Handle speculation_log #endif @@ -948,12 +948,12 @@ _consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts()); _stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs()); -#ifdef GRAAL - _graal_installed_code = installed_code(); +#ifdef JVMCI + _jvmci_installed_code = installed_code(); _speculation_log = (instanceOop)speculation_log(); - if (compiler->is_graal()) { - // Graal might not produce any stub sections + if (compiler->is_jvmci()) { + // JVMCI might not produce any stub sections if (offsets->value(CodeOffsets::Exceptions) != -1) { _exception_offset = code_offset() + offsets->value(CodeOffsets::Exceptions); } else { @@ -981,7 +981,7 @@ _deoptimize_mh_offset = _stub_offset + offsets->value(CodeOffsets::DeoptMH); } else { _deoptimize_mh_offset = -1; -#ifdef GRAAL +#ifdef JVMCI } #endif } @@ -1027,7 +1027,7 @@ // we use the information of entry points to find out if a method is // static or non static - assert(compiler->is_c2() || compiler->is_graal() || + assert(compiler->is_c2() || compiler->is_jvmci() || _method->is_static() == (entry_point() == _verified_entry_point), " entry points must be same for static methods and vice versa"); } @@ -1398,7 +1398,7 @@ } void nmethod::inc_decompile_count() { - if (!is_compiled_by_c2() && !is_compiled_by_graal()) return; + if (!is_compiled_by_c2() && !is_compiled_by_jvmci()) return; // Could be gated by ProfileTraps, but do not bother... Method* m = method(); if (m == NULL) return; @@ -1475,15 +1475,15 @@ // Unregister must be done before the state change Universe::heap()->unregister_nmethod(this); -#ifdef GRAAL +#ifdef JVMCI // The method can only be unloaded after the pointer to the installed code // Java wrapper is no longer alive. Here we need to clear out this weak // reference to the dead object. Nulling out the reference has to happen // after the method is unregistered since the original value may be still // tracked by the rset. - if (_graal_installed_code != NULL) { - InstalledCode::set_address(_graal_installed_code, 0); - _graal_installed_code = NULL; + if (_jvmci_installed_code != NULL) { + InstalledCode::set_address(_jvmci_installed_code, 0); + _jvmci_installed_code = NULL; } #endif @@ -1652,10 +1652,10 @@ } else { assert(state == not_entrant, "other cases may need to be handled differently"); } -#ifdef GRAAL - if (_graal_installed_code != NULL) { +#ifdef JVMCI + if (_jvmci_installed_code != NULL) { // Break the link between nmethod and InstalledCode such that the nmethod can subsequently be flushed safely. - InstalledCode::set_address(_graal_installed_code, 0); + InstalledCode::set_address(_jvmci_installed_code, 0); } #endif @@ -1964,18 +1964,18 @@ } } -#ifdef GRAAL - // Follow Graal method +#ifdef JVMCI + // Follow JVMCI method BarrierSet* bs = Universe::heap()->barrier_set(); - if (_graal_installed_code != NULL) { - if (_graal_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_graal_installed_code)) { - if (!is_alive->do_object_b(_graal_installed_code)) { - bs->write_ref_nmethod_pre(&_graal_installed_code, this); - _graal_installed_code = NULL; - bs->write_ref_nmethod_post(&_graal_installed_code, this); + if (_jvmci_installed_code != NULL) { + if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) { + if (!is_alive->do_object_b(_jvmci_installed_code)) { + bs->write_ref_nmethod_pre(&_jvmci_installed_code, this); + _jvmci_installed_code = NULL; + bs->write_ref_nmethod_post(&_jvmci_installed_code, this); } } else { - if (can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { + if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { return; } } @@ -2101,15 +2101,15 @@ unloading_occurred = true; } -#ifdef GRAAL - // Follow Graal method - if (_graal_installed_code != NULL) { - if (_graal_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_graal_installed_code)) { - if (!is_alive->do_object_b(_graal_installed_code)) { - _graal_installed_code = NULL; +#ifdef JVMCI + // Follow JVMCI method + if (_jvmci_installed_code != NULL) { + if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) { + if (!is_alive->do_object_b(_jvmci_installed_code)) { + _jvmci_installed_code = NULL; } } else { - if (can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { + if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { return false; } } @@ -2190,18 +2190,18 @@ return postponed; } -#ifdef GRAAL - // Follow Graal method +#ifdef JVMCI + // Follow JVMCI method BarrierSet* bs = Universe::heap()->barrier_set(); - if (_graal_installed_code != NULL) { - if (_graal_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_graal_installed_code)) { - if (!is_alive->do_object_b(_graal_installed_code)) { - bs->write_ref_nmethod_pre(&_graal_installed_code, this); - _graal_installed_code = NULL; - bs->write_ref_nmethod_post(&_graal_installed_code, this); + if (_jvmci_installed_code != NULL) { + if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) { + if (!is_alive->do_object_b(_jvmci_installed_code)) { + bs->write_ref_nmethod_pre(&_jvmci_installed_code, this); + _jvmci_installed_code = NULL; + bs->write_ref_nmethod_post(&_jvmci_installed_code, this); } } else { - if (can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { + if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { is_unloaded = true; } } @@ -2400,9 +2400,9 @@ // (See comment above.) } -#ifdef GRAAL - if (_graal_installed_code != NULL) { - f->do_oop((oop*) &_graal_installed_code); +#ifdef JVMCI + if (_jvmci_installed_code != NULL) { + f->do_oop((oop*) &_jvmci_installed_code); } if (_speculation_log != NULL) { f->do_oop((oop*) &_speculation_log); @@ -3057,8 +3057,8 @@ tty->print("(c2) "); } else if (is_compiled_by_shark()) { tty->print("(shark) "); - } else if (is_compiled_by_graal()) { - tty->print("(Graal) "); + } else if (is_compiled_by_jvmci()) { + tty->print("(JVMCI) "); } else { tty->print("(nm) "); } @@ -3262,9 +3262,9 @@ void nmethod::print_nmethod_labels(outputStream* stream, address block_begin) const { if (block_begin == entry_point()) stream->print_cr("[Entry Point]"); if (block_begin == verified_entry_point()) stream->print_cr("[Verified Entry Point]"); - if (GRAAL_ONLY(_exception_offset >= 0 &&) block_begin == exception_begin()) stream->print_cr("[Exception Handler]"); + if (JVMCI_ONLY(_exception_offset >= 0 &&) block_begin == exception_begin()) stream->print_cr("[Exception Handler]"); if (block_begin == stub_begin()) stream->print_cr("[Stub Code]"); - if (GRAAL_ONLY(_deoptimize_offset >= 0 &&) block_begin == deopt_handler_begin()) stream->print_cr("[Deopt Handler Code]"); + if (JVMCI_ONLY(_deoptimize_offset >= 0 &&) block_begin == deopt_handler_begin()) stream->print_cr("[Deopt Handler Code]"); if (has_method_handle_invokes()) if (block_begin == deopt_mh_handler_begin()) stream->print_cr("[Deopt MH Handler Code]"); @@ -3510,8 +3510,8 @@ #ifdef COMPILER2 c2_java_nmethod_stats.print_nmethod_stats("C2"); #endif -#ifdef GRAAL - graal_java_nmethod_stats.print_nmethod_stats("Graal"); +#ifdef JVMCI + jvmci_java_nmethod_stats.print_nmethod_stats("JVMCI"); #endif #ifdef SHARK shark_java_nmethod_stats.print_nmethod_stats("Shark"); @@ -3525,12 +3525,12 @@ if (xtty != NULL) xtty->tail("statistics"); } -#ifdef GRAAL -char* nmethod::graal_installed_code_name(char* buf, size_t buflen) { - if (!this->is_compiled_by_graal()) { +#ifdef JVMCI +char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) { + if (!this->is_compiled_by_jvmci()) { return NULL; } - oop installedCode = this->graal_installed_code(); + oop installedCode = this->jvmci_installed_code(); if (installedCode != NULL) { oop installedCodeName = NULL; if (installedCode->is_a(InstalledCode::klass())) {
--- a/src/share/vm/code/nmethod.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/nmethod.hpp Thu May 28 15:36:48 2015 +0200 @@ -126,9 +126,9 @@ int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method jmethodID _jmethod_id; // Cache of method()->jmethod_id() -#ifdef GRAAL +#ifdef JVMCI // Needed to keep nmethods alive that are not the default nmethod for the associated Method. - oop _graal_installed_code; + oop _jvmci_installed_code; oop _speculation_log; #endif @@ -299,7 +299,7 @@ ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, int comp_level -#ifdef GRAAL +#ifdef JVMCI , Handle installed_code, Handle speculation_log #endif @@ -340,7 +340,7 @@ ImplicitExceptionTable* nul_chk_table, AbstractCompiler* compiler, int comp_level -#ifdef GRAAL +#ifdef JVMCI , Handle installed_code = Handle(), Handle speculation_log = Handle() #endif @@ -383,7 +383,7 @@ bool is_osr_method() const { return _entry_bci != InvocationEntryBci; } bool is_compiled_by_c1() const; - bool is_compiled_by_graal() const; + bool is_compiled_by_jvmci() const; bool is_compiled_by_c2() const; bool is_compiled_by_shark() const; @@ -626,10 +626,10 @@ // Evolution support. We make old (discarded) compiled methods point to new Method*s. void set_method(Method* method) { _method = method; } -#ifdef GRAAL - oop graal_installed_code() { return _graal_installed_code ; } - char* graal_installed_code_name(char* buf, size_t buflen); - void set_graal_installed_code(oop installed_code) { _graal_installed_code = installed_code; } +#ifdef JVMCI + oop jvmci_installed_code() { return _jvmci_installed_code ; } + char* jvmci_installed_code_name(char* buf, size_t buflen); + void set_jvmci_installed_code(oop installed_code) { _jvmci_installed_code = installed_code; } oop speculation_log() { return _speculation_log ; } void set_speculation_log(oop speculation_log) { _speculation_log = speculation_log; } #endif @@ -695,13 +695,13 @@ // Return true is the PC is one would expect if the frame is being deopted. bool is_deopt_pc (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); } - // (thomaswue) When using graal, the address might be off by 5 (because this is the size of the call instruction. + // (thomaswue) When using jvmci, the address might be off by 5 (because this is the size of the call instruction. // (thomaswue) TODO: Replace this by a more general mechanism. // (sanzinger) SPARC has another offset, looked for some variable existing in HotSpot which describes this offset, but i have not // found anything. bool is_deopt_entry (address pc) { return pc == deopt_handler_begin() -#ifdef GRAAL +#ifdef JVMCI || pc == deopt_handler_begin() + #ifdef TARGET_ARCH_sparc 8 @@ -709,7 +709,7 @@ #ifdef TARGET_ARCH_x86 5 #endif // x86 -#endif // GRAAL +#endif // JVMCI ; } bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); }
--- a/src/share/vm/code/scopeDesc.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/code/scopeDesc.cpp Thu May 28 15:36:48 2015 +0200 @@ -226,8 +226,8 @@ } } -#if defined(COMPILER2) || defined(GRAAL) - if (NOT_GRAAL(DoEscapeAnalysis &&) is_top() && _objects != NULL) { +#if defined(COMPILER2) || defined(JVMCI) + if (NOT_JVMCI(DoEscapeAnalysis &&) is_top() && _objects != NULL) { tty->print_cr("Objects"); for (int i = 0; i < _objects->length(); i++) { ObjectValue* sv = _objects->at(i)->as_ObjectValue(); @@ -237,7 +237,7 @@ tty->cr(); } } -#endif // COMPILER2 || GRAAL +#endif // COMPILER2 || JVMCI } #endif
--- a/src/share/vm/compiler/abstractCompiler.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/compiler/abstractCompiler.hpp Thu May 28 15:36:48 2015 +0200 @@ -29,7 +29,7 @@ typedef void (*initializer)(void); -#ifdef GRAAL +#ifdef JVMCI // Per-compiler statistics class CompilerStatistics VALUE_OBJ_CLASS_SPEC { friend class VMStructs; @@ -84,12 +84,12 @@ // The (closed set) of concrete compiler classes. Using an tag like this // avoids a confusing use of macros around the definition of the // 'is_<compiler type>' methods. - enum Type { c1, c2, shark, graal }; + enum Type { c1, c2, shark, jvmci }; private: Type _type; -#ifdef GRAAL +#ifdef JVMCI CompilerStatistics _stats; #endif @@ -112,7 +112,7 @@ bool is_c1 () { return _type == c1; } bool is_c2 () { return _type == c2; } bool is_shark() { return _type == shark; } - bool is_graal() { return _type == graal; } + bool is_jvmci() { return _type == jvmci; } // Customization virtual void initialize () = 0; @@ -136,7 +136,7 @@ ShouldNotReachHere(); } -#ifdef GRAAL +#ifdef JVMCI CompilerStatistics* stats() { return &_stats; } #endif };
--- a/src/share/vm/compiler/compileBroker.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/compiler/compileBroker.cpp Thu May 28 15:36:48 2015 +0200 @@ -49,10 +49,10 @@ #ifdef COMPILER1 #include "c1/c1_Compiler.hpp" #endif -#ifdef GRAAL -#include "graal/graalCompiler.hpp" -#ifdef COMPILERGRAAL -#include "graal/graalRuntime.hpp" +#ifdef JVMCI +#include "jvmci/jvmciCompiler.hpp" +#ifdef COMPILERJVMCI +#include "jvmci/jvmciRuntime.hpp" #include "runtime/vframe.hpp" #endif #endif @@ -916,25 +916,25 @@ // Set the interface to the current compiler(s). int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); int c2_count = CompilationPolicy::policy()->compiler_count(CompLevel_full_optimization); -#ifdef GRAAL - GraalCompiler* graal = new GraalCompiler(); +#ifdef JVMCI + JVMCICompiler* jvmci = new JVMCICompiler(); #endif -#if defined(COMPILERGRAAL) - _compilers[1] = graal; - if (FLAG_IS_DEFAULT(GraalThreads)) { - if (!TieredCompilation && FLAG_IS_DEFAULT(BootstrapGraal) || BootstrapGraal) { - // Graal will bootstrap so give it more threads +#if defined(COMPILERJVMCI) + _compilers[1] = jvmci; + if (FLAG_IS_DEFAULT(JVMCIThreads)) { + if (!TieredCompilation && FLAG_IS_DEFAULT(BootstrapJVMCI) || BootstrapJVMCI) { + // JVMCI will bootstrap so give it more threads c2_count = MIN2(32, os::active_processor_count()); } } else { - c2_count = GraalThreads; + c2_count = JVMCIThreads; } - if (FLAG_IS_DEFAULT(GraalHostThreads)) { + if (FLAG_IS_DEFAULT(JVMCIHostThreads)) { } else { - c1_count = GraalHostThreads; + c1_count = JVMCIHostThreads; } -#endif // COMPILERGRAAL +#endif // COMPILERJVMCI #ifdef COMPILER1 if (c1_count > 0) { @@ -1142,9 +1142,9 @@ void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) { EXCEPTION_MARK; -#if !defined(ZERO) && !defined(SHARK) && !defined(COMPILERGRAAL) +#if !defined(ZERO) && !defined(SHARK) && !defined(COMPILERJVMCI) assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?"); -#endif // !ZERO && !SHARK && !COMPILERGRAAL +#endif // !ZERO && !SHARK && !COMPILERJVMCI // Initialize the compilation queue if (c2_compiler_count > 0) { _c2_compile_queue = new CompileQueue("C2 CompileQueue", MethodCompileQueue_lock); @@ -1322,9 +1322,9 @@ // Should this thread wait for completion of the compile? blocking = is_compile_blocking(); -#ifdef COMPILERGRAAL +#ifdef COMPILERJVMCI if (blocking) { - // Don't allow blocking compiles for requests triggered by Graal. + // Don't allow blocking compiles for requests triggered by JVMCI. if (thread->is_Compiler_thread()) { blocking = false; } @@ -1342,14 +1342,14 @@ // Don't allow blocking compilation requests to JVMCI // if JVMCI itself is not yet initialized - if (!GraalRuntime::is_HotSpotJVMCIRuntime_initialized() && compiler(comp_level)->is_graal()) { + if (!JVMCIRuntime::is_HotSpotJVMCIRuntime_initialized() && compiler(comp_level)->is_jvmci()) { blocking = false; } - // Don't allow blocking compilation requests if we are in GraalRuntime::shutdown + // Don't allow blocking compilation requests if we are in JVMCIRuntime::shutdown // to avoid deadlock between compiler thread(s) and threads run at shutdown // such as the DestroyJavaVM thread. - if (GraalRuntime::shutdown_called()) { + if (JVMCIRuntime::shutdown_called()) { blocking = false; } } @@ -2081,19 +2081,19 @@ MutexLocker locker(Compile_lock, thread); system_dictionary_modification_counter = SystemDictionary::number_of_modifications(); } -#ifdef COMPILERGRAAL - if (comp != NULL && comp->is_graal()) { - GraalCompiler* graal = (GraalCompiler*) comp; +#ifdef COMPILERJVMCI + if (comp != NULL && comp->is_jvmci()) { + JVMCICompiler* jvmci = (JVMCICompiler*) comp; TraceTime t1("compilation", &time); EventCompilation event; - GraalEnv env(task, system_dictionary_modification_counter); - graal->compile_method(target_handle, osr_bci, &env); + JVMCIEnv env(task, system_dictionary_modification_counter); + jvmci->compile_method(target_handle, osr_bci, &env); post_compile(thread, task, event, task->code() != NULL, NULL); } else -#endif // COMPILERGRAAL +#endif // COMPILERJVMCI { NoHandleMark nhm; @@ -2406,18 +2406,18 @@ if (CITime) { int bytes_compiled = method->code_size() + task->num_inlined_bytecodes(); - GRAAL_ONLY(CompilerStatistics* stats = compiler(task->comp_level())->stats();) + JVMCI_ONLY(CompilerStatistics* stats = compiler(task->comp_level())->stats();) if (is_osr) { _t_osr_compilation.add(time); _sum_osr_bytes_compiled += bytes_compiled; - GRAAL_ONLY(stats->_osr.update(time, bytes_compiled);) + JVMCI_ONLY(stats->_osr.update(time, bytes_compiled);) } else { _t_standard_compilation.add(time); _sum_standard_bytes_compiled += method->code_size() + task->num_inlined_bytecodes(); - GRAAL_ONLY(stats->_standard.update(time, bytes_compiled);) + JVMCI_ONLY(stats->_standard.update(time, bytes_compiled);) } - GRAAL_ONLY(stats->_nmethods_size += code->total_size();) - GRAAL_ONLY(stats->_nmethods_code_size += code->insts_size();) + JVMCI_ONLY(stats->_nmethods_size += code->total_size();) + JVMCI_ONLY(stats->_nmethods_code_size += code->insts_size();) } if (UsePerfData) { @@ -2473,7 +2473,7 @@ } } -#ifdef GRAAL +#ifdef JVMCI void CompileBroker::print_times(AbstractCompiler* comp) { CompilerStatistics* stats = comp->stats(); tty->print_cr(" %s {speed: %d bytes/s; standard: %6.3f s, %d bytes, %d methods; osr: %6.3f s, %d bytes, %d methods; nmethods_size: %d bytes; nmethods_code_size: %d bytes}", @@ -2486,7 +2486,7 @@ #endif void CompileBroker::print_times(bool per_compiler, bool aggregate) { -#ifdef GRAAL +#ifdef JVMCI elapsedTimer standard_compilation; elapsedTimer total_compilation; elapsedTimer osr_compilation; @@ -2535,9 +2535,9 @@ total_compilation.add(osr_compilation); total_compilation.add(standard_compilation); -#ifndef COMPILERGRAAL - // In hosted mode, print the Graal compiler specific counters manually. - GraalCompiler::print_compilation_timers(); +#ifndef COMPILERJVMCI + // In hosted mode, print the JVMCI compiler specific counters manually. + JVMCICompiler::print_compilation_timers(); #endif #else elapsedTimer standard_compilation = CompileBroker::_t_standard_compilation;
--- a/src/share/vm/compiler/compileBroker.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/compiler/compileBroker.hpp Thu May 28 15:36:48 2015 +0200 @@ -456,7 +456,7 @@ // Redefine Classes support static void mark_on_stack(); -#ifdef GRAAL +#ifdef JVMCI // Print curent compilation time stats for a given compiler static void print_times(AbstractCompiler* comp); #endif
--- a/src/share/vm/compiler/disassembler.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/compiler/disassembler.cpp Thu May 28 15:36:48 2015 +0200 @@ -529,12 +529,12 @@ nm->method()->method_holder()->name()->print_symbol_on(env.output()); env.output()->print("."); nm->method()->name()->print_symbol_on(env.output()); -#ifdef GRAAL +#ifdef JVMCI { char buffer[O_BUFLEN]; - char* graalName = nm->graal_installed_code_name(buffer, O_BUFLEN); - if (graalName != NULL) { - env.output()->print(" (%s)", graalName); + char* jvmciName = nm->jvmci_installed_code_name(buffer, O_BUFLEN); + if (jvmciName != NULL) { + env.output()->print(" (%s)", jvmciName); } } #endif
--- a/src/share/vm/compiler/oopMap.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/compiler/oopMap.cpp Thu May 28 15:36:48 2015 +0200 @@ -317,7 +317,7 @@ static void add_derived_oop(oop* base, oop* derived) { #ifndef TIERED COMPILER1_PRESENT(ShouldNotReachHere();) - COMPILERGRAAL_PRESENT(ShouldNotReachHere();) + COMPILERJVMCI_PRESENT(ShouldNotReachHere();) #endif // TIERED #ifdef COMPILER2 DerivedPointerTable::add(derived, base); @@ -379,7 +379,7 @@ if (!oms.is_done()) { #ifndef TIERED COMPILER1_PRESENT(ShouldNotReachHere();) - COMPILERGRAAL_PRESENT(ShouldNotReachHere();) + COMPILERJVMCI_PRESENT(ShouldNotReachHere();) #endif // !TIERED // Protect the operation on the derived pointers. This // protects the addition of derived pointers to the shared @@ -493,7 +493,7 @@ // Check that runtime stubs save all callee-saved registers #ifdef COMPILER2 - assert(cb->is_compiled_by_c1() || cb->is_compiled_by_graal() || !cb->is_runtime_stub() || + assert(cb->is_compiled_by_c1() || cb->is_compiled_by_jvmci() || !cb->is_runtime_stub() || (nof_callee >= SAVED_ON_ENTRY_REG_COUNT || nof_callee >= C_SAVED_ON_ENTRY_REG_COUNT), "must save all"); #endif // COMPILER2 @@ -507,7 +507,7 @@ bool OopMap::has_derived_pointer() const { #ifndef TIERED COMPILER1_PRESENT(return false); - COMPILERGRAAL_PRESENT(return false); + COMPILERJVMCI_PRESENT(return false); #endif // !TIERED #ifdef COMPILER2 OopMapStream oms((OopMap*)this,OopMapValue::derived_oop_value);
--- a/src/share/vm/gc_interface/collectedHeap.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/gc_interface/collectedHeap.cpp Thu May 28 15:36:48 2015 +0200 @@ -217,8 +217,8 @@ #ifdef COMPILER2 _defer_initial_card_mark = ReduceInitialCardMarks && can_elide_tlab_store_barriers() && (DeferInitialCardMark || card_mark_must_follow_store()); -#elif defined GRAAL - _defer_initial_card_mark = GraalDeferredInitBarriers && can_elide_tlab_store_barriers() +#elif defined JVMCI + _defer_initial_card_mark = JVMCIDeferredInitBarriers && can_elide_tlab_store_barriers() && (DeferInitialCardMark || card_mark_must_follow_store()); #else assert(_defer_initial_card_mark == false, "Who would set it?"); @@ -527,7 +527,7 @@ " to threads list is doomed to failure!"); for (JavaThread *thread = Threads::first(); thread; thread = thread->next()) { if (use_tlab) thread->tlab().make_parsable(retire_tlabs); -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) // The deferred store barriers must all have been flushed to the // card-table (or other remembered set structure) before GC starts // processing the card-table (or other remembered set).
--- a/src/share/vm/graal/graalCodeInstaller.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,989 +0,0 @@ -/* - * Copyright (c) 2011, 2014, 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. - */ - -#include "precompiled.hpp" -#include "code/compiledIC.hpp" -#include "compiler/compileBroker.hpp" -#include "compiler/disassembler.hpp" -#include "runtime/javaCalls.hpp" -#include "graal/graalEnv.hpp" -#include "graal/graalCompiler.hpp" -#include "graal/graalCodeInstaller.hpp" -#include "graal/graalJavaAccess.hpp" -#include "graal/graalCompilerToVM.hpp" -#include "graal/graalRuntime.hpp" -#include "asm/register.hpp" -#include "classfile/vmSymbols.hpp" -#include "code/vmreg.hpp" - -#ifdef TARGET_ARCH_x86 -# include "vmreg_x86.inline.hpp" -#endif -#ifdef TARGET_ARCH_sparc -# include "vmreg_sparc.inline.hpp" -#endif -#ifdef TARGET_ARCH_zero -# include "vmreg_zero.inline.hpp" -#endif -#ifdef TARGET_ARCH_arm -# include "vmreg_arm.inline.hpp" -#endif -#ifdef TARGET_ARCH_ppc -# include "vmreg_ppc.inline.hpp" -#endif - - -// frequently used constants -// Allocate them with new so they are never destroyed (otherwise, a -// forced exit could destroy these objects while they are still in -// use). -ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantOopWriteValue(NULL); -ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(-1); -ConstantIntValue* CodeInstaller::_int_0_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(0); -ConstantIntValue* CodeInstaller::_int_1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(1); -ConstantIntValue* CodeInstaller::_int_2_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(2); -LocationValue* CodeInstaller::_illegal_value = new (ResourceObj::C_HEAP, mtCompiler) LocationValue(Location()); - -Method* getMethodFromHotSpotMethod(oop hotspot_method) { - assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass()), "sanity"); - return asMethod(HotSpotResolvedJavaMethodImpl::metaspaceMethod(hotspot_method)); -} - -const int MapWordBits = 64; - -static int entry_value(typeArrayOop words, int i) { - jint words_idx = i / MapWordBits; - assert(words_idx >= 0 && words_idx < words->length(), "unexpected index"); - jlong word = words->long_at(words_idx); - return (word >> (i % MapWordBits)) & 15LL; -} - -static int fixedmap_size(oop bitset) { - typeArrayOop arr = HotSpotOopMap::words(bitset); - return arr->length() * MapWordBits; -} - -static void set_vmreg_oops(OopMap* map, VMReg reg, typeArrayOop words, int idx) { - int value = entry_value(words, 4 * idx); - switch (value) { - case 10: - map->set_oop(reg); - break; - case 5: - map->set_narrowoop(reg); - map->set_narrowoop(reg->next()); - break; - case 1: - map->set_narrowoop(reg); - break; - case 4: - map->set_narrowoop(reg->next()); - break; - case 0: - break; - default: - assert(false, err_msg("unexpected bit pattern at %d = 0x%x", idx, value)); - ShouldNotReachHere(); - } -} - -// creates a HotSpot oop map out of the byte arrays provided by DebugInfo -static OopMap* create_oop_map(jint total_frame_size, jint parameter_count, oop debug_info) { - OopMap* map = new OopMap(total_frame_size, parameter_count); - oop reference_map = DebugInfo::referenceMap(debug_info); - oop register_map = HotSpotReferenceMap::registerRefMap(reference_map); - oop frame_map = HotSpotReferenceMap::frameRefMap(reference_map); - oop callee_save_info = (oop) DebugInfo::calleeSaveInfo(debug_info); - - if (register_map != NULL) { - typeArrayOop words = HotSpotOopMap::words(register_map); - int mapIdx = 0; - for (jint i = 0; i < RegisterImpl::number_of_registers; i++) { - set_vmreg_oops(map, as_Register(i)->as_VMReg(), words, mapIdx); - mapIdx++; - } -#ifdef TARGET_ARCH_x86 - for (jint i = 0; i < XMMRegisterImpl::number_of_registers; i++) { - VMReg reg = as_XMMRegister(i)->as_VMReg(); - for (jint j = 0; j < 4; j++) { - set_vmreg_oops(map, reg->next(2 * j), words, mapIdx++); - } - } -#endif -#ifdef TARGET_ARCH_sparc - for (jint i = 0; i < FloatRegisterImpl::number_of_registers; i++) { - VMReg reg = as_FloatRegister(i)->as_VMReg(); - set_vmreg_oops(map, reg, words, mapIdx++); - } -#endif - } - - typeArrayOop words = HotSpotOopMap::words(frame_map); - int size = fixedmap_size(frame_map) / 4; - for (jint i = 0; i < size; i++) { - // HotSpot stack slots are 4 bytes - VMReg reg = VMRegImpl::stack2reg(i * VMRegImpl::slots_per_word); - set_vmreg_oops(map, reg, words, i); - } - - if (callee_save_info != NULL) { - objArrayOop registers = RegisterSaveLayout::registers(callee_save_info); - typeArrayOop slots = RegisterSaveLayout::slots(callee_save_info); - for (jint i = 0; i < slots->length(); i++) { - oop graal_reg = registers->obj_at(i); - jint graal_reg_number = code_Register::number(graal_reg); - VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(graal_reg_number); - // HotSpot stack slots are 4 bytes - jint graal_slot = slots->int_at(i); - jint hotspot_slot = graal_slot * VMRegImpl::slots_per_word; - VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); - map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); -#ifdef _LP64 - // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) - VMReg hotspot_slot_hi_as_reg = VMRegImpl::stack2reg(hotspot_slot + 1); - map->set_callee_saved(hotspot_slot_hi_as_reg, hotspot_reg->next()); -#endif - } - } - return map; -} - -static void record_metadata_reference(oop obj, jlong prim, jboolean compressed, OopRecorder* oop_recorder) { - if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { - Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); - if (compressed) { - assert(Klass::decode_klass((narrowKlass) prim) == klass, err_msg("%s @ " INTPTR_FORMAT " != " PTR64_FORMAT, klass->name()->as_C_string(), p2i(klass), prim)); - } else { - assert((Klass*) prim == klass, err_msg("%s @ " INTPTR_FORMAT " != " PTR64_FORMAT, klass->name()->as_C_string(), p2i(klass), prim)); - } - int index = oop_recorder->find_index(klass); - TRACE_graal_3("metadata[%d of %d] = %s", index, oop_recorder->metadata_count(), klass->name()->as_C_string()); - } else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) { - Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj); - assert(!compressed, err_msg("unexpected compressed method pointer %s @ " INTPTR_FORMAT " = " PTR64_FORMAT, method->name()->as_C_string(), p2i(method), prim)); - int index = oop_recorder->find_index(method); - TRACE_graal_3("metadata[%d of %d] = %s", index, oop_recorder->metadata_count(), method->name()->as_C_string()); - } else { - assert(java_lang_String::is_instance(obj), - err_msg("unexpected metadata reference (%s) for constant " JLONG_FORMAT " (" PTR64_FORMAT ")", obj->klass()->name()->as_C_string(), prim, prim)); - } -} - -// Records any Metadata values embedded in a Constant (e.g., the value returned by HotSpotResolvedObjectTypeImpl.klass()). -static void record_metadata_in_constant(oop constant, OopRecorder* oop_recorder) { - if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { - oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); - jlong prim = HotSpotMetaspaceConstantImpl::primitive(constant); - assert(Kind::typeChar(AbstractValue::kind(constant)) == 'j', "must have word kind"); - assert(obj != NULL, "must have an object"); - assert(prim != 0, "must have a primitive value"); - - record_metadata_reference(obj, prim, false, oop_recorder); - } -} - -static void record_metadata_in_patch(Handle& constant, OopRecorder* oop_recorder) { - record_metadata_reference(HotSpotMetaspaceConstantImpl::metaspaceObject(constant), HotSpotMetaspaceConstantImpl::primitive(constant), HotSpotMetaspaceConstantImpl::compressed(constant), oop_recorder); -} - -ScopeValue* CodeInstaller::get_scope_value(oop value, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) { - second = NULL; - if (value == AbstractValue::ILLEGAL()) { - return _illegal_value; - } - - oop lirKind = AbstractValue::lirKind(value); - oop platformKind = LIRKind::platformKind(lirKind); - jint referenceMask = LIRKind::referenceMask(lirKind); - assert(referenceMask != -1, "derived pointers are not allowed"); - assert(referenceMask == 0 || referenceMask == 1, "unexpected referenceMask"); - bool reference = referenceMask == 1; - - BasicType type = GraalRuntime::kindToBasicType(Kind::typeChar(platformKind)); - - if (value->is_a(RegisterValue::klass())) { - oop reg = RegisterValue::reg(value); - jint number = code_Register::number(reg); - VMReg hotspotRegister = get_hotspot_reg(number); - if (is_general_purpose_reg(hotspotRegister)) { - Location::Type locationType; - if (type == T_INT) { - locationType = reference ? Location::narrowoop : Location::int_in_long; - } else if(type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { - locationType = Location::int_in_long; - } else if (type == T_FLOAT) { - locationType = Location::int_in_long; - } else if (type == T_LONG) { - locationType = reference ? Location::oop : Location::lng; - } else { - assert(type == T_OBJECT && reference, "unexpected type in cpu register"); - locationType = Location::oop; - } - ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); - if (type == T_LONG && !reference) { - second = value; - } - return value; - } else { - assert(type == T_FLOAT || type == T_DOUBLE, "only float and double expected in xmm register"); - Location::Type locationType; - if (type == T_FLOAT) { - // this seems weird, but the same value is used in c1_LinearScan - locationType = Location::normal; - } else { - locationType = Location::dbl; - } - assert(!reference, "unexpected type in floating point register"); - ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); - if (type == T_DOUBLE) { - second = value; - } - return value; - } - } else if (value->is_a(StackSlot::klass())) { - Location::Type locationType; - if (type == T_LONG) { - locationType = reference ? Location::oop : Location::lng; - } else if (type == T_INT) { - locationType = reference ? Location::narrowoop : Location::normal; - } else if(type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { - locationType = Location::normal; - } else if (type == T_FLOAT) { - assert(!reference, "unexpected type in stack slot"); - locationType = Location::normal; - } else if (type == T_DOUBLE) { - assert(!reference, "unexpected type in stack slot"); - locationType = Location::dbl; - } else { - assert(type == T_OBJECT && reference, "unexpected type in stack slot"); - locationType = Location::oop; - } - jint offset = StackSlot::offset(value); -#ifdef TARGET_ARCH_sparc - if(offset >= 0) { - offset += 128; - } -#endif - if (StackSlot::addFrameSize(value)) { - offset += _total_frame_size; - } - ScopeValue* value = new LocationValue(Location::new_stk_loc(locationType, offset)); - if (type == T_DOUBLE || (type == T_LONG && !reference)) { - second = value; - } - return value; - } else if (value->is_a(JavaConstant::klass())){ - record_metadata_in_constant(value, _oop_recorder); - if (value->is_a(PrimitiveConstant::klass())) { - assert(!reference, "unexpected primitive constant type"); - if(value->is_a(RawConstant::klass())) { - jlong prim = PrimitiveConstant::primitive(value); - return new ConstantLongValue(prim); - } else if (type == T_INT || type == T_FLOAT) { - jint prim = (jint)PrimitiveConstant::primitive(value); - switch (prim) { - case -1: return _int_m1_scope_value; - case 0: return _int_0_scope_value; - case 1: return _int_1_scope_value; - case 2: return _int_2_scope_value; - default: return new ConstantIntValue(prim); - } - } else { - assert(type == T_LONG || type == T_DOUBLE, "unexpected primitive constant type"); - jlong prim = PrimitiveConstant::primitive(value); - second = _int_1_scope_value; - return new ConstantLongValue(prim); - } - } else { - assert(reference, "unexpected object constant type"); - if (value->is_a(NullConstant::klass()) || value->is_a(HotSpotCompressedNullConstant::klass())) { - return _oop_null_scope_value; - } else { - assert(value->is_a(HotSpotObjectConstantImpl::klass()), "unexpected constant type"); - oop obj = HotSpotObjectConstantImpl::object(value); - assert(obj != NULL, "null value must be in NullConstant"); - return new ConstantOopWriteValue(JNIHandles::make_local(obj)); - } - } - } else if (value->is_a(VirtualObject::klass())) { - int id = VirtualObject::id(value); - ScopeValue* object = objects->at(id); - assert(object != NULL, "missing value"); - return object; - } else { - value->klass()->print(); - value->print(); - } - ShouldNotReachHere(); - return NULL; -} - -void CodeInstaller::record_object_value(ObjectValue* sv, oop value, GrowableArray<ScopeValue*>* objects) { - oop type = VirtualObject::type(value); - int id = VirtualObject::id(value); - oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); - Klass* klass = java_lang_Class::as_Klass(javaMirror); - bool isLongArray = klass == Universe::longArrayKlassObj(); - - objArrayOop values = VirtualObject::values(value); - for (jint i = 0; i < values->length(); i++) { - ScopeValue* cur_second = NULL; - oop object = values->obj_at(i); - ScopeValue* value = get_scope_value(object, objects, cur_second); - - if (isLongArray && cur_second == NULL) { - // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. - // add an int 0 constant - cur_second = _int_0_scope_value; - } - - if (cur_second != NULL) { - sv->field_values()->append(cur_second); - } - assert(value != NULL, "missing value"); - sv->field_values()->append(value); - } -} - -MonitorValue* CodeInstaller::get_monitor_value(oop value, GrowableArray<ScopeValue*>* objects) { - guarantee(value->is_a(StackLockValue::klass()), "Monitors must be of type MonitorValue"); - - ScopeValue* second = NULL; - ScopeValue* owner_value = get_scope_value(StackLockValue::owner(value), objects, second); - assert(second == NULL, "monitor cannot occupy two stack slots"); - - ScopeValue* lock_data_value = get_scope_value(StackLockValue::slot(value), objects, second); - assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); - assert(lock_data_value->is_location(), "invalid monitor location"); - Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); - - bool eliminated = false; - if (StackLockValue::eliminated(value)) { - eliminated = true; - } - - return new MonitorValue(owner_value, lock_data_loc, eliminated); -} - -void CodeInstaller::initialize_dependencies(oop compiled_code) { - JavaThread* thread = JavaThread::current(); - CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL; - _oop_recorder = new OopRecorder(&_arena, true); - _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL); - objArrayHandle assumptions = CompilationResult::assumptions(HotSpotCompiledCode::comp(compiled_code)); - if (!assumptions.is_null()) { - int length = assumptions->length(); - for (int i = 0; i < length; ++i) { - Handle assumption = assumptions->obj_at(i); - if (!assumption.is_null()) { - if (assumption->klass() == Assumptions_NoFinalizableSubclass::klass()) { - assumption_NoFinalizableSubclass(assumption); - } else if (assumption->klass() == Assumptions_ConcreteSubtype::klass()) { - assumption_ConcreteSubtype(assumption); - } else if (assumption->klass() == Assumptions_LeafType::klass()) { - assumption_LeafType(assumption); - } else if (assumption->klass() == Assumptions_ConcreteMethod::klass()) { - assumption_ConcreteMethod(assumption); - } else if (assumption->klass() == Assumptions_CallSiteTargetValue::klass()) { - assumption_CallSiteTargetValue(assumption); - } else { - assumption->print(); - fatal("unexpected Assumption subclass"); - } - } - } - } - objArrayHandle methods = CompilationResult::methods(HotSpotCompiledCode::comp(compiled_code)); - if (!methods.is_null()) { - int length = methods->length(); - for (int i = 0; i < length; ++i) { - Handle method_handle = methods->obj_at(i); - methodHandle method = getMethodFromHotSpotMethod(method_handle()); - _dependencies->assert_evol_method(method()); - } - } -} - -// constructor used to create a method -GraalEnv::CodeInstallResult CodeInstaller::install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log) { - BufferBlob* buffer_blob = GraalRuntime::initialize_buffer_blob(); - if (buffer_blob == NULL) { - return GraalEnv::cache_full; - } - - CodeBuffer buffer(buffer_blob); - jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); - initialize_dependencies(JNIHandles::resolve(compiled_code_obj)); - - // Get instructions and constants CodeSections early because we need it. - _instructions = buffer.insts(); - _constants = buffer.consts(); - - { - initialize_fields(JNIHandles::resolve(compiled_code_obj)); - if (!initialize_buffer(buffer)) { - return GraalEnv::code_too_large; - } - process_exception_handlers(); - } - - int stack_slots = _total_frame_size / HeapWordSize; // conversion to words - - GraalEnv::CodeInstallResult result; - if (!compiled_code->is_a(HotSpotCompiledNmethod::klass())) { - oop stubName = CompilationResult::name(HotSpotCompiledCode::comp(compiled_code_obj)); - char* name = strdup(java_lang_String::as_utf8_string(stubName)); - cb = RuntimeStub::new_runtime_stub(name, - &buffer, - CodeOffsets::frame_never_safe, - stack_slots, - _debug_recorder->_oopmaps, - false); - result = GraalEnv::ok; - } else { - nmethod* nm = NULL; - methodHandle method = getMethodFromHotSpotMethod(HotSpotCompiledNmethod::method(compiled_code)); - jint entry_bci = HotSpotCompiledNmethod::entryBCI(compiled_code); - jint id = HotSpotCompiledNmethod::id(compiled_code); - GraalEnv* env = (GraalEnv*) (address) HotSpotCompiledNmethod::graalEnv(compiled_code); - if (id == -1) { - // Make sure a valid compile_id is associated with every compile - id = CompileBroker::assign_compile_id_unlocked(Thread::current(), method, entry_bci); - } - result = GraalEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, - GraalCompiler::instance(), _debug_recorder, _dependencies, env, id, false, installed_code, compiled_code, speculation_log); - cb = nm; - } - - if (cb != NULL) { - // Make sure the pre-calculated constants section size was correct. - guarantee((cb->code_begin() - cb->content_begin()) >= _constants_size, err_msg("%d < %d", (int)(cb->code_begin() - cb->content_begin()), _constants_size)); - } - return result; -} - -void CodeInstaller::initialize_fields(oop compiled_code) { - Handle comp_result = HotSpotCompiledCode::comp(compiled_code); - if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) { - Handle hotspotJavaMethod = HotSpotCompiledNmethod::method(compiled_code); - methodHandle method = getMethodFromHotSpotMethod(hotspotJavaMethod()); - _parameter_count = method->size_of_parameters(); - TRACE_graal_1("installing code for %s", method->name_and_sig_as_C_string()); - } else { - // Must be a HotSpotCompiledRuntimeStub - // TODO (ds) not sure if this is correct - only used in OopMap constructor for non-product builds - _parameter_count = 0; - } - _sites_handle = JNIHandles::make_local(HotSpotCompiledCode::sites(compiled_code)); - _exception_handlers_handle = JNIHandles::make_local(HotSpotCompiledCode::exceptionHandlers(compiled_code)); - - _code_handle = JNIHandles::make_local(CompilationResult::targetCode(comp_result)); - _code_size = CompilationResult::targetCodeSize(comp_result); - _total_frame_size = CompilationResult::totalFrameSize(comp_result); - _custom_stack_area_offset = CompilationResult::customStackAreaOffset(comp_result); - - // Pre-calculate the constants section size. This is required for PC-relative addressing. - _data_section_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSection(compiled_code)); - guarantee(HotSpotCompiledCode::dataSectionAlignment(compiled_code) <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); - _constants_size = data_section()->length(); - - _data_section_patches_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSectionPatches(compiled_code)); - -#ifndef PRODUCT - _comments_handle = JNIHandles::make_local(HotSpotCompiledCode::comments(compiled_code)); -#endif - - _next_call_type = INVOKE_INVALID; -} - -int CodeInstaller::estimate_stub_entries() { - // Estimate the number of static call stubs that might be emitted. - int static_call_stubs = 0; - objArrayOop sites = this->sites(); - for (int i = 0; i < sites->length(); i++) { - oop site = sites->obj_at(i); - if (site->is_a(CompilationResult_Mark::klass())) { - oop id_obj = CompilationResult_Mark::id(site); - if (id_obj != NULL) { - assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected"); - jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); - if (id == INVOKESTATIC || id == INVOKESPECIAL) { - static_call_stubs++; - } - } - } - } - return static_call_stubs; -} - -// perform data and call relocation on the CodeBuffer -bool CodeInstaller::initialize_buffer(CodeBuffer& buffer) { - HandleMark hm; - objArrayHandle sites = this->sites(); - int locs_buffer_size = sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); - char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); - buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); - // Allocate enough space in the stub section for the static call - // stubs. Stubs have extra relocs but they are managed by the stub - // section itself so they don't need to be accounted for in the - // locs_buffer above. - buffer.initialize_stubs_size(estimate_stub_entries() * CompiledStaticCall::to_interp_stub_size()); - buffer.initialize_consts_size(_constants_size); - - _debug_recorder = new DebugInformationRecorder(_oop_recorder); - _debug_recorder->set_oopmaps(new OopMapSet()); - - buffer.initialize_oop_recorder(_oop_recorder); - - // copy the constant data into the newly created CodeBuffer - address end_data = _constants->start() + _constants_size; - memcpy(_constants->start(), data_section()->base(T_BYTE), _constants_size); - _constants->set_end(end_data); - - // copy the code into the newly created CodeBuffer - address end_pc = _instructions->start() + _code_size; - if (!_instructions->allocates2(end_pc)) { - return false; - } - memcpy(_instructions->start(), code()->base(T_BYTE), _code_size); - _instructions->set_end(end_pc); - - for (int i = 0; i < data_section_patches()->length(); i++) { - Handle patch = data_section_patches()->obj_at(i); - Handle reference = CompilationResult_DataPatch::reference(patch); - assert(reference->is_a(CompilationResult_ConstantReference::klass()), err_msg("patch in data section must be a ConstantReference")); - Handle constant = CompilationResult_ConstantReference::constant(reference); - if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { - record_metadata_in_patch(constant, _oop_recorder); - } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { - Handle obj = HotSpotObjectConstantImpl::object(constant); - jobject value = JNIHandles::make_local(obj()); - int oop_index = _oop_recorder->find_index(value); - - address dest = _constants->start() + CompilationResult_Site::pcOffset(patch); - if (HotSpotObjectConstantImpl::compressed(constant)) { -#ifdef _LP64 - _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); -#else - fatal("unexpected compressed oop in 32-bit mode"); -#endif - } else { - _constants->relocate(dest, oop_Relocation::spec(oop_index)); - } - } else { - ShouldNotReachHere(); - } - } - jint last_pc_offset = -1; - for (int i = 0; i < sites->length(); i++) { - { - No_Safepoint_Verifier no_safepoint; - oop site = sites->obj_at(i); - jint pc_offset = CompilationResult_Site::pcOffset(site); - - if (site->is_a(CompilationResult_Call::klass())) { - TRACE_graal_4("call at %i", pc_offset); - site_Call(buffer, pc_offset, site); - } else if (site->is_a(CompilationResult_Infopoint::klass())) { - // three reasons for infopoints denote actual safepoints - oop reason = CompilationResult_Infopoint::reason(site); - if (InfopointReason::SAFEPOINT() == reason || InfopointReason::CALL() == reason || InfopointReason::IMPLICIT_EXCEPTION() == reason) { - TRACE_graal_4("safepoint at %i", pc_offset); - site_Safepoint(buffer, pc_offset, site); - } else { - // if the infopoint is not an actual safepoint, it must have one of the other reasons - // (safeguard against new safepoint types that require handling above) - assert(InfopointReason::METHOD_START() == reason || InfopointReason::METHOD_END() == reason || InfopointReason::LINE_NUMBER() == reason, ""); - site_Infopoint(buffer, pc_offset, site); - } - } else if (site->is_a(CompilationResult_DataPatch::klass())) { - TRACE_graal_4("datapatch at %i", pc_offset); - site_DataPatch(buffer, pc_offset, site); - } else if (site->is_a(CompilationResult_Mark::klass())) { - TRACE_graal_4("mark at %i", pc_offset); - site_Mark(buffer, pc_offset, site); - } else { - fatal("unexpected Site subclass"); - } - last_pc_offset = pc_offset; - } - if (CodeInstallSafepointChecks && SafepointSynchronize::do_call_back()) { - // this is a hacky way to force a safepoint check but nothing else was jumping out at me. - ThreadToNativeFromVM ttnfv(JavaThread::current()); - } - } - -#ifndef PRODUCT - if (comments() != NULL) { - No_Safepoint_Verifier no_safepoint; - for (int i = 0; i < comments()->length(); i++) { - oop comment = comments()->obj_at(i); - assert(comment->is_a(HotSpotCompiledCode_Comment::klass()), "cce"); - jint offset = HotSpotCompiledCode_Comment::pcOffset(comment); - char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); - buffer.block_comment(offset, text); - } - } -#endif - return true; -} - -void CodeInstaller::assumption_NoFinalizableSubclass(Handle assumption) { - Handle receiverType_handle = Assumptions_NoFinalizableSubclass::receiverType(assumption()); - Klass* receiverType = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(receiverType_handle)); - _dependencies->assert_has_no_finalizable_subclasses(receiverType); -} - -void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) { - Handle context_handle = Assumptions_ConcreteSubtype::context(assumption()); - Handle subtype_handle = Assumptions_ConcreteSubtype::subtype(assumption()); - Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); - Klass* subtype = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(subtype_handle)); - - assert(context->is_abstract(), ""); - _dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype); -} - -void CodeInstaller::assumption_LeafType(Handle assumption) { - Handle context_handle = Assumptions_LeafType::context(assumption()); - Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); - - _dependencies->assert_leaf_type(context); -} - -void CodeInstaller::assumption_ConcreteMethod(Handle assumption) { - Handle impl_handle = Assumptions_ConcreteMethod::impl(assumption()); - Handle context_handle = Assumptions_ConcreteMethod::context(assumption()); - - methodHandle impl = getMethodFromHotSpotMethod(impl_handle()); - Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); - - _dependencies->assert_unique_concrete_method(context, impl()); -} - -void CodeInstaller::assumption_CallSiteTargetValue(Handle assumption) { - Handle callSite = Assumptions_CallSiteTargetValue::callSite(assumption()); - Handle methodHandle = Assumptions_CallSiteTargetValue::methodHandle(assumption()); - - _dependencies->assert_call_site_target_value(callSite(), methodHandle()); -} - -void CodeInstaller::process_exception_handlers() { - if (exception_handlers() != NULL) { - objArrayOop handlers = exception_handlers(); - for (int i = 0; i < handlers->length(); i++) { - oop exc = handlers->obj_at(i); - jint pc_offset = CompilationResult_Site::pcOffset(exc); - jint handler_offset = CompilationResult_ExceptionHandler::handlerPos(exc); - - // Subtable header - _exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0)); - - // Subtable entry - _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); - } - } -} - -// If deoptimization happens, the interpreter should reexecute these bytecodes. -// This function mainly helps the compilers to set up the reexecute bit. -static bool bytecode_should_reexecute(Bytecodes::Code code) { - switch (code) { - case Bytecodes::_invokedynamic: - case Bytecodes::_invokevirtual: - case Bytecodes::_invokeinterface: - case Bytecodes::_invokespecial: - case Bytecodes::_invokestatic: - return false; - default: - return true; - } - return true; -} - -GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(oop debug_info) { - objArrayOop virtualObjects = DebugInfo::virtualObjectMapping(debug_info); - if (virtualObjects == NULL) { - return NULL; - } - GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(virtualObjects->length(), virtualObjects->length(), NULL); - // Create the unique ObjectValues - for (int i = 0; i < virtualObjects->length(); i++) { - oop value = virtualObjects->obj_at(i); - int id = VirtualObject::id(value); - oop type = VirtualObject::type(value); - oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); - ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror))); - assert(objects->at(id) == NULL, "once"); - objects->at_put(id, sv); - } - // All the values which could be referenced by the VirtualObjects - // exist, so now describe all the VirtualObjects themselves. - for (int i = 0; i < virtualObjects->length(); i++) { - oop value = virtualObjects->obj_at(i); - int id = VirtualObject::id(value); - record_object_value(objects->at(id)->as_ObjectValue(), value, objects); - } - _debug_recorder->dump_object_pool(objects); - return objects; -} - -void CodeInstaller::record_scope(jint pc_offset, oop debug_info) { - oop position = DebugInfo::bytecodePosition(debug_info); - if (position == NULL) { - // Stubs do not record scope info, just oop maps - return; - } - - GrowableArray<ScopeValue*>* objectMapping = record_virtual_objects(debug_info); - record_scope(pc_offset, position, objectMapping); -} - -void CodeInstaller::record_scope(jint pc_offset, oop position, GrowableArray<ScopeValue*>* objects) { - oop frame = NULL; - if (position->is_a(BytecodeFrame::klass())) { - frame = position; - } - oop caller_frame = BytecodePosition::caller(position); - if (caller_frame != NULL) { - record_scope(pc_offset, caller_frame, objects); - } - - oop hotspot_method = BytecodePosition::method(position); - Method* method = getMethodFromHotSpotMethod(hotspot_method); - jint bci = BytecodePosition::bci(position); - if (bci == BytecodeFrame::BEFORE_BCI()) { - bci = SynchronizationEntryBCI; - } - - if (TraceGraal >= 2) { - tty->print_cr("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); - } - - bool reexecute = false; - if (frame != NULL) { - if (bci == SynchronizationEntryBCI){ - reexecute = false; - } else { - Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); - reexecute = bytecode_should_reexecute(code); - if (frame != NULL) { - reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE); - } - } - } - - DebugToken* locals_token = NULL; - DebugToken* expressions_token = NULL; - DebugToken* monitors_token = NULL; - bool throw_exception = false; - - if (frame != NULL) { - jint local_count = BytecodeFrame::numLocals(frame); - jint expression_count = BytecodeFrame::numStack(frame); - jint monitor_count = BytecodeFrame::numLocks(frame); - objArrayOop values = BytecodeFrame::values(frame); - - assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); - - GrowableArray<ScopeValue*>* locals = local_count > 0 ? new GrowableArray<ScopeValue*> (local_count) : NULL; - GrowableArray<ScopeValue*>* expressions = expression_count > 0 ? new GrowableArray<ScopeValue*> (expression_count) : NULL; - GrowableArray<MonitorValue*>* monitors = monitor_count > 0 ? new GrowableArray<MonitorValue*> (monitor_count) : NULL; - - if (TraceGraal >= 2) { - tty->print_cr("Scope at bci %d with %d values", bci, values->length()); - tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); - } - - for (jint i = 0; i < values->length(); i++) { - ScopeValue* second = NULL; - oop value = values->obj_at(i); - if (i < local_count) { - ScopeValue* first = get_scope_value(value, objects, second); - if (second != NULL) { - locals->append(second); - } - locals->append(first); - } else if (i < local_count + expression_count) { - ScopeValue* first = get_scope_value(value, objects, second); - if (second != NULL) { - expressions->append(second); - } - expressions->append(first); - } else { - monitors->append(get_monitor_value(value, objects)); - } - if (second != NULL) { - i++; - assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL"); - assert(values->obj_at(i) == AbstractValue::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL"); - } - } - - locals_token = _debug_recorder->create_scope_values(locals); - expressions_token = _debug_recorder->create_scope_values(expressions); - monitors_token = _debug_recorder->create_monitor_values(monitors); - - throw_exception = BytecodeFrame::rethrowException(frame) == JNI_TRUE; - } - - _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, - locals_token, expressions_token, monitors_token); -} - -void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) { - oop debug_info = CompilationResult_Infopoint::debugInfo(site); - assert(debug_info != NULL, "debug info expected"); - - // address instruction = _instructions->start() + pc_offset; - // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); - _debug_recorder->add_safepoint(pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); - record_scope(pc_offset, debug_info); - _debug_recorder->end_safepoint(pc_offset); -} - -void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, oop site) { - oop debug_info = CompilationResult_Infopoint::debugInfo(site); - assert(debug_info != NULL, "debug info expected"); - - _debug_recorder->add_non_safepoint(pc_offset); - record_scope(pc_offset, debug_info); - _debug_recorder->end_non_safepoint(pc_offset); -} - -void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) { - oop target = CompilationResult_Call::target(site); - InstanceKlass* target_klass = InstanceKlass::cast(target->klass()); - - oop hotspot_method = NULL; // JavaMethod - oop foreign_call = NULL; - - if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) { - foreign_call = target; - } else { - hotspot_method = target; - } - - oop debug_info = CompilationResult_Call::debugInfo(site); - - assert(!!hotspot_method ^ !!foreign_call, "Call site needs exactly one type"); - - NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset); - jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method); - - if (debug_info != NULL) { - _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); - record_scope(next_pc_offset, debug_info); - } - - if (foreign_call != NULL) { - jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call); - CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination); - } else { // method != NULL - assert(hotspot_method != NULL, "unexpected JavaMethod"); - assert(debug_info != NULL, "debug info expected"); - - TRACE_graal_3("method call"); - CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset); - if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { - // Need a static call stub for transitions from compiled to interpreted. - CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset); - } - } - - _next_call_type = INVOKE_INVALID; - - if (debug_info != NULL) { - _debug_recorder->end_safepoint(next_pc_offset); - } -} - -void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, oop site) { - oop reference = CompilationResult_DataPatch::reference(site); - if (reference->is_a(CompilationResult_ConstantReference::klass())) { - Handle constant = CompilationResult_ConstantReference::constant(reference); - if (constant->is_a(HotSpotObjectConstantImpl::klass())) { - pd_patch_OopConstant(pc_offset, constant); - } else if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { - record_metadata_in_patch(constant, _oop_recorder); - } else { - fatal("unknown constant type in data patch"); - } - } else if (reference->is_a(CompilationResult_DataSectionReference::klass())) { - int data_offset = CompilationResult_DataSectionReference::offset(reference); - assert(0 <= data_offset && data_offset < _constants_size, err_msg("data offset 0x%X points outside data section (size 0x%X)", data_offset, _constants_size)); - pd_patch_DataSectionReference(pc_offset, data_offset); - } else { - fatal("unknown data patch type"); - } -} - -void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, oop site) { - oop id_obj = CompilationResult_Mark::id(site); - - if (id_obj != NULL) { - assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected"); - jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); - - address pc = _instructions->start() + pc_offset; - - switch (id) { - case UNVERIFIED_ENTRY: - _offsets.set_value(CodeOffsets::Entry, pc_offset); - break; - case VERIFIED_ENTRY: - _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset); - break; - case OSR_ENTRY: - _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset); - break; - case EXCEPTION_HANDLER_ENTRY: - _offsets.set_value(CodeOffsets::Exceptions, pc_offset); - break; - case DEOPT_HANDLER_ENTRY: - _offsets.set_value(CodeOffsets::Deopt, pc_offset); - break; - case INVOKEVIRTUAL: - case INVOKEINTERFACE: - case INLINE_INVOKE: - case INVOKESTATIC: - case INVOKESPECIAL: - _next_call_type = (MarkId) id; - _invoke_mark_pc = pc; - break; - case POLL_NEAR: - case POLL_FAR: - case POLL_RETURN_NEAR: - case POLL_RETURN_FAR: - pd_relocate_poll(pc, id); - break; - case CARD_TABLE_SHIFT: - case CARD_TABLE_ADDRESS: - break; - default: - ShouldNotReachHere(); - break; - } - } -} -
--- a/src/share/vm/graal/graalCodeInstaller.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2011, 2014, 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. - */ - -#ifndef SHARE_VM_GRAAL_GRAAL_CODE_INSTALLER_HPP -#define SHARE_VM_GRAAL_GRAAL_CODE_INSTALLER_HPP - -#include "graal/graalEnv.hpp" - -/* - * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod. - */ -class CodeInstaller : public StackObj { - friend class VMStructs; -private: - enum MarkId { - VERIFIED_ENTRY = 1, - UNVERIFIED_ENTRY = 2, - OSR_ENTRY = 3, - EXCEPTION_HANDLER_ENTRY = 4, - DEOPT_HANDLER_ENTRY = 5, - INVOKEINTERFACE = 6, - INVOKEVIRTUAL = 7, - INVOKESTATIC = 8, - INVOKESPECIAL = 9, - INLINE_INVOKE = 10, - POLL_NEAR = 11, - POLL_RETURN_NEAR = 12, - POLL_FAR = 13, - POLL_RETURN_FAR = 14, - CARD_TABLE_ADDRESS = 15, - CARD_TABLE_SHIFT = 16, - INVOKE_INVALID = -1 - }; - - Arena _arena; - - jobject _data_section_handle; - jobject _data_section_patches_handle; - jobject _sites_handle; - jobject _exception_handlers_handle; - CodeOffsets _offsets; - - jobject _code_handle; - jint _code_size; - jint _total_frame_size; - jint _custom_stack_area_offset; - jint _parameter_count; - jint _constants_size; -#ifndef PRODUCT - jobject _comments_handle; -#endif - - MarkId _next_call_type; - address _invoke_mark_pc; - - CodeSection* _instructions; - CodeSection* _constants; - - OopRecorder* _oop_recorder; - DebugInformationRecorder* _debug_recorder; - Dependencies* _dependencies; - ExceptionHandlerTable _exception_handler_table; - - static ConstantOopWriteValue* _oop_null_scope_value; - static ConstantIntValue* _int_m1_scope_value; - static ConstantIntValue* _int_0_scope_value; - static ConstantIntValue* _int_1_scope_value; - static ConstantIntValue* _int_2_scope_value; - static LocationValue* _illegal_value; - - jint pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method); - void pd_patch_OopConstant(int pc_offset, Handle& constant); - void pd_patch_DataSectionReference(int pc_offset, int data_offset); - void pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst); - void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination); - void pd_relocate_JavaMethod(oop method, jint pc_offset); - void pd_relocate_poll(address pc, jint mark); - - objArrayOop sites() { return (objArrayOop) JNIHandles::resolve(_sites_handle); } - arrayOop code() { return (arrayOop) JNIHandles::resolve(_code_handle); } - arrayOop data_section() { return (arrayOop) JNIHandles::resolve(_data_section_handle); } - objArrayOop data_section_patches() { return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); } - objArrayOop exception_handlers() { return (objArrayOop) JNIHandles::resolve(_exception_handlers_handle); } -#ifndef PRODUCT - objArrayOop comments() { return (objArrayOop) JNIHandles::resolve(_comments_handle); } -#endif - -public: - - CodeInstaller() : _arena(mtCompiler) {} - GraalEnv::CodeInstallResult install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log); - - static address runtime_call_target_address(oop runtime_call); - static VMReg get_hotspot_reg(jint graalRegisterNumber); - static bool is_general_purpose_reg(VMReg hotspotRegister); - -private: - ScopeValue* get_scope_value(oop value, GrowableArray<ScopeValue*>* objects, ScopeValue* &second); - MonitorValue* get_monitor_value(oop value, GrowableArray<ScopeValue*>* objects); - - // extract the fields of the CompilationResult - void initialize_fields(oop target_method); - void initialize_dependencies(oop target_method); - - int estimate_stub_entries(); - - // perform data and call relocation on the CodeBuffer - bool initialize_buffer(CodeBuffer& buffer); - - void assumption_NoFinalizableSubclass(Handle assumption); - void assumption_ConcreteSubtype(Handle assumption); - void assumption_LeafType(Handle assumption); - void assumption_ConcreteMethod(Handle assumption); - void assumption_CallSiteTargetValue(Handle assumption); - - void site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site); - void site_Infopoint(CodeBuffer& buffer, jint pc_offset, oop site); - void site_Call(CodeBuffer& buffer, jint pc_offset, oop site); - void site_DataPatch(CodeBuffer& buffer, jint pc_offset, oop site); - void site_Mark(CodeBuffer& buffer, jint pc_offset, oop site); - - void record_scope(jint pc_offset, oop debug_info); - void record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects); - void record_object_value(ObjectValue* sv, oop value, GrowableArray<ScopeValue*>* objects); - - GrowableArray<ScopeValue*>* record_virtual_objects(oop debug_info); - - void process_exception_handlers(); - int estimateStubSpace(int static_call_stubs); -}; - -/** - * Gets the Method metaspace object from a HotSpotResolvedJavaMethodImpl Java object. - */ -Method* getMethodFromHotSpotMethod(oop hotspot_method); - - - -#endif // SHARE_VM_GRAAL_GRAAL_CODE_INSTALLER_HPP
--- a/src/share/vm/graal/graalCompiler.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#include "precompiled.hpp" -#include "memory/oopFactory.hpp" -#include "runtime/javaCalls.hpp" -#include "graal/graalCompiler.hpp" -#include "graal/graalEnv.hpp" -#include "graal/graalRuntime.hpp" -#include "runtime/compilationPolicy.hpp" -#include "runtime/globals_extension.hpp" - -GraalCompiler* GraalCompiler::_instance = NULL; -elapsedTimer GraalCompiler::_codeInstallTimer; - -GraalCompiler::GraalCompiler() : AbstractCompiler(graal) { -#ifdef COMPILERGRAAL - _bootstrapping = false; - _methodsCompiled = 0; -#endif - assert(_instance == NULL, "only one instance allowed"); - _instance = this; -} - -// Initialization -void GraalCompiler::initialize() { -#ifdef COMPILERGRAAL - if (!UseCompiler || !should_perform_init()) { - return; - } - - BufferBlob* buffer_blob = GraalRuntime::initialize_buffer_blob(); - if (buffer_blob == NULL) { - set_state(failed); - } else { - set_state(initialized); - } - // Graal is considered as application code so we need to - // stop the VM deferring compilation now. - CompilationPolicy::completed_vm_startup(); -#endif // COMPILERGRAAL -} - -#ifdef COMPILERGRAAL -void GraalCompiler::bootstrap() { - JavaThread* THREAD = JavaThread::current(); - _bootstrapping = true; - // Allow bootstrap to perform Graal compilations of itself - bool c1only = GraalCompileWithC1Only; - GraalCompileWithC1Only = false; - ResourceMark rm; - HandleMark hm; - if (PrintBootstrap) { - tty->print("Bootstrapping Graal"); - } - jlong start = os::javaTimeMillis(); - - Array<Method*>* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods(); - // Initialize compile queue with a selected set of methods. - int len = objectMethods->length(); - for (int i = 0; i < len; i++) { - methodHandle mh = objectMethods->at(i); - if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { - ResourceMark rm; - int hot_count = 10; // TODO: what's the appropriate value? - CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD); - } - } - - int qsize; - bool first_round = true; - int z = 0; - do { - // Loop until there is something in the queue. - do { - os::sleep(THREAD, 100, true); - qsize = CompileBroker::queue_size(CompLevel_full_optimization); - } while (first_round && qsize == 0); - first_round = false; - if (PrintBootstrap) { - while (z < (_methodsCompiled / 100)) { - ++z; - tty->print_raw("."); - } - } - } while (qsize != 0); - - if (PrintBootstrap) { - tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled); - } - GraalCompileWithC1Only = c1only; - _bootstrapping = false; -} - -void GraalCompiler::compile_method(methodHandle method, int entry_bci, GraalEnv* env) { - GRAAL_EXCEPTION_CONTEXT - - bool is_osr = entry_bci != InvocationEntryBci; - if (_bootstrapping && is_osr) { - // no OSR compilations during bootstrap - the compiler is just too slow at this point, - // and we know that there are no endless loops - return; - } - - GraalRuntime::ensure_graal_class_loader_is_initialized(); - HandleMark hm; - ResourceMark rm; - JavaValue result(T_VOID); - JavaCallArguments args; - args.push_long((jlong) (address) method()); - args.push_int(entry_bci); - args.push_long((jlong) (address) env); - args.push_int(env->task()->compile_id()); - JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, CHECK_ABORT); - - _methodsCompiled++; -} - - -// Compilation entry point for methods -void GraalCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { - ShouldNotReachHere(); -} - -// Print compilation timers and statistics -void GraalCompiler::print_timers() { - print_compilation_timers(); -} - -#endif // COMPILERGRAAL - -// Print compilation timers and statistics -void GraalCompiler::print_compilation_timers() { - TRACE_graal_1("GraalCompiler::print_timers"); - tty->print_cr(" Graal code install time: %6.3f s", _codeInstallTimer.seconds()); -} - -void GraalCompiler::compile_the_world() { - HandleMark hm; - JavaThread* THREAD = JavaThread::current(); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", CHECK_ABORT); - KlassHandle klass = GraalRuntime::load_required_class(name); - TempNewSymbol compileTheWorld = SymbolTable::new_symbol("compileTheWorld", CHECK_ABORT); - JavaValue result(T_VOID); - JavaCallArguments args; - args.push_oop(GraalRuntime::get_HotSpotJVMCIRuntime()); - JavaCalls::call_special(&result, klass, compileTheWorld, vmSymbols::void_method_signature(), &args, CHECK_ABORT); -}
--- a/src/share/vm/graal/graalCompiler.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifndef SHARE_VM_GRAAL_GRAAL_COMPILER_HPP -#define SHARE_VM_GRAAL_GRAAL_COMPILER_HPP - -#include "compiler/abstractCompiler.hpp" -#include "graal/graalEnv.hpp" - -class GraalCompiler : public AbstractCompiler { - -private: - -#ifdef COMPILERGRAAL - bool _bootstrapping; - - /** - * Number of methods compiled by Graal. This is not synchronized - * so may not be 100% accurate. - */ - volatile int _methodsCompiled; - -#endif - - static GraalCompiler* _instance; - - static elapsedTimer _codeInstallTimer; - -public: - - GraalCompiler(); - - static GraalCompiler* instance() { return _instance; } - - virtual const char* name() { return "Graal"; } - - virtual bool supports_native() { return true; } - virtual bool supports_osr () { return true; } - - bool is_graal() { return true; } - bool is_c1 () { return false; } - bool is_c2 () { return false; } - - bool needs_stubs () { return false; } - - // Initialization - virtual void initialize(); - -#ifdef COMPILERGRAAL - - void bootstrap(); - - // Compilation entry point for methods - virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci); - - void compile_method(methodHandle target, int entry_bci, GraalEnv* env); - - // Print compilation timers and statistics - virtual void print_timers(); - - // Print compilation statistics - void reset_compilation_stats(); -#endif // COMPILERGRAAL - - // Print compilation timers and statistics - static void print_compilation_timers(); - - static elapsedTimer* codeInstallTimer() { return &_codeInstallTimer; } - - void compile_the_world(); -}; - -#endif // SHARE_VM_GRAAL_GRAAL_COMPILER_HPP
--- a/src/share/vm/graal/graalCompilerToVM.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1116 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#include "precompiled.hpp" -#include "code/scopeDesc.hpp" -#include "memory/oopFactory.hpp" -#include "oops/generateOopMap.hpp" -#include "oops/fieldStreams.hpp" -#include "runtime/fieldDescriptor.hpp" -#include "runtime/javaCalls.hpp" -#include "graal/graalRuntime.hpp" -#include "compiler/compileBroker.hpp" -#include "compiler/compilerOracle.hpp" -#include "compiler/disassembler.hpp" -#include "graal/graalCompilerToVM.hpp" -#include "graal/graalCompiler.hpp" -#include "graal/graalEnv.hpp" -#include "graal/graalJavaAccess.hpp" -#include "graal/graalCodeInstaller.hpp" -#include "gc_implementation/g1/heapRegion.hpp" -#include "runtime/javaCalls.hpp" -#include "runtime/deoptimization.hpp" -#include "runtime/vframe.hpp" -#include "runtime/vframe_hp.hpp" -#include "runtime/vmStructs.hpp" - - -// Entry to native method implementation that transitions current thread to '_thread_in_vm'. -#define C2V_VMENTRY(result_type, name, signature) \ - JNIEXPORT result_type JNICALL c2v_ ## name signature { \ - TRACE_graal_3("CompilerToVM::" #name); \ - GRAAL_VM_ENTRY_MARK; \ - -#define C2V_END } - -extern "C" { -extern VMStructEntry* gHotSpotVMStructs; -extern uint64_t gHotSpotVMStructEntryTypeNameOffset; -extern uint64_t gHotSpotVMStructEntryFieldNameOffset; -extern uint64_t gHotSpotVMStructEntryTypeStringOffset; -extern uint64_t gHotSpotVMStructEntryIsStaticOffset; -extern uint64_t gHotSpotVMStructEntryOffsetOffset; -extern uint64_t gHotSpotVMStructEntryAddressOffset; -extern uint64_t gHotSpotVMStructEntryArrayStride; - -extern VMTypeEntry* gHotSpotVMTypes; -extern uint64_t gHotSpotVMTypeEntryTypeNameOffset; -extern uint64_t gHotSpotVMTypeEntrySuperclassNameOffset; -extern uint64_t gHotSpotVMTypeEntryIsOopTypeOffset; -extern uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset; -extern uint64_t gHotSpotVMTypeEntryIsUnsignedOffset; -extern uint64_t gHotSpotVMTypeEntrySizeOffset; -extern uint64_t gHotSpotVMTypeEntryArrayStride; - -extern VMIntConstantEntry* gHotSpotVMIntConstants; -extern uint64_t gHotSpotVMIntConstantEntryNameOffset; -extern uint64_t gHotSpotVMIntConstantEntryValueOffset; -extern uint64_t gHotSpotVMIntConstantEntryArrayStride; - -extern VMLongConstantEntry* gHotSpotVMLongConstants; -extern uint64_t gHotSpotVMLongConstantEntryNameOffset; -extern uint64_t gHotSpotVMLongConstantEntryValueOffset; -extern uint64_t gHotSpotVMLongConstantEntryArrayStride; -} - -C2V_VMENTRY(void, initializeConfiguration, (JNIEnv *, jobject, jobject config)) - VMStructs::initHotSpotVMConfig(JNIHandles::resolve(config)); -C2V_END - -C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jlong metaspace_method)) - methodHandle method = asMethod(metaspace_method); - ResourceMark rm; - - int code_size = method->code_size(); - typeArrayOop reconstituted_code = oopFactory::new_byteArray(code_size, CHECK_NULL); - - guarantee(method->method_holder()->is_rewritten(), "Method's holder should be rewritten"); - // iterate over all bytecodes and replace non-Java bytecodes - - for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) { - Bytecodes::Code code = s.code(); - Bytecodes::Code raw_code = s.raw_code(); - int bci = s.bci(); - int len = s.instruction_size(); - - // Restore original byte code. - reconstituted_code->byte_at_put(bci, (jbyte) (s.is_wide()? Bytecodes::_wide : code)); - if (len > 1) { - memcpy(reconstituted_code->byte_at_addr(bci + 1), s.bcp()+1, len-1); - } - - if (len > 1) { - // Restore the big-endian constant pool indexes. - // Cf. Rewriter::scan_method - switch (code) { - case Bytecodes::_getstatic: - case Bytecodes::_putstatic: - case Bytecodes::_getfield: - case Bytecodes::_putfield: - case Bytecodes::_invokevirtual: - case Bytecodes::_invokespecial: - case Bytecodes::_invokestatic: - case Bytecodes::_invokeinterface: - case Bytecodes::_invokehandle: { - int cp_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); - Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); - break; - } - - case Bytecodes::_invokedynamic: - int cp_index = Bytes::get_native_u4((address) reconstituted_code->byte_at_addr(bci + 1)); - Bytes::put_Java_u4((address) reconstituted_code->byte_at_addr(bci + 1), (u4) cp_index); - break; - } - - // Not all ldc byte code are rewritten. - switch (raw_code) { - case Bytecodes::_fast_aldc: { - int cpc_index = reconstituted_code->byte_at(bci + 1) & 0xff; - int cp_index = method->constants()->object_to_cp_index(cpc_index); - assert(cp_index < method->constants()->length(), "sanity check"); - reconstituted_code->byte_at_put(bci + 1, (jbyte) cp_index); - break; - } - - case Bytecodes::_fast_aldc_w: { - int cpc_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); - int cp_index = method->constants()->object_to_cp_index(cpc_index); - assert(cp_index < method->constants()->length(), "sanity check"); - Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); - break; - } - } - } - } - - return (jbyteArray) JNIHandles::make_local(THREAD, reconstituted_code); -C2V_END - -C2V_VMENTRY(jint, exceptionTableLength, (JNIEnv *, jobject, jlong metaspace_method)) - ResourceMark rm; - methodHandle method = asMethod(metaspace_method); - return method->exception_table_length(); -C2V_END - -C2V_VMENTRY(jlong, exceptionTableStart, (JNIEnv *, jobject, jlong metaspace_method)) - ResourceMark rm; - methodHandle method = asMethod(metaspace_method); - assert(method->exception_table_length() != 0, "should be handled in Java code"); - return (jlong) (address) method->exception_table_start(); -C2V_END - -C2V_VMENTRY(jint, hasBalancedMonitors, (JNIEnv *, jobject, jlong metaspace_method)) - // Analyze the method to see if monitors are used properly. - methodHandle method(THREAD, asMethod(metaspace_method)); - { - EXCEPTION_MARK; - ResourceMark rm(THREAD); - GeneratePairingInfo gpi(method); - gpi.compute_map(CATCH); - if (!gpi.monitor_safe()) { - return false; - } - method->set_guaranteed_monitor_matching(); - } - return true; -C2V_END - -C2V_VMENTRY(jlong, getMetaspaceMethod, (JNIEnv *, jobject, jclass holder_handle, jint slot)) - oop java_class = JNIHandles::resolve(holder_handle); - Klass* holder = java_lang_Class::as_Klass(java_class); - methodHandle method = InstanceKlass::cast(holder)->method_with_idnum(slot); - return (jlong) (address) method(); -} - -C2V_VMENTRY(jlong, findUniqueConcreteMethod, (JNIEnv *, jobject, jlong metaspace_klass, jlong metaspace_method)) - methodHandle method = asMethod(metaspace_method); - KlassHandle holder = asKlass(metaspace_klass); - assert(!holder->is_interface(), "should be handled in Java code"); - ResourceMark rm; - MutexLocker locker(Compile_lock); - Method* ucm = Dependencies::find_unique_concrete_method(holder(), method()); - return (jlong) (address) ucm; -C2V_END - -C2V_VMENTRY(jlong, getKlassImplementor, (JNIEnv *, jobject, jlong metaspace_klass)) - InstanceKlass* klass = (InstanceKlass*) asKlass(metaspace_klass); - return (jlong) (address) klass->implementor(); -C2V_END - -C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jlong metaspace_method)) - methodHandle method = asMethod(metaspace_method); - return method->is_ignored_by_security_stack_walk(); -C2V_END - -C2V_VMENTRY(jboolean, canInlineMethod,(JNIEnv *, jobject, jlong metaspace_method)) - methodHandle method = asMethod(metaspace_method); - return !method->is_not_compilable() && !CompilerOracle::should_not_inline(method) && !method->dont_inline(); -C2V_END - -C2V_VMENTRY(jboolean, shouldInlineMethod,(JNIEnv *, jobject, jlong metaspace_method)) - methodHandle method = asMethod(metaspace_method); - return CompilerOracle::should_inline(method) || method->force_inline(); -C2V_END - -C2V_VMENTRY(jlong, lookupType, (JNIEnv*, jobject, jstring jname, jclass accessing_class, jboolean resolve)) - ResourceMark rm; - Handle name = JNIHandles::resolve(jname); - Symbol* class_name = java_lang_String::as_symbol(name, THREAD); - assert(class_name != NULL, "name to symbol creation failed"); - assert(class_name->size() > 1, "primitive types should be handled in Java code"); - - Klass* resolved_klass = NULL; - Handle class_loader; - Handle protection_domain; - if (JNIHandles::resolve(accessing_class) == NULL) { - THROW_(vmSymbols::java_lang_NullPointerException(), 0L); - } - Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class)); - class_loader = accessing_klass->class_loader(); - protection_domain = accessing_klass->protection_domain(); - - if (resolve) { - resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_0); - } else { - if (class_name->byte_at(0) == 'L' && - class_name->byte_at(class_name->utf8_length()-1) == ';') { - // This is a name from a signature. Strip off the trimmings. - // Call recursive to keep scope of strippedsym. - TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1, - class_name->utf8_length()-2, - CHECK_0); - resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0); - } else if (FieldType::is_array(class_name)) { - FieldArrayInfo fd; - // dimension and object_key in FieldArrayInfo are assigned as a side-effect - // of this call - BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0); - if (t == T_OBJECT) { - TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(), - class_name->utf8_length()-2-fd.dimension(), - CHECK_0); - // naked oop "k" is OK here -- we assign back into it - resolved_klass = SystemDictionary::find(strippedsym, - class_loader, - protection_domain, - CHECK_0); - if (resolved_klass != NULL) { - resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0); - } - } else { - resolved_klass = Universe::typeArrayKlassObj(t); - resolved_klass = TypeArrayKlass::cast(resolved_klass)->array_klass(fd.dimension(), CHECK_0); - } - } - } - return (jlong) (address) resolved_klass; -C2V_END - -C2V_VMENTRY(jobject, resolveConstantInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; - oop result = cp->resolve_constant_at(index, CHECK_NULL); - return JNIHandles::make_local(THREAD, result); -C2V_END - -C2V_VMENTRY(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; - oop result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); - return JNIHandles::make_local(THREAD, result); -C2V_END - -C2V_VMENTRY(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - return cp->name_and_type_ref_index_at(index); -C2V_END - -C2V_VMENTRY(jobject, lookupNameRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - Handle sym = java_lang_String::create_from_symbol(cp->name_ref_at(index), CHECK_NULL); - return JNIHandles::make_local(THREAD, sym()); -C2V_END - -C2V_VMENTRY(jobject, lookupSignatureRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - Handle sym = java_lang_String::create_from_symbol(cp->signature_ref_at(index), CHECK_NULL); - return JNIHandles::make_local(THREAD, sym()); -C2V_END - -C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - return cp->klass_ref_index_at(index); -C2V_END - -C2V_VMENTRY(jlong, constantPoolKlassAt, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; - return (jlong) (address) cp->klass_at(index, THREAD); -C2V_END - -C2V_VMENTRY(jlong, lookupKlassInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - KlassHandle loading_klass(cp->pool_holder()); - bool is_accessible = false; - KlassHandle klass = GraalEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); - if (klass.is_null()) { - // We have to lock the cpool to keep the oop from being resolved - // while we are accessing it. - MonitorLockerEx ml(cp->lock()); - constantTag tag = cp->tag_at(index); - if (tag.is_klass()) { - // The klass has been inserted into the constant pool - // very recently. - return (jlong) CompilerToVM::tag_pointer(cp->resolved_klass_at(index)); - } else if (tag.is_symbol()) { - return (jlong) CompilerToVM::tag_pointer(cp->symbol_at(index)); - } else { - assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag"); - return (jlong) CompilerToVM::tag_pointer(cp->unresolved_klass_at(index)); - } - } - return (jlong) CompilerToVM::tag_pointer(klass()); -C2V_END - -C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); - return JNIHandles::make_local(THREAD, appendix_oop); -C2V_END - -C2V_VMENTRY(jlong, lookupMethodInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - instanceKlassHandle pool_holder(cp->pool_holder()); - Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); - methodHandle method = GraalEnv::get_method_by_index(cp, index, bc, pool_holder); - return (jlong) (address) method(); -C2V_END - -C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; - return cp->remap_instruction_operand_from_cache(index); -C2V_END - -C2V_VMENTRY(jlong, resolveField, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode, jlongArray info_handle)) - ResourceMark rm; - constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; - Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); - fieldDescriptor result; - LinkResolver::resolve_field_access(result, cp, index, Bytecodes::java_code(code), true, false, CHECK_0); - typeArrayOop info = (typeArrayOop) JNIHandles::resolve(info_handle); - assert(info != NULL && info->length() == 2, "must be"); - info->long_at_put(0, (jlong) result.access_flags().as_int()); - info->long_at_put(1, (jlong) result.offset()); - return (jlong) (address) result.field_holder(); -C2V_END - -C2V_VMENTRY(jint, getVtableIndexForInterface, (JNIEnv *, jobject, jlong metaspace_klass, jlong metaspace_method)) - Klass* klass = (Klass*) metaspace_klass; - Method* method = (Method*) metaspace_method; - assert(!klass->is_interface(), ""); - return LinkResolver::vtable_index_of_interface_method(klass, method); -C2V_END - -C2V_VMENTRY(jlong, resolveMethod, (JNIEnv *, jobject, jlong metaspace_klass_receiver, jlong metaspace_method, jlong metaspace_klass_caller)) - Klass* recv_klass = (Klass*) metaspace_klass_receiver; - Klass* caller_klass = (Klass*) metaspace_klass_caller; - Method* method = (Method*) metaspace_method; - - if (recv_klass->oop_is_array() || (InstanceKlass::cast(recv_klass)->is_linked())) { - Klass* holder_klass = method->method_holder(); - Symbol* method_name = method->name(); - Symbol* method_signature = method->signature(); - - - if (holder_klass->is_interface()) { - // do link-time resolution to check all access rules. - methodHandle resolved_method; - LinkResolver::linktime_resolve_interface_method(resolved_method, holder_klass, method_name, method_signature, caller_klass, true, CHECK_AND_CLEAR_0); - if (resolved_method->is_private()) { - return (jlong) (address) NULL; - } - assert(recv_klass->is_subtype_of(holder_klass), ""); - // do actual lookup - methodHandle sel_method; - LinkResolver::lookup_instance_method_in_klasses(sel_method, recv_klass, - resolved_method->name(), - resolved_method->signature(), CHECK_AND_CLEAR_0); - return (jlong) (address) sel_method(); - } else { - // do link-time resolution to check all access rules. - methodHandle resolved_method; - LinkResolver::linktime_resolve_virtual_method(resolved_method, holder_klass, method_name, method_signature, caller_klass, true, CHECK_AND_CLEAR_0); - // do actual lookup (see LinkResolver::runtime_resolve_virtual_method) - int vtable_index = Method::invalid_vtable_index; - Method* selected_method; - - if (resolved_method->method_holder()->is_interface()) { // miranda method - vtable_index = LinkResolver::vtable_index_of_interface_method(holder_klass, resolved_method); - assert(vtable_index >= 0 , "we should have valid vtable index at this point"); - - InstanceKlass* inst = InstanceKlass::cast(recv_klass); - selected_method = inst->method_at_vtable(vtable_index); - } else { - // at this point we are sure that resolved_method is virtual and not - // a miranda method; therefore, it must have a valid vtable index. - assert(!resolved_method->has_itable_index(), ""); - vtable_index = resolved_method->vtable_index(); - // We could get a negative vtable_index for final methods, - // because as an optimization they are they are never put in the vtable, - // unless they override an existing method. - // If we do get a negative, it means the resolved method is the the selected - // method, and it can never be changed by an override. - if (vtable_index == Method::nonvirtual_vtable_index) { - assert(resolved_method->can_be_statically_bound(), "cannot override this method"); - selected_method = resolved_method(); - } else { - // recv_klass might be an arrayKlassOop but all vtables start at - // the same place. The cast is to avoid virtual call and assertion. - InstanceKlass* inst = (InstanceKlass*)recv_klass; - selected_method = inst->method_at_vtable(vtable_index); - } - } - return (jlong) (address) selected_method; - } - } - return (jlong) (address) NULL; -C2V_END - -C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jlong metaspace_klass)) - Klass* klass = (Klass*) metaspace_klass; - assert(klass != NULL, "method must not be called for primitive types"); - return Dependencies::find_finalizable_subclass(klass) != NULL; -C2V_END - -C2V_VMENTRY(jlong, getClassInitializer, (JNIEnv *, jobject, jlong metaspace_klass)) - InstanceKlass* klass = (InstanceKlass*) metaspace_klass; - return (jlong) (address) klass->class_initializer(); -C2V_END - -C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv*, jobject, jlong addr)) - address target_addr = (address) addr; - if (target_addr != 0x0) { - int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int)); - int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int)); - return MAX2(ABS(off_low), ABS(off_high)); - } - return -1; -C2V_END - -C2V_VMENTRY(void, doNotInlineOrCompile,(JNIEnv *, jobject, jlong metaspace_method)) - methodHandle method = asMethod(metaspace_method); - method->set_not_c1_compilable(); - method->set_not_c2_compilable(); - method->set_dont_inline(true); -C2V_END - -C2V_VMENTRY(jint, installCode, (JNIEnv *jniEnv, jobject, jobject compiled_code, jobject installed_code, jobject speculation_log)) - ResourceMark rm; - HandleMark hm; - Handle compiled_code_handle = JNIHandles::resolve(compiled_code); - CodeBlob* cb = NULL; - Handle installed_code_handle = JNIHandles::resolve(installed_code); - Handle speculation_log_handle = JNIHandles::resolve(speculation_log); - - TraceTime install_time("installCode", GraalCompiler::codeInstallTimer()); - CodeInstaller installer; - GraalEnv::CodeInstallResult result = installer.install(compiled_code_handle, cb, installed_code_handle, speculation_log_handle); - - if (PrintCodeCacheOnCompilation) { - stringStream s; - // Dump code cache into a buffer before locking the tty, - { - MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - CodeCache::print_summary(&s, false); - } - ttyLocker ttyl; - tty->print_raw_cr(s.as_string()); - } - - if (result != GraalEnv::ok) { - assert(cb == NULL, "should be"); - } else { - if (!installed_code_handle.is_null()) { - assert(installed_code_handle->is_a(InstalledCode::klass()), "wrong type"); - InstalledCode::set_address(installed_code_handle, (jlong) cb); - InstalledCode::set_version(installed_code_handle, InstalledCode::version(installed_code_handle) + 1); - oop comp_result = HotSpotCompiledCode::comp(compiled_code_handle); - if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { - HotSpotInstalledCode::set_size(installed_code_handle, cb->size()); - HotSpotInstalledCode::set_codeStart(installed_code_handle, (jlong) cb->code_begin()); - HotSpotInstalledCode::set_codeSize(installed_code_handle, cb->code_size()); - } - nmethod* nm = cb->as_nmethod_or_null(); - if (nm != NULL && installed_code_handle->is_scavengable()) { - assert(nm->detect_scavenge_root_oops(), "nm should be scavengable if installed_code is scavengable"); - if (!UseG1GC) { - assert(nm->on_scavenge_root_list(), "nm should be on scavengable list"); - } - } - } - } - return result; -C2V_END - -C2V_VMENTRY(void, notifyCompilationStatistics, (JNIEnv *jniEnv, jobject, jint id, jobject hotspot_method, jboolean osr, jint processedBytecodes, jlong time, jlong timeUnitsPerSecond, jobject installed_code)) - CompilerStatistics* stats = GraalCompiler::instance()->stats(); - - elapsedTimer timer = elapsedTimer(time, timeUnitsPerSecond); - if (osr) { - stats->_osr.update(timer, processedBytecodes); - } else { - stats->_standard.update(timer, processedBytecodes); - } - Handle installed_code_handle = JNIHandles::resolve(installed_code); - if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { - stats->_nmethods_size += HotSpotInstalledCode::size(installed_code_handle); - stats->_nmethods_code_size += HotSpotInstalledCode::codeSize(installed_code_handle); - } - - if (CITimeEach) { - methodHandle method = asMethod(HotSpotResolvedJavaMethodImpl::metaspaceMethod(hotspot_method)); - float bytes_per_sec = 1.0 * processedBytecodes / timer.seconds(); - tty->print_cr("%3d seconds: %f bytes/sec: %f (bytes %d)", - id, timer.seconds(), bytes_per_sec, processedBytecodes); - } -C2V_END - -C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject)) - CompilerStatistics* stats = GraalCompiler::instance()->stats(); - stats->_standard.reset(); - stats->_osr.reset(); -C2V_END - -C2V_VMENTRY(jobject, disassembleCodeBlob, (JNIEnv *jniEnv, jobject, jlong codeBlob)) - ResourceMark rm; - HandleMark hm; - - CodeBlob* cb = (CodeBlob*) (address) codeBlob; - if (cb == NULL) { - return NULL; - } - - // We don't want the stringStream buffer to resize during disassembly as it - // uses scoped resource memory. If a nested function called during disassembly uses - // a ResourceMark and the buffer expands within the scope of the mark, - // the buffer becomes garbage when that scope is exited. Experience shows that - // the disassembled code is typically about 10x the code size so a fixed buffer - // sized to 20x code size plus a fixed amount for header info should be sufficient. - int bufferSize = cb->code_size() * 20 + 1024; - char* buffer = NEW_RESOURCE_ARRAY(char, bufferSize); - stringStream st(buffer, bufferSize); - if (cb->is_nmethod()) { - nmethod* nm = (nmethod*) cb; - if (!nm->is_alive()) { - return NULL; - } - Disassembler::decode(nm, &st); - } else { - Disassembler::decode(cb, &st); - } - if (st.size() <= 0) { - return NULL; - } - - Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); - return JNIHandles::make_local(THREAD, result()); -C2V_END - -C2V_VMENTRY(jobject, getStackTraceElement, (JNIEnv*, jobject, jlong metaspace_method, int bci)) - ResourceMark rm; - HandleMark hm; - - methodHandle method = asMethod(metaspace_method); - oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); - return JNIHandles::make_local(THREAD, element); -C2V_END - -C2V_VMENTRY(jobject, executeCompiledMethodVarargs, (JNIEnv*, jobject, jobject args, jobject hotspotInstalledCode)) - ResourceMark rm; - HandleMark hm; - - jlong nmethodValue = InstalledCode::address(hotspotInstalledCode); - if (nmethodValue == 0L) { - THROW_(vmSymbols::com_oracle_jvmci_code_InvalidInstalledCodeException(), NULL); - } - nmethod* nm = (nmethod*) (address) nmethodValue; - methodHandle mh = nm->method(); - Symbol* signature = mh->signature(); - JavaCallArguments jca(mh->size_of_parameters()); - - JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); - JavaValue result(jap.get_ret_type()); - jca.set_alternative_target(nm); - JavaCalls::call(&result, mh, &jca, CHECK_NULL); - - if (jap.get_ret_type() == T_VOID) { - return NULL; - } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) { - return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); - } else { - jvalue *value = (jvalue *) result.get_value_addr(); - // Narrow the value down if required (Important on big endian machines) - switch (jap.get_ret_type()) { - case T_BOOLEAN: - value->z = (jboolean) value->i; - break; - case T_BYTE: - value->b = (jbyte) value->i; - break; - case T_CHAR: - value->c = (jchar) value->i; - break; - case T_SHORT: - value->s = (jshort) value->i; - break; - } - oop o = java_lang_boxing_object::create(jap.get_ret_type(), value, CHECK_NULL); - return JNIHandles::make_local(THREAD, o); - } -C2V_END - -C2V_VMENTRY(jlongArray, getLineNumberTable, (JNIEnv *, jobject, jlong metaspace_method)) - Method* method = (Method*) metaspace_method; - if (!method->has_linenumber_table()) { - return NULL; - } - u2 num_entries = 0; - CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table()); - while (streamForSize.read_pair()) { - num_entries++; - } - - CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); - typeArrayOop result = oopFactory::new_longArray(2 * num_entries, CHECK_NULL); - - int i = 0; - jlong value; - while (stream.read_pair()) { - value = ((long) stream.bci()); - result->long_at_put(i, value); - value = ((long) stream.line()); - result->long_at_put(i + 1, value); - i += 2; - } - - return (jlongArray) JNIHandles::make_local(THREAD, result); -C2V_END - -C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jlong metaspace_method)) - ResourceMark rm; - Method* method = (Method*) metaspace_method; - if (!method->has_localvariable_table()) { - return 0; - } - return (jlong) (address) method->localvariable_table_start(); -C2V_END - -C2V_VMENTRY(jint, getLocalVariableTableLength, (JNIEnv *, jobject, jlong metaspace_method)) - ResourceMark rm; - Method* method = (Method*) metaspace_method; - return method->localvariable_table_length(); -C2V_END - -C2V_VMENTRY(void, reprofile, (JNIEnv*, jobject, jlong metaspace_method)) - Method* method = asMethod(metaspace_method); - MethodCounters* mcs = method->method_counters(); - if (mcs != NULL) { - mcs->clear_counters(); - } - NOT_PRODUCT(method->set_compiled_invocation_count(0)); - - nmethod* code = method->code(); - if (code != NULL) { - code->make_not_entrant(); - } - - MethodData* method_data = method->method_data(); - if (method_data == NULL) { - ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); - method_data = MethodData::allocate(loader_data, method, CHECK); - method->set_method_data(method_data); - } else { - method_data->initialize(); - } -C2V_END - - -C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv*, jobject, jobject hotspotInstalledCode)) - jlong nativeMethod = InstalledCode::address(hotspotInstalledCode); - nmethod* m = (nmethod*)nativeMethod; - if (m != NULL && !m->is_not_entrant()) { - m->mark_for_deoptimization(); - VM_Deoptimize op; - VMThread::execute(&op); - } - InstalledCode::set_address(hotspotInstalledCode, 0); -C2V_END - -C2V_VMENTRY(jobject, getJavaMirror, (JNIEnv* env, jobject, jlong metaspace_klass)) - Klass* klass = asKlass(metaspace_klass); - return JNIHandles::make_local(THREAD, klass->java_mirror()); -C2V_END - -C2V_VMENTRY(jlong, readUnsafeKlassPointer, (JNIEnv*, jobject, jobject o)) - oop resolved_o = JNIHandles::resolve(o); - jlong klass = (jlong)(address)resolved_o->klass(); - return klass; -C2V_END - -C2V_VMENTRY(jobject, readUncompressedOop, (JNIEnv*, jobject, jlong addr)) - oop ret = oopDesc::load_decode_heap_oop((oop*)(address)addr); - return JNIHandles::make_local(THREAD, ret); -C2V_END - -C2V_VMENTRY(jlongArray, collectCounters, (JNIEnv*, jobject)) - typeArrayOop arrayOop = oopFactory::new_longArray(GraalCounterSize, CHECK_NULL); - JavaThread::collect_counters(arrayOop); - return (jlongArray) JNIHandles::make_local(THREAD, arrayOop); -C2V_END - -C2V_VMENTRY(int, allocateCompileId, (JNIEnv*, jobject, jlong metaspace_method, int entry_bci)) - HandleMark hm; - ResourceMark rm; - Method* method = (Method*) metaspace_method; - return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci); -C2V_END - - -C2V_VMENTRY(jboolean, isMature, (JNIEnv*, jobject, jlong metaspace_method_data)) - MethodData* mdo = asMethodData(metaspace_method_data); - return mdo != NULL && mdo->is_mature(); -C2V_END - -C2V_VMENTRY(jboolean, hasCompiledCodeForOSR, (JNIEnv*, jobject, jlong metaspace_method, int entry_bci, int comp_level)) - Method* method = asMethod(metaspace_method); - return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != NULL; -C2V_END - -C2V_VMENTRY(jlong, getTimeStamp, (JNIEnv*, jobject)) - // tty->time_stamp is the time since VM start which should be used - // for all HotSpot log output when a timestamp is required. - return tty->time_stamp().milliseconds(); -C2V_END - -C2V_VMENTRY(jobject, getSymbol, (JNIEnv*, jobject, jlong metaspaceSymbol)) - Handle sym = java_lang_String::create_from_symbol((Symbol*)(address)metaspaceSymbol, CHECK_NULL); - return JNIHandles::make_local(THREAD, sym()); -C2V_END - -bool matches(jlongArray methods, Method* method) { - typeArrayOop methods_oop = (typeArrayOop) JNIHandles::resolve(methods); - - for (int i = 0; i < methods_oop->length(); i++) { - if (methods_oop->long_at(i) == (jlong) method) { - return true; - } - } - return false; -} - -C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv*, jobject compilerToVM, jobject hs_frame, jlongArray methods, jint initialSkip)) - ResourceMark rm; - - if (!thread->has_last_Java_frame()) return NULL; - Handle result = InstanceKlass::cast(HotSpotStackFrameReference::klass())->allocate_instance(thread); - HotSpotStackFrameReference::klass()->initialize(thread); - - StackFrameStream fst(thread); - if (hs_frame != NULL) { - // look for the correct stack frame if one is given - intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame); - while (fst.current()->sp() != stack_pointer && !fst.is_done()) { - fst.next(); - } - if (fst.current()->sp() != stack_pointer) { - THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "stack frame not found") - } - } - - int frame_number = 0; - vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); - if (hs_frame != NULL) { - // look for the correct vframe within the stack frame if one is given - int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame); - while (frame_number < last_frame_number) { - if (vf->is_top()) { - THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "invalid frame number") - } - vf = vf->sender(); - frame_number ++; - } - // move one frame forward - if (vf->is_top()) { - if (fst.is_done()) { - return NULL; - } - fst.next(); - vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); - frame_number = 0; - } else { - vf = vf->sender(); - frame_number++; - } - } - - while (true) { - // look for the given method - while (true) { - StackValueCollection* locals = NULL; - if (vf->is_compiled_frame()) { - // compiled method frame - compiledVFrame* cvf = compiledVFrame::cast(vf); - if (methods == NULL || matches(methods, cvf->method())) { - if (initialSkip > 0) { - initialSkip --; - } else { - GrowableArray<ScopeValue*>* objects = cvf->scope()->objects(); - bool reallocated = false; - if (objects != NULL) { - reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD); - Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, reallocated); - - GrowableArray<ScopeValue*>* local_values = cvf->scope()->locals(); - typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread); - for (int i = 0; i < local_values->length(); i++) { - ScopeValue* value = local_values->at(i); - if (value->is_object()) { - array->bool_at_put(i, true); - } - } - HotSpotStackFrameReference::set_localIsVirtual(result, array()); - } else { - HotSpotStackFrameReference::set_localIsVirtual(result, NULL); - } - - locals = cvf->locals(); - HotSpotStackFrameReference::set_bci(result, cvf->bci()); - HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) cvf->method()); - } - } - } else if (vf->is_interpreted_frame()) { - // interpreted method frame - interpretedVFrame* ivf = interpretedVFrame::cast(vf); - if (methods == NULL || matches(methods, ivf->method())) { - if (initialSkip > 0) { - initialSkip --; - } else { - locals = ivf->locals(); - HotSpotStackFrameReference::set_bci(result, ivf->bci()); - HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) ivf->method()); - HotSpotStackFrameReference::set_localIsVirtual(result, NULL); - } - } - } - - // locals != NULL means that we found a matching frame and result is already partially initialized - if (locals != NULL) { - HotSpotStackFrameReference::set_compilerToVM(result, JNIHandles::resolve(compilerToVM)); - HotSpotStackFrameReference::set_stackPointer(result, (jlong) fst.current()->sp()); - HotSpotStackFrameReference::set_frameNumber(result, frame_number); - - // initialize the locals array - objArrayHandle array = oopFactory::new_objectArray(locals->size(), thread); - for (int i = 0; i < locals->size(); i++) { - StackValue* var = locals->at(i); - if (var->type() == T_OBJECT) { - array->obj_at_put(i, locals->at(i)->get_obj()()); - } - } - HotSpotStackFrameReference::set_locals(result, array()); - - return JNIHandles::make_local(thread, result()); - } - - if (vf->is_top()) { - break; - } - frame_number++; - vf = vf->sender(); - } // end of vframe loop - - if (fst.is_done()) { - break; - } - fst.next(); - vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); - frame_number = 0; - } // end of frame loop - - // the end was reached without finding a matching method - return NULL; -C2V_END - -C2V_VMENTRY(void, resolveInvokeDynamic, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) - ConstantPool* cp = (ConstantPool*)metaspace_constant_pool; - CallInfo callInfo; - LinkResolver::resolve_invokedynamic(callInfo, cp, index, CHECK); - ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index); - cp_cache_entry->set_dynamic_call(cp, callInfo); -C2V_END - -C2V_VMENTRY(jboolean, shouldDebugNonSafepoints, (JNIEnv*, jobject)) - //see compute_recording_non_safepoints in debugInfroRec.cpp - if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) { - return true; - } - return DebugNonSafepoints; -C2V_END - -// public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); -C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv*, jobject, jobject hs_frame, bool invalidate)) - ResourceMark rm; - - if (hs_frame == NULL) { - THROW_MSG(vmSymbols::java_lang_NullPointerException(), "stack frame is null") - } - - HotSpotStackFrameReference::klass()->initialize(thread); - - // look for the given stack frame - StackFrameStream fst(thread); - intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame); - while (fst.current()->sp() != stack_pointer && !fst.is_done()) { - fst.next(); - } - if (fst.current()->sp() != stack_pointer) { - THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found") - } - - if (invalidate) { - assert(fst.current()->cb()->is_nmethod(), "nmethod expected"); - ((nmethod*) fst.current()->cb())->make_not_entrant(); - } - Deoptimization::deoptimize(thread, *fst.current(), fst.register_map(), Deoptimization::Reason_none); - - vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); - if (!vf->is_compiled_frame()) { - THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected") - } - - GrowableArray<compiledVFrame*>* virtualFrames = new GrowableArray<compiledVFrame*>(10); - while (true) { - assert(vf->is_compiled_frame(), "Wrong frame type"); - virtualFrames->push(compiledVFrame::cast(vf)); - if (vf->is_top()) { - break; - } - vf = vf->sender(); - } - - int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame); - if (last_frame_number >= virtualFrames->length()) { - THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "invalid frame number") - } - - // Reallocate the non-escaping objects and restore their fields. - assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope"); - GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects(); - - if (objects == NULL) { - // no objects to materialize - return; - } - - bool reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD); - Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, reallocated); - - for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) { - compiledVFrame* cvf = virtualFrames->at(frame_index); - - GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals(); - StackValueCollection* locals = cvf->locals(); - - if (locals != NULL) { - for (int i2 = 0; i2 < locals->size(); i2++) { - StackValue* var = locals->at(i2); - if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) { - jvalue val; - val.l = (jobject) locals->at(i2)->get_obj()(); - cvf->update_local(T_OBJECT, i2, val); - } - } - } - } - - // all locals are materialized by now - HotSpotStackFrameReference::set_localIsVirtual(hs_frame, NULL); - - // update the locals array - objArrayHandle array = HotSpotStackFrameReference::locals(hs_frame); - StackValueCollection* locals = virtualFrames->at(last_frame_number)->locals(); - for (int i = 0; i < locals->size(); i++) { - StackValue* var = locals->at(i); - if (var->type() == T_OBJECT) { - array->obj_at_put(i, locals->at(i)->get_obj()()); - } - } -C2V_END - -C2V_VMENTRY(void, writeDebugOutput, (JNIEnv*, jobject, jbyteArray bytes, jint offset, jint length)) - while (length > 0) { - jbyte* start = ((typeArrayOop) JNIHandles::resolve(bytes))->byte_at_addr(offset); - tty->write((char*) start, MIN2(length, O_BUFLEN)); - length -= O_BUFLEN; - offset += O_BUFLEN; - } -C2V_END - -C2V_VMENTRY(void, flushDebugOutput, (JNIEnv*, jobject)) - tty->flush(); -C2V_END - - -#define CC (char*) /*cast a literal from (const char*)*/ -#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) - -#define TYPE "Lcom/oracle/jvmci/meta/JavaType;" -#define METHOD "Lcom/oracle/jvmci/meta/JavaMethod;" -#define FIELD "Lcom/oracle/jvmci/meta/JavaField;" -#define SPECULATION_LOG "Lcom/oracle/jvmci/code/SpeculationLog;" -#define STRING "Ljava/lang/String;" -#define OBJECT "Ljava/lang/Object;" -#define CLASS "Ljava/lang/Class;" -#define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" -#define INSTALLED_CODE "Lcom/oracle/jvmci/code/InstalledCode;" -#define RESOLVED_METHOD "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;" -#define HS_RESOLVED_METHOD "Lcom/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod;" -#define HS_COMPILED_CODE "Lcom/oracle/jvmci/hotspot/HotSpotCompiledCode;" -#define HS_CONFIG "Lcom/oracle/jvmci/hotspot/HotSpotVMConfig;" -#define HS_STACK_FRAME_REF "Lcom/oracle/jvmci/hotspot/HotSpotStackFrameReference;" -#define METASPACE_KLASS "J" -#define METASPACE_METHOD "J" -#define METASPACE_METHOD_DATA "J" -#define METASPACE_CONSTANT_POOL "J" - -JNINativeMethod CompilerToVM_methods[] = { - {CC"getBytecode", CC"("METASPACE_METHOD")[B", FN_PTR(getBytecode)}, - {CC"exceptionTableStart", CC"("METASPACE_METHOD")J", FN_PTR(exceptionTableStart)}, - {CC"exceptionTableLength", CC"("METASPACE_METHOD")I", FN_PTR(exceptionTableLength)}, - {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)}, - {CC"findUniqueConcreteMethod", CC"("METASPACE_KLASS METASPACE_METHOD")"METASPACE_METHOD, FN_PTR(findUniqueConcreteMethod)}, - {CC"getKlassImplementor", CC"("METASPACE_KLASS")"METASPACE_KLASS, FN_PTR(getKlassImplementor)}, - {CC"getStackTraceElement", CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)}, - {CC"methodIsIgnoredBySecurityStackWalk", CC"("METASPACE_METHOD")Z", FN_PTR(methodIsIgnoredBySecurityStackWalk)}, - {CC"doNotInlineOrCompile", CC"("METASPACE_METHOD")V", FN_PTR(doNotInlineOrCompile)}, - {CC"canInlineMethod", CC"("METASPACE_METHOD")Z", FN_PTR(canInlineMethod)}, - {CC"shouldInlineMethod", CC"("METASPACE_METHOD")Z", FN_PTR(shouldInlineMethod)}, - {CC"lookupType", CC"("STRING CLASS"Z)"METASPACE_KLASS, FN_PTR(lookupType)}, - {CC"resolveConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolveConstantInPool)}, - {CC"resolvePossiblyCachedConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolvePossiblyCachedConstantInPool)}, - {CC"lookupNameRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"STRING, FN_PTR(lookupNameRefInPool)}, - {CC"lookupNameAndTypeRefIndexInPool", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(lookupNameAndTypeRefIndexInPool)}, - {CC"lookupSignatureRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"STRING, FN_PTR(lookupSignatureRefInPool)}, - {CC"lookupKlassRefIndexInPool", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(lookupKlassRefIndexInPool)}, - {CC"constantPoolKlassAt", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(constantPoolKlassAt)}, - {CC"lookupKlassInPool", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(lookupKlassInPool)}, - {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupAppendixInPool)}, - {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METASPACE_METHOD, FN_PTR(lookupMethodInPool)}, - {CC"constantPoolRemapInstructionOperandFromCache", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(constantPoolRemapInstructionOperandFromCache)}, - {CC"resolveField", CC"("METASPACE_CONSTANT_POOL"IB[J)"METASPACE_KLASS, FN_PTR(resolveField)}, - {CC"resolveInvokeDynamic", CC"("METASPACE_CONSTANT_POOL"I)V", FN_PTR(resolveInvokeDynamic)}, - {CC"resolveMethod", CC"("METASPACE_KLASS METASPACE_METHOD METASPACE_KLASS")"METASPACE_METHOD, FN_PTR(resolveMethod)}, - {CC"getVtableIndexForInterface", CC"("METASPACE_KLASS METASPACE_METHOD")I", FN_PTR(getVtableIndexForInterface)}, - {CC"getClassInitializer", CC"("METASPACE_KLASS")"METASPACE_METHOD, FN_PTR(getClassInitializer)}, - {CC"hasFinalizableSubclass", CC"("METASPACE_KLASS")Z", FN_PTR(hasFinalizableSubclass)}, - {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, - {CC"getMetaspaceMethod", CC"("CLASS"I)"METASPACE_METHOD, FN_PTR(getMetaspaceMethod)}, - {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)}, - {CC"installCode", CC"("HS_COMPILED_CODE INSTALLED_CODE SPECULATION_LOG")I", FN_PTR(installCode)}, - {CC"notifyCompilationStatistics", CC"(I"HS_RESOLVED_METHOD"ZIJJ"INSTALLED_CODE")V", FN_PTR(notifyCompilationStatistics)}, - {CC"resetCompilationStatistics", CC"()V", FN_PTR(resetCompilationStatistics)}, - {CC"disassembleCodeBlob", CC"(J)"STRING, FN_PTR(disassembleCodeBlob)}, - {CC"executeCompiledMethodVarargs", CC"(["OBJECT INSTALLED_CODE")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, - {CC"getLineNumberTable", CC"("METASPACE_METHOD")[J", FN_PTR(getLineNumberTable)}, - {CC"getLocalVariableTableStart", CC"("METASPACE_METHOD")J", FN_PTR(getLocalVariableTableStart)}, - {CC"getLocalVariableTableLength", CC"("METASPACE_METHOD")I", FN_PTR(getLocalVariableTableLength)}, - {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, - {CC"invalidateInstalledCode", CC"("INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)}, - {CC"getJavaMirror", CC"("METASPACE_KLASS")"CLASS, FN_PTR(getJavaMirror)}, - {CC"readUnsafeKlassPointer", CC"("OBJECT")J", FN_PTR(readUnsafeKlassPointer)}, - {CC"readUncompressedOop", CC"(J)"OBJECT, FN_PTR(readUncompressedOop)}, - {CC"collectCounters", CC"()[J", FN_PTR(collectCounters)}, - {CC"allocateCompileId", CC"("METASPACE_METHOD"I)I", FN_PTR(allocateCompileId)}, - {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)}, - {CC"hasCompiledCodeForOSR", CC"("METASPACE_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)}, - {CC"getSymbol", CC"(J)"STRING, FN_PTR(getSymbol)}, - {CC"getTimeStamp", CC"()J", FN_PTR(getTimeStamp)}, - {CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "[JI)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)}, - {CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)}, - {CC"shouldDebugNonSafepoints", CC"()Z", FN_PTR(shouldDebugNonSafepoints)}, - {CC"writeDebugOutput", CC"([BII)V", FN_PTR(writeDebugOutput)}, - {CC"flushDebugOutput", CC"()V", FN_PTR(flushDebugOutput)}, -}; - -int CompilerToVM_methods_count() { - return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); -} -
--- a/src/share/vm/graal/graalCompilerToVM.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2011, 2013, 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. - */ - -#ifndef SHARE_VM_GRAAL_GRAAL_COMPILER_TO_VM_HPP -#define SHARE_VM_GRAAL_GRAAL_COMPILER_TO_VM_HPP - -#include "prims/jni.h" -#include "runtime/javaCalls.hpp" - -class CompilerToVM { -public: - /** - * Tag bits used by lookupKlassInPool to distinguish the types in Java. - */ - enum Tags { - KLASS_TAG = 0x0, - SYMBOL_TAG = 0x1 - }; - - static intptr_t tag_pointer(Klass* klass) { - return ((intptr_t) klass) | KLASS_TAG; - } - - static intptr_t tag_pointer(Symbol* symbol) { - return ((intptr_t) symbol) | SYMBOL_TAG; - } - - // nothing here - no need to define the jni method implementations in a header file -}; - -extern JNINativeMethod CompilerToVM_methods[]; -int CompilerToVM_methods_count(); - -inline Method* asMethod(jlong metaspaceMethod) { - return (Method*) (address) metaspaceMethod; -} - -inline MethodData* asMethodData(jlong metaspaceMethodData) { - return (MethodData*) (address) metaspaceMethodData; -} - -inline Klass* asKlass(jlong metaspaceKlass) { - return (Klass*) (address) metaspaceKlass; -} - -class JavaArgumentUnboxer : public SignatureIterator { - protected: - JavaCallArguments* _jca; - arrayOop _args; - int _index; - - oop next_arg(BasicType expectedType) { - assert(_index < _args->length(), "out of bounds"); - oop arg=((objArrayOop) (_args))->obj_at(_index++); - assert(expectedType == T_OBJECT || java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch"); - return arg; - } - - public: - JavaArgumentUnboxer(Symbol* signature, JavaCallArguments* jca, arrayOop args, bool is_static) : SignatureIterator(signature) { - this->_return_type = T_ILLEGAL; - _jca = jca; - _index = 0; - _args = args; - if (!is_static) { - _jca->push_oop(next_arg(T_OBJECT)); - } - iterate(); - assert(_index == args->length(), "arg count mismatch with signature"); - } - - inline void do_bool() { if (!is_return_type()) _jca->push_int(next_arg(T_BOOLEAN)->bool_field(java_lang_boxing_object::value_offset_in_bytes(T_BOOLEAN))); } - inline void do_char() { if (!is_return_type()) _jca->push_int(next_arg(T_CHAR)->char_field(java_lang_boxing_object::value_offset_in_bytes(T_CHAR))); } - inline void do_short() { if (!is_return_type()) _jca->push_int(next_arg(T_SHORT)->short_field(java_lang_boxing_object::value_offset_in_bytes(T_SHORT))); } - inline void do_byte() { if (!is_return_type()) _jca->push_int(next_arg(T_BYTE)->byte_field(java_lang_boxing_object::value_offset_in_bytes(T_BYTE))); } - inline void do_int() { if (!is_return_type()) _jca->push_int(next_arg(T_INT)->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT))); } - - inline void do_long() { if (!is_return_type()) _jca->push_long(next_arg(T_LONG)->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG))); } - inline void do_float() { if (!is_return_type()) _jca->push_float(next_arg(T_FLOAT)->float_field(java_lang_boxing_object::value_offset_in_bytes(T_FLOAT))); } - inline void do_double() { if (!is_return_type()) _jca->push_double(next_arg(T_DOUBLE)->double_field(java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE))); } - - inline void do_object() { _jca->push_oop(next_arg(T_OBJECT)); } - inline void do_object(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); } - inline void do_array(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); } - inline void do_void() { } -}; - -#endif // SHARE_VM_GRAAL_GRAAL_COMPILER_TO_VM_HPP
--- a/src/share/vm/graal/graalEnv.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,617 +0,0 @@ -/* - * Copyright (c) 1999, 2011, 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. - * - */ - -#include "precompiled.hpp" -#include "graal/graalEnv.hpp" -#include "classfile/systemDictionary.hpp" -#include "classfile/vmSymbols.hpp" -#include "code/scopeDesc.hpp" -#include "runtime/sweeper.hpp" -#include "compiler/compileBroker.hpp" -#include "compiler/compileLog.hpp" -#include "compiler/compilerOracle.hpp" -#include "interpreter/linkResolver.hpp" -#include "memory/allocation.inline.hpp" -#include "memory/oopFactory.hpp" -#include "memory/universe.inline.hpp" -#include "oops/methodData.hpp" -#include "oops/objArrayKlass.hpp" -#include "prims/jvmtiExport.hpp" -#include "runtime/init.hpp" -#include "runtime/reflection.hpp" -#include "runtime/sharedRuntime.hpp" -#include "utilities/dtrace.hpp" -#include "graal/graalRuntime.hpp" -#include "graal/graalJavaAccess.hpp" - -GraalEnv::GraalEnv(CompileTask* task, int system_dictionary_modification_counter) { - _task = task; - _system_dictionary_modification_counter = system_dictionary_modification_counter; - { - // Get Jvmti capabilities under lock to get consistent values. - MutexLocker mu(JvmtiThreadState_lock); - _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint(); - _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables(); - _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions(); - } -} - -// ------------------------------------------------------------------ -// Note: the logic of this method should mirror the logic of -// constantPoolOopDesc::verify_constant_pool_resolve. -bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { - if (accessing_klass->oop_is_objArray()) { - accessing_klass = ObjArrayKlass::cast(accessing_klass())->bottom_klass(); - } - if (!accessing_klass->oop_is_instance()) { - return true; - } - - if (resolved_klass->oop_is_objArray()) { - // Find the element klass, if this is an array. - resolved_klass = ObjArrayKlass::cast(resolved_klass())->bottom_klass(); - } - if (resolved_klass->oop_is_instance()) { - return Reflection::verify_class_access(accessing_klass(), resolved_klass(), true); - } - return true; -} - -// ------------------------------------------------------------------ -KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle& accessing_klass, - constantPoolHandle& cpool, - Symbol* sym, - bool require_local) { - GRAAL_EXCEPTION_CONTEXT; - - // Now we need to check the SystemDictionary - if (sym->byte_at(0) == 'L' && - sym->byte_at(sym->utf8_length()-1) == ';') { - // This is a name from a signature. Strip off the trimmings. - // Call recursive to keep scope of strippedsym. - TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, - sym->utf8_length()-2, - CHECK_(KlassHandle())); - return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); - } - - Handle loader(THREAD, (oop)NULL); - Handle domain(THREAD, (oop)NULL); - if (!accessing_klass.is_null()) { - loader = Handle(THREAD, accessing_klass->class_loader()); - domain = Handle(THREAD, accessing_klass->protection_domain()); - } - - KlassHandle found_klass; - { - ttyUnlocker ttyul; // release tty lock to avoid ordering problems - MutexLocker ml(Compile_lock); - Klass* kls; - if (!require_local) { - kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_(KlassHandle())); - } else { - kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_(KlassHandle())); - } - found_klass = KlassHandle(THREAD, kls); - } - - // If we fail to find an array klass, look again for its element type. - // The element type may be available either locally or via constraints. - // In either case, if we can find the element type in the system dictionary, - // we must build an array type around it. The CI requires array klasses - // to be loaded if their element klasses are loaded, except when memory - // is exhausted. - if (sym->byte_at(0) == '[' && - (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) { - // We have an unloaded array. - // Build it on the fly if the element class exists. - TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, - sym->utf8_length()-1, - CHECK_(KlassHandle())); - - // Get element Klass recursively. - KlassHandle elem_klass = - get_klass_by_name_impl(accessing_klass, - cpool, - elem_sym, - require_local); - if (!elem_klass.is_null()) { - // Now make an array for it - return elem_klass->array_klass(CHECK_(KlassHandle())); - } - } - - if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) { - // Look inside the constant pool for pre-resolved class entries. - for (int i = cpool->length() - 1; i >= 1; i--) { - if (cpool->tag_at(i).is_klass()) { - Klass* kls = cpool->resolved_klass_at(i); - if (kls->name() == sym) { - return kls; - } - } - } - } - - return found_klass(); -} - -// ------------------------------------------------------------------ -KlassHandle GraalEnv::get_klass_by_name(KlassHandle& accessing_klass, - Symbol* klass_name, - bool require_local) { - ResourceMark rm; - constantPoolHandle cpool; - return get_klass_by_name_impl(accessing_klass, - cpool, - klass_name, - require_local); -} - -// ------------------------------------------------------------------ -// Implementation of get_klass_by_index. -KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool, - int index, - bool& is_accessible, - KlassHandle& accessor) { - GRAAL_EXCEPTION_CONTEXT; - KlassHandle klass (THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); - Symbol* klass_name = NULL; - if (klass.is_null()) { - // The klass has not been inserted into the constant pool. - // Try to look it up by name. - { - // We have to lock the cpool to keep the oop from being resolved - // while we are accessing it. - MonitorLockerEx ml(cpool->lock()); - - constantTag tag = cpool->tag_at(index); - if (tag.is_klass()) { - // The klass has been inserted into the constant pool - // very recently. - klass = KlassHandle(THREAD, cpool->resolved_klass_at(index)); - } else if (tag.is_symbol()) { - klass_name = cpool->symbol_at(index); - } else { - assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag"); - klass_name = cpool->unresolved_klass_at(index); - } - } - } - - if (klass.is_null()) { - // Not found in constant pool. Use the name to do the lookup. - KlassHandle k = get_klass_by_name_impl(accessor, - cpool, - klass_name, - false); - // Calculate accessibility the hard way. - if (k.is_null()) { - is_accessible = false; - } else if (k->class_loader() != accessor->class_loader() && - get_klass_by_name_impl(accessor, cpool, k->name(), true).is_null()) { - // Loaded only remotely. Not linked yet. - is_accessible = false; - } else { - // Linked locally, and we must also check public/private, etc. - is_accessible = check_klass_accessibility(accessor, k); - } - if (!is_accessible) { - return KlassHandle(); - } - return k; - } - - // It is known to be accessible, since it was found in the constant pool. - is_accessible = true; - return klass; -} - -// ------------------------------------------------------------------ -// Get a klass from the constant pool. -KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle& cpool, - int index, - bool& is_accessible, - KlassHandle& accessor) { - ResourceMark rm; - KlassHandle result = get_klass_by_index_impl(cpool, index, is_accessible, accessor); - return result; -} - -// ------------------------------------------------------------------ -// Implementation of get_field_by_index. -// -// Implementation note: the results of field lookups are cached -// in the accessor klass. -void GraalEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc, - int index) { - GRAAL_EXCEPTION_CONTEXT; - - assert(klass->is_linked(), "must be linked before using its constant-pool"); - - constantPoolHandle cpool(thread, klass->constants()); - - // Get the field's name, signature, and type. - Symbol* name = cpool->name_ref_at(index); - - int nt_index = cpool->name_and_type_ref_index_at(index); - int sig_index = cpool->signature_ref_index_at(nt_index); - Symbol* signature = cpool->symbol_at(sig_index); - - // Get the field's declared holder. - int holder_index = cpool->klass_ref_index_at(index); - bool holder_is_accessible; - KlassHandle declared_holder = get_klass_by_index(cpool, holder_index, - holder_is_accessible, - klass); - - // The declared holder of this field may not have been loaded. - // Bail out with partial field information. - if (!holder_is_accessible) { - return; - } - - - // Perform the field lookup. - Klass* canonical_holder = - InstanceKlass::cast(declared_holder())->find_field(name, signature, &field_desc); - if (canonical_holder == NULL) { - return; - } - - assert(canonical_holder == field_desc.field_holder(), "just checking"); -} - -// ------------------------------------------------------------------ -// Get a field by index from a klass's constant pool. -void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, int index) { - ResourceMark rm; - return get_field_by_index_impl(accessor, fd, index); -} - -// ------------------------------------------------------------------ -// Perform an appropriate method lookup based on accessor, holder, -// name, signature, and bytecode. -methodHandle GraalEnv::lookup_method(instanceKlassHandle& h_accessor, - instanceKlassHandle& h_holder, - Symbol* name, - Symbol* sig, - Bytecodes::Code bc) { - GRAAL_EXCEPTION_CONTEXT; - LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL)); - methodHandle dest_method; - switch (bc) { - case Bytecodes::_invokestatic: - dest_method = - LinkResolver::resolve_static_call_or_null(h_holder, name, sig, h_accessor); - break; - case Bytecodes::_invokespecial: - dest_method = - LinkResolver::resolve_special_call_or_null(h_holder, name, sig, h_accessor); - break; - case Bytecodes::_invokeinterface: - dest_method = - LinkResolver::linktime_resolve_interface_method_or_null(h_holder, name, sig, - h_accessor, true); - break; - case Bytecodes::_invokevirtual: - dest_method = - LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, name, sig, - h_accessor, true); - break; - default: ShouldNotReachHere(); - } - - return dest_method; -} - - -// ------------------------------------------------------------------ -methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle& cpool, - int index, Bytecodes::Code bc, - instanceKlassHandle& accessor) { - if (bc == Bytecodes::_invokedynamic) { - ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index); - bool is_resolved = !cpce->is_f1_null(); - if (is_resolved) { - // Get the invoker Method* from the constant pool. - // (The appendix argument, if any, will be noted in the method's signature.) - Method* adapter = cpce->f1_as_method(); - return methodHandle(adapter); - } - - return NULL; - } - - int holder_index = cpool->klass_ref_index_at(index); - bool holder_is_accessible; - KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); - - // Get the method's name and signature. - Symbol* name_sym = cpool->name_ref_at(index); - Symbol* sig_sym = cpool->signature_ref_at(index); - - if (cpool->has_preresolution() - || (holder() == SystemDictionary::MethodHandle_klass() && - MethodHandles::is_signature_polymorphic_name(holder(), name_sym))) { - // Short-circuit lookups for JSR 292-related call sites. - // That is, do not rely only on name-based lookups, because they may fail - // if the names are not resolvable in the boot class loader (7056328). - switch (bc) { - case Bytecodes::_invokevirtual: - case Bytecodes::_invokeinterface: - case Bytecodes::_invokespecial: - case Bytecodes::_invokestatic: - { - Method* m = ConstantPool::method_at_if_loaded(cpool, index); - if (m != NULL) { - return m; - } - } - break; - } - } - - if (holder_is_accessible) { // Our declared holder is loaded. - instanceKlassHandle lookup = get_instance_klass_for_declared_method_holder(holder); - methodHandle m = lookup_method(accessor, lookup, name_sym, sig_sym, bc); - if (!m.is_null() && - (bc == Bytecodes::_invokestatic - ? InstanceKlass::cast(m->method_holder())->is_not_initialized() - : !InstanceKlass::cast(m->method_holder())->is_loaded())) { - m = NULL; - } - if (!m.is_null()) { - // We found the method. - return m; - } - } - - // Either the declared holder was not loaded, or the method could - // not be found. - - return NULL; -} - -// ------------------------------------------------------------------ -instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle& method_holder) { - // For the case of <array>.clone(), the method holder can be an ArrayKlass* - // instead of an InstanceKlass*. For that case simply pretend that the - // declared holder is Object.clone since that's where the call will bottom out. - if (method_holder->oop_is_instance()) { - return instanceKlassHandle(method_holder()); - } else if (method_holder->oop_is_array()) { - return instanceKlassHandle(SystemDictionary::Object_klass()); - } else { - ShouldNotReachHere(); - } - return NULL; -} - - -// ------------------------------------------------------------------ -methodHandle GraalEnv::get_method_by_index(constantPoolHandle& cpool, - int index, Bytecodes::Code bc, - instanceKlassHandle& accessor) { - ResourceMark rm; - return get_method_by_index_impl(cpool, index, bc, accessor); -} - -// ------------------------------------------------------------------ -// Check for changes to the system dictionary during compilation -// class loads, evolution, breakpoints -GraalEnv::CodeInstallResult GraalEnv::check_for_system_dictionary_modification(Dependencies* dependencies, Handle compiled_code, - GraalEnv* env, char** failure_detail) { - // If JVMTI capabilities were enabled during compile, the compilation is invalidated. - if (env != NULL) { - if (!env->_jvmti_can_hotswap_or_post_breakpoint && JvmtiExport::can_hotswap_or_post_breakpoint()) { - *failure_detail = (char*) "Hotswapping or breakpointing was enabled during compilation"; - return GraalEnv::dependencies_failed; - } - } - - // Dependencies must be checked when the system dictionary changes - // or if we don't know whether it has changed (i.e., env == NULL). - // In debug mode, always check dependencies. - bool counter_changed = env != NULL && env->_system_dictionary_modification_counter != SystemDictionary::number_of_modifications(); - bool verify_deps = env == NULL || trueInDebug || Debug::ENABLED(); - if (!counter_changed && !verify_deps) { - return GraalEnv::ok; - } - - for (Dependencies::DepStream deps(dependencies); deps.next(); ) { - Klass* witness = deps.check_dependency(); - if (witness != NULL) { - // Use a fixed size buffer to prevent the string stream from - // resizing in the context of an inner resource mark. - char* buffer = NEW_RESOURCE_ARRAY(char, O_BUFLEN); - stringStream st(buffer, O_BUFLEN); - deps.print_dependency(witness, true, &st); - *failure_detail = st.as_string(); - if (env == NULL || counter_changed) { - return GraalEnv::dependencies_failed; - } else { - // The dependencies were invalid at the time of installation - // without any intervening modification of the system - // dictionary. That means they were invalidly constructed. - return GraalEnv::dependencies_invalid; - } - } - if (LogCompilation) { - deps.log_dependency(); - } - } - - return GraalEnv::ok; -} - -// ------------------------------------------------------------------ -GraalEnv::CodeInstallResult GraalEnv::register_method( - methodHandle& method, - nmethod*& nm, - int entry_bci, - CodeOffsets* offsets, - int orig_pc_offset, - CodeBuffer* code_buffer, - int frame_words, - OopMapSet* oop_map_set, - ExceptionHandlerTable* handler_table, - AbstractCompiler* compiler, - DebugInformationRecorder* debug_info, - Dependencies* dependencies, - GraalEnv* env, - int compile_id, - bool has_unsafe_access, - Handle installed_code, - Handle compiled_code, - Handle speculation_log) { - GRAAL_EXCEPTION_CONTEXT; - NMethodSweeper::possibly_sweep(); - nm = NULL; - int comp_level = CompLevel_full_optimization; - char* failure_detail = NULL; - GraalEnv::CodeInstallResult result; - { - // To prevent compile queue updates. - MutexLocker locker(MethodCompileQueue_lock, THREAD); - - // Prevent SystemDictionary::add_to_hierarchy from running - // and invalidating our dependencies until we install this method. - MutexLocker ml(Compile_lock); - - // Encode the dependencies now, so we can check them right away. - dependencies->encode_content_bytes(); - - // Check for {class loads, evolution, breakpoints} during compilation - result = check_for_system_dictionary_modification(dependencies, compiled_code, env, &failure_detail); - if (result != GraalEnv::ok) { - // While not a true deoptimization, it is a preemptive decompile. - MethodData* mdp = method()->method_data(); - if (mdp != NULL) { - mdp->inc_decompile_count(); - if (mdp->decompile_count() > (uint)PerMethodRecompilationCutoff) { - // TODO (chaeubl) enable this in the fastdebug build only once we are more stable - ResourceMark m; - tty->print_cr("WARN: endless recompilation of %s. Method was set to not compilable.", method()->name_and_sig_as_C_string()); - //ShouldNotReachHere(); - } - } - - // All buffers in the CodeBuffer are allocated in the CodeCache. - // If the code buffer is created on each compile attempt - // as in C2, then it must be freed. - //code_buffer->free_blob(); - } else { - ImplicitExceptionTable implicit_tbl; - nm = nmethod::new_nmethod(method, - compile_id, - entry_bci, - offsets, - orig_pc_offset, - debug_info, dependencies, code_buffer, - frame_words, oop_map_set, - handler_table, &implicit_tbl, - compiler, comp_level, installed_code, speculation_log); - - // Free codeBlobs - //code_buffer->free_blob(); - - if (nm == NULL) { - // The CodeCache is full. Print out warning and disable compilation. - { - MutexUnlocker ml(Compile_lock); - MutexUnlocker locker(MethodCompileQueue_lock); - CompileBroker::handle_full_code_cache(); - } - } else { - nm->set_has_unsafe_access(has_unsafe_access); -#ifdef TARGET_ARCH_x86 - // It might be preferable to set this only for methods which - // use vector instructions but we currently don't track this - // and it probably wouldn't make much difference. - nm->set_has_wide_vectors(MaxVectorSize > 16); -#endif - - // Record successful registration. - // (Put nm into the task handle *before* publishing to the Java heap.) - CompileTask* task = env == NULL ? NULL : env->task(); - if (task != NULL) task->set_code(nm); - - if (installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(installed_code())) { - if (entry_bci == InvocationEntryBci) { - if (TieredCompilation) { - // If there is an old version we're done with it - nmethod* old = method->code(); - if (TraceMethodReplacement && old != NULL) { - ResourceMark rm; - char *method_name = method->name_and_sig_as_C_string(); - tty->print_cr("Replacing method %s", method_name); - } - if (old != NULL ) { - old->make_not_entrant(); - } - } - if (TraceNMethodInstalls) { - ResourceMark rm; - char *method_name = method->name_and_sig_as_C_string(); - ttyLocker ttyl; - tty->print_cr("Installing method (%d) %s [entry point: %p]", - comp_level, - method_name, nm->entry_point()); - } - // Allow the code to be executed - method->set_code(method, nm); - } else { - if (TraceNMethodInstalls ) { - ResourceMark rm; - char *method_name = method->name_and_sig_as_C_string(); - ttyLocker ttyl; - tty->print_cr("Installing osr method (%d) %s @ %d", - comp_level, - method_name, - entry_bci); - } - InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); - } - } - } - result = nm != NULL ? GraalEnv::ok :GraalEnv::cache_full; - } - } - - // String creation must be done outside lock - if (failure_detail != NULL) { - // A failure to allocate the string is silently ignored. - Handle message = java_lang_String::create_from_str(failure_detail, THREAD); - HotSpotCompiledNmethod::set_installationFailureMessage(compiled_code, message()); - } - - // JVMTI -- compiled method notification (must be done outside lock) - if (nm != NULL) { - nm->post_compiled_method_load_event(); - } - - return result; -} -
--- a/src/share/vm/graal/graalEnv.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -/* - * Copyright (c) 1999, 2011, 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. - * - */ - -#ifndef SHARE_VM_GRAAL_GRAALENV_HPP -#define SHARE_VM_GRAAL_GRAALENV_HPP - -#include "classfile/systemDictionary.hpp" -#include "code/debugInfoRec.hpp" -#include "code/dependencies.hpp" -#include "code/exceptionHandlerTable.hpp" -#include "compiler/oopMap.hpp" -#include "runtime/thread.hpp" - -class CompileTask; - -// Bring the Graal compiler thread into the VM state. -#define GRAAL_VM_ENTRY_MARK \ - JavaThread* thread = JavaThread::current(); \ - ThreadInVMfromNative __tiv(thread); \ - ResetNoHandleMark rnhm; \ - HandleMarkCleaner __hm(thread); \ - Thread* THREAD = thread; \ - debug_only(VMNativeEntryWrapper __vew;) - -#define GRAAL_EXCEPTION_CONTEXT \ - JavaThread* thread=JavaThread::current(); \ - Thread* THREAD = thread; - -// -// This class is the top level broker for requests from the compiler -// to the VM. -class GraalEnv : StackObj { - CI_PACKAGE_ACCESS_TO - - friend class CompileBroker; - friend class Dependencies; // for get_object, during logging - -public: - - enum CodeInstallResult { - ok, - dependencies_failed, - dependencies_invalid, - cache_full, - code_too_large - }; - - // Look up a klass by name from a particular class loader (the accessor's). - // If require_local, result must be defined in that class loader, or NULL. - // If !require_local, a result from remote class loader may be reported, - // if sufficient class loader constraints exist such that initiating - // a class loading request from the given loader is bound to return - // the class defined in the remote loader (or throw an error). - // - // Return an unloaded klass if !require_local and no class at all is found. - // - // The CI treats a klass as loaded if it is consistently defined in - // another loader, even if it hasn't yet been loaded in all loaders - // that could potentially see it via delegation. - static KlassHandle get_klass_by_name(KlassHandle& accessing_klass, - Symbol* klass_name, - bool require_local); - - // Constant pool access. - static KlassHandle get_klass_by_index(constantPoolHandle& cpool, - int klass_index, - bool& is_accessible, - KlassHandle& loading_klass); - static void get_field_by_index(instanceKlassHandle& loading_klass, fieldDescriptor& fd, - int field_index); - static methodHandle get_method_by_index(constantPoolHandle& cpool, - int method_index, Bytecodes::Code bc, - instanceKlassHandle& loading_klass); - - GraalEnv(CompileTask* task, int system_dictionary_modification_counter); - -private: - CompileTask* _task; - int _system_dictionary_modification_counter; - - // Cache JVMTI state - bool _jvmti_can_hotswap_or_post_breakpoint; - bool _jvmti_can_access_local_variables; - bool _jvmti_can_post_on_exceptions; - - // Implementation methods for loading and constant pool access. - static KlassHandle get_klass_by_name_impl(KlassHandle& accessing_klass, - constantPoolHandle& cpool, - Symbol* klass_name, - bool require_local); - static KlassHandle get_klass_by_index_impl(constantPoolHandle& cpool, - int klass_index, - bool& is_accessible, - KlassHandle& loading_klass); - static void get_field_by_index_impl(instanceKlassHandle& loading_klass, fieldDescriptor& fd, - int field_index); - static methodHandle get_method_by_index_impl(constantPoolHandle& cpool, - int method_index, Bytecodes::Code bc, - instanceKlassHandle& loading_klass); - - // Helper methods - static bool check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass); - static methodHandle lookup_method(instanceKlassHandle& accessor, - instanceKlassHandle& holder, - Symbol* name, - Symbol* sig, - Bytecodes::Code bc); - - private: - - // Is this thread currently in the VM state? - static bool is_in_vm(); - - // Helper routine for determining the validity of a compilation - // with respect to concurrent class loading. - static GraalEnv::CodeInstallResult check_for_system_dictionary_modification(Dependencies* target, Handle compiled_code, - GraalEnv* env, char** failure_detail); - -public: - CompileTask* task() { return _task; } - - // Register the result of a compilation. - static GraalEnv::CodeInstallResult register_method( - methodHandle& target, - nmethod*& nm, - int entry_bci, - CodeOffsets* offsets, - int orig_pc_offset, - CodeBuffer* code_buffer, - int frame_words, - OopMapSet* oop_map_set, - ExceptionHandlerTable* handler_table, - AbstractCompiler* compiler, - DebugInformationRecorder* debug_info, - Dependencies* dependencies, - GraalEnv* env, - int compile_id, - bool has_unsafe_access, - Handle installed_code, - Handle compiled_code, - Handle speculation_log); - - // converts the Klass* representing the holder of a method into a - // InstanceKlass*. This is needed since the holder of a method in - // the bytecodes could be an array type. Basically this converts - // array types into java/lang/Object and other types stay as they are. - static instanceKlassHandle get_instance_klass_for_declared_method_holder(KlassHandle& klass); -}; - -#endif // SHARE_VM_GRAAL_GRAALENV_HPP
--- a/src/share/vm/graal/graalGlobals.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2000, 2010, 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. - * - */ - -#include "precompiled.hpp" -#include "graal/graalGlobals.hpp" - -GRAAL_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
--- a/src/share/vm/graal/graalGlobals.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2000, 2012, 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. - * - */ - -#ifndef SHARE_VM_GRAAL_GRAALGLOBALS_HPP -#define SHARE_VM_GRAAL_GRAALGLOBALS_HPP - -#include "runtime/globals.hpp" -#ifdef TARGET_ARCH_x86 -# include "graalGlobals_x86.hpp" -#endif -#ifdef TARGET_ARCH_sparc -# include "graalGlobals_sparc.hpp" -#endif -#ifdef TARGET_ARCH_arm -# include "graalGlobals_arm.hpp" -#endif -#ifdef TARGET_ARCH_ppc -# include "graalGlobals_ppc.hpp" -#endif - -// -// Defines all global flags used by the Graal compiler. Only flags that need -// to be accessible to the Graal C++ code should be defined here. All other -// Graal flags should be defined in GraalOptions.java. -// -#define GRAAL_FLAGS(develop, develop_pd, product, product_pd, notproduct) \ - \ - product(bool, DebugGraal, true, \ - "Enable JVMTI for the compiler thread") \ - \ - product(bool, UseGraalClassLoader, true, \ - "Load Graal classes with separate class loader") \ - \ - COMPILERGRAAL_PRESENT(product(bool, BootstrapGraal, true, \ - "Bootstrap Graal before running Java main method")) \ - \ - COMPILERGRAAL_PRESENT(product(bool, PrintBootstrap, true, \ - "Print Graal bootstrap progress and summary")) \ - \ - COMPILERGRAAL_PRESENT(product(intx, GraalThreads, 1, \ - "Force number of Graal compiler threads to use")) \ - \ - COMPILERGRAAL_PRESENT(product(intx, GraalHostThreads, 1, \ - "Force number of compiler threads for Graal host compiler")) \ - \ - GRAAL_ONLY(product(bool, CodeInstallSafepointChecks, true, \ - "Perform explicit safepoint checks while installing code")) \ - \ - NOT_COMPILER2(product_pd(intx, MaxVectorSize, \ - "Max vector size in bytes, " \ - "actual size could be less depending on elements type")) \ - \ - product(intx, TraceGraal, 0, \ - "Trace level for Graal") \ - \ - product(intx, GraalCounterSize, 0, \ - "Reserved size for benchmark counters") \ - \ - product(bool, GraalCountersExcludeCompiler, true, \ - "Exclude Graal compiler threads from benchmark counters") \ - \ - product(bool, GraalDeferredInitBarriers, true, \ - "Defer write barriers of young objects") \ - \ - product(bool, GraalHProfEnabled, false, \ - "Is Heap Profiler enabled") \ - \ - product(bool, GraalCompileWithC1Only, true, \ - "Only compile Graal classes with C1") \ - \ - product(bool, GraalCompileAppFirst, false, \ - "Prioritize application compilations over Graal compilations") \ - \ - develop(bool, GraalUseFastLocking, true, \ - "Use fast inlined locking code") \ - \ - develop(bool, GraalUseFastNewTypeArray, true, \ - "Use fast inlined type array allocation") \ - \ - develop(bool, GraalUseFastNewObjectArray, true, \ - "Use fast inlined object array allocation") \ - \ - product(intx, GraalNMethodSizeLimit, (80*K)*wordSize, \ - "Maximum size of a compiled method.") \ - \ - notproduct(bool, GraalPrintSimpleStubs, false, \ - "Print simple Graal stubs") \ - \ - develop(bool, TraceUncollectedSpeculations, false, \ - "Print message when a failed speculation was not collected") \ - - -// Read default values for Graal globals - -GRAAL_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_NOTPRODUCT_FLAG) - -#endif // SHARE_VM_GRAAL_GRAALGLOBALS_HPP
--- a/src/share/vm/graal/graalJavaAccess.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011, 2012 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. - */ - -#include "precompiled.hpp" -#include "graal/graalJavaAccess.hpp" -#include "runtime/jniHandles.hpp" -#include "classfile/symbolTable.hpp" -// This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field. -// It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded. - -void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field) { - InstanceKlass* ik = InstanceKlass::cast(klass); - Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name)); - Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature)); - if (name_symbol == NULL || signature_symbol == NULL) { -#ifndef PRODUCT - ik->print_on(tty); -#endif - guarantee(false, err_msg("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string())); - } - - fieldDescriptor fd; - if (!ik->find_field(name_symbol, signature_symbol, &fd)) { - ResourceMark rm; - fatal(err_msg("Invalid layout of %s at %s", name_symbol->as_C_string(), ik->external_name())); - } - guarantee(fd.is_static() == static_field, "static/instance mismatch"); - dest_offset = fd.offset(); -} - -// This piece of macro magic creates the contents of the graal_compute_offsets method that initializes the field indices of all the access classes. - -#define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name ""); - -#define END_CLASS } - -#define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field); -#define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false) -#define INT_FIELD(klass, name) FIELD(klass, name, "I", false) -#define BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", false) -#define LONG_FIELD(klass, name) FIELD(klass, name, "J", false) -#define FLOAT_FIELD(klass, name) FIELD(klass, name, "F", false) -#define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false) -#define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true) -#define STATIC_INT_FIELD(klass, name) FIELD(klass, name, "I", true) -#define STATIC_BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", true) - - -void graal_compute_offsets() { - COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, OOP_FIELD, OOP_FIELD, STATIC_OOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD) - guarantee(InstalledCode::_address_offset == sizeof(oopDesc), "codeBlob must be first field!"); -} - -#define EMPTY0 -#define EMPTY1(x) -#define EMPTY2(x,y) -#define FIELD2(klass, name) int klass::_##name##_offset = 0; -#define FIELD3(klass, name, sig) FIELD2(klass, name) - -COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2) - - - - -
--- a/src/share/vm/graal/graalJavaAccess.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2011, 2014, 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. - */ - -#ifndef SHARE_VM_GRAAL_GRAAL_JAVA_ACCESS_HPP -#define SHARE_VM_GRAAL_GRAAL_JAVA_ACCESS_HPP - -void graal_compute_offsets(); - -#include "classfile/systemDictionary.hpp" -#include "oops/instanceMirrorKlass.hpp" - -/* This macro defines the structure of the CompilationResult - classes. - * It will generate classes with accessors similar to javaClasses.hpp, but with specializations for oops, Handles and jni handles. - * - * The public interface of these classes will look like this: - - * class StackSlot : AllStatic { - * public: - * static Klass* klass(); - * static jint index(oop obj); - * static jint index(Handle obj); - * static jint index(jobject obj); - * static void set_index(oop obj, jint x); - * static void set_index(Handle obj, jint x); - * static void set_index(jobject obj, jint x); - * }; - * - */ - -#define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, boolean_field, long_field, float_field, oop_field, typeArrayOop_field, objArrayOop_field, static_oop_field, static_int_field, static_boolean_field) \ - start_class(HotSpotResolvedObjectTypeImpl) \ - oop_field(HotSpotResolvedObjectTypeImpl, javaClass, "Ljava/lang/Class;") \ - end_class \ - start_class(HotSpotResolvedJavaMethodImpl) \ - long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \ - end_class \ - start_class(InstalledCode) \ - long_field(InstalledCode, address) \ - long_field(InstalledCode, version) \ - oop_field(InstalledCode, name, "Ljava/lang/String;") \ - end_class \ - start_class(HotSpotInstalledCode) \ - int_field(HotSpotInstalledCode, size) \ - long_field(HotSpotInstalledCode, codeStart) \ - int_field(HotSpotInstalledCode, codeSize) \ - end_class \ - start_class(HotSpotNmethod) \ - boolean_field(HotSpotNmethod, isDefault) \ - end_class \ - start_class(HotSpotCompiledCode) \ - oop_field(HotSpotCompiledCode, comp, "Lcom/oracle/jvmci/code/CompilationResult;") \ - objArrayOop_field(HotSpotCompiledCode, sites, "[Lcom/oracle/jvmci/code/CompilationResult$Site;") \ - objArrayOop_field(HotSpotCompiledCode, exceptionHandlers, "[Lcom/oracle/jvmci/code/CompilationResult$ExceptionHandler;") \ - objArrayOop_field(HotSpotCompiledCode, comments, "[Lcom/oracle/jvmci/hotspot/HotSpotCompiledCode$Comment;") \ - typeArrayOop_field(HotSpotCompiledCode, dataSection, "[B") \ - int_field(HotSpotCompiledCode, dataSectionAlignment) \ - objArrayOop_field(HotSpotCompiledCode, dataSectionPatches, "[Lcom/oracle/jvmci/code/CompilationResult$DataPatch;") \ - end_class \ - start_class(HotSpotCompiledCode_Comment) \ - oop_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;") \ - int_field(HotSpotCompiledCode_Comment, pcOffset) \ - end_class \ - start_class(HotSpotCompiledNmethod) \ - oop_field(HotSpotCompiledNmethod, method, "Lcom/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod;") \ - oop_field(HotSpotCompiledNmethod, installationFailureMessage, "Ljava/lang/String;") \ - int_field(HotSpotCompiledNmethod, entryBCI) \ - int_field(HotSpotCompiledNmethod, id) \ - long_field(HotSpotCompiledNmethod, graalEnv) \ - end_class \ - start_class(HotSpotForeignCallTarget) \ - long_field(HotSpotForeignCallTarget, address) \ - end_class \ - start_class(CompilationResult) \ - int_field(CompilationResult, totalFrameSize) \ - int_field(CompilationResult, customStackAreaOffset) \ - oop_field(CompilationResult, name, "Ljava/lang/String;") \ - typeArrayOop_field(CompilationResult, targetCode, "[B") \ - objArrayOop_field(CompilationResult, assumptions, "[Lcom/oracle/jvmci/meta/Assumptions$Assumption;") \ - objArrayOop_field(CompilationResult, methods, "[Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ - int_field(CompilationResult, targetCodeSize) \ - end_class \ - start_class(Assumptions_NoFinalizableSubclass) \ - oop_field(Assumptions_NoFinalizableSubclass, receiverType, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ - end_class \ - start_class(Assumptions_ConcreteSubtype) \ - oop_field(Assumptions_ConcreteSubtype, context, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ - oop_field(Assumptions_ConcreteSubtype, subtype, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ - end_class \ - start_class(Assumptions_LeafType) \ - oop_field(Assumptions_LeafType, context, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ - end_class \ - start_class(Assumptions_ConcreteMethod) \ - oop_field(Assumptions_ConcreteMethod, method, "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ - oop_field(Assumptions_ConcreteMethod, context, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ - oop_field(Assumptions_ConcreteMethod, impl, "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ - end_class \ - start_class(Assumptions_CallSiteTargetValue) \ - oop_field(Assumptions_CallSiteTargetValue, callSite, "Ljava/lang/invoke/CallSite;") \ - oop_field(Assumptions_CallSiteTargetValue, methodHandle, "Ljava/lang/invoke/MethodHandle;") \ - end_class \ - start_class(CompilationResult_Site) \ - int_field(CompilationResult_Site, pcOffset) \ - end_class \ - start_class(CompilationResult_Call) \ - oop_field(CompilationResult_Call, target, "Lcom/oracle/jvmci/meta/InvokeTarget;") \ - oop_field(CompilationResult_Call, debugInfo, "Lcom/oracle/jvmci/code/DebugInfo;") \ - end_class \ - start_class(CompilationResult_DataPatch) \ - oop_field(CompilationResult_DataPatch, reference, "Lcom/oracle/jvmci/code/CompilationResult$Reference;") \ - end_class \ - start_class(CompilationResult_ConstantReference) \ - oop_field(CompilationResult_ConstantReference, constant, "Lcom/oracle/jvmci/meta/VMConstant;") \ - end_class \ - start_class(CompilationResult_DataSectionReference) \ - int_field(CompilationResult_DataSectionReference, offset) \ - end_class \ - start_class(InfopointReason) \ - static_oop_field(InfopointReason, UNKNOWN, "Lcom/oracle/jvmci/code/InfopointReason;") \ - static_oop_field(InfopointReason, SAFEPOINT, "Lcom/oracle/jvmci/code/InfopointReason;") \ - static_oop_field(InfopointReason, CALL, "Lcom/oracle/jvmci/code/InfopointReason;") \ - static_oop_field(InfopointReason, IMPLICIT_EXCEPTION, "Lcom/oracle/jvmci/code/InfopointReason;") \ - static_oop_field(InfopointReason, METHOD_START, "Lcom/oracle/jvmci/code/InfopointReason;") \ - static_oop_field(InfopointReason, METHOD_END, "Lcom/oracle/jvmci/code/InfopointReason;") \ - static_oop_field(InfopointReason, LINE_NUMBER, "Lcom/oracle/jvmci/code/InfopointReason;") \ - end_class \ - start_class(CompilationResult_Infopoint) \ - oop_field(CompilationResult_Infopoint, debugInfo, "Lcom/oracle/jvmci/code/DebugInfo;") \ - oop_field(CompilationResult_Infopoint, reason, "Lcom/oracle/jvmci/code/InfopointReason;") \ - end_class \ - start_class(CompilationResult_ExceptionHandler) \ - int_field(CompilationResult_ExceptionHandler, handlerPos) \ - end_class \ - start_class(CompilationResult_Mark) \ - oop_field(CompilationResult_Mark, id, "Ljava/lang/Object;") \ - end_class \ - start_class(DebugInfo) \ - oop_field(DebugInfo, bytecodePosition, "Lcom/oracle/jvmci/code/BytecodePosition;") \ - oop_field(DebugInfo, referenceMap, "Lcom/oracle/jvmci/code/ReferenceMap;") \ - oop_field(DebugInfo, calleeSaveInfo, "Lcom/oracle/jvmci/code/RegisterSaveLayout;") \ - objArrayOop_field(DebugInfo, virtualObjectMapping, "[Lcom/oracle/jvmci/meta/Value;") \ - end_class \ - start_class(HotSpotReferenceMap) \ - oop_field(HotSpotReferenceMap, registerRefMap, "Lcom/oracle/jvmci/hotspot/HotSpotReferenceMap$HotSpotOopMap;") \ - oop_field(HotSpotReferenceMap, frameRefMap, "Lcom/oracle/jvmci/hotspot/HotSpotReferenceMap$HotSpotOopMap;") \ - end_class \ - start_class(RegisterSaveLayout) \ - objArrayOop_field(RegisterSaveLayout, registers, "[Lcom/oracle/jvmci/code/Register;") \ - typeArrayOop_field(RegisterSaveLayout, slots, "[I") \ - end_class \ - start_class(HotSpotOopMap) \ - typeArrayOop_field(HotSpotOopMap, words, "[J") \ - end_class \ - start_class(BytecodeFrame) \ - objArrayOop_field(BytecodeFrame, values, "[Lcom/oracle/jvmci/meta/Value;") \ - int_field(BytecodeFrame, numLocals) \ - int_field(BytecodeFrame, numStack) \ - int_field(BytecodeFrame, numLocks) \ - boolean_field(BytecodeFrame, rethrowException) \ - boolean_field(BytecodeFrame, duringCall) \ - static_int_field(BytecodeFrame, BEFORE_BCI) \ - end_class \ - start_class(BytecodePosition) \ - oop_field(BytecodePosition, caller, "Lcom/oracle/jvmci/code/BytecodePosition;") \ - oop_field(BytecodePosition, method, "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ - int_field(BytecodePosition, bci) \ - end_class \ - start_class(JavaConstant) \ - end_class \ - start_class(PrimitiveConstant) \ - long_field(PrimitiveConstant, primitive) \ - end_class \ - start_class(RawConstant) \ - long_field(RawConstant, primitive) \ - end_class \ - start_class(NullConstant) \ - end_class \ - start_class(HotSpotCompressedNullConstant) \ - end_class \ - start_class(HotSpotObjectConstantImpl) \ - oop_field(HotSpotObjectConstantImpl, object, "Ljava/lang/Object;") \ - boolean_field(HotSpotObjectConstantImpl, compressed) \ - end_class \ - start_class(HotSpotMetaspaceConstantImpl) \ - long_field(HotSpotMetaspaceConstantImpl, primitive) \ - oop_field(HotSpotMetaspaceConstantImpl, metaspaceObject, "Ljava/lang/Object;") \ - boolean_field(HotSpotMetaspaceConstantImpl, compressed) \ - end_class \ - start_class(Kind) \ - char_field(Kind, typeChar) \ - static_oop_field(Kind, Boolean, "Lcom/oracle/jvmci/meta/Kind;"); \ - static_oop_field(Kind, Byte, "Lcom/oracle/jvmci/meta/Kind;"); \ - static_oop_field(Kind, Char, "Lcom/oracle/jvmci/meta/Kind;"); \ - static_oop_field(Kind, Short, "Lcom/oracle/jvmci/meta/Kind;"); \ - static_oop_field(Kind, Int, "Lcom/oracle/jvmci/meta/Kind;"); \ - static_oop_field(Kind, Long, "Lcom/oracle/jvmci/meta/Kind;"); \ - end_class \ - start_class(LIRKind) \ - oop_field(LIRKind, platformKind, "Lcom/oracle/jvmci/meta/PlatformKind;") \ - int_field(LIRKind, referenceMask) \ - end_class \ - start_class(AbstractValue) \ - oop_field(AbstractValue, kind, "Lcom/oracle/jvmci/meta/Kind;") \ - oop_field(AbstractValue, lirKind, "Lcom/oracle/jvmci/meta/LIRKind;") \ - static_oop_field(AbstractValue, ILLEGAL, "Lcom/oracle/jvmci/meta/AllocatableValue;"); \ - end_class \ - start_class(RegisterValue) \ - oop_field(RegisterValue, reg, "Lcom/oracle/jvmci/code/Register;") \ - end_class \ - start_class(RegisterCategory) \ - oop_field(RegisterCategory, name, "Ljava/lang/String;") \ - int_field(RegisterCategory, referenceMapOffset) \ - int_field(RegisterCategory, referenceMapShift) \ - end_class \ - start_class(code_Register) \ - int_field(code_Register, number) \ - int_field(code_Register, encoding) \ - oop_field(code_Register, registerCategory, "Lcom/oracle/jvmci/code/Register$RegisterCategory;") \ - end_class \ - start_class(StackSlot) \ - int_field(StackSlot, offset) \ - boolean_field(StackSlot, addFrameSize) \ - end_class \ - start_class(VirtualObject) \ - int_field(VirtualObject, id) \ - oop_field(VirtualObject, type, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ - objArrayOop_field(VirtualObject, values, "[Lcom/oracle/jvmci/meta/Value;") \ - end_class \ - start_class(StackLockValue) \ - oop_field(StackLockValue, owner, "Lcom/oracle/jvmci/meta/Value;") \ - oop_field(StackLockValue, slot, "Lcom/oracle/jvmci/code/StackSlotValue;") \ - boolean_field(StackLockValue, eliminated) \ - end_class \ - start_class(SpeculationLog) \ - oop_field(SpeculationLog, lastFailed, "Ljava/lang/Object;") \ - end_class \ - start_class(HotSpotStackFrameReference) \ - oop_field(HotSpotStackFrameReference, compilerToVM, "Lcom/oracle/jvmci/hotspot/CompilerToVM;") \ - long_field(HotSpotStackFrameReference, stackPointer) \ - int_field(HotSpotStackFrameReference, frameNumber) \ - int_field(HotSpotStackFrameReference, bci) \ - long_field(HotSpotStackFrameReference, metaspaceMethod) \ - objArrayOop_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;") \ - typeArrayOop_field(HotSpotStackFrameReference, localIsVirtual, "[Z") \ - end_class \ - start_class(Debug) \ - static_boolean_field(Debug, ENABLED) \ - end_class \ - /* end*/ - -#define START_CLASS(name) \ -class name : AllStatic { \ - private: \ - friend class GraalCompiler; \ - static void check(oop obj, const char* field_name) { \ - assert(obj != NULL, err_msg("NULL field access of %s.%s", #name, field_name)); \ - assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected"); \ - } \ - static void compute_offsets(); \ - public: \ - static Klass* klass() { return SystemDictionary::name##_klass(); } - -#define END_CLASS }; - -#define FIELD(name, type, accessor, cast) \ - static int _##name##_offset; \ - static type name(oop obj) { check(obj, #name); return cast obj->accessor(_##name##_offset); } \ - static type name(Handle& obj) { check(obj(), #name); return cast obj->accessor(_##name##_offset); } \ - static type name(jobject obj) { check(JNIHandles::resolve(obj), #name); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ - static void set_##name(oop obj, type x) { check(obj, #name); obj->accessor##_put(_##name##_offset, x); } \ - static void set_##name(Handle& obj, type x) { check(obj(), #name); obj->accessor##_put(_##name##_offset, x); } \ - static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } - -#define EMPTY_CAST -#define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field, EMPTY_CAST) -#define INT_FIELD(klass, name) FIELD(name, jint, int_field, EMPTY_CAST) -#define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field, EMPTY_CAST) -#define LONG_FIELD(klass, name) FIELD(name, jlong, long_field, EMPTY_CAST) -#define FLOAT_FIELD(klass, name) FIELD(name, jfloat, float_field, EMPTY_CAST) -#define OOP_FIELD(klass, name, signature) FIELD(name, oop, obj_field, EMPTY_CAST) -#define OBJARRAYOOP_FIELD(klass, name, signature) FIELD(name, objArrayOop, obj_field, (objArrayOop)) -#define TYPEARRAYOOP_FIELD(klass, name, signature) FIELD(name, typeArrayOop, obj_field, (typeArrayOop)) -#define STATIC_OOP_FIELD(klassName, name, signature) \ - static int _##name##_offset; \ - static oop name() { \ - InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ - address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ - if (UseCompressedOops) { \ - return oopDesc::load_decode_heap_oop((narrowOop *)addr); \ - } else { \ - return oopDesc::load_decode_heap_oop((oop*)addr); \ - } \ - } \ - static void set_##name(oop x) { \ - InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ - address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ - if (UseCompressedOops) { \ - oop_store((narrowOop *)addr, x); \ - } else { \ - oop_store((oop*)addr, x); \ - } \ - } -#define STATIC_PRIMITIVE_FIELD(klassName, name, jtypename) \ - static int _##name##_offset; \ - static jtypename name() { \ - InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ - address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ - return *((jtypename *)addr); \ - } \ - static void set_##name(jtypename x) { \ - InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ - address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ - *((jtypename *)addr) = x; \ - } - -#define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint) -#define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean) - -COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, TYPEARRAYOOP_FIELD, OBJARRAYOOP_FIELD, STATIC_OOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD) -#undef START_CLASS -#undef END_CLASS -#undef FIELD -#undef CHAR_FIELD -#undef INT_FIELD -#undef BOOLEAN_FIELD -#undef LONG_FIELD -#undef FLOAT_FIELD -#undef OOP_FIELD -#undef TYPEARRAYOOP_FIELD -#undef OBJARRAYOOP_FIELD -#undef STATIC_OOP_FIELD -#undef STATIC_INT_FIELD -#undef STATIC_BOOLEAN_FIELD -#undef EMPTY_CAST - -void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field); - -#endif // SHARE_VM_GRAAL_GRAAL_JAVA_ACCESS_HPP
--- a/src/share/vm/graal/graalRuntime.cpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1164 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - -#include "precompiled.hpp" -#include "asm/codeBuffer.hpp" -#include "compiler/compileBroker.hpp" -#include "compiler/disassembler.hpp" -#include "graal/graalRuntime.hpp" -#include "graal/graalCompilerToVM.hpp" -#include "graal/graalCompiler.hpp" -#include "graal/graalJavaAccess.hpp" -#include "graal/graalEnv.hpp" -#include "memory/oopFactory.hpp" -#include "prims/jvm.h" -#include "runtime/biasedLocking.hpp" -#include "runtime/interfaceSupport.hpp" -#include "runtime/arguments.hpp" -#include "runtime/reflection.hpp" -#include "utilities/debug.hpp" - - jobject GraalRuntime::_HotSpotJVMCIRuntime_instance = NULL; -bool GraalRuntime::_HotSpotJVMCIRuntime_initialized = false; -bool GraalRuntime::_shutdown_called = false; - -void GraalRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) { - uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); - uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; - AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)")); - NOT_LP64(error("check TLAB allocation code for address space conflicts")); - - ensure_graal_class_loader_is_initialized(); - - JavaThread* THREAD = JavaThread::current(); - { - ThreadToNativeFromVM trans(THREAD); - - ResourceMark rm; - HandleMark hm; - - graal_compute_offsets(); - - // Ensure _non_oop_bits is initialized - Universe::non_oop_word(); - - env->RegisterNatives(c2vmClass, CompilerToVM_methods, CompilerToVM_methods_count()); - } - if (HAS_PENDING_EXCEPTION) { - abort_on_pending_exception(PENDING_EXCEPTION, "Could not register natives"); - } -} - -BufferBlob* GraalRuntime::initialize_buffer_blob() { - JavaThread* THREAD = JavaThread::current(); - BufferBlob* buffer_blob = THREAD->get_buffer_blob(); - if (buffer_blob == NULL) { - buffer_blob = BufferBlob::create("Graal thread-local CodeBuffer", GraalNMethodSizeLimit); - if (buffer_blob != NULL) { - THREAD->set_buffer_blob(buffer_blob); - } - } - return buffer_blob; -} - -BasicType GraalRuntime::kindToBasicType(jchar ch) { - switch(ch) { - case 'z': return T_BOOLEAN; - case 'b': return T_BYTE; - case 's': return T_SHORT; - case 'c': return T_CHAR; - case 'i': return T_INT; - case 'f': return T_FLOAT; - case 'j': return T_LONG; - case 'd': return T_DOUBLE; - case 'a': return T_OBJECT; - case '-': return T_ILLEGAL; - default: - fatal(err_msg("unexpected Kind: %c", ch)); - break; - } - return T_ILLEGAL; -} - -// Simple helper to see if the caller of a runtime stub which -// entered the VM has been deoptimized - -static bool caller_is_deopted() { - JavaThread* thread = JavaThread::current(); - RegisterMap reg_map(thread, false); - frame runtime_frame = thread->last_frame(); - frame caller_frame = runtime_frame.sender(®_map); - assert(caller_frame.is_compiled_frame(), "must be compiled"); - return caller_frame.is_deoptimized_frame(); -} - -// Stress deoptimization -static void deopt_caller() { - if ( !caller_is_deopted()) { - JavaThread* thread = JavaThread::current(); - RegisterMap reg_map(thread, false); - frame runtime_frame = thread->last_frame(); - frame caller_frame = runtime_frame.sender(®_map); - Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); - assert(caller_is_deopted(), "Must be deoptimized"); - } -} - -JRT_BLOCK_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) - JRT_BLOCK; - assert(klass->is_klass(), "not a class"); - instanceKlassHandle h(thread, klass); - h->check_valid_for_instantiation(true, CHECK); - // make sure klass is initialized - h->initialize(CHECK); - // allocate instance and return via TLS - oop obj = h->allocate_instance(CHECK); - thread->set_vm_result(obj); - JRT_BLOCK_END; - - if (GraalDeferredInitBarriers) { - new_store_pre_barrier(thread); - } -JRT_END - -JRT_BLOCK_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) - JRT_BLOCK; - // Note: no handle for klass needed since they are not used - // anymore after new_objArray() and no GC can happen before. - // (This may have to change if this code changes!) - assert(array_klass->is_klass(), "not a class"); - oop obj; - if (array_klass->oop_is_typeArray()) { - BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); - obj = oopFactory::new_typeArray(elt_type, length, CHECK); - } else { - Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); - obj = oopFactory::new_objArray(elem_klass, length, CHECK); - } - thread->set_vm_result(obj); - // This is pretty rare but this runtime patch is stressful to deoptimization - // if we deoptimize here so force a deopt to stress the path. - if (DeoptimizeALot) { - static int deopts = 0; - // Alternate between deoptimizing and raising an error (which will also cause a deopt) - if (deopts++ % 2 == 0) { - ResourceMark rm(THREAD); - THROW(vmSymbols::java_lang_OutOfMemoryError()); - } else { - deopt_caller(); - } - } - JRT_BLOCK_END; - - if (GraalDeferredInitBarriers) { - new_store_pre_barrier(thread); - } -JRT_END - -void GraalRuntime::new_store_pre_barrier(JavaThread* thread) { - // After any safepoint, just before going back to compiled code, - // we inform the GC that we will be doing initializing writes to - // this object in the future without emitting card-marks, so - // GC may take any compensating steps. - // NOTE: Keep this code consistent with GraphKit::store_barrier. - - oop new_obj = thread->vm_result(); - if (new_obj == NULL) return; - - assert(Universe::heap()->can_elide_tlab_store_barriers(), - "compiler must check this first"); - // GC may decide to give back a safer copy of new_obj. - new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj); - thread->set_vm_result(new_obj); -} - -JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) - assert(klass->is_klass(), "not a class"); - assert(rank >= 1, "rank must be nonzero"); - oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); - thread->set_vm_result(obj); -JRT_END - -JRT_ENTRY(void, GraalRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length)) - oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); - thread->set_vm_result(obj); -JRT_END - -JRT_ENTRY(void, GraalRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) - instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror)); - - if (klass == NULL) { - ResourceMark rm(THREAD); - THROW(vmSymbols::java_lang_InstantiationException()); - } - - // Create new instance (the receiver) - klass->check_valid_for_instantiation(false, CHECK); - - // Make sure klass gets initialized - klass->initialize(CHECK); - - oop obj = klass->allocate_instance(CHECK); - thread->set_vm_result(obj); -JRT_END - -extern void vm_exit(int code); - -// Enter this method from compiled code handler below. This is where we transition -// to VM mode. This is done as a helper routine so that the method called directly -// from compiled code does not have to transition to VM. This allows the entry -// method to see if the nmethod that we have just looked up a handler for has -// been deoptimized while we were in the vm. This simplifies the assembly code -// cpu directories. -// -// We are entering here from exception stub (via the entry method below) -// If there is a compiled exception handler in this method, we will continue there; -// otherwise we will unwind the stack and continue at the caller of top frame method -// Note: we enter in Java using a special JRT wrapper. This wrapper allows us to -// control the area where we can allow a safepoint. After we exit the safepoint area we can -// check to see if the handler we are going to return is now in a nmethod that has -// been deoptimized. If that is the case we return the deopt blob -// unpack_with_exception entry instead. This makes life for the exception blob easier -// because making that same check and diverting is painful from assembly language. -JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) - // Reset method handle flag. - thread->set_is_method_handle_return(false); - - Handle exception(thread, ex); - nm = CodeCache::find_nmethod(pc); - assert(nm != NULL, "this is not an nmethod"); - // Adjust the pc as needed/ - if (nm->is_deopt_pc(pc)) { - RegisterMap map(thread, false); - frame exception_frame = thread->last_frame().sender(&map); - // if the frame isn't deopted then pc must not correspond to the caller of last_frame - assert(exception_frame.is_deoptimized_frame(), "must be deopted"); - pc = exception_frame.pc(); - } -#ifdef ASSERT - assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); - assert(exception->is_oop(), "just checking"); - // Check that exception is a subclass of Throwable, otherwise we have a VerifyError - if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { - if (ExitVMOnVerifyError) vm_exit(-1); - ShouldNotReachHere(); - } -#endif - - // Check the stack guard pages and reenable them if necessary and there is - // enough space on the stack to do so. Use fast exceptions only if the guard - // pages are enabled. - bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); - if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); - - if (JvmtiExport::can_post_on_exceptions()) { - // To ensure correct notification of exception catches and throws - // we have to deoptimize here. If we attempted to notify the - // catches and throws during this exception lookup it's possible - // we could deoptimize on the way out of the VM and end back in - // the interpreter at the throw site. This would result in double - // notifications since the interpreter would also notify about - // these same catches and throws as it unwound the frame. - - RegisterMap reg_map(thread); - frame stub_frame = thread->last_frame(); - frame caller_frame = stub_frame.sender(®_map); - - // We don't really want to deoptimize the nmethod itself since we - // can actually continue in the exception handler ourselves but I - // don't see an easy way to have the desired effect. - Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); - assert(caller_is_deopted(), "Must be deoptimized"); - - return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); - } - - // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions - if (guard_pages_enabled) { - address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); - if (fast_continuation != NULL) { - // Set flag if return address is a method handle call site. - thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); - return fast_continuation; - } - } - - // If the stack guard pages are enabled, check whether there is a handler in - // the current method. Otherwise (guard pages disabled), force an unwind and - // skip the exception cache update (i.e., just leave continuation==NULL). - address continuation = NULL; - if (guard_pages_enabled) { - - // New exception handling mechanism can support inlined methods - // with exception handlers since the mappings are from PC to PC - - // debugging support - // tracing - if (TraceExceptions) { - ttyLocker ttyl; - ResourceMark rm; - tty->print_cr("Exception <%s> (" INTPTR_FORMAT ") thrown in compiled method <%s> at PC " INTPTR_FORMAT " for thread " INTPTR_FORMAT "", - exception->print_value_string(), p2i((address)exception()), nm->method()->print_value_string(), p2i(pc), p2i(thread)); - } - // for AbortVMOnException flag - NOT_PRODUCT(Exceptions::debug_check_abort(exception)); - - // Clear out the exception oop and pc since looking up an - // exception handler can cause class loading, which might throw an - // exception and those fields are expected to be clear during - // normal bytecode execution. - thread->clear_exception_oop_and_pc(); - - continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); - // If an exception was thrown during exception dispatch, the exception oop may have changed - thread->set_exception_oop(exception()); - thread->set_exception_pc(pc); - - // the exception cache is used only by non-implicit exceptions - if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { - nm->add_handler_for_exception_and_pc(exception, pc, continuation); - } - } - - // Set flag if return address is a method handle call site. - thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); - - if (TraceExceptions) { - ttyLocker ttyl; - ResourceMark rm; - tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT, - p2i(thread), p2i(continuation), p2i(pc)); - } - - return continuation; -JRT_END - -// Enter this method from compiled code only if there is a Java exception handler -// in the method handling the exception. -// We are entering here from exception stub. We don't do a normal VM transition here. -// We do it in a helper. This is so we can check to see if the nmethod we have just -// searched for an exception handler has been deoptimized in the meantime. -address GraalRuntime::exception_handler_for_pc(JavaThread* thread) { - oop exception = thread->exception_oop(); - address pc = thread->exception_pc(); - // Still in Java mode - DEBUG_ONLY(ResetNoHandleMark rnhm); - nmethod* nm = NULL; - address continuation = NULL; - { - // Enter VM mode by calling the helper - ResetNoHandleMark rnhm; - continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); - } - // Back in JAVA, use no oops DON'T safepoint - - // Now check to see if the nmethod we were called from is now deoptimized. - // If so we must return to the deopt blob and deoptimize the nmethod - if (nm != NULL && caller_is_deopted()) { - continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); - } - - assert(continuation != NULL, "no handler found"); - return continuation; -} - -JRT_ENTRY(void, GraalRuntime::create_null_exception(JavaThread* thread)) - SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException()); - thread->set_vm_result(PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; -JRT_END - -JRT_ENTRY(void, GraalRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index)) - char message[jintAsStringSize]; - sprintf(message, "%d", index); - SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message); - thread->set_vm_result(PENDING_EXCEPTION); - CLEAR_PENDING_EXCEPTION; -JRT_END - -JRT_ENTRY_NO_ASYNC(void, GraalRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) - if (TraceGraal >= 3) { - char type[O_BUFLEN]; - obj->klass()->name()->as_C_string(type, O_BUFLEN); - markOop mark = obj->mark(); - tty->print_cr("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(mark), p2i(lock)); - tty->flush(); - } -#ifdef ASSERT - if (PrintBiasedLockingStatistics) { - Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); - } -#endif - Handle h_obj(thread, obj); - assert(h_obj()->is_oop(), "must be NULL or an object"); - if (UseBiasedLocking) { - // Retry fast entry if bias is revoked to avoid unnecessary inflation - ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK); - } else { - if (GraalUseFastLocking) { - // When using fast locking, the compiled code has already tried the fast case - ObjectSynchronizer::slow_enter(h_obj, lock, THREAD); - } else { - ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD); - } - } - if (TraceGraal >= 3) { - tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj)); - } -JRT_END - -JRT_LEAF(void, GraalRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) - assert(thread == JavaThread::current(), "threads must correspond"); - assert(thread->last_Java_sp(), "last_Java_sp must be set"); - // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown - EXCEPTION_MARK; - -#ifdef DEBUG - if (!obj->is_oop()) { - ResetNoHandleMark rhm; - nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); - if (method != NULL) { - tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), p2i(obj)); - } - thread->print_stack_on(tty); - assert(false, "invalid lock object pointer dected"); - } -#endif - - if (GraalUseFastLocking) { - // When using fast locking, the compiled code has already tried the fast case - ObjectSynchronizer::slow_exit(obj, lock, THREAD); - } else { - ObjectSynchronizer::fast_exit(obj, lock, THREAD); - } - if (TraceGraal >= 3) { - char type[O_BUFLEN]; - obj->klass()->name()->as_C_string(type, O_BUFLEN); - tty->print_cr("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock)); - tty->flush(); - } -JRT_END - -JRT_LEAF(void, GraalRuntime::log_object(JavaThread* thread, oopDesc* obj, jint flags)) - bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); - bool addr = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); - bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE); - if (!string) { - if (!addr && obj->is_oop_or_null(true)) { - char buf[O_BUFLEN]; - tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj)); - } else { - tty->print(INTPTR_FORMAT, p2i(obj)); - } - } else { - ResourceMark rm; - assert(obj != NULL && java_lang_String::is_instance(obj), "must be"); - char *buf = java_lang_String::as_utf8_string(obj); - tty->print_raw(buf); - } - if (newline) { - tty->cr(); - } -JRT_END - -JRT_LEAF(void, GraalRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj)) - thread->satb_mark_queue().enqueue(obj); -JRT_END - -JRT_LEAF(void, GraalRuntime::write_barrier_post(JavaThread* thread, void* card_addr)) - thread->dirty_card_queue().enqueue(card_addr); -JRT_END - -JRT_LEAF(jboolean, GraalRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child)) - bool ret = true; - if(!Universe::heap()->is_in_closed_subset(parent)) { - tty->print_cr("Parent Object "INTPTR_FORMAT" not in heap", p2i(parent)); - parent->print(); - ret=false; - } - if(!Universe::heap()->is_in_closed_subset(child)) { - tty->print_cr("Child Object "INTPTR_FORMAT" not in heap", p2i(child)); - child->print(); - ret=false; - } - return (jint)ret; -JRT_END - -JRT_ENTRY(void, GraalRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value)) - ResourceMark rm; - const char *error_msg = where == 0L ? "<internal Graal error>" : (char*) (address) where; - char *detail_msg = NULL; - if (format != 0L) { - const char* buf = (char*) (address) format; - size_t detail_msg_length = strlen(buf) * 2; - detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); - jio_snprintf(detail_msg, detail_msg_length, buf, value); - } - report_vm_error(__FILE__, __LINE__, error_msg, detail_msg); -JRT_END - -JRT_LEAF(oopDesc*, GraalRuntime::load_and_clear_exception(JavaThread* thread)) - oop exception = thread->exception_oop(); - assert(exception != NULL, "npe"); - thread->set_exception_oop(NULL); - thread->set_exception_pc(0); - return exception; -JRT_END - -JRT_LEAF(void, GraalRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3)) - ResourceMark rm; - assert(format != NULL && java_lang_String::is_instance(format), "must be"); - char *buf = java_lang_String::as_utf8_string(format); - tty->print(buf, v1, v2, v3); -JRT_END - -static void decipher(jlong v, bool ignoreZero) { - if (v != 0 || !ignoreZero) { - void* p = (void *)(address) v; - CodeBlob* cb = CodeCache::find_blob(p); - if (cb) { - if (cb->is_nmethod()) { - char buf[O_BUFLEN]; - tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin())); - return; - } - cb->print_value_on(tty); - return; - } - if (Universe::heap()->is_in(p)) { - oop obj = oop(p); - obj->print_value_on(tty); - return; - } - tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v); - } -} - -JRT_LEAF(void, GraalRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) - ResourceMark rm; - char *buf = (char*) (address) format; - if (vmError) { - if (buf != NULL) { - fatal(err_msg(buf, v1, v2, v3)); - } else { - fatal("<anonymous error>"); - } - } else if (buf != NULL) { - tty->print(buf, v1, v2, v3); - } else { - assert(v2 == 0, "v2 != 0"); - assert(v3 == 0, "v3 != 0"); - decipher(v1, false); - } -JRT_END - -JRT_LEAF(void, GraalRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) - union { - jlong l; - jdouble d; - jfloat f; - } uu; - uu.l = value; - switch (typeChar) { - case 'z': tty->print(value == 0 ? "false" : "true"); break; - case 'b': tty->print("%d", (jbyte) value); break; - case 'c': tty->print("%c", (jchar) value); break; - case 's': tty->print("%d", (jshort) value); break; - case 'i': tty->print("%d", (jint) value); break; - case 'f': tty->print("%f", uu.f); break; - case 'j': tty->print(JLONG_FORMAT, value); break; - case 'd': tty->print("%lf", uu.d); break; - default: assert(false, "unknown typeChar"); break; - } - if (newline) { - tty->cr(); - } -JRT_END - -JRT_ENTRY(jint, GraalRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj)) - return (jint) obj->identity_hash(); -JRT_END - -JRT_ENTRY(jboolean, GraalRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted)) - // Ensure that the C++ Thread and OSThread structures aren't freed before we operate. - // This locking requires thread_in_vm which is why this method cannot be JRT_LEAF. - Handle receiverHandle(thread, receiver); - MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock); - JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle()); - if (receiverThread == NULL) { - // The other thread may exit during this process, which is ok so return false. - return JNI_FALSE; - } else { - return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0); - } -JRT_END - -JRT_ENTRY(jint, GraalRuntime::test_deoptimize_call_int(JavaThread* thread, int value)) - deopt_caller(); - return value; -JRT_END - -// private static void Factory.init() -JVM_ENTRY(void, JVM_InitGraalClassLoader(JNIEnv *env, jclass c, jobject loader_handle)) - SystemDictionary::init_graal_loader(JNIHandles::resolve(loader_handle)); - SystemDictionary::WKID scan = SystemDictionary::FIRST_GRAAL_WKID; - SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_GRAAL_WKID, scan, CHECK); -JVM_END - -// private static JVMCIRuntime JVMCI.initializeRuntime() -JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c)) - GraalRuntime::initialize_HotSpotJVMCIRuntime(); - return GraalRuntime::get_HotSpotJVMCIRuntime_jobject(); -JVM_END - -// private static String[] Services.getServiceImpls(Class service) -JVM_ENTRY(jobject, JVM_GetGraalServiceImpls(JNIEnv *env, jclass c, jclass serviceClass)) - HandleMark hm; - ResourceMark rm; - KlassHandle serviceKlass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(serviceClass))); - return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(serviceKlass, THREAD)()); -JVM_END - -// private static TruffleRuntime Truffle.createRuntime() -JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c)) - GraalRuntime::ensure_graal_class_loader_is_initialized(); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", CHECK_NULL); - KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL); - - TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", CHECK_NULL); - TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/truffle/api/TruffleRuntime;", CHECK_NULL); - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL); - return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); -JVM_END - -// private static NativeFunctionInterfaceRuntime.createInterface() -JVM_ENTRY(jobject, JVM_CreateNativeFunctionInterface(JNIEnv *env, jclass c)) - GraalRuntime::ensure_graal_class_loader_is_initialized(); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", CHECK_NULL); - KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL); - - TempNewSymbol makeInstance = SymbolTable::new_symbol("createNativeFunctionInterface", CHECK_NULL); - TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/nfi/api/NativeFunctionInterface;", CHECK_NULL); - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL); - return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); -JVM_END - -void GraalRuntime::check_generated_sources_sha1(TRAPS) { - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/sourcegen/GeneratedSourcesSha1", CHECK_ABORT); - KlassHandle klass = load_required_class(name); - fieldDescriptor fd; - if (!InstanceKlass::cast(klass())->find_field(vmSymbols::value_name(), vmSymbols::string_signature(), true, &fd)) { - THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), "GeneratedSourcesSha1.value"); - } - - Symbol* value = java_lang_String::as_symbol(klass->java_mirror()->obj_field(fd.offset()), CHECK); - if (!value->equals(_generated_sources_sha1)) { - char buf[200]; - jio_snprintf(buf, sizeof(buf), "Generated sources SHA1 check failed (%s != %s) - need to rebuild the VM", value->as_C_string(), _generated_sources_sha1); - THROW_MSG(vmSymbols::java_lang_InternalError(), buf); - } -} - -Handle GraalRuntime::callInitializer(const char* className, const char* methodName, const char* returnType) { - guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); - Thread* THREAD = Thread::current(); - check_generated_sources_sha1(CHECK_ABORT_(Handle())); - - TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_ABORT_(Handle())); - KlassHandle klass = load_required_class(name); - TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_ABORT_(Handle())); - TempNewSymbol sig = SymbolTable::new_symbol(returnType, CHECK_ABORT_(Handle())); - JavaValue result(T_OBJECT); - JavaCalls::call_static(&result, klass, runtime, sig, CHECK_ABORT_(Handle())); - return Handle((oop)result.get_jobject()); -} - -void GraalRuntime::initialize_HotSpotJVMCIRuntime() { - if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { -#ifdef ASSERT - // This should only be called in the context of the JVMCI class being initialized - Thread* THREAD = Thread::current(); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/runtime/JVMCI", CHECK_ABORT); - instanceKlassHandle klass = InstanceKlass::cast(load_required_class(name)); - assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), - "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); -#endif - - Handle result = callInitializer("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", "runtime", - "()Lcom/oracle/jvmci/hotspot/HotSpotJVMCIRuntime;"); - _HotSpotJVMCIRuntime_initialized = true; - _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); - } -} - -void GraalRuntime::initialize_JVMCI() { - if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { - callInitializer("com/oracle/jvmci/runtime/JVMCI", "getRuntime", "()Lcom/oracle/jvmci/runtime/JVMCIRuntime;"); - } - assert(_HotSpotJVMCIRuntime_initialized == true, "what?"); -} - -// private static void CompilerToVMImpl.init() -JVM_ENTRY(void, JVM_InitializeGraalNatives(JNIEnv *env, jclass c2vmClass)) - GraalRuntime::initialize_natives(env, c2vmClass); -JVM_END - -// private static OptionsParsed[] HotSpotOptions.parseVMOptions(Class) -JVM_ENTRY(jobject, JVM_ParseGraalOptions(JNIEnv *env, jclass c, jobject optionsParsedClass_obj)) - HandleMark hm; - KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c))); - GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_NULL); - KlassHandle optionsParsedClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(optionsParsedClass_obj))); - return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(optionsParsedClass, THREAD)()); -JVM_END - - -void GraalRuntime::ensure_graal_class_loader_is_initialized() { - // This initialization code is guarded by a static pointer to the Factory class. - // Once it is non-null, the Graal class loader and well known Graal classes are - // guaranteed to have been initialized. By going through the static - // initializer of Factory, we can rely on class initialization semantics to - // synchronize threads racing to do the initialization. - static Klass* _FactoryKlass = NULL; - if (_FactoryKlass == NULL) { - Thread* THREAD = Thread::current(); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/loader/Factory", CHECK_ABORT); - KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, THREAD); - if (HAS_PENDING_EXCEPTION) { - static volatile int seen_error = 0; - if (!seen_error && Atomic::cmpxchg(1, &seen_error, 0) == 0) { - // Only report the failure on the first thread that hits it - abort_on_pending_exception(PENDING_EXCEPTION, "Graal classes are not available"); - } else { - CLEAR_PENDING_EXCEPTION; - // Give first thread time to report the error. - os::sleep(THREAD, 100, false); - vm_abort(false); - } - } - - // We cannot use graalJavaAccess for this because we are currently in the - // process of initializing that mechanism. - TempNewSymbol field_name = SymbolTable::new_symbol("useGraalClassLoader", CHECK_ABORT); - fieldDescriptor field_desc; - if (klass->find_field(field_name, vmSymbols::bool_signature(), &field_desc) == NULL) { - ResourceMark rm; - fatal(err_msg("Invalid layout of %s at %s", field_name->as_C_string(), klass->external_name())); - } - - InstanceKlass* ik = InstanceKlass::cast(klass()); - address addr = ik->static_field_addr(field_desc.offset() - InstanceMirrorKlass::offset_of_static_fields()); - *((jboolean *) addr) = (jboolean) UseGraalClassLoader; - klass->initialize(CHECK_ABORT); - _FactoryKlass = klass(); - } -} - -jint GraalRuntime::check_arguments(TRAPS) { - KlassHandle nullHandle; - parse_arguments(nullHandle, THREAD); - if (HAS_PENDING_EXCEPTION) { - // Errors in parsing Graal arguments cause exceptions. - // We now load and initialize HotSpotOptions which in turn - // causes argument parsing to be redone with better error messages. - CLEAR_PENDING_EXCEPTION; - TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/jvmci/hotspot/HotSpotOptions;", CHECK_ABORT_(JNI_ERR)); - instanceKlassHandle hotSpotOptionsClass = resolve_or_fail(name, CHECK_ABORT_(JNI_ERR)); - - parse_arguments(hotSpotOptionsClass, THREAD); - assert(HAS_PENDING_EXCEPTION, "must be"); - - ResourceMark rm; - Handle exception = PENDING_EXCEPTION; - CLEAR_PENDING_EXCEPTION; - oop message = java_lang_Throwable::message(exception); - if (message != NULL) { - tty->print_cr("Error parsing Graal options: %s", java_lang_String::as_utf8_string(message)); - } else { - call_printStackTrace(exception, THREAD); - } - return JNI_ERR; - } - return JNI_OK; -} - -void GraalRuntime::parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS) { - ResourceMark rm(THREAD); - - // Process option overrides from graal.options first - parse_graal_options_file(hotSpotOptionsClass, CHECK); - - // Now process options on the command line - int numOptions = Arguments::num_graal_args(); - for (int i = 0; i < numOptions; i++) { - char* arg = Arguments::graal_args_array()[i]; - parse_argument(hotSpotOptionsClass, arg, CHECK); - } -} - -void GraalRuntime::check_required_value(const char* name, size_t name_len, const char* value, TRAPS) { - if (value == NULL) { - char buf[200]; - jio_snprintf(buf, sizeof(buf), "Must use '-G:%.*s=<value>' format for %.*s option", name_len, name, name_len, name); - THROW_MSG(vmSymbols::java_lang_InternalError(), buf); - } -} - -void GraalRuntime::parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS) { - ensure_graal_class_loader_is_initialized(); - char first = arg[0]; - char* name; - size_t name_len; - bool recognized = true; - if (first == '+' || first == '-') { - name = arg + 1; - name_len = strlen(name); - recognized = set_option_bool(hotSpotOptionsClass, name, name_len, first, CHECK); - } else { - char* sep = strchr(arg, '='); - name = arg; - char* value = NULL; - if (sep != NULL) { - name_len = sep - name; - value = sep + 1; - } else { - name_len = strlen(name); - } - recognized = set_option(hotSpotOptionsClass, name, name_len, value, CHECK); - } - - if (!recognized) { - bool throw_err = hotSpotOptionsClass.is_null(); - if (!hotSpotOptionsClass.is_null()) { - set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), ' ', Handle(), 0L); - if (!HAS_PENDING_EXCEPTION) { - throw_err = true; - } - } - - if (throw_err) { - char buf[200]; - jio_snprintf(buf, sizeof(buf), "Unrecognized Graal option %.*s", name_len, name); - THROW_MSG(vmSymbols::java_lang_InternalError(), buf); - } - } -} - -void GraalRuntime::parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS) { - const char* home = Arguments::get_java_home(); - size_t path_len = strlen(home) + strlen("/lib/graal.options") + 1; - char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); - char sep = os::file_separator()[0]; - sprintf(path, "%s%clib%cgraal.options", home, sep, sep); - - struct stat st; - if (os::stat(path, &st) == 0) { - int file_handle = os::open(path, 0, 0); - if (file_handle != -1) { - char* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, st.st_size); - int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); - if (num_read == -1) { - warning("Error reading file %s due to %s", path, strerror(errno)); - } else if (num_read != st.st_size) { - warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path); - } - os::close(file_handle); - if (num_read == st.st_size) { - char* line = buffer; - int lineNo = 1; - while (line - buffer < num_read) { - char* nl = strchr(line, '\n'); - if (nl != NULL) { - *nl = '\0'; - } - parse_argument(hotSpotOptionsClass, line, THREAD); - if (HAS_PENDING_EXCEPTION) { - warning("Error in %s:%d", path, lineNo); - return; - } - if (nl != NULL) { - line = nl + 1; - lineNo++; - } else { - // File without newline at the end - break; - } - } - } - } else { - warning("Error opening file %s due to %s", path, strerror(errno)); - } - } -} - -jlong GraalRuntime::parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS) { - check_required_value(name, name_len, value, CHECK_(0L)); - union { - jint i; - jlong l; - double d; - } uu; - uu.l = 0L; - char dummy; - switch (spec) { - case 'd': - case 'f': { - if (sscanf(value, "%lf%c", &uu.d, &dummy) == 1) { - return uu.l; - } - break; - } - case 'i': { - if (sscanf(value, "%d%c", &uu.i, &dummy) == 1) { - return (jlong)uu.i; - } - break; - } - default: - ShouldNotReachHere(); - } - ResourceMark rm(THREAD); - char buf[200]; - bool missing = strlen(value) == 0; - if (missing) { - jio_snprintf(buf, sizeof(buf), "Missing %s value for Graal option %.*s", (spec == 'i' ? "numeric" : "float/double"), name_len, name); - } else { - jio_snprintf(buf, sizeof(buf), "Invalid %s value for Graal option %.*s: %s", (spec == 'i' ? "numeric" : "float/double"), name_len, name, value); - } - THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L); -} - -void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) { - Thread* THREAD = Thread::current(); - Handle name_handle; - if (name != NULL) { - if (strlen(name) > name_len) { - // Temporarily replace '=' with NULL to create the Java string for the option name - char save = name[name_len]; - name[name_len] = '\0'; - name_handle = java_lang_String::create_from_str(name, THREAD); - name[name_len] = '='; - if (HAS_PENDING_EXCEPTION) { - return; - } - } else { - assert(strlen(name) == name_len, "must be"); - name_handle = java_lang_String::create_from_str(name, CHECK); - } - } - - TempNewSymbol setOption = SymbolTable::new_symbol("setOption", CHECK); - TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/jvmci/options/OptionValue;CLjava/lang/String;J)V", CHECK); - JavaValue result(T_VOID); - JavaCallArguments args; - args.push_oop(name_handle()); - args.push_oop(option()); - args.push_int(spec); - args.push_oop(stringValue()); - args.push_long(primitiveValue); - JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK); -} - -Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) { - TempNewSymbol name = SymbolTable::new_symbol(declaringClass, CHECK_NH); - Klass* klass = resolve_or_fail(name, CHECK_NH); - - // The class has been loaded so the field and signature should already be in the symbol - // table. If they're not there, the field doesn't exist. - TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName)); - TempNewSymbol signame = SymbolTable::probe(fieldSig, (int)strlen(fieldSig)); - if (fieldname == NULL || signame == NULL) { - THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle()); - } - // Make sure class is initialized before handing id's out to fields - klass->initialize(CHECK_NH); - - fieldDescriptor fd; - if (!InstanceKlass::cast(klass)->find_field(fieldname, signame, true, &fd)) { - THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle()); - } - - Handle ret = klass->java_mirror()->obj_field(fd.offset()); - return ret; -} - -Handle GraalRuntime::create_Service(const char* name, TRAPS) { - TempNewSymbol kname = SymbolTable::new_symbol(name, CHECK_NH); - Klass* k = resolve_or_fail(kname, CHECK_NH); - instanceKlassHandle klass(THREAD, k); - klass->initialize(CHECK_NH); - klass->check_valid_for_instantiation(true, CHECK_NH); - JavaValue result(T_VOID); - instanceHandle service = klass->allocate_instance_handle(CHECK_NH); - JavaCalls::call_special(&result, service, klass, vmSymbols::object_initializer_name(), vmSymbols::void_method_signature(), THREAD); - return service; -} - -void GraalRuntime::shutdown() { - if (_HotSpotJVMCIRuntime_instance != NULL) { - _shutdown_called = true; - JavaThread* THREAD = JavaThread::current(); - HandleMark hm(THREAD); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", CHECK_ABORT); - KlassHandle klass = load_required_class(name); - JavaValue result(T_VOID); - JavaCallArguments args; - args.push_oop(get_HotSpotJVMCIRuntime()); - JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT); - - JNIHandles::destroy_global(_HotSpotJVMCIRuntime_instance); - _HotSpotJVMCIRuntime_instance = NULL; - } -} - -void GraalRuntime::call_printStackTrace(Handle exception, Thread* thread) { - assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected"); - JavaValue result(T_VOID); - JavaCalls::call_virtual(&result, - exception, - KlassHandle(thread, - SystemDictionary::Throwable_klass()), - vmSymbols::printStackTrace_name(), - vmSymbols::void_method_signature(), - thread); -} - -void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) { - Thread* THREAD = Thread::current(); - CLEAR_PENDING_EXCEPTION; - tty->print_raw_cr(message); - call_printStackTrace(exception, THREAD); - - // Give other aborting threads to also print their stack traces. - // This can be very useful when debugging class initialization - // failures. - os::sleep(THREAD, 200, false); - - vm_abort(dump_core); -} - -Klass* GraalRuntime::resolve_or_null(Symbol* name, TRAPS) { - return SystemDictionary::resolve_or_null(name, SystemDictionary::graal_loader(), Handle(), CHECK_NULL); -} - -Klass* GraalRuntime::resolve_or_fail(Symbol* name, TRAPS) { - return SystemDictionary::resolve_or_fail(name, SystemDictionary::graal_loader(), Handle(), true, CHECK_NULL); -} - -Klass* GraalRuntime::load_required_class(Symbol* name) { - Klass* klass = resolve_or_null(name, Thread::current()); - if (klass == NULL) { - tty->print_cr("Could not load class %s", name->as_C_string()); - vm_abort(false); - } - return klass; -} - -Handle GraalRuntime::get_service_impls(KlassHandle serviceKlass, TRAPS) { - const char* home = Arguments::get_java_home(); - const char* serviceName = serviceKlass->external_name(); - size_t path_len = strlen(home) + strlen("/lib/graal/services/") + strlen(serviceName) + 1; - char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); - char sep = os::file_separator()[0]; - sprintf(path, "%s%clib%cgraal%cservices%c%s", home, sep, sep, sep, sep, serviceName); - struct stat st; - if (os::stat(path, &st) == 0) { - int file_handle = os::open(path, 0, 0); - if (file_handle != -1) { - char* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, st.st_size + 1); - int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); - if (num_read == -1) { - warning("Error reading file %s due to %s", path, strerror(errno)); - } else if (num_read != st.st_size) { - warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path); - } - os::close(file_handle); - if (num_read == st.st_size) { - buffer[num_read] = '\0'; - GrowableArray<char*>* implNames = new GrowableArray<char*>(); - char* line = buffer; - while (line - buffer < num_read) { - // find line end (\r, \n or \r\n) - char* nextline = NULL; - char* cr = strchr(line, '\r'); - char* lf = strchr(line, '\n'); - if (cr != NULL && lf != NULL) { - char* min = MIN2(cr, lf); - *min = '\0'; - if (lf == cr + 1) { - nextline = lf + 1; - } else { - nextline = min + 1; - } - } else if (cr != NULL) { - *cr = '\0'; - nextline = cr + 1; - } else if (lf != NULL) { - *lf = '\0'; - nextline = lf + 1; - } - // trim left - while (*line == ' ' || *line == '\t') line++; - char* end = line + strlen(line); - // trim right - while (end > line && (*(end -1) == ' ' || *(end -1) == '\t')) end--; - *end = '\0'; - // skip comments and empty lines - if (*line != '#' && strlen(line) > 0) { - // Turn all '.'s into '/'s - for (size_t index = 0; line[index] != '\0'; index++) { - if (line[index] == '.') { - line[index] = '/'; - } - } - implNames->append(line); - } - if (nextline != NULL) { - line = nextline; - } else { - // File without newline at the end - break; - } - } - - objArrayOop servicesOop = oopFactory::new_objArray(serviceKlass(), implNames->length(), CHECK_NH); - objArrayHandle services(THREAD, servicesOop); - for (int i = 0; i < implNames->length(); ++i) { - char* implName = implNames->at(i); - Handle service = create_Service(implName, CHECK_NH); - services->obj_at_put(i, service()); - } - return services; - } - } else { - warning("Error opening file %s due to %s", path, strerror(errno)); - } - } else { - warning("Error opening file %s due to %s", path, strerror(errno)); - } - return Handle(); -} - -#include "graalRuntime.inline.hpp"
--- a/src/share/vm/graal/graalRuntime.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,292 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - -#ifndef SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP -#define SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP - -#include "interpreter/interpreter.hpp" -#include "memory/allocation.hpp" -#include "runtime/deoptimization.hpp" - -class GraalRuntime: public CHeapObj<mtCompiler> { - private: - - static jobject _HotSpotJVMCIRuntime_instance; - static bool _HotSpotJVMCIRuntime_initialized; - static const char* _generated_sources_sha1; - - static bool _shutdown_called; - - /** - * Reads the OptionValue object from a specified static field. - * - * @throws LinkageError if the field could not be resolved - */ - static Handle get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS); - - /** - * Parses the string form of a numeric, float or double option into a jlong (using raw bits for floats/doubles). - * - * @param spec 'i', 'f' or 'd' (see HotSpotOptions.setOption()) - * @param name option name - * @param name_len length of option name - * @param value string value to parse - * @throws InternalError if value could not be parsed according to spec - */ - static jlong parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS); - - /** - * Loads default option value overrides from a <jre_home>/lib/graal.options if it exists. Each - * line in this file must have the format of a Graal command line option without the - * leading "-G:" prefix. These option values are set prior to processing of any Graal - * options present on the command line. - */ - static void parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS); - - /** - * Parses a given argument and sets the denoted Graal option. - * - * @throws InternalError if there was a problem parsing or setting the option - */ - static void parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS); - - /** - * Searches for a Boolean Graal option denoted by a given name and sets it value. - * - * The definition of this method is in graalRuntime.inline.hpp - * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. - * - * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option - * @param name option name - * @param name_len length of option name - * @param value '+' to set the option, '-' to reset the option - * @returns true if the option was found - * @throws InternalError if there was a problem setting the option's value - */ - static bool set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS); - - /** - * Searches for a Graal option denoted by a given name and sets it value. - * - * The definition of this method is in graalRuntime.inline.hpp - * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. - * - * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option - * @param name option name - * @param name_len length of option name - * @returns true if the option was found - * @throws InternalError if there was a problem setting the option's value - */ - static bool set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS); - - /** - * Raises an InternalError for an option that expects a value but was specified without a "=<value>" prefix. - */ - static void check_required_value(const char* name, size_t name_len, const char* value, TRAPS); - - /** - * Java call to HotSpotOptions.setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue) - * - * @param name option name - * @param name_len length of option name - */ - static void set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue); - - /** - * Instantiates a service object, calls its default constructor and returns it. - * - * @param name the name of a class implementing com.oracle.graal.api.runtime.Service - */ - static Handle create_Service(const char* name, TRAPS); - - /** - * Checks that _generated_sources_sha1 equals GeneratedSourcesSha1.value. - */ - static void check_generated_sources_sha1(TRAPS); - - public: - - /** - * Ensures that the Graal class loader is initialized and the well known Graal classes are loaded. - */ - static void ensure_graal_class_loader_is_initialized(); - - static void initialize_natives(JNIEnv *env, jclass c2vmClass); - - static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; } - - /** - * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary - */ - static Handle get_HotSpotJVMCIRuntime() { - initialize_JVMCI(); - return Handle(JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance)); - } - - static jobject get_HotSpotJVMCIRuntime_jobject() { - initialize_JVMCI(); - assert(_HotSpotJVMCIRuntime_initialized, "must be"); - return _HotSpotJVMCIRuntime_instance; - } - - static Handle callInitializer(const char* className, const char* methodName, const char* returnType); - - /** - * Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime() - */ - static void initialize_JVMCI(); - - /** - * Explicitly initialize HotSpotJVMCIRuntime itself - */ - static void initialize_HotSpotJVMCIRuntime(); - - static void shutdown(); - - static bool shutdown_called() { - return _shutdown_called; - } - - /** - * Given an interface representing a Graal service (i.e. sub-interface of - * com.oracle.graal.api.runtime.Service), gets an array of objects, one per - * known implementation of the service. - * - * The definition of this method is in graalRuntime.inline.hpp - * which is generated by com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp. - */ - static Handle get_service_impls(KlassHandle serviceKlass, TRAPS); - - /** - * Aborts the VM due to an unexpected exception. - */ - static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false); - - /** - * Calls Throwable.printStackTrace() on a given exception. - */ - static void call_printStackTrace(Handle exception, Thread* thread); - -#define CHECK_ABORT THREAD); \ - if (HAS_PENDING_EXCEPTION) { \ - char buf[256]; \ - jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ - GraalRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \ - return; \ - } \ - (void)(0 - -#define CHECK_ABORT_(result) THREAD); \ - if (HAS_PENDING_EXCEPTION) { \ - char buf[256]; \ - jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ - GraalRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \ - return result; \ - } \ - (void)(0 - - /** - * Same as SystemDictionary::resolve_or_null but uses the Graal loader. - */ - static Klass* resolve_or_null(Symbol* name, TRAPS); - - /** - * Same as SystemDictionary::resolve_or_fail but uses the Graal loader. - */ - static Klass* resolve_or_fail(Symbol* name, TRAPS); - - /** - * Loads a given Graal class and aborts the VM if it fails. - */ - static Klass* load_required_class(Symbol* name); - - static BufferBlob* initialize_buffer_blob(); - - /** - * Checks that all Graal specific VM options presented by the launcher are recognized - * and formatted correctly. To set relevant Java fields from the option, parse_arguments() - * must be called. This method makes no Java calls apart from creating exception objects - * if there is an errors in the Graal options. - */ - static jint check_arguments(TRAPS); - - /** - * Parses the JVMCI specific VM options that were presented by the launcher and sets - * the relevants Java fields. - */ - static void parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS); - - static BasicType kindToBasicType(jchar ch); - - // The following routines are all called from compiled Graal code - - static void new_instance(JavaThread* thread, Klass* klass); - static void new_array(JavaThread* thread, Klass* klass, jint length); - static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims); - static void dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length); - static void dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror); - static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupted); - static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3); - static jint identity_hash_code(JavaThread* thread, oopDesc* obj); - static address exception_handler_for_pc(JavaThread* thread); - static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock); - static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock); - static void create_null_exception(JavaThread* thread); - static void create_out_of_bounds_exception(JavaThread* thread, jint index); - static void vm_error(JavaThread* thread, jlong where, jlong format, jlong value); - static oopDesc* load_and_clear_exception(JavaThread* thread); - static void log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3); - static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline); - // Note: Must be kept in sync with constants in com.oracle.graal.replacements.Log - enum { - LOG_OBJECT_NEWLINE = 0x01, - LOG_OBJECT_STRING = 0x02, - LOG_OBJECT_ADDRESS = 0x04 - }; - static void log_object(JavaThread* thread, oopDesc* msg, jint flags); - static void write_barrier_pre(JavaThread* thread, oopDesc* obj); - static void write_barrier_post(JavaThread* thread, void* card); - static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child); - static void new_store_pre_barrier(JavaThread* thread); - - // Test only function - static int test_deoptimize_call_int(JavaThread* thread, int value); -}; - -// Tracing macros - -#define IF_TRACE_graal_1 if (!(TraceGraal >= 1)) ; else -#define IF_TRACE_graal_2 if (!(TraceGraal >= 2)) ; else -#define IF_TRACE_graal_3 if (!(TraceGraal >= 3)) ; else -#define IF_TRACE_graal_4 if (!(TraceGraal >= 4)) ; else -#define IF_TRACE_graal_5 if (!(TraceGraal >= 5)) ; else - -// using commas and else to keep one-instruction semantics - -#define TRACE_graal_1 if (!(TraceGraal >= 1 && (tty->print("TraceGraal-1: "), true))) ; else tty->print_cr -#define TRACE_graal_2 if (!(TraceGraal >= 2 && (tty->print(" TraceGraal-2: "), true))) ; else tty->print_cr -#define TRACE_graal_3 if (!(TraceGraal >= 3 && (tty->print(" TraceGraal-3: "), true))) ; else tty->print_cr -#define TRACE_graal_4 if (!(TraceGraal >= 4 && (tty->print(" TraceGraal-4: "), true))) ; else tty->print_cr -#define TRACE_graal_5 if (!(TraceGraal >= 5 && (tty->print(" TraceGraal-5: "), true))) ; else tty->print_cr - -#endif // SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP
--- a/src/share/vm/graal/vmStructs_graal.hpp Wed May 27 13:43:27 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2013, 2014, 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. - * - */ - -#ifndef SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP -#define SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP - -#include "compiler/abstractCompiler.hpp" -#include "graal/graalCodeInstaller.hpp" -#include "graal/graalCompilerToVM.hpp" -#include "graal/graalEnv.hpp" - -#define VM_STRUCTS_GRAAL(nonstatic_field, static_field) \ - nonstatic_field(ThreadShadow, _pending_deoptimization, int) \ - nonstatic_field(ThreadShadow, _pending_failed_speculation, oop) \ - nonstatic_field(ThreadShadow, _pending_transfer_to_interpreter, bool) \ - nonstatic_field(MethodData, _jvmci_ir_size, int) \ - nonstatic_field(GraalEnv, _task, CompileTask*) \ - nonstatic_field(GraalEnv, _jvmti_can_hotswap_or_post_breakpoint, bool) \ - -#define VM_TYPES_GRAAL(declare_type, declare_toplevel_type) \ - declare_toplevel_type(GraalEnv) \ - -#define VM_INT_CONSTANTS_GRAAL(declare_constant, declare_preprocessor_constant) \ - declare_constant(Deoptimization::Reason_unreached0) \ - declare_constant(Deoptimization::Reason_type_checked_inlining) \ - declare_constant(Deoptimization::Reason_optimized_type_check) \ - declare_constant(Deoptimization::Reason_aliasing) \ - declare_constant(Deoptimization::Reason_transfer_to_interpreter) \ - declare_constant(Deoptimization::Reason_not_compiled_exception_handler) \ - declare_constant(Deoptimization::Reason_unresolved) \ - declare_constant(Deoptimization::Reason_jsr_mismatch) \ - declare_constant(GraalEnv::ok) \ - declare_constant(GraalEnv::dependencies_failed) \ - declare_constant(GraalEnv::dependencies_invalid) \ - declare_constant(GraalEnv::cache_full) \ - declare_constant(GraalEnv::code_too_large) \ - \ - declare_preprocessor_constant("JVM_ACC_SYNTHETIC", JVM_ACC_SYNTHETIC) \ - declare_preprocessor_constant("JVM_RECOGNIZED_FIELD_MODIFIERS", JVM_RECOGNIZED_FIELD_MODIFIERS) \ - \ - declare_constant(CompilerToVM::KLASS_TAG) \ - declare_constant(CompilerToVM::SYMBOL_TAG) \ - \ - declare_constant(CodeInstaller::VERIFIED_ENTRY) \ - declare_constant(CodeInstaller::UNVERIFIED_ENTRY) \ - declare_constant(CodeInstaller::OSR_ENTRY) \ - declare_constant(CodeInstaller::EXCEPTION_HANDLER_ENTRY) \ - declare_constant(CodeInstaller::DEOPT_HANDLER_ENTRY) \ - declare_constant(CodeInstaller::INVOKEINTERFACE) \ - declare_constant(CodeInstaller::INVOKEVIRTUAL) \ - declare_constant(CodeInstaller::INVOKESTATIC) \ - declare_constant(CodeInstaller::INVOKESPECIAL) \ - declare_constant(CodeInstaller::INLINE_INVOKE) \ - declare_constant(CodeInstaller::POLL_NEAR) \ - declare_constant(CodeInstaller::POLL_RETURN_NEAR) \ - declare_constant(CodeInstaller::POLL_FAR) \ - declare_constant(CodeInstaller::POLL_RETURN_FAR) \ - declare_constant(CodeInstaller::CARD_TABLE_SHIFT) \ - declare_constant(CodeInstaller::CARD_TABLE_ADDRESS) \ - declare_constant(CodeInstaller::INVOKE_INVALID) \ - \ - declare_constant(Method::invalid_vtable_index) \ - -#endif // SHARE_VM_GRAAL_VMSTRUCTS_GRAAL_HPP
--- a/src/share/vm/interpreter/interpreter.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/interpreter/interpreter.cpp Thu May 28 15:36:48 2015 +0200 @@ -409,7 +409,7 @@ address AbstractInterpreter::deopt_reexecute_entry(Method* method, address bcp) { assert(method->contains(bcp), "just checkin'"); Bytecodes::Code code = Bytecodes::java_code_at(method, bcp); -#if defined(COMPILER1) || defined(GRAAL) +#if defined(COMPILER1) || defined(JVMCI) if(code == Bytecodes::_athrow ) { return Interpreter::rethrow_exception_entry(); }
--- a/src/share/vm/interpreter/interpreterRuntime.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/interpreter/interpreterRuntime.cpp Thu May 28 15:36:48 2015 +0200 @@ -475,7 +475,7 @@ } } while (should_repeat == true); -#ifdef GRAAL +#ifdef JVMCI if (h_method->method_data() != NULL) { ResourceMark rm(thread); ProfileData* pdata = h_method->method_data()->allocate_bci_to_data(current_bci, NULL);
--- a/src/share/vm/interpreter/linkResolver.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/interpreter/linkResolver.hpp Thu May 28 15:36:48 2015 +0200 @@ -125,11 +125,11 @@ private: static void lookup_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, bool in_imethod_resolve, TRAPS); -#ifdef GRAAL +#ifdef JVMCI public: #endif static void lookup_instance_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); -#ifdef GRAAL +#ifdef JVMCI private: #endif static void lookup_method_in_interfaces (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); @@ -145,12 +145,12 @@ static void linktime_resolve_static_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); static void linktime_resolve_special_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); -#ifdef GRAAL +#ifdef JVMCI public: #endif static void linktime_resolve_virtual_method (methodHandle &resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature,KlassHandle current_klass, bool check_access, TRAPS); static void linktime_resolve_interface_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS); -#ifdef GRAAL +#ifdef JVMCI private: #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciCodeInstaller.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,989 @@ +/* + * Copyright (c) 2011, 2014, 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. + */ + +#include "precompiled.hpp" +#include "code/compiledIC.hpp" +#include "compiler/compileBroker.hpp" +#include "compiler/disassembler.hpp" +#include "runtime/javaCalls.hpp" +#include "jvmci/jvmciEnv.hpp" +#include "jvmci/jvmciCompiler.hpp" +#include "jvmci/jvmciCodeInstaller.hpp" +#include "jvmci/jvmciJavaAccess.hpp" +#include "jvmci/jvmciCompilerToVM.hpp" +#include "jvmci/jvmciRuntime.hpp" +#include "asm/register.hpp" +#include "classfile/vmSymbols.hpp" +#include "code/vmreg.hpp" + +#ifdef TARGET_ARCH_x86 +# include "vmreg_x86.inline.hpp" +#endif +#ifdef TARGET_ARCH_sparc +# include "vmreg_sparc.inline.hpp" +#endif +#ifdef TARGET_ARCH_zero +# include "vmreg_zero.inline.hpp" +#endif +#ifdef TARGET_ARCH_arm +# include "vmreg_arm.inline.hpp" +#endif +#ifdef TARGET_ARCH_ppc +# include "vmreg_ppc.inline.hpp" +#endif + + +// frequently used constants +// Allocate them with new so they are never destroyed (otherwise, a +// forced exit could destroy these objects while they are still in +// use). +ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantOopWriteValue(NULL); +ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(-1); +ConstantIntValue* CodeInstaller::_int_0_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(0); +ConstantIntValue* CodeInstaller::_int_1_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(1); +ConstantIntValue* CodeInstaller::_int_2_scope_value = new (ResourceObj::C_HEAP, mtCompiler) ConstantIntValue(2); +LocationValue* CodeInstaller::_illegal_value = new (ResourceObj::C_HEAP, mtCompiler) LocationValue(Location()); + +Method* getMethodFromHotSpotMethod(oop hotspot_method) { + assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethodImpl::klass()), "sanity"); + return asMethod(HotSpotResolvedJavaMethodImpl::metaspaceMethod(hotspot_method)); +} + +const int MapWordBits = 64; + +static int entry_value(typeArrayOop words, int i) { + jint words_idx = i / MapWordBits; + assert(words_idx >= 0 && words_idx < words->length(), "unexpected index"); + jlong word = words->long_at(words_idx); + return (word >> (i % MapWordBits)) & 15LL; +} + +static int fixedmap_size(oop bitset) { + typeArrayOop arr = HotSpotOopMap::words(bitset); + return arr->length() * MapWordBits; +} + +static void set_vmreg_oops(OopMap* map, VMReg reg, typeArrayOop words, int idx) { + int value = entry_value(words, 4 * idx); + switch (value) { + case 10: + map->set_oop(reg); + break; + case 5: + map->set_narrowoop(reg); + map->set_narrowoop(reg->next()); + break; + case 1: + map->set_narrowoop(reg); + break; + case 4: + map->set_narrowoop(reg->next()); + break; + case 0: + break; + default: + assert(false, err_msg("unexpected bit pattern at %d = 0x%x", idx, value)); + ShouldNotReachHere(); + } +} + +// creates a HotSpot oop map out of the byte arrays provided by DebugInfo +static OopMap* create_oop_map(jint total_frame_size, jint parameter_count, oop debug_info) { + OopMap* map = new OopMap(total_frame_size, parameter_count); + oop reference_map = DebugInfo::referenceMap(debug_info); + oop register_map = HotSpotReferenceMap::registerRefMap(reference_map); + oop frame_map = HotSpotReferenceMap::frameRefMap(reference_map); + oop callee_save_info = (oop) DebugInfo::calleeSaveInfo(debug_info); + + if (register_map != NULL) { + typeArrayOop words = HotSpotOopMap::words(register_map); + int mapIdx = 0; + for (jint i = 0; i < RegisterImpl::number_of_registers; i++) { + set_vmreg_oops(map, as_Register(i)->as_VMReg(), words, mapIdx); + mapIdx++; + } +#ifdef TARGET_ARCH_x86 + for (jint i = 0; i < XMMRegisterImpl::number_of_registers; i++) { + VMReg reg = as_XMMRegister(i)->as_VMReg(); + for (jint j = 0; j < 4; j++) { + set_vmreg_oops(map, reg->next(2 * j), words, mapIdx++); + } + } +#endif +#ifdef TARGET_ARCH_sparc + for (jint i = 0; i < FloatRegisterImpl::number_of_registers; i++) { + VMReg reg = as_FloatRegister(i)->as_VMReg(); + set_vmreg_oops(map, reg, words, mapIdx++); + } +#endif + } + + typeArrayOop words = HotSpotOopMap::words(frame_map); + int size = fixedmap_size(frame_map) / 4; + for (jint i = 0; i < size; i++) { + // HotSpot stack slots are 4 bytes + VMReg reg = VMRegImpl::stack2reg(i * VMRegImpl::slots_per_word); + set_vmreg_oops(map, reg, words, i); + } + + if (callee_save_info != NULL) { + objArrayOop registers = RegisterSaveLayout::registers(callee_save_info); + typeArrayOop slots = RegisterSaveLayout::slots(callee_save_info); + for (jint i = 0; i < slots->length(); i++) { + oop jvmci_reg = registers->obj_at(i); + jint jvmci_reg_number = code_Register::number(jvmci_reg); + VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number); + // HotSpot stack slots are 4 bytes + jint jvmci_slot = slots->int_at(i); + jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; + VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); + map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); +#ifdef _LP64 + // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) + VMReg hotspot_slot_hi_as_reg = VMRegImpl::stack2reg(hotspot_slot + 1); + map->set_callee_saved(hotspot_slot_hi_as_reg, hotspot_reg->next()); +#endif + } + } + return map; +} + +static void record_metadata_reference(oop obj, jlong prim, jboolean compressed, OopRecorder* oop_recorder) { + if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) { + Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj)); + if (compressed) { + assert(Klass::decode_klass((narrowKlass) prim) == klass, err_msg("%s @ " INTPTR_FORMAT " != " PTR64_FORMAT, klass->name()->as_C_string(), p2i(klass), prim)); + } else { + assert((Klass*) prim == klass, err_msg("%s @ " INTPTR_FORMAT " != " PTR64_FORMAT, klass->name()->as_C_string(), p2i(klass), prim)); + } + int index = oop_recorder->find_index(klass); + TRACE_jvmci_3("metadata[%d of %d] = %s", index, oop_recorder->metadata_count(), klass->name()->as_C_string()); + } else if (obj->is_a(HotSpotResolvedJavaMethodImpl::klass())) { + Method* method = (Method*) (address) HotSpotResolvedJavaMethodImpl::metaspaceMethod(obj); + assert(!compressed, err_msg("unexpected compressed method pointer %s @ " INTPTR_FORMAT " = " PTR64_FORMAT, method->name()->as_C_string(), p2i(method), prim)); + int index = oop_recorder->find_index(method); + TRACE_jvmci_3("metadata[%d of %d] = %s", index, oop_recorder->metadata_count(), method->name()->as_C_string()); + } else { + assert(java_lang_String::is_instance(obj), + err_msg("unexpected metadata reference (%s) for constant " JLONG_FORMAT " (" PTR64_FORMAT ")", obj->klass()->name()->as_C_string(), prim, prim)); + } +} + +// Records any Metadata values embedded in a Constant (e.g., the value returned by HotSpotResolvedObjectTypeImpl.klass()). +static void record_metadata_in_constant(oop constant, OopRecorder* oop_recorder) { + if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { + oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant); + jlong prim = HotSpotMetaspaceConstantImpl::primitive(constant); + assert(Kind::typeChar(AbstractValue::kind(constant)) == 'j', "must have word kind"); + assert(obj != NULL, "must have an object"); + assert(prim != 0, "must have a primitive value"); + + record_metadata_reference(obj, prim, false, oop_recorder); + } +} + +static void record_metadata_in_patch(Handle& constant, OopRecorder* oop_recorder) { + record_metadata_reference(HotSpotMetaspaceConstantImpl::metaspaceObject(constant), HotSpotMetaspaceConstantImpl::primitive(constant), HotSpotMetaspaceConstantImpl::compressed(constant), oop_recorder); +} + +ScopeValue* CodeInstaller::get_scope_value(oop value, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) { + second = NULL; + if (value == AbstractValue::ILLEGAL()) { + return _illegal_value; + } + + oop lirKind = AbstractValue::lirKind(value); + oop platformKind = LIRKind::platformKind(lirKind); + jint referenceMask = LIRKind::referenceMask(lirKind); + assert(referenceMask != -1, "derived pointers are not allowed"); + assert(referenceMask == 0 || referenceMask == 1, "unexpected referenceMask"); + bool reference = referenceMask == 1; + + BasicType type = JVMCIRuntime::kindToBasicType(Kind::typeChar(platformKind)); + + if (value->is_a(RegisterValue::klass())) { + oop reg = RegisterValue::reg(value); + jint number = code_Register::number(reg); + VMReg hotspotRegister = get_hotspot_reg(number); + if (is_general_purpose_reg(hotspotRegister)) { + Location::Type locationType; + if (type == T_INT) { + locationType = reference ? Location::narrowoop : Location::int_in_long; + } else if(type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { + locationType = Location::int_in_long; + } else if (type == T_FLOAT) { + locationType = Location::int_in_long; + } else if (type == T_LONG) { + locationType = reference ? Location::oop : Location::lng; + } else { + assert(type == T_OBJECT && reference, "unexpected type in cpu register"); + locationType = Location::oop; + } + ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); + if (type == T_LONG && !reference) { + second = value; + } + return value; + } else { + assert(type == T_FLOAT || type == T_DOUBLE, "only float and double expected in xmm register"); + Location::Type locationType; + if (type == T_FLOAT) { + // this seems weird, but the same value is used in c1_LinearScan + locationType = Location::normal; + } else { + locationType = Location::dbl; + } + assert(!reference, "unexpected type in floating point register"); + ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); + if (type == T_DOUBLE) { + second = value; + } + return value; + } + } else if (value->is_a(StackSlot::klass())) { + Location::Type locationType; + if (type == T_LONG) { + locationType = reference ? Location::oop : Location::lng; + } else if (type == T_INT) { + locationType = reference ? Location::narrowoop : Location::normal; + } else if(type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { + locationType = Location::normal; + } else if (type == T_FLOAT) { + assert(!reference, "unexpected type in stack slot"); + locationType = Location::normal; + } else if (type == T_DOUBLE) { + assert(!reference, "unexpected type in stack slot"); + locationType = Location::dbl; + } else { + assert(type == T_OBJECT && reference, "unexpected type in stack slot"); + locationType = Location::oop; + } + jint offset = StackSlot::offset(value); +#ifdef TARGET_ARCH_sparc + if(offset >= 0) { + offset += 128; + } +#endif + if (StackSlot::addFrameSize(value)) { + offset += _total_frame_size; + } + ScopeValue* value = new LocationValue(Location::new_stk_loc(locationType, offset)); + if (type == T_DOUBLE || (type == T_LONG && !reference)) { + second = value; + } + return value; + } else if (value->is_a(JavaConstant::klass())){ + record_metadata_in_constant(value, _oop_recorder); + if (value->is_a(PrimitiveConstant::klass())) { + assert(!reference, "unexpected primitive constant type"); + if(value->is_a(RawConstant::klass())) { + jlong prim = PrimitiveConstant::primitive(value); + return new ConstantLongValue(prim); + } else if (type == T_INT || type == T_FLOAT) { + jint prim = (jint)PrimitiveConstant::primitive(value); + switch (prim) { + case -1: return _int_m1_scope_value; + case 0: return _int_0_scope_value; + case 1: return _int_1_scope_value; + case 2: return _int_2_scope_value; + default: return new ConstantIntValue(prim); + } + } else { + assert(type == T_LONG || type == T_DOUBLE, "unexpected primitive constant type"); + jlong prim = PrimitiveConstant::primitive(value); + second = _int_1_scope_value; + return new ConstantLongValue(prim); + } + } else { + assert(reference, "unexpected object constant type"); + if (value->is_a(NullConstant::klass()) || value->is_a(HotSpotCompressedNullConstant::klass())) { + return _oop_null_scope_value; + } else { + assert(value->is_a(HotSpotObjectConstantImpl::klass()), "unexpected constant type"); + oop obj = HotSpotObjectConstantImpl::object(value); + assert(obj != NULL, "null value must be in NullConstant"); + return new ConstantOopWriteValue(JNIHandles::make_local(obj)); + } + } + } else if (value->is_a(VirtualObject::klass())) { + int id = VirtualObject::id(value); + ScopeValue* object = objects->at(id); + assert(object != NULL, "missing value"); + return object; + } else { + value->klass()->print(); + value->print(); + } + ShouldNotReachHere(); + return NULL; +} + +void CodeInstaller::record_object_value(ObjectValue* sv, oop value, GrowableArray<ScopeValue*>* objects) { + oop type = VirtualObject::type(value); + int id = VirtualObject::id(value); + oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); + Klass* klass = java_lang_Class::as_Klass(javaMirror); + bool isLongArray = klass == Universe::longArrayKlassObj(); + + objArrayOop values = VirtualObject::values(value); + for (jint i = 0; i < values->length(); i++) { + ScopeValue* cur_second = NULL; + oop object = values->obj_at(i); + ScopeValue* value = get_scope_value(object, objects, cur_second); + + if (isLongArray && cur_second == NULL) { + // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. + // add an int 0 constant + cur_second = _int_0_scope_value; + } + + if (cur_second != NULL) { + sv->field_values()->append(cur_second); + } + assert(value != NULL, "missing value"); + sv->field_values()->append(value); + } +} + +MonitorValue* CodeInstaller::get_monitor_value(oop value, GrowableArray<ScopeValue*>* objects) { + guarantee(value->is_a(StackLockValue::klass()), "Monitors must be of type MonitorValue"); + + ScopeValue* second = NULL; + ScopeValue* owner_value = get_scope_value(StackLockValue::owner(value), objects, second); + assert(second == NULL, "monitor cannot occupy two stack slots"); + + ScopeValue* lock_data_value = get_scope_value(StackLockValue::slot(value), objects, second); + assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots"); + assert(lock_data_value->is_location(), "invalid monitor location"); + Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); + + bool eliminated = false; + if (StackLockValue::eliminated(value)) { + eliminated = true; + } + + return new MonitorValue(owner_value, lock_data_loc, eliminated); +} + +void CodeInstaller::initialize_dependencies(oop compiled_code) { + JavaThread* thread = JavaThread::current(); + CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL; + _oop_recorder = new OopRecorder(&_arena, true); + _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL); + objArrayHandle assumptions = CompilationResult::assumptions(HotSpotCompiledCode::comp(compiled_code)); + if (!assumptions.is_null()) { + int length = assumptions->length(); + for (int i = 0; i < length; ++i) { + Handle assumption = assumptions->obj_at(i); + if (!assumption.is_null()) { + if (assumption->klass() == Assumptions_NoFinalizableSubclass::klass()) { + assumption_NoFinalizableSubclass(assumption); + } else if (assumption->klass() == Assumptions_ConcreteSubtype::klass()) { + assumption_ConcreteSubtype(assumption); + } else if (assumption->klass() == Assumptions_LeafType::klass()) { + assumption_LeafType(assumption); + } else if (assumption->klass() == Assumptions_ConcreteMethod::klass()) { + assumption_ConcreteMethod(assumption); + } else if (assumption->klass() == Assumptions_CallSiteTargetValue::klass()) { + assumption_CallSiteTargetValue(assumption); + } else { + assumption->print(); + fatal("unexpected Assumption subclass"); + } + } + } + } + objArrayHandle methods = CompilationResult::methods(HotSpotCompiledCode::comp(compiled_code)); + if (!methods.is_null()) { + int length = methods->length(); + for (int i = 0; i < length; ++i) { + Handle method_handle = methods->obj_at(i); + methodHandle method = getMethodFromHotSpotMethod(method_handle()); + _dependencies->assert_evol_method(method()); + } + } +} + +// constructor used to create a method +JVMCIEnv::CodeInstallResult CodeInstaller::install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log) { + BufferBlob* buffer_blob = JVMCIRuntime::initialize_buffer_blob(); + if (buffer_blob == NULL) { + return JVMCIEnv::cache_full; + } + + CodeBuffer buffer(buffer_blob); + jobject compiled_code_obj = JNIHandles::make_local(compiled_code()); + initialize_dependencies(JNIHandles::resolve(compiled_code_obj)); + + // Get instructions and constants CodeSections early because we need it. + _instructions = buffer.insts(); + _constants = buffer.consts(); + + { + initialize_fields(JNIHandles::resolve(compiled_code_obj)); + if (!initialize_buffer(buffer)) { + return JVMCIEnv::code_too_large; + } + process_exception_handlers(); + } + + int stack_slots = _total_frame_size / HeapWordSize; // conversion to words + + JVMCIEnv::CodeInstallResult result; + if (!compiled_code->is_a(HotSpotCompiledNmethod::klass())) { + oop stubName = CompilationResult::name(HotSpotCompiledCode::comp(compiled_code_obj)); + char* name = strdup(java_lang_String::as_utf8_string(stubName)); + cb = RuntimeStub::new_runtime_stub(name, + &buffer, + CodeOffsets::frame_never_safe, + stack_slots, + _debug_recorder->_oopmaps, + false); + result = JVMCIEnv::ok; + } else { + nmethod* nm = NULL; + methodHandle method = getMethodFromHotSpotMethod(HotSpotCompiledNmethod::method(compiled_code)); + jint entry_bci = HotSpotCompiledNmethod::entryBCI(compiled_code); + jint id = HotSpotCompiledNmethod::id(compiled_code); + JVMCIEnv* env = (JVMCIEnv*) (address) HotSpotCompiledNmethod::jvmciEnv(compiled_code); + if (id == -1) { + // Make sure a valid compile_id is associated with every compile + id = CompileBroker::assign_compile_id_unlocked(Thread::current(), method, entry_bci); + } + result = JVMCIEnv::register_method(method, nm, entry_bci, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, + JVMCICompiler::instance(), _debug_recorder, _dependencies, env, id, false, installed_code, compiled_code, speculation_log); + cb = nm; + } + + if (cb != NULL) { + // Make sure the pre-calculated constants section size was correct. + guarantee((cb->code_begin() - cb->content_begin()) >= _constants_size, err_msg("%d < %d", (int)(cb->code_begin() - cb->content_begin()), _constants_size)); + } + return result; +} + +void CodeInstaller::initialize_fields(oop compiled_code) { + Handle comp_result = HotSpotCompiledCode::comp(compiled_code); + if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) { + Handle hotspotJavaMethod = HotSpotCompiledNmethod::method(compiled_code); + methodHandle method = getMethodFromHotSpotMethod(hotspotJavaMethod()); + _parameter_count = method->size_of_parameters(); + TRACE_jvmci_1("installing code for %s", method->name_and_sig_as_C_string()); + } else { + // Must be a HotSpotCompiledRuntimeStub + // TODO (ds) not sure if this is correct - only used in OopMap constructor for non-product builds + _parameter_count = 0; + } + _sites_handle = JNIHandles::make_local(HotSpotCompiledCode::sites(compiled_code)); + _exception_handlers_handle = JNIHandles::make_local(HotSpotCompiledCode::exceptionHandlers(compiled_code)); + + _code_handle = JNIHandles::make_local(CompilationResult::targetCode(comp_result)); + _code_size = CompilationResult::targetCodeSize(comp_result); + _total_frame_size = CompilationResult::totalFrameSize(comp_result); + _custom_stack_area_offset = CompilationResult::customStackAreaOffset(comp_result); + + // Pre-calculate the constants section size. This is required for PC-relative addressing. + _data_section_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSection(compiled_code)); + guarantee(HotSpotCompiledCode::dataSectionAlignment(compiled_code) <= _constants->alignment(), "Alignment inside constants section is restricted by alignment of section begin"); + _constants_size = data_section()->length(); + + _data_section_patches_handle = JNIHandles::make_local(HotSpotCompiledCode::dataSectionPatches(compiled_code)); + +#ifndef PRODUCT + _comments_handle = JNIHandles::make_local(HotSpotCompiledCode::comments(compiled_code)); +#endif + + _next_call_type = INVOKE_INVALID; +} + +int CodeInstaller::estimate_stub_entries() { + // Estimate the number of static call stubs that might be emitted. + int static_call_stubs = 0; + objArrayOop sites = this->sites(); + for (int i = 0; i < sites->length(); i++) { + oop site = sites->obj_at(i); + if (site->is_a(CompilationResult_Mark::klass())) { + oop id_obj = CompilationResult_Mark::id(site); + if (id_obj != NULL) { + assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected"); + jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); + if (id == INVOKESTATIC || id == INVOKESPECIAL) { + static_call_stubs++; + } + } + } + } + return static_call_stubs; +} + +// perform data and call relocation on the CodeBuffer +bool CodeInstaller::initialize_buffer(CodeBuffer& buffer) { + HandleMark hm; + objArrayHandle sites = this->sites(); + int locs_buffer_size = sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); + char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); + buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); + // Allocate enough space in the stub section for the static call + // stubs. Stubs have extra relocs but they are managed by the stub + // section itself so they don't need to be accounted for in the + // locs_buffer above. + buffer.initialize_stubs_size(estimate_stub_entries() * CompiledStaticCall::to_interp_stub_size()); + buffer.initialize_consts_size(_constants_size); + + _debug_recorder = new DebugInformationRecorder(_oop_recorder); + _debug_recorder->set_oopmaps(new OopMapSet()); + + buffer.initialize_oop_recorder(_oop_recorder); + + // copy the constant data into the newly created CodeBuffer + address end_data = _constants->start() + _constants_size; + memcpy(_constants->start(), data_section()->base(T_BYTE), _constants_size); + _constants->set_end(end_data); + + // copy the code into the newly created CodeBuffer + address end_pc = _instructions->start() + _code_size; + if (!_instructions->allocates2(end_pc)) { + return false; + } + memcpy(_instructions->start(), code()->base(T_BYTE), _code_size); + _instructions->set_end(end_pc); + + for (int i = 0; i < data_section_patches()->length(); i++) { + Handle patch = data_section_patches()->obj_at(i); + Handle reference = CompilationResult_DataPatch::reference(patch); + assert(reference->is_a(CompilationResult_ConstantReference::klass()), err_msg("patch in data section must be a ConstantReference")); + Handle constant = CompilationResult_ConstantReference::constant(reference); + if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { + record_metadata_in_patch(constant, _oop_recorder); + } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) { + Handle obj = HotSpotObjectConstantImpl::object(constant); + jobject value = JNIHandles::make_local(obj()); + int oop_index = _oop_recorder->find_index(value); + + address dest = _constants->start() + CompilationResult_Site::pcOffset(patch); + if (HotSpotObjectConstantImpl::compressed(constant)) { +#ifdef _LP64 + _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); +#else + fatal("unexpected compressed oop in 32-bit mode"); +#endif + } else { + _constants->relocate(dest, oop_Relocation::spec(oop_index)); + } + } else { + ShouldNotReachHere(); + } + } + jint last_pc_offset = -1; + for (int i = 0; i < sites->length(); i++) { + { + No_Safepoint_Verifier no_safepoint; + oop site = sites->obj_at(i); + jint pc_offset = CompilationResult_Site::pcOffset(site); + + if (site->is_a(CompilationResult_Call::klass())) { + TRACE_jvmci_4("call at %i", pc_offset); + site_Call(buffer, pc_offset, site); + } else if (site->is_a(CompilationResult_Infopoint::klass())) { + // three reasons for infopoints denote actual safepoints + oop reason = CompilationResult_Infopoint::reason(site); + if (InfopointReason::SAFEPOINT() == reason || InfopointReason::CALL() == reason || InfopointReason::IMPLICIT_EXCEPTION() == reason) { + TRACE_jvmci_4("safepoint at %i", pc_offset); + site_Safepoint(buffer, pc_offset, site); + } else { + // if the infopoint is not an actual safepoint, it must have one of the other reasons + // (safeguard against new safepoint types that require handling above) + assert(InfopointReason::METHOD_START() == reason || InfopointReason::METHOD_END() == reason || InfopointReason::LINE_NUMBER() == reason, ""); + site_Infopoint(buffer, pc_offset, site); + } + } else if (site->is_a(CompilationResult_DataPatch::klass())) { + TRACE_jvmci_4("datapatch at %i", pc_offset); + site_DataPatch(buffer, pc_offset, site); + } else if (site->is_a(CompilationResult_Mark::klass())) { + TRACE_jvmci_4("mark at %i", pc_offset); + site_Mark(buffer, pc_offset, site); + } else { + fatal("unexpected Site subclass"); + } + last_pc_offset = pc_offset; + } + if (CodeInstallSafepointChecks && SafepointSynchronize::do_call_back()) { + // this is a hacky way to force a safepoint check but nothing else was jumping out at me. + ThreadToNativeFromVM ttnfv(JavaThread::current()); + } + } + +#ifndef PRODUCT + if (comments() != NULL) { + No_Safepoint_Verifier no_safepoint; + for (int i = 0; i < comments()->length(); i++) { + oop comment = comments()->obj_at(i); + assert(comment->is_a(HotSpotCompiledCode_Comment::klass()), "cce"); + jint offset = HotSpotCompiledCode_Comment::pcOffset(comment); + char* text = java_lang_String::as_utf8_string(HotSpotCompiledCode_Comment::text(comment)); + buffer.block_comment(offset, text); + } + } +#endif + return true; +} + +void CodeInstaller::assumption_NoFinalizableSubclass(Handle assumption) { + Handle receiverType_handle = Assumptions_NoFinalizableSubclass::receiverType(assumption()); + Klass* receiverType = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(receiverType_handle)); + _dependencies->assert_has_no_finalizable_subclasses(receiverType); +} + +void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) { + Handle context_handle = Assumptions_ConcreteSubtype::context(assumption()); + Handle subtype_handle = Assumptions_ConcreteSubtype::subtype(assumption()); + Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); + Klass* subtype = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(subtype_handle)); + + assert(context->is_abstract(), ""); + _dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype); +} + +void CodeInstaller::assumption_LeafType(Handle assumption) { + Handle context_handle = Assumptions_LeafType::context(assumption()); + Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); + + _dependencies->assert_leaf_type(context); +} + +void CodeInstaller::assumption_ConcreteMethod(Handle assumption) { + Handle impl_handle = Assumptions_ConcreteMethod::impl(assumption()); + Handle context_handle = Assumptions_ConcreteMethod::context(assumption()); + + methodHandle impl = getMethodFromHotSpotMethod(impl_handle()); + Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle)); + + _dependencies->assert_unique_concrete_method(context, impl()); +} + +void CodeInstaller::assumption_CallSiteTargetValue(Handle assumption) { + Handle callSite = Assumptions_CallSiteTargetValue::callSite(assumption()); + Handle methodHandle = Assumptions_CallSiteTargetValue::methodHandle(assumption()); + + _dependencies->assert_call_site_target_value(callSite(), methodHandle()); +} + +void CodeInstaller::process_exception_handlers() { + if (exception_handlers() != NULL) { + objArrayOop handlers = exception_handlers(); + for (int i = 0; i < handlers->length(); i++) { + oop exc = handlers->obj_at(i); + jint pc_offset = CompilationResult_Site::pcOffset(exc); + jint handler_offset = CompilationResult_ExceptionHandler::handlerPos(exc); + + // Subtable header + _exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0)); + + // Subtable entry + _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); + } + } +} + +// If deoptimization happens, the interpreter should reexecute these bytecodes. +// This function mainly helps the compilers to set up the reexecute bit. +static bool bytecode_should_reexecute(Bytecodes::Code code) { + switch (code) { + case Bytecodes::_invokedynamic: + case Bytecodes::_invokevirtual: + case Bytecodes::_invokeinterface: + case Bytecodes::_invokespecial: + case Bytecodes::_invokestatic: + return false; + default: + return true; + } + return true; +} + +GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(oop debug_info) { + objArrayOop virtualObjects = DebugInfo::virtualObjectMapping(debug_info); + if (virtualObjects == NULL) { + return NULL; + } + GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(virtualObjects->length(), virtualObjects->length(), NULL); + // Create the unique ObjectValues + for (int i = 0; i < virtualObjects->length(); i++) { + oop value = virtualObjects->obj_at(i); + int id = VirtualObject::id(value); + oop type = VirtualObject::type(value); + oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type); + ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror))); + assert(objects->at(id) == NULL, "once"); + objects->at_put(id, sv); + } + // All the values which could be referenced by the VirtualObjects + // exist, so now describe all the VirtualObjects themselves. + for (int i = 0; i < virtualObjects->length(); i++) { + oop value = virtualObjects->obj_at(i); + int id = VirtualObject::id(value); + record_object_value(objects->at(id)->as_ObjectValue(), value, objects); + } + _debug_recorder->dump_object_pool(objects); + return objects; +} + +void CodeInstaller::record_scope(jint pc_offset, oop debug_info) { + oop position = DebugInfo::bytecodePosition(debug_info); + if (position == NULL) { + // Stubs do not record scope info, just oop maps + return; + } + + GrowableArray<ScopeValue*>* objectMapping = record_virtual_objects(debug_info); + record_scope(pc_offset, position, objectMapping); +} + +void CodeInstaller::record_scope(jint pc_offset, oop position, GrowableArray<ScopeValue*>* objects) { + oop frame = NULL; + if (position->is_a(BytecodeFrame::klass())) { + frame = position; + } + oop caller_frame = BytecodePosition::caller(position); + if (caller_frame != NULL) { + record_scope(pc_offset, caller_frame, objects); + } + + oop hotspot_method = BytecodePosition::method(position); + Method* method = getMethodFromHotSpotMethod(hotspot_method); + jint bci = BytecodePosition::bci(position); + if (bci == BytecodeFrame::BEFORE_BCI()) { + bci = SynchronizationEntryBCI; + } + + if (TraceJVMCI >= 2) { + tty->print_cr("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); + } + + bool reexecute = false; + if (frame != NULL) { + if (bci == SynchronizationEntryBCI){ + reexecute = false; + } else { + Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci)); + reexecute = bytecode_should_reexecute(code); + if (frame != NULL) { + reexecute = (BytecodeFrame::duringCall(frame) == JNI_FALSE); + } + } + } + + DebugToken* locals_token = NULL; + DebugToken* expressions_token = NULL; + DebugToken* monitors_token = NULL; + bool throw_exception = false; + + if (frame != NULL) { + jint local_count = BytecodeFrame::numLocals(frame); + jint expression_count = BytecodeFrame::numStack(frame); + jint monitor_count = BytecodeFrame::numLocks(frame); + objArrayOop values = BytecodeFrame::values(frame); + + assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length"); + + GrowableArray<ScopeValue*>* locals = local_count > 0 ? new GrowableArray<ScopeValue*> (local_count) : NULL; + GrowableArray<ScopeValue*>* expressions = expression_count > 0 ? new GrowableArray<ScopeValue*> (expression_count) : NULL; + GrowableArray<MonitorValue*>* monitors = monitor_count > 0 ? new GrowableArray<MonitorValue*> (monitor_count) : NULL; + + if (TraceJVMCI >= 2) { + tty->print_cr("Scope at bci %d with %d values", bci, values->length()); + tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); + } + + for (jint i = 0; i < values->length(); i++) { + ScopeValue* second = NULL; + oop value = values->obj_at(i); + if (i < local_count) { + ScopeValue* first = get_scope_value(value, objects, second); + if (second != NULL) { + locals->append(second); + } + locals->append(first); + } else if (i < local_count + expression_count) { + ScopeValue* first = get_scope_value(value, objects, second); + if (second != NULL) { + expressions->append(second); + } + expressions->append(first); + } else { + monitors->append(get_monitor_value(value, objects)); + } + if (second != NULL) { + i++; + assert(i < values->length(), "double-slot value not followed by Value.ILLEGAL"); + assert(values->obj_at(i) == AbstractValue::ILLEGAL(), "double-slot value not followed by Value.ILLEGAL"); + } + } + + locals_token = _debug_recorder->create_scope_values(locals); + expressions_token = _debug_recorder->create_scope_values(expressions); + monitors_token = _debug_recorder->create_monitor_values(monitors); + + throw_exception = BytecodeFrame::rethrowException(frame) == JNI_TRUE; + } + + _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, false, + locals_token, expressions_token, monitors_token); +} + +void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) { + oop debug_info = CompilationResult_Infopoint::debugInfo(site); + assert(debug_info != NULL, "debug info expected"); + + // address instruction = _instructions->start() + pc_offset; + // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); + _debug_recorder->add_safepoint(pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); + record_scope(pc_offset, debug_info); + _debug_recorder->end_safepoint(pc_offset); +} + +void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, oop site) { + oop debug_info = CompilationResult_Infopoint::debugInfo(site); + assert(debug_info != NULL, "debug info expected"); + + _debug_recorder->add_non_safepoint(pc_offset); + record_scope(pc_offset, debug_info); + _debug_recorder->end_non_safepoint(pc_offset); +} + +void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) { + oop target = CompilationResult_Call::target(site); + InstanceKlass* target_klass = InstanceKlass::cast(target->klass()); + + oop hotspot_method = NULL; // JavaMethod + oop foreign_call = NULL; + + if (target_klass->is_subclass_of(SystemDictionary::HotSpotForeignCallTarget_klass())) { + foreign_call = target; + } else { + hotspot_method = target; + } + + oop debug_info = CompilationResult_Call::debugInfo(site); + + assert(!!hotspot_method ^ !!foreign_call, "Call site needs exactly one type"); + + NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset); + jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method); + + if (debug_info != NULL) { + _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_total_frame_size, _parameter_count, debug_info)); + record_scope(next_pc_offset, debug_info); + } + + if (foreign_call != NULL) { + jlong foreign_call_destination = HotSpotForeignCallTarget::address(foreign_call); + CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination); + } else { // method != NULL + assert(hotspot_method != NULL, "unexpected JavaMethod"); + assert(debug_info != NULL, "debug info expected"); + + TRACE_jvmci_3("method call"); + CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset); + if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { + // Need a static call stub for transitions from compiled to interpreted. + CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset); + } + } + + _next_call_type = INVOKE_INVALID; + + if (debug_info != NULL) { + _debug_recorder->end_safepoint(next_pc_offset); + } +} + +void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, oop site) { + oop reference = CompilationResult_DataPatch::reference(site); + if (reference->is_a(CompilationResult_ConstantReference::klass())) { + Handle constant = CompilationResult_ConstantReference::constant(reference); + if (constant->is_a(HotSpotObjectConstantImpl::klass())) { + pd_patch_OopConstant(pc_offset, constant); + } else if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) { + record_metadata_in_patch(constant, _oop_recorder); + } else { + fatal("unknown constant type in data patch"); + } + } else if (reference->is_a(CompilationResult_DataSectionReference::klass())) { + int data_offset = CompilationResult_DataSectionReference::offset(reference); + assert(0 <= data_offset && data_offset < _constants_size, err_msg("data offset 0x%X points outside data section (size 0x%X)", data_offset, _constants_size)); + pd_patch_DataSectionReference(pc_offset, data_offset); + } else { + fatal("unknown data patch type"); + } +} + +void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, oop site) { + oop id_obj = CompilationResult_Mark::id(site); + + if (id_obj != NULL) { + assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected"); + jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); + + address pc = _instructions->start() + pc_offset; + + switch (id) { + case UNVERIFIED_ENTRY: + _offsets.set_value(CodeOffsets::Entry, pc_offset); + break; + case VERIFIED_ENTRY: + _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset); + break; + case OSR_ENTRY: + _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset); + break; + case EXCEPTION_HANDLER_ENTRY: + _offsets.set_value(CodeOffsets::Exceptions, pc_offset); + break; + case DEOPT_HANDLER_ENTRY: + _offsets.set_value(CodeOffsets::Deopt, pc_offset); + break; + case INVOKEVIRTUAL: + case INVOKEINTERFACE: + case INLINE_INVOKE: + case INVOKESTATIC: + case INVOKESPECIAL: + _next_call_type = (MarkId) id; + _invoke_mark_pc = pc; + break; + case POLL_NEAR: + case POLL_FAR: + case POLL_RETURN_NEAR: + case POLL_RETURN_FAR: + pd_relocate_poll(pc, id); + break; + case CARD_TABLE_SHIFT: + case CARD_TABLE_ADDRESS: + break; + default: + ShouldNotReachHere(); + break; + } + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciCodeInstaller.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2011, 2014, 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. + */ + +#ifndef SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP +#define SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP + +#include "jvmci/jvmciEnv.hpp" + +/* + * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod. + */ +class CodeInstaller : public StackObj { + friend class VMStructs; +private: + enum MarkId { + VERIFIED_ENTRY = 1, + UNVERIFIED_ENTRY = 2, + OSR_ENTRY = 3, + EXCEPTION_HANDLER_ENTRY = 4, + DEOPT_HANDLER_ENTRY = 5, + INVOKEINTERFACE = 6, + INVOKEVIRTUAL = 7, + INVOKESTATIC = 8, + INVOKESPECIAL = 9, + INLINE_INVOKE = 10, + POLL_NEAR = 11, + POLL_RETURN_NEAR = 12, + POLL_FAR = 13, + POLL_RETURN_FAR = 14, + CARD_TABLE_ADDRESS = 15, + CARD_TABLE_SHIFT = 16, + INVOKE_INVALID = -1 + }; + + Arena _arena; + + jobject _data_section_handle; + jobject _data_section_patches_handle; + jobject _sites_handle; + jobject _exception_handlers_handle; + CodeOffsets _offsets; + + jobject _code_handle; + jint _code_size; + jint _total_frame_size; + jint _custom_stack_area_offset; + jint _parameter_count; + jint _constants_size; +#ifndef PRODUCT + jobject _comments_handle; +#endif + + MarkId _next_call_type; + address _invoke_mark_pc; + + CodeSection* _instructions; + CodeSection* _constants; + + OopRecorder* _oop_recorder; + DebugInformationRecorder* _debug_recorder; + Dependencies* _dependencies; + ExceptionHandlerTable _exception_handler_table; + + static ConstantOopWriteValue* _oop_null_scope_value; + static ConstantIntValue* _int_m1_scope_value; + static ConstantIntValue* _int_0_scope_value; + static ConstantIntValue* _int_1_scope_value; + static ConstantIntValue* _int_2_scope_value; + static LocationValue* _illegal_value; + + jint pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method); + void pd_patch_OopConstant(int pc_offset, Handle& constant); + void pd_patch_DataSectionReference(int pc_offset, int data_offset); + void pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst); + void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination); + void pd_relocate_JavaMethod(oop method, jint pc_offset); + void pd_relocate_poll(address pc, jint mark); + + objArrayOop sites() { return (objArrayOop) JNIHandles::resolve(_sites_handle); } + arrayOop code() { return (arrayOop) JNIHandles::resolve(_code_handle); } + arrayOop data_section() { return (arrayOop) JNIHandles::resolve(_data_section_handle); } + objArrayOop data_section_patches() { return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); } + objArrayOop exception_handlers() { return (objArrayOop) JNIHandles::resolve(_exception_handlers_handle); } +#ifndef PRODUCT + objArrayOop comments() { return (objArrayOop) JNIHandles::resolve(_comments_handle); } +#endif + +public: + + CodeInstaller() : _arena(mtCompiler) {} + JVMCIEnv::CodeInstallResult install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log); + + static address runtime_call_target_address(oop runtime_call); + static VMReg get_hotspot_reg(jint jvmciRegisterNumber); + static bool is_general_purpose_reg(VMReg hotspotRegister); + +private: + ScopeValue* get_scope_value(oop value, GrowableArray<ScopeValue*>* objects, ScopeValue* &second); + MonitorValue* get_monitor_value(oop value, GrowableArray<ScopeValue*>* objects); + + // extract the fields of the CompilationResult + void initialize_fields(oop target_method); + void initialize_dependencies(oop target_method); + + int estimate_stub_entries(); + + // perform data and call relocation on the CodeBuffer + bool initialize_buffer(CodeBuffer& buffer); + + void assumption_NoFinalizableSubclass(Handle assumption); + void assumption_ConcreteSubtype(Handle assumption); + void assumption_LeafType(Handle assumption); + void assumption_ConcreteMethod(Handle assumption); + void assumption_CallSiteTargetValue(Handle assumption); + + void site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site); + void site_Infopoint(CodeBuffer& buffer, jint pc_offset, oop site); + void site_Call(CodeBuffer& buffer, jint pc_offset, oop site); + void site_DataPatch(CodeBuffer& buffer, jint pc_offset, oop site); + void site_Mark(CodeBuffer& buffer, jint pc_offset, oop site); + + void record_scope(jint pc_offset, oop debug_info); + void record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects); + void record_object_value(ObjectValue* sv, oop value, GrowableArray<ScopeValue*>* objects); + + GrowableArray<ScopeValue*>* record_virtual_objects(oop debug_info); + + void process_exception_handlers(); + int estimateStubSpace(int static_call_stubs); +}; + +/** + * Gets the Method metaspace object from a HotSpotResolvedJavaMethodImpl Java object. + */ +Method* getMethodFromHotSpotMethod(oop hotspot_method); + + + +#endif // SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciCompiler.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2011, 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. + */ + +#include "precompiled.hpp" +#include "memory/oopFactory.hpp" +#include "runtime/javaCalls.hpp" +#include "jvmci/jvmciCompiler.hpp" +#include "jvmci/jvmciEnv.hpp" +#include "jvmci/jvmciRuntime.hpp" +#include "runtime/compilationPolicy.hpp" +#include "runtime/globals_extension.hpp" + +JVMCICompiler* JVMCICompiler::_instance = NULL; +elapsedTimer JVMCICompiler::_codeInstallTimer; + +JVMCICompiler::JVMCICompiler() : AbstractCompiler(jvmci) { +#ifdef COMPILERJVMCI + _bootstrapping = false; + _methodsCompiled = 0; +#endif + assert(_instance == NULL, "only one instance allowed"); + _instance = this; +} + +// Initialization +void JVMCICompiler::initialize() { +#ifdef COMPILERJVMCI + if (!UseCompiler || !should_perform_init()) { + return; + } + + BufferBlob* buffer_blob = JVMCIRuntime::initialize_buffer_blob(); + if (buffer_blob == NULL) { + set_state(failed); + } else { + set_state(initialized); + } + // JVMCI is considered as application code so we need to + // stop the VM deferring compilation now. + CompilationPolicy::completed_vm_startup(); +#endif // COMPILERJVMCI +} + +#ifdef COMPILERJVMCI +void JVMCICompiler::bootstrap() { + JavaThread* THREAD = JavaThread::current(); + _bootstrapping = true; + // Allow bootstrap to perform JVMCI compilations of itself + bool c1only = JVMCICompileWithC1Only; + JVMCICompileWithC1Only = false; + ResourceMark rm; + HandleMark hm; + if (PrintBootstrap) { + tty->print("Bootstrapping JVMCI"); + } + jlong start = os::javaTimeMillis(); + + Array<Method*>* objectMethods = InstanceKlass::cast(SystemDictionary::Object_klass())->methods(); + // Initialize compile queue with a selected set of methods. + int len = objectMethods->length(); + for (int i = 0; i < len; i++) { + methodHandle mh = objectMethods->at(i); + if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { + ResourceMark rm; + int hot_count = 10; // TODO: what's the appropriate value? + CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD); + } + } + + int qsize; + bool first_round = true; + int z = 0; + do { + // Loop until there is something in the queue. + do { + os::sleep(THREAD, 100, true); + qsize = CompileBroker::queue_size(CompLevel_full_optimization); + } while (first_round && qsize == 0); + first_round = false; + if (PrintBootstrap) { + while (z < (_methodsCompiled / 100)) { + ++z; + tty->print_raw("."); + } + } + } while (qsize != 0); + + if (PrintBootstrap) { + tty->print_cr(" in " JLONG_FORMAT " ms (compiled %d methods)", os::javaTimeMillis() - start, _methodsCompiled); + } + JVMCICompileWithC1Only = c1only; + _bootstrapping = false; +} + +void JVMCICompiler::compile_method(methodHandle method, int entry_bci, JVMCIEnv* env) { + JVMCI_EXCEPTION_CONTEXT + + bool is_osr = entry_bci != InvocationEntryBci; + if (_bootstrapping && is_osr) { + // no OSR compilations during bootstrap - the compiler is just too slow at this point, + // and we know that there are no endless loops + return; + } + + JVMCIRuntime::ensure_jvmci_class_loader_is_initialized(); + HandleMark hm; + ResourceMark rm; + JavaValue result(T_VOID); + JavaCallArguments args; + args.push_long((jlong) (address) method()); + args.push_int(entry_bci); + args.push_long((jlong) (address) env); + args.push_int(env->task()->compile_id()); + JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, CHECK_ABORT); + + _methodsCompiled++; +} + + +// Compilation entry point for methods +void JVMCICompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) { + ShouldNotReachHere(); +} + +// Print compilation timers and statistics +void JVMCICompiler::print_timers() { + print_compilation_timers(); +} + +#endif // COMPILERJVMCI + +// Print compilation timers and statistics +void JVMCICompiler::print_compilation_timers() { + TRACE_jvmci_1("JVMCICompiler::print_timers"); + tty->print_cr(" JVMCI code install time: %6.3f s", _codeInstallTimer.seconds()); +} + +void JVMCICompiler::compile_the_world() { + HandleMark hm; + JavaThread* THREAD = JavaThread::current(); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", CHECK_ABORT); + KlassHandle klass = JVMCIRuntime::load_required_class(name); + TempNewSymbol compileTheWorld = SymbolTable::new_symbol("compileTheWorld", CHECK_ABORT); + JavaValue result(T_VOID); + JavaCallArguments args; + args.push_oop(JVMCIRuntime::get_HotSpotJVMCIRuntime()); + JavaCalls::call_special(&result, klass, compileTheWorld, vmSymbols::void_method_signature(), &args, CHECK_ABORT); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciCompiler.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2011, 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. + */ + +#ifndef SHARE_VM_JVMCI_JVMCI_COMPILER_HPP +#define SHARE_VM_JVMCI_JVMCI_COMPILER_HPP + +#include "compiler/abstractCompiler.hpp" +#include "jvmci/jvmciEnv.hpp" + +class JVMCICompiler : public AbstractCompiler { + +private: + +#ifdef COMPILERJVMCI + bool _bootstrapping; + + /** + * Number of methods compiled by JVMCI. This is not synchronized + * so may not be 100% accurate. + */ + volatile int _methodsCompiled; + +#endif + + static JVMCICompiler* _instance; + + static elapsedTimer _codeInstallTimer; + +public: + + JVMCICompiler(); + + static JVMCICompiler* instance() { return _instance; } + + virtual const char* name() { return "JVMCI"; } + + virtual bool supports_native() { return true; } + virtual bool supports_osr () { return true; } + + bool is_jvmci() { return true; } + bool is_c1 () { return false; } + bool is_c2 () { return false; } + + bool needs_stubs () { return false; } + + // Initialization + virtual void initialize(); + +#ifdef COMPILERJVMCI + + void bootstrap(); + + // Compilation entry point for methods + virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci); + + void compile_method(methodHandle target, int entry_bci, JVMCIEnv* env); + + // Print compilation timers and statistics + virtual void print_timers(); + + // Print compilation statistics + void reset_compilation_stats(); +#endif // COMPILERJVMCI + + // Print compilation timers and statistics + static void print_compilation_timers(); + + static elapsedTimer* codeInstallTimer() { return &_codeInstallTimer; } + + void compile_the_world(); +}; + +#endif // SHARE_VM_JVMCI_JVMCI_COMPILER_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,1116 @@ +/* + * Copyright (c) 2011, 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. + */ + +#include "precompiled.hpp" +#include "code/scopeDesc.hpp" +#include "memory/oopFactory.hpp" +#include "oops/generateOopMap.hpp" +#include "oops/fieldStreams.hpp" +#include "runtime/fieldDescriptor.hpp" +#include "runtime/javaCalls.hpp" +#include "jvmci/jvmciRuntime.hpp" +#include "compiler/compileBroker.hpp" +#include "compiler/compilerOracle.hpp" +#include "compiler/disassembler.hpp" +#include "jvmci/jvmciCompilerToVM.hpp" +#include "jvmci/jvmciCompiler.hpp" +#include "jvmci/jvmciEnv.hpp" +#include "jvmci/jvmciJavaAccess.hpp" +#include "jvmci/jvmciCodeInstaller.hpp" +#include "gc_implementation/g1/heapRegion.hpp" +#include "runtime/javaCalls.hpp" +#include "runtime/deoptimization.hpp" +#include "runtime/vframe.hpp" +#include "runtime/vframe_hp.hpp" +#include "runtime/vmStructs.hpp" + + +// Entry to native method implementation that transitions current thread to '_thread_in_vm'. +#define C2V_VMENTRY(result_type, name, signature) \ + JNIEXPORT result_type JNICALL c2v_ ## name signature { \ + TRACE_jvmci_3("CompilerToVM::" #name); \ + JVMCI_VM_ENTRY_MARK; \ + +#define C2V_END } + +extern "C" { +extern VMStructEntry* gHotSpotVMStructs; +extern uint64_t gHotSpotVMStructEntryTypeNameOffset; +extern uint64_t gHotSpotVMStructEntryFieldNameOffset; +extern uint64_t gHotSpotVMStructEntryTypeStringOffset; +extern uint64_t gHotSpotVMStructEntryIsStaticOffset; +extern uint64_t gHotSpotVMStructEntryOffsetOffset; +extern uint64_t gHotSpotVMStructEntryAddressOffset; +extern uint64_t gHotSpotVMStructEntryArrayStride; + +extern VMTypeEntry* gHotSpotVMTypes; +extern uint64_t gHotSpotVMTypeEntryTypeNameOffset; +extern uint64_t gHotSpotVMTypeEntrySuperclassNameOffset; +extern uint64_t gHotSpotVMTypeEntryIsOopTypeOffset; +extern uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset; +extern uint64_t gHotSpotVMTypeEntryIsUnsignedOffset; +extern uint64_t gHotSpotVMTypeEntrySizeOffset; +extern uint64_t gHotSpotVMTypeEntryArrayStride; + +extern VMIntConstantEntry* gHotSpotVMIntConstants; +extern uint64_t gHotSpotVMIntConstantEntryNameOffset; +extern uint64_t gHotSpotVMIntConstantEntryValueOffset; +extern uint64_t gHotSpotVMIntConstantEntryArrayStride; + +extern VMLongConstantEntry* gHotSpotVMLongConstants; +extern uint64_t gHotSpotVMLongConstantEntryNameOffset; +extern uint64_t gHotSpotVMLongConstantEntryValueOffset; +extern uint64_t gHotSpotVMLongConstantEntryArrayStride; +} + +C2V_VMENTRY(void, initializeConfiguration, (JNIEnv *, jobject, jobject config)) + VMStructs::initHotSpotVMConfig(JNIHandles::resolve(config)); +C2V_END + +C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jlong metaspace_method)) + methodHandle method = asMethod(metaspace_method); + ResourceMark rm; + + int code_size = method->code_size(); + typeArrayOop reconstituted_code = oopFactory::new_byteArray(code_size, CHECK_NULL); + + guarantee(method->method_holder()->is_rewritten(), "Method's holder should be rewritten"); + // iterate over all bytecodes and replace non-Java bytecodes + + for (BytecodeStream s(method); s.next() != Bytecodes::_illegal; ) { + Bytecodes::Code code = s.code(); + Bytecodes::Code raw_code = s.raw_code(); + int bci = s.bci(); + int len = s.instruction_size(); + + // Restore original byte code. + reconstituted_code->byte_at_put(bci, (jbyte) (s.is_wide()? Bytecodes::_wide : code)); + if (len > 1) { + memcpy(reconstituted_code->byte_at_addr(bci + 1), s.bcp()+1, len-1); + } + + if (len > 1) { + // Restore the big-endian constant pool indexes. + // Cf. Rewriter::scan_method + switch (code) { + case Bytecodes::_getstatic: + case Bytecodes::_putstatic: + case Bytecodes::_getfield: + case Bytecodes::_putfield: + case Bytecodes::_invokevirtual: + case Bytecodes::_invokespecial: + case Bytecodes::_invokestatic: + case Bytecodes::_invokeinterface: + case Bytecodes::_invokehandle: { + int cp_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); + Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); + break; + } + + case Bytecodes::_invokedynamic: + int cp_index = Bytes::get_native_u4((address) reconstituted_code->byte_at_addr(bci + 1)); + Bytes::put_Java_u4((address) reconstituted_code->byte_at_addr(bci + 1), (u4) cp_index); + break; + } + + // Not all ldc byte code are rewritten. + switch (raw_code) { + case Bytecodes::_fast_aldc: { + int cpc_index = reconstituted_code->byte_at(bci + 1) & 0xff; + int cp_index = method->constants()->object_to_cp_index(cpc_index); + assert(cp_index < method->constants()->length(), "sanity check"); + reconstituted_code->byte_at_put(bci + 1, (jbyte) cp_index); + break; + } + + case Bytecodes::_fast_aldc_w: { + int cpc_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); + int cp_index = method->constants()->object_to_cp_index(cpc_index); + assert(cp_index < method->constants()->length(), "sanity check"); + Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); + break; + } + } + } + } + + return (jbyteArray) JNIHandles::make_local(THREAD, reconstituted_code); +C2V_END + +C2V_VMENTRY(jint, exceptionTableLength, (JNIEnv *, jobject, jlong metaspace_method)) + ResourceMark rm; + methodHandle method = asMethod(metaspace_method); + return method->exception_table_length(); +C2V_END + +C2V_VMENTRY(jlong, exceptionTableStart, (JNIEnv *, jobject, jlong metaspace_method)) + ResourceMark rm; + methodHandle method = asMethod(metaspace_method); + assert(method->exception_table_length() != 0, "should be handled in Java code"); + return (jlong) (address) method->exception_table_start(); +C2V_END + +C2V_VMENTRY(jint, hasBalancedMonitors, (JNIEnv *, jobject, jlong metaspace_method)) + // Analyze the method to see if monitors are used properly. + methodHandle method(THREAD, asMethod(metaspace_method)); + { + EXCEPTION_MARK; + ResourceMark rm(THREAD); + GeneratePairingInfo gpi(method); + gpi.compute_map(CATCH); + if (!gpi.monitor_safe()) { + return false; + } + method->set_guaranteed_monitor_matching(); + } + return true; +C2V_END + +C2V_VMENTRY(jlong, getMetaspaceMethod, (JNIEnv *, jobject, jclass holder_handle, jint slot)) + oop java_class = JNIHandles::resolve(holder_handle); + Klass* holder = java_lang_Class::as_Klass(java_class); + methodHandle method = InstanceKlass::cast(holder)->method_with_idnum(slot); + return (jlong) (address) method(); +} + +C2V_VMENTRY(jlong, findUniqueConcreteMethod, (JNIEnv *, jobject, jlong metaspace_klass, jlong metaspace_method)) + methodHandle method = asMethod(metaspace_method); + KlassHandle holder = asKlass(metaspace_klass); + assert(!holder->is_interface(), "should be handled in Java code"); + ResourceMark rm; + MutexLocker locker(Compile_lock); + Method* ucm = Dependencies::find_unique_concrete_method(holder(), method()); + return (jlong) (address) ucm; +C2V_END + +C2V_VMENTRY(jlong, getKlassImplementor, (JNIEnv *, jobject, jlong metaspace_klass)) + InstanceKlass* klass = (InstanceKlass*) asKlass(metaspace_klass); + return (jlong) (address) klass->implementor(); +C2V_END + +C2V_VMENTRY(jboolean, methodIsIgnoredBySecurityStackWalk,(JNIEnv *, jobject, jlong metaspace_method)) + methodHandle method = asMethod(metaspace_method); + return method->is_ignored_by_security_stack_walk(); +C2V_END + +C2V_VMENTRY(jboolean, canInlineMethod,(JNIEnv *, jobject, jlong metaspace_method)) + methodHandle method = asMethod(metaspace_method); + return !method->is_not_compilable() && !CompilerOracle::should_not_inline(method) && !method->dont_inline(); +C2V_END + +C2V_VMENTRY(jboolean, shouldInlineMethod,(JNIEnv *, jobject, jlong metaspace_method)) + methodHandle method = asMethod(metaspace_method); + return CompilerOracle::should_inline(method) || method->force_inline(); +C2V_END + +C2V_VMENTRY(jlong, lookupType, (JNIEnv*, jobject, jstring jname, jclass accessing_class, jboolean resolve)) + ResourceMark rm; + Handle name = JNIHandles::resolve(jname); + Symbol* class_name = java_lang_String::as_symbol(name, THREAD); + assert(class_name != NULL, "name to symbol creation failed"); + assert(class_name->size() > 1, "primitive types should be handled in Java code"); + + Klass* resolved_klass = NULL; + Handle class_loader; + Handle protection_domain; + if (JNIHandles::resolve(accessing_class) == NULL) { + THROW_(vmSymbols::java_lang_NullPointerException(), 0L); + } + Klass* accessing_klass = java_lang_Class::as_Klass(JNIHandles::resolve(accessing_class)); + class_loader = accessing_klass->class_loader(); + protection_domain = accessing_klass->protection_domain(); + + if (resolve) { + resolved_klass = SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK_0); + } else { + if (class_name->byte_at(0) == 'L' && + class_name->byte_at(class_name->utf8_length()-1) == ';') { + // This is a name from a signature. Strip off the trimmings. + // Call recursive to keep scope of strippedsym. + TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1, + class_name->utf8_length()-2, + CHECK_0); + resolved_klass = SystemDictionary::find(strippedsym, class_loader, protection_domain, CHECK_0); + } else if (FieldType::is_array(class_name)) { + FieldArrayInfo fd; + // dimension and object_key in FieldArrayInfo are assigned as a side-effect + // of this call + BasicType t = FieldType::get_array_info(class_name, fd, CHECK_0); + if (t == T_OBJECT) { + TempNewSymbol strippedsym = SymbolTable::new_symbol(class_name->as_utf8()+1+fd.dimension(), + class_name->utf8_length()-2-fd.dimension(), + CHECK_0); + // naked oop "k" is OK here -- we assign back into it + resolved_klass = SystemDictionary::find(strippedsym, + class_loader, + protection_domain, + CHECK_0); + if (resolved_klass != NULL) { + resolved_klass = resolved_klass->array_klass(fd.dimension(), CHECK_0); + } + } else { + resolved_klass = Universe::typeArrayKlassObj(t); + resolved_klass = TypeArrayKlass::cast(resolved_klass)->array_klass(fd.dimension(), CHECK_0); + } + } + } + return (jlong) (address) resolved_klass; +C2V_END + +C2V_VMENTRY(jobject, resolveConstantInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; + oop result = cp->resolve_constant_at(index, CHECK_NULL); + return JNIHandles::make_local(THREAD, result); +C2V_END + +C2V_VMENTRY(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; + oop result = cp->resolve_possibly_cached_constant_at(index, CHECK_NULL); + return JNIHandles::make_local(THREAD, result); +C2V_END + +C2V_VMENTRY(jint, lookupNameAndTypeRefIndexInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + return cp->name_and_type_ref_index_at(index); +C2V_END + +C2V_VMENTRY(jobject, lookupNameRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + Handle sym = java_lang_String::create_from_symbol(cp->name_ref_at(index), CHECK_NULL); + return JNIHandles::make_local(THREAD, sym()); +C2V_END + +C2V_VMENTRY(jobject, lookupSignatureRefInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + Handle sym = java_lang_String::create_from_symbol(cp->signature_ref_at(index), CHECK_NULL); + return JNIHandles::make_local(THREAD, sym()); +C2V_END + +C2V_VMENTRY(jint, lookupKlassRefIndexInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + return cp->klass_ref_index_at(index); +C2V_END + +C2V_VMENTRY(jlong, constantPoolKlassAt, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; + return (jlong) (address) cp->klass_at(index, THREAD); +C2V_END + +C2V_VMENTRY(jlong, lookupKlassInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + KlassHandle loading_klass(cp->pool_holder()); + bool is_accessible = false; + KlassHandle klass = JVMCIEnv::get_klass_by_index(cp, index, is_accessible, loading_klass); + if (klass.is_null()) { + // We have to lock the cpool to keep the oop from being resolved + // while we are accessing it. + MonitorLockerEx ml(cp->lock()); + constantTag tag = cp->tag_at(index); + if (tag.is_klass()) { + // The klass has been inserted into the constant pool + // very recently. + return (jlong) CompilerToVM::tag_pointer(cp->resolved_klass_at(index)); + } else if (tag.is_symbol()) { + return (jlong) CompilerToVM::tag_pointer(cp->symbol_at(index)); + } else { + assert(cp->tag_at(index).is_unresolved_klass(), "wrong tag"); + return (jlong) CompilerToVM::tag_pointer(cp->unresolved_klass_at(index)); + } + } + return (jlong) CompilerToVM::tag_pointer(klass()); +C2V_END + +C2V_VMENTRY(jobject, lookupAppendixInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + oop appendix_oop = ConstantPool::appendix_at_if_loaded(cp, index); + return JNIHandles::make_local(THREAD, appendix_oop); +C2V_END + +C2V_VMENTRY(jlong, lookupMethodInPool, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode)) + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + instanceKlassHandle pool_holder(cp->pool_holder()); + Bytecodes::Code bc = (Bytecodes::Code) (((int) opcode) & 0xFF); + methodHandle method = JVMCIEnv::get_method_by_index(cp, index, bc, pool_holder); + return (jlong) (address) method(); +C2V_END + +C2V_VMENTRY(jint, constantPoolRemapInstructionOperandFromCache, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + ConstantPool* cp = (ConstantPool*) metaspace_constant_pool; + return cp->remap_instruction_operand_from_cache(index); +C2V_END + +C2V_VMENTRY(jlong, resolveField, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index, jbyte opcode, jlongArray info_handle)) + ResourceMark rm; + constantPoolHandle cp = (ConstantPool*) metaspace_constant_pool; + Bytecodes::Code code = (Bytecodes::Code)(((int) opcode) & 0xFF); + fieldDescriptor result; + LinkResolver::resolve_field_access(result, cp, index, Bytecodes::java_code(code), true, false, CHECK_0); + typeArrayOop info = (typeArrayOop) JNIHandles::resolve(info_handle); + assert(info != NULL && info->length() == 2, "must be"); + info->long_at_put(0, (jlong) result.access_flags().as_int()); + info->long_at_put(1, (jlong) result.offset()); + return (jlong) (address) result.field_holder(); +C2V_END + +C2V_VMENTRY(jint, getVtableIndexForInterface, (JNIEnv *, jobject, jlong metaspace_klass, jlong metaspace_method)) + Klass* klass = (Klass*) metaspace_klass; + Method* method = (Method*) metaspace_method; + assert(!klass->is_interface(), ""); + return LinkResolver::vtable_index_of_interface_method(klass, method); +C2V_END + +C2V_VMENTRY(jlong, resolveMethod, (JNIEnv *, jobject, jlong metaspace_klass_receiver, jlong metaspace_method, jlong metaspace_klass_caller)) + Klass* recv_klass = (Klass*) metaspace_klass_receiver; + Klass* caller_klass = (Klass*) metaspace_klass_caller; + Method* method = (Method*) metaspace_method; + + if (recv_klass->oop_is_array() || (InstanceKlass::cast(recv_klass)->is_linked())) { + Klass* holder_klass = method->method_holder(); + Symbol* method_name = method->name(); + Symbol* method_signature = method->signature(); + + + if (holder_klass->is_interface()) { + // do link-time resolution to check all access rules. + methodHandle resolved_method; + LinkResolver::linktime_resolve_interface_method(resolved_method, holder_klass, method_name, method_signature, caller_klass, true, CHECK_AND_CLEAR_0); + if (resolved_method->is_private()) { + return (jlong) (address) NULL; + } + assert(recv_klass->is_subtype_of(holder_klass), ""); + // do actual lookup + methodHandle sel_method; + LinkResolver::lookup_instance_method_in_klasses(sel_method, recv_klass, + resolved_method->name(), + resolved_method->signature(), CHECK_AND_CLEAR_0); + return (jlong) (address) sel_method(); + } else { + // do link-time resolution to check all access rules. + methodHandle resolved_method; + LinkResolver::linktime_resolve_virtual_method(resolved_method, holder_klass, method_name, method_signature, caller_klass, true, CHECK_AND_CLEAR_0); + // do actual lookup (see LinkResolver::runtime_resolve_virtual_method) + int vtable_index = Method::invalid_vtable_index; + Method* selected_method; + + if (resolved_method->method_holder()->is_interface()) { // miranda method + vtable_index = LinkResolver::vtable_index_of_interface_method(holder_klass, resolved_method); + assert(vtable_index >= 0 , "we should have valid vtable index at this point"); + + InstanceKlass* inst = InstanceKlass::cast(recv_klass); + selected_method = inst->method_at_vtable(vtable_index); + } else { + // at this point we are sure that resolved_method is virtual and not + // a miranda method; therefore, it must have a valid vtable index. + assert(!resolved_method->has_itable_index(), ""); + vtable_index = resolved_method->vtable_index(); + // We could get a negative vtable_index for final methods, + // because as an optimization they are they are never put in the vtable, + // unless they override an existing method. + // If we do get a negative, it means the resolved method is the the selected + // method, and it can never be changed by an override. + if (vtable_index == Method::nonvirtual_vtable_index) { + assert(resolved_method->can_be_statically_bound(), "cannot override this method"); + selected_method = resolved_method(); + } else { + // recv_klass might be an arrayKlassOop but all vtables start at + // the same place. The cast is to avoid virtual call and assertion. + InstanceKlass* inst = (InstanceKlass*)recv_klass; + selected_method = inst->method_at_vtable(vtable_index); + } + } + return (jlong) (address) selected_method; + } + } + return (jlong) (address) NULL; +C2V_END + +C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jlong metaspace_klass)) + Klass* klass = (Klass*) metaspace_klass; + assert(klass != NULL, "method must not be called for primitive types"); + return Dependencies::find_finalizable_subclass(klass) != NULL; +C2V_END + +C2V_VMENTRY(jlong, getClassInitializer, (JNIEnv *, jobject, jlong metaspace_klass)) + InstanceKlass* klass = (InstanceKlass*) metaspace_klass; + return (jlong) (address) klass->class_initializer(); +C2V_END + +C2V_VMENTRY(jlong, getMaxCallTargetOffset, (JNIEnv*, jobject, jlong addr)) + address target_addr = (address) addr; + if (target_addr != 0x0) { + int64_t off_low = (int64_t)target_addr - ((int64_t)CodeCache::low_bound() + sizeof(int)); + int64_t off_high = (int64_t)target_addr - ((int64_t)CodeCache::high_bound() + sizeof(int)); + return MAX2(ABS(off_low), ABS(off_high)); + } + return -1; +C2V_END + +C2V_VMENTRY(void, doNotInlineOrCompile,(JNIEnv *, jobject, jlong metaspace_method)) + methodHandle method = asMethod(metaspace_method); + method->set_not_c1_compilable(); + method->set_not_c2_compilable(); + method->set_dont_inline(true); +C2V_END + +C2V_VMENTRY(jint, installCode, (JNIEnv *jniEnv, jobject, jobject compiled_code, jobject installed_code, jobject speculation_log)) + ResourceMark rm; + HandleMark hm; + Handle compiled_code_handle = JNIHandles::resolve(compiled_code); + CodeBlob* cb = NULL; + Handle installed_code_handle = JNIHandles::resolve(installed_code); + Handle speculation_log_handle = JNIHandles::resolve(speculation_log); + + TraceTime install_time("installCode", JVMCICompiler::codeInstallTimer()); + CodeInstaller installer; + JVMCIEnv::CodeInstallResult result = installer.install(compiled_code_handle, cb, installed_code_handle, speculation_log_handle); + + if (PrintCodeCacheOnCompilation) { + stringStream s; + // Dump code cache into a buffer before locking the tty, + { + MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + CodeCache::print_summary(&s, false); + } + ttyLocker ttyl; + tty->print_raw_cr(s.as_string()); + } + + if (result != JVMCIEnv::ok) { + assert(cb == NULL, "should be"); + } else { + if (!installed_code_handle.is_null()) { + assert(installed_code_handle->is_a(InstalledCode::klass()), "wrong type"); + InstalledCode::set_address(installed_code_handle, (jlong) cb); + InstalledCode::set_version(installed_code_handle, InstalledCode::version(installed_code_handle) + 1); + oop comp_result = HotSpotCompiledCode::comp(compiled_code_handle); + if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { + HotSpotInstalledCode::set_size(installed_code_handle, cb->size()); + HotSpotInstalledCode::set_codeStart(installed_code_handle, (jlong) cb->code_begin()); + HotSpotInstalledCode::set_codeSize(installed_code_handle, cb->code_size()); + } + nmethod* nm = cb->as_nmethod_or_null(); + if (nm != NULL && installed_code_handle->is_scavengable()) { + assert(nm->detect_scavenge_root_oops(), "nm should be scavengable if installed_code is scavengable"); + if (!UseG1GC) { + assert(nm->on_scavenge_root_list(), "nm should be on scavengable list"); + } + } + } + } + return result; +C2V_END + +C2V_VMENTRY(void, notifyCompilationStatistics, (JNIEnv *jniEnv, jobject, jint id, jobject hotspot_method, jboolean osr, jint processedBytecodes, jlong time, jlong timeUnitsPerSecond, jobject installed_code)) + CompilerStatistics* stats = JVMCICompiler::instance()->stats(); + + elapsedTimer timer = elapsedTimer(time, timeUnitsPerSecond); + if (osr) { + stats->_osr.update(timer, processedBytecodes); + } else { + stats->_standard.update(timer, processedBytecodes); + } + Handle installed_code_handle = JNIHandles::resolve(installed_code); + if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) { + stats->_nmethods_size += HotSpotInstalledCode::size(installed_code_handle); + stats->_nmethods_code_size += HotSpotInstalledCode::codeSize(installed_code_handle); + } + + if (CITimeEach) { + methodHandle method = asMethod(HotSpotResolvedJavaMethodImpl::metaspaceMethod(hotspot_method)); + float bytes_per_sec = 1.0 * processedBytecodes / timer.seconds(); + tty->print_cr("%3d seconds: %f bytes/sec: %f (bytes %d)", + id, timer.seconds(), bytes_per_sec, processedBytecodes); + } +C2V_END + +C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject)) + CompilerStatistics* stats = JVMCICompiler::instance()->stats(); + stats->_standard.reset(); + stats->_osr.reset(); +C2V_END + +C2V_VMENTRY(jobject, disassembleCodeBlob, (JNIEnv *jniEnv, jobject, jlong codeBlob)) + ResourceMark rm; + HandleMark hm; + + CodeBlob* cb = (CodeBlob*) (address) codeBlob; + if (cb == NULL) { + return NULL; + } + + // We don't want the stringStream buffer to resize during disassembly as it + // uses scoped resource memory. If a nested function called during disassembly uses + // a ResourceMark and the buffer expands within the scope of the mark, + // the buffer becomes garbage when that scope is exited. Experience shows that + // the disassembled code is typically about 10x the code size so a fixed buffer + // sized to 20x code size plus a fixed amount for header info should be sufficient. + int bufferSize = cb->code_size() * 20 + 1024; + char* buffer = NEW_RESOURCE_ARRAY(char, bufferSize); + stringStream st(buffer, bufferSize); + if (cb->is_nmethod()) { + nmethod* nm = (nmethod*) cb; + if (!nm->is_alive()) { + return NULL; + } + Disassembler::decode(nm, &st); + } else { + Disassembler::decode(cb, &st); + } + if (st.size() <= 0) { + return NULL; + } + + Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); + return JNIHandles::make_local(THREAD, result()); +C2V_END + +C2V_VMENTRY(jobject, getStackTraceElement, (JNIEnv*, jobject, jlong metaspace_method, int bci)) + ResourceMark rm; + HandleMark hm; + + methodHandle method = asMethod(metaspace_method); + oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); + return JNIHandles::make_local(THREAD, element); +C2V_END + +C2V_VMENTRY(jobject, executeCompiledMethodVarargs, (JNIEnv*, jobject, jobject args, jobject hotspotInstalledCode)) + ResourceMark rm; + HandleMark hm; + + jlong nmethodValue = InstalledCode::address(hotspotInstalledCode); + if (nmethodValue == 0L) { + THROW_(vmSymbols::com_oracle_jvmci_code_InvalidInstalledCodeException(), NULL); + } + nmethod* nm = (nmethod*) (address) nmethodValue; + methodHandle mh = nm->method(); + Symbol* signature = mh->signature(); + JavaCallArguments jca(mh->size_of_parameters()); + + JavaArgumentUnboxer jap(signature, &jca, (arrayOop) JNIHandles::resolve(args), mh->is_static()); + JavaValue result(jap.get_ret_type()); + jca.set_alternative_target(nm); + JavaCalls::call(&result, mh, &jca, CHECK_NULL); + + if (jap.get_ret_type() == T_VOID) { + return NULL; + } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) { + return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); + } else { + jvalue *value = (jvalue *) result.get_value_addr(); + // Narrow the value down if required (Important on big endian machines) + switch (jap.get_ret_type()) { + case T_BOOLEAN: + value->z = (jboolean) value->i; + break; + case T_BYTE: + value->b = (jbyte) value->i; + break; + case T_CHAR: + value->c = (jchar) value->i; + break; + case T_SHORT: + value->s = (jshort) value->i; + break; + } + oop o = java_lang_boxing_object::create(jap.get_ret_type(), value, CHECK_NULL); + return JNIHandles::make_local(THREAD, o); + } +C2V_END + +C2V_VMENTRY(jlongArray, getLineNumberTable, (JNIEnv *, jobject, jlong metaspace_method)) + Method* method = (Method*) metaspace_method; + if (!method->has_linenumber_table()) { + return NULL; + } + u2 num_entries = 0; + CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table()); + while (streamForSize.read_pair()) { + num_entries++; + } + + CompressedLineNumberReadStream stream(method->compressed_linenumber_table()); + typeArrayOop result = oopFactory::new_longArray(2 * num_entries, CHECK_NULL); + + int i = 0; + jlong value; + while (stream.read_pair()) { + value = ((long) stream.bci()); + result->long_at_put(i, value); + value = ((long) stream.line()); + result->long_at_put(i + 1, value); + i += 2; + } + + return (jlongArray) JNIHandles::make_local(THREAD, result); +C2V_END + +C2V_VMENTRY(jlong, getLocalVariableTableStart, (JNIEnv *, jobject, jlong metaspace_method)) + ResourceMark rm; + Method* method = (Method*) metaspace_method; + if (!method->has_localvariable_table()) { + return 0; + } + return (jlong) (address) method->localvariable_table_start(); +C2V_END + +C2V_VMENTRY(jint, getLocalVariableTableLength, (JNIEnv *, jobject, jlong metaspace_method)) + ResourceMark rm; + Method* method = (Method*) metaspace_method; + return method->localvariable_table_length(); +C2V_END + +C2V_VMENTRY(void, reprofile, (JNIEnv*, jobject, jlong metaspace_method)) + Method* method = asMethod(metaspace_method); + MethodCounters* mcs = method->method_counters(); + if (mcs != NULL) { + mcs->clear_counters(); + } + NOT_PRODUCT(method->set_compiled_invocation_count(0)); + + nmethod* code = method->code(); + if (code != NULL) { + code->make_not_entrant(); + } + + MethodData* method_data = method->method_data(); + if (method_data == NULL) { + ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); + method_data = MethodData::allocate(loader_data, method, CHECK); + method->set_method_data(method_data); + } else { + method_data->initialize(); + } +C2V_END + + +C2V_VMENTRY(void, invalidateInstalledCode, (JNIEnv*, jobject, jobject hotspotInstalledCode)) + jlong nativeMethod = InstalledCode::address(hotspotInstalledCode); + nmethod* m = (nmethod*)nativeMethod; + if (m != NULL && !m->is_not_entrant()) { + m->mark_for_deoptimization(); + VM_Deoptimize op; + VMThread::execute(&op); + } + InstalledCode::set_address(hotspotInstalledCode, 0); +C2V_END + +C2V_VMENTRY(jobject, getJavaMirror, (JNIEnv* env, jobject, jlong metaspace_klass)) + Klass* klass = asKlass(metaspace_klass); + return JNIHandles::make_local(THREAD, klass->java_mirror()); +C2V_END + +C2V_VMENTRY(jlong, readUnsafeKlassPointer, (JNIEnv*, jobject, jobject o)) + oop resolved_o = JNIHandles::resolve(o); + jlong klass = (jlong)(address)resolved_o->klass(); + return klass; +C2V_END + +C2V_VMENTRY(jobject, readUncompressedOop, (JNIEnv*, jobject, jlong addr)) + oop ret = oopDesc::load_decode_heap_oop((oop*)(address)addr); + return JNIHandles::make_local(THREAD, ret); +C2V_END + +C2V_VMENTRY(jlongArray, collectCounters, (JNIEnv*, jobject)) + typeArrayOop arrayOop = oopFactory::new_longArray(JVMCICounterSize, CHECK_NULL); + JavaThread::collect_counters(arrayOop); + return (jlongArray) JNIHandles::make_local(THREAD, arrayOop); +C2V_END + +C2V_VMENTRY(int, allocateCompileId, (JNIEnv*, jobject, jlong metaspace_method, int entry_bci)) + HandleMark hm; + ResourceMark rm; + Method* method = (Method*) metaspace_method; + return CompileBroker::assign_compile_id_unlocked(THREAD, method, entry_bci); +C2V_END + + +C2V_VMENTRY(jboolean, isMature, (JNIEnv*, jobject, jlong metaspace_method_data)) + MethodData* mdo = asMethodData(metaspace_method_data); + return mdo != NULL && mdo->is_mature(); +C2V_END + +C2V_VMENTRY(jboolean, hasCompiledCodeForOSR, (JNIEnv*, jobject, jlong metaspace_method, int entry_bci, int comp_level)) + Method* method = asMethod(metaspace_method); + return method->lookup_osr_nmethod_for(entry_bci, comp_level, true) != NULL; +C2V_END + +C2V_VMENTRY(jlong, getTimeStamp, (JNIEnv*, jobject)) + // tty->time_stamp is the time since VM start which should be used + // for all HotSpot log output when a timestamp is required. + return tty->time_stamp().milliseconds(); +C2V_END + +C2V_VMENTRY(jobject, getSymbol, (JNIEnv*, jobject, jlong metaspaceSymbol)) + Handle sym = java_lang_String::create_from_symbol((Symbol*)(address)metaspaceSymbol, CHECK_NULL); + return JNIHandles::make_local(THREAD, sym()); +C2V_END + +bool matches(jlongArray methods, Method* method) { + typeArrayOop methods_oop = (typeArrayOop) JNIHandles::resolve(methods); + + for (int i = 0; i < methods_oop->length(); i++) { + if (methods_oop->long_at(i) == (jlong) method) { + return true; + } + } + return false; +} + +C2V_VMENTRY(jobject, getNextStackFrame, (JNIEnv*, jobject compilerToVM, jobject hs_frame, jlongArray methods, jint initialSkip)) + ResourceMark rm; + + if (!thread->has_last_Java_frame()) return NULL; + Handle result = InstanceKlass::cast(HotSpotStackFrameReference::klass())->allocate_instance(thread); + HotSpotStackFrameReference::klass()->initialize(thread); + + StackFrameStream fst(thread); + if (hs_frame != NULL) { + // look for the correct stack frame if one is given + intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame); + while (fst.current()->sp() != stack_pointer && !fst.is_done()) { + fst.next(); + } + if (fst.current()->sp() != stack_pointer) { + THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "stack frame not found") + } + } + + int frame_number = 0; + vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); + if (hs_frame != NULL) { + // look for the correct vframe within the stack frame if one is given + int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame); + while (frame_number < last_frame_number) { + if (vf->is_top()) { + THROW_MSG_NULL(vmSymbols::java_lang_IllegalStateException(), "invalid frame number") + } + vf = vf->sender(); + frame_number ++; + } + // move one frame forward + if (vf->is_top()) { + if (fst.is_done()) { + return NULL; + } + fst.next(); + vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); + frame_number = 0; + } else { + vf = vf->sender(); + frame_number++; + } + } + + while (true) { + // look for the given method + while (true) { + StackValueCollection* locals = NULL; + if (vf->is_compiled_frame()) { + // compiled method frame + compiledVFrame* cvf = compiledVFrame::cast(vf); + if (methods == NULL || matches(methods, cvf->method())) { + if (initialSkip > 0) { + initialSkip --; + } else { + GrowableArray<ScopeValue*>* objects = cvf->scope()->objects(); + bool reallocated = false; + if (objects != NULL) { + reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD); + Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, reallocated); + + GrowableArray<ScopeValue*>* local_values = cvf->scope()->locals(); + typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread); + for (int i = 0; i < local_values->length(); i++) { + ScopeValue* value = local_values->at(i); + if (value->is_object()) { + array->bool_at_put(i, true); + } + } + HotSpotStackFrameReference::set_localIsVirtual(result, array()); + } else { + HotSpotStackFrameReference::set_localIsVirtual(result, NULL); + } + + locals = cvf->locals(); + HotSpotStackFrameReference::set_bci(result, cvf->bci()); + HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) cvf->method()); + } + } + } else if (vf->is_interpreted_frame()) { + // interpreted method frame + interpretedVFrame* ivf = interpretedVFrame::cast(vf); + if (methods == NULL || matches(methods, ivf->method())) { + if (initialSkip > 0) { + initialSkip --; + } else { + locals = ivf->locals(); + HotSpotStackFrameReference::set_bci(result, ivf->bci()); + HotSpotStackFrameReference::set_metaspaceMethod(result, (jlong) ivf->method()); + HotSpotStackFrameReference::set_localIsVirtual(result, NULL); + } + } + } + + // locals != NULL means that we found a matching frame and result is already partially initialized + if (locals != NULL) { + HotSpotStackFrameReference::set_compilerToVM(result, JNIHandles::resolve(compilerToVM)); + HotSpotStackFrameReference::set_stackPointer(result, (jlong) fst.current()->sp()); + HotSpotStackFrameReference::set_frameNumber(result, frame_number); + + // initialize the locals array + objArrayHandle array = oopFactory::new_objectArray(locals->size(), thread); + for (int i = 0; i < locals->size(); i++) { + StackValue* var = locals->at(i); + if (var->type() == T_OBJECT) { + array->obj_at_put(i, locals->at(i)->get_obj()()); + } + } + HotSpotStackFrameReference::set_locals(result, array()); + + return JNIHandles::make_local(thread, result()); + } + + if (vf->is_top()) { + break; + } + frame_number++; + vf = vf->sender(); + } // end of vframe loop + + if (fst.is_done()) { + break; + } + fst.next(); + vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); + frame_number = 0; + } // end of frame loop + + // the end was reached without finding a matching method + return NULL; +C2V_END + +C2V_VMENTRY(void, resolveInvokeDynamic, (JNIEnv*, jobject, jlong metaspace_constant_pool, jint index)) + ConstantPool* cp = (ConstantPool*)metaspace_constant_pool; + CallInfo callInfo; + LinkResolver::resolve_invokedynamic(callInfo, cp, index, CHECK); + ConstantPoolCacheEntry* cp_cache_entry = cp->invokedynamic_cp_cache_entry_at(index); + cp_cache_entry->set_dynamic_call(cp, callInfo); +C2V_END + +C2V_VMENTRY(jboolean, shouldDebugNonSafepoints, (JNIEnv*, jobject)) + //see compute_recording_non_safepoints in debugInfroRec.cpp + if (JvmtiExport::should_post_compiled_method_load() && FLAG_IS_DEFAULT(DebugNonSafepoints)) { + return true; + } + return DebugNonSafepoints; +C2V_END + +// public native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); +C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv*, jobject, jobject hs_frame, bool invalidate)) + ResourceMark rm; + + if (hs_frame == NULL) { + THROW_MSG(vmSymbols::java_lang_NullPointerException(), "stack frame is null") + } + + HotSpotStackFrameReference::klass()->initialize(thread); + + // look for the given stack frame + StackFrameStream fst(thread); + intptr_t* stack_pointer = (intptr_t*) HotSpotStackFrameReference::stackPointer(hs_frame); + while (fst.current()->sp() != stack_pointer && !fst.is_done()) { + fst.next(); + } + if (fst.current()->sp() != stack_pointer) { + THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "stack frame not found") + } + + if (invalidate) { + assert(fst.current()->cb()->is_nmethod(), "nmethod expected"); + ((nmethod*) fst.current()->cb())->make_not_entrant(); + } + Deoptimization::deoptimize(thread, *fst.current(), fst.register_map(), Deoptimization::Reason_none); + + vframe* vf = vframe::new_vframe(fst.current(), fst.register_map(), thread); + if (!vf->is_compiled_frame()) { + THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "compiled stack frame expected") + } + + GrowableArray<compiledVFrame*>* virtualFrames = new GrowableArray<compiledVFrame*>(10); + while (true) { + assert(vf->is_compiled_frame(), "Wrong frame type"); + virtualFrames->push(compiledVFrame::cast(vf)); + if (vf->is_top()) { + break; + } + vf = vf->sender(); + } + + int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame); + if (last_frame_number >= virtualFrames->length()) { + THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "invalid frame number") + } + + // Reallocate the non-escaping objects and restore their fields. + assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope"); + GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects(); + + if (objects == NULL) { + // no objects to materialize + return; + } + + bool reallocated = Deoptimization::realloc_objects(thread, fst.current(), objects, THREAD); + Deoptimization::reassign_fields(fst.current(), fst.register_map(), objects, reallocated); + + for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) { + compiledVFrame* cvf = virtualFrames->at(frame_index); + + GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals(); + StackValueCollection* locals = cvf->locals(); + + if (locals != NULL) { + for (int i2 = 0; i2 < locals->size(); i2++) { + StackValue* var = locals->at(i2); + if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) { + jvalue val; + val.l = (jobject) locals->at(i2)->get_obj()(); + cvf->update_local(T_OBJECT, i2, val); + } + } + } + } + + // all locals are materialized by now + HotSpotStackFrameReference::set_localIsVirtual(hs_frame, NULL); + + // update the locals array + objArrayHandle array = HotSpotStackFrameReference::locals(hs_frame); + StackValueCollection* locals = virtualFrames->at(last_frame_number)->locals(); + for (int i = 0; i < locals->size(); i++) { + StackValue* var = locals->at(i); + if (var->type() == T_OBJECT) { + array->obj_at_put(i, locals->at(i)->get_obj()()); + } + } +C2V_END + +C2V_VMENTRY(void, writeDebugOutput, (JNIEnv*, jobject, jbyteArray bytes, jint offset, jint length)) + while (length > 0) { + jbyte* start = ((typeArrayOop) JNIHandles::resolve(bytes))->byte_at_addr(offset); + tty->write((char*) start, MIN2(length, O_BUFLEN)); + length -= O_BUFLEN; + offset += O_BUFLEN; + } +C2V_END + +C2V_VMENTRY(void, flushDebugOutput, (JNIEnv*, jobject)) + tty->flush(); +C2V_END + + +#define CC (char*) /*cast a literal from (const char*)*/ +#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) + +#define TYPE "Lcom/oracle/jvmci/meta/JavaType;" +#define METHOD "Lcom/oracle/jvmci/meta/JavaMethod;" +#define FIELD "Lcom/oracle/jvmci/meta/JavaField;" +#define SPECULATION_LOG "Lcom/oracle/jvmci/code/SpeculationLog;" +#define STRING "Ljava/lang/String;" +#define OBJECT "Ljava/lang/Object;" +#define CLASS "Ljava/lang/Class;" +#define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" +#define INSTALLED_CODE "Lcom/oracle/jvmci/code/InstalledCode;" +#define RESOLVED_METHOD "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;" +#define HS_RESOLVED_METHOD "Lcom/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod;" +#define HS_COMPILED_CODE "Lcom/oracle/jvmci/hotspot/HotSpotCompiledCode;" +#define HS_CONFIG "Lcom/oracle/jvmci/hotspot/HotSpotVMConfig;" +#define HS_STACK_FRAME_REF "Lcom/oracle/jvmci/hotspot/HotSpotStackFrameReference;" +#define METASPACE_KLASS "J" +#define METASPACE_METHOD "J" +#define METASPACE_METHOD_DATA "J" +#define METASPACE_CONSTANT_POOL "J" + +JNINativeMethod CompilerToVM_methods[] = { + {CC"getBytecode", CC"("METASPACE_METHOD")[B", FN_PTR(getBytecode)}, + {CC"exceptionTableStart", CC"("METASPACE_METHOD")J", FN_PTR(exceptionTableStart)}, + {CC"exceptionTableLength", CC"("METASPACE_METHOD")I", FN_PTR(exceptionTableLength)}, + {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)}, + {CC"findUniqueConcreteMethod", CC"("METASPACE_KLASS METASPACE_METHOD")"METASPACE_METHOD, FN_PTR(findUniqueConcreteMethod)}, + {CC"getKlassImplementor", CC"("METASPACE_KLASS")"METASPACE_KLASS, FN_PTR(getKlassImplementor)}, + {CC"getStackTraceElement", CC"("METASPACE_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)}, + {CC"methodIsIgnoredBySecurityStackWalk", CC"("METASPACE_METHOD")Z", FN_PTR(methodIsIgnoredBySecurityStackWalk)}, + {CC"doNotInlineOrCompile", CC"("METASPACE_METHOD")V", FN_PTR(doNotInlineOrCompile)}, + {CC"canInlineMethod", CC"("METASPACE_METHOD")Z", FN_PTR(canInlineMethod)}, + {CC"shouldInlineMethod", CC"("METASPACE_METHOD")Z", FN_PTR(shouldInlineMethod)}, + {CC"lookupType", CC"("STRING CLASS"Z)"METASPACE_KLASS, FN_PTR(lookupType)}, + {CC"resolveConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolveConstantInPool)}, + {CC"resolvePossiblyCachedConstantInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(resolvePossiblyCachedConstantInPool)}, + {CC"lookupNameRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"STRING, FN_PTR(lookupNameRefInPool)}, + {CC"lookupNameAndTypeRefIndexInPool", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(lookupNameAndTypeRefIndexInPool)}, + {CC"lookupSignatureRefInPool", CC"("METASPACE_CONSTANT_POOL"I)"STRING, FN_PTR(lookupSignatureRefInPool)}, + {CC"lookupKlassRefIndexInPool", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(lookupKlassRefIndexInPool)}, + {CC"constantPoolKlassAt", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(constantPoolKlassAt)}, + {CC"lookupKlassInPool", CC"("METASPACE_CONSTANT_POOL"I)"METASPACE_KLASS, FN_PTR(lookupKlassInPool)}, + {CC"lookupAppendixInPool", CC"("METASPACE_CONSTANT_POOL"I)"OBJECT, FN_PTR(lookupAppendixInPool)}, + {CC"lookupMethodInPool", CC"("METASPACE_CONSTANT_POOL"IB)"METASPACE_METHOD, FN_PTR(lookupMethodInPool)}, + {CC"constantPoolRemapInstructionOperandFromCache", CC"("METASPACE_CONSTANT_POOL"I)I", FN_PTR(constantPoolRemapInstructionOperandFromCache)}, + {CC"resolveField", CC"("METASPACE_CONSTANT_POOL"IB[J)"METASPACE_KLASS, FN_PTR(resolveField)}, + {CC"resolveInvokeDynamic", CC"("METASPACE_CONSTANT_POOL"I)V", FN_PTR(resolveInvokeDynamic)}, + {CC"resolveMethod", CC"("METASPACE_KLASS METASPACE_METHOD METASPACE_KLASS")"METASPACE_METHOD, FN_PTR(resolveMethod)}, + {CC"getVtableIndexForInterface", CC"("METASPACE_KLASS METASPACE_METHOD")I", FN_PTR(getVtableIndexForInterface)}, + {CC"getClassInitializer", CC"("METASPACE_KLASS")"METASPACE_METHOD, FN_PTR(getClassInitializer)}, + {CC"hasFinalizableSubclass", CC"("METASPACE_KLASS")Z", FN_PTR(hasFinalizableSubclass)}, + {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, + {CC"getMetaspaceMethod", CC"("CLASS"I)"METASPACE_METHOD, FN_PTR(getMetaspaceMethod)}, + {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)}, + {CC"installCode", CC"("HS_COMPILED_CODE INSTALLED_CODE SPECULATION_LOG")I", FN_PTR(installCode)}, + {CC"notifyCompilationStatistics", CC"(I"HS_RESOLVED_METHOD"ZIJJ"INSTALLED_CODE")V", FN_PTR(notifyCompilationStatistics)}, + {CC"resetCompilationStatistics", CC"()V", FN_PTR(resetCompilationStatistics)}, + {CC"disassembleCodeBlob", CC"(J)"STRING, FN_PTR(disassembleCodeBlob)}, + {CC"executeCompiledMethodVarargs", CC"(["OBJECT INSTALLED_CODE")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, + {CC"getLineNumberTable", CC"("METASPACE_METHOD")[J", FN_PTR(getLineNumberTable)}, + {CC"getLocalVariableTableStart", CC"("METASPACE_METHOD")J", FN_PTR(getLocalVariableTableStart)}, + {CC"getLocalVariableTableLength", CC"("METASPACE_METHOD")I", FN_PTR(getLocalVariableTableLength)}, + {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, + {CC"invalidateInstalledCode", CC"("INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)}, + {CC"getJavaMirror", CC"("METASPACE_KLASS")"CLASS, FN_PTR(getJavaMirror)}, + {CC"readUnsafeKlassPointer", CC"("OBJECT")J", FN_PTR(readUnsafeKlassPointer)}, + {CC"readUncompressedOop", CC"(J)"OBJECT, FN_PTR(readUncompressedOop)}, + {CC"collectCounters", CC"()[J", FN_PTR(collectCounters)}, + {CC"allocateCompileId", CC"("METASPACE_METHOD"I)I", FN_PTR(allocateCompileId)}, + {CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)}, + {CC"hasCompiledCodeForOSR", CC"("METASPACE_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)}, + {CC"getSymbol", CC"(J)"STRING, FN_PTR(getSymbol)}, + {CC"getTimeStamp", CC"()J", FN_PTR(getTimeStamp)}, + {CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "[JI)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)}, + {CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)}, + {CC"shouldDebugNonSafepoints", CC"()Z", FN_PTR(shouldDebugNonSafepoints)}, + {CC"writeDebugOutput", CC"([BII)V", FN_PTR(writeDebugOutput)}, + {CC"flushDebugOutput", CC"()V", FN_PTR(flushDebugOutput)}, +}; + +int CompilerToVM_methods_count() { + return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2011, 2013, 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. + */ + +#ifndef SHARE_VM_JVMCI_JVMCI_COMPILER_TO_VM_HPP +#define SHARE_VM_JVMCI_JVMCI_COMPILER_TO_VM_HPP + +#include "prims/jni.h" +#include "runtime/javaCalls.hpp" + +class CompilerToVM { +public: + /** + * Tag bits used by lookupKlassInPool to distinguish the types in Java. + */ + enum Tags { + KLASS_TAG = 0x0, + SYMBOL_TAG = 0x1 + }; + + static intptr_t tag_pointer(Klass* klass) { + return ((intptr_t) klass) | KLASS_TAG; + } + + static intptr_t tag_pointer(Symbol* symbol) { + return ((intptr_t) symbol) | SYMBOL_TAG; + } + + // nothing here - no need to define the jni method implementations in a header file +}; + +extern JNINativeMethod CompilerToVM_methods[]; +int CompilerToVM_methods_count(); + +inline Method* asMethod(jlong metaspaceMethod) { + return (Method*) (address) metaspaceMethod; +} + +inline MethodData* asMethodData(jlong metaspaceMethodData) { + return (MethodData*) (address) metaspaceMethodData; +} + +inline Klass* asKlass(jlong metaspaceKlass) { + return (Klass*) (address) metaspaceKlass; +} + +class JavaArgumentUnboxer : public SignatureIterator { + protected: + JavaCallArguments* _jca; + arrayOop _args; + int _index; + + oop next_arg(BasicType expectedType) { + assert(_index < _args->length(), "out of bounds"); + oop arg=((objArrayOop) (_args))->obj_at(_index++); + assert(expectedType == T_OBJECT || java_lang_boxing_object::is_instance(arg, expectedType), "arg type mismatch"); + return arg; + } + + public: + JavaArgumentUnboxer(Symbol* signature, JavaCallArguments* jca, arrayOop args, bool is_static) : SignatureIterator(signature) { + this->_return_type = T_ILLEGAL; + _jca = jca; + _index = 0; + _args = args; + if (!is_static) { + _jca->push_oop(next_arg(T_OBJECT)); + } + iterate(); + assert(_index == args->length(), "arg count mismatch with signature"); + } + + inline void do_bool() { if (!is_return_type()) _jca->push_int(next_arg(T_BOOLEAN)->bool_field(java_lang_boxing_object::value_offset_in_bytes(T_BOOLEAN))); } + inline void do_char() { if (!is_return_type()) _jca->push_int(next_arg(T_CHAR)->char_field(java_lang_boxing_object::value_offset_in_bytes(T_CHAR))); } + inline void do_short() { if (!is_return_type()) _jca->push_int(next_arg(T_SHORT)->short_field(java_lang_boxing_object::value_offset_in_bytes(T_SHORT))); } + inline void do_byte() { if (!is_return_type()) _jca->push_int(next_arg(T_BYTE)->byte_field(java_lang_boxing_object::value_offset_in_bytes(T_BYTE))); } + inline void do_int() { if (!is_return_type()) _jca->push_int(next_arg(T_INT)->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT))); } + + inline void do_long() { if (!is_return_type()) _jca->push_long(next_arg(T_LONG)->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG))); } + inline void do_float() { if (!is_return_type()) _jca->push_float(next_arg(T_FLOAT)->float_field(java_lang_boxing_object::value_offset_in_bytes(T_FLOAT))); } + inline void do_double() { if (!is_return_type()) _jca->push_double(next_arg(T_DOUBLE)->double_field(java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE))); } + + inline void do_object() { _jca->push_oop(next_arg(T_OBJECT)); } + inline void do_object(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); } + inline void do_array(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); } + inline void do_void() { } +}; + +#endif // SHARE_VM_JVMCI_JVMCI_COMPILER_TO_VM_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciEnv.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,617 @@ +/* + * Copyright (c) 1999, 2011, 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. + * + */ + +#include "precompiled.hpp" +#include "jvmci/jvmciEnv.hpp" +#include "classfile/systemDictionary.hpp" +#include "classfile/vmSymbols.hpp" +#include "code/scopeDesc.hpp" +#include "runtime/sweeper.hpp" +#include "compiler/compileBroker.hpp" +#include "compiler/compileLog.hpp" +#include "compiler/compilerOracle.hpp" +#include "interpreter/linkResolver.hpp" +#include "memory/allocation.inline.hpp" +#include "memory/oopFactory.hpp" +#include "memory/universe.inline.hpp" +#include "oops/methodData.hpp" +#include "oops/objArrayKlass.hpp" +#include "prims/jvmtiExport.hpp" +#include "runtime/init.hpp" +#include "runtime/reflection.hpp" +#include "runtime/sharedRuntime.hpp" +#include "utilities/dtrace.hpp" +#include "jvmci/jvmciRuntime.hpp" +#include "jvmci/jvmciJavaAccess.hpp" + +JVMCIEnv::JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter) { + _task = task; + _system_dictionary_modification_counter = system_dictionary_modification_counter; + { + // Get Jvmti capabilities under lock to get consistent values. + MutexLocker mu(JvmtiThreadState_lock); + _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint(); + _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables(); + _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions(); + } +} + +// ------------------------------------------------------------------ +// Note: the logic of this method should mirror the logic of +// constantPoolOopDesc::verify_constant_pool_resolve. +bool JVMCIEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) { + if (accessing_klass->oop_is_objArray()) { + accessing_klass = ObjArrayKlass::cast(accessing_klass())->bottom_klass(); + } + if (!accessing_klass->oop_is_instance()) { + return true; + } + + if (resolved_klass->oop_is_objArray()) { + // Find the element klass, if this is an array. + resolved_klass = ObjArrayKlass::cast(resolved_klass())->bottom_klass(); + } + if (resolved_klass->oop_is_instance()) { + return Reflection::verify_class_access(accessing_klass(), resolved_klass(), true); + } + return true; +} + +// ------------------------------------------------------------------ +KlassHandle JVMCIEnv::get_klass_by_name_impl(KlassHandle& accessing_klass, + constantPoolHandle& cpool, + Symbol* sym, + bool require_local) { + JVMCI_EXCEPTION_CONTEXT; + + // Now we need to check the SystemDictionary + if (sym->byte_at(0) == 'L' && + sym->byte_at(sym->utf8_length()-1) == ';') { + // This is a name from a signature. Strip off the trimmings. + // Call recursive to keep scope of strippedsym. + TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, + sym->utf8_length()-2, + CHECK_(KlassHandle())); + return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local); + } + + Handle loader(THREAD, (oop)NULL); + Handle domain(THREAD, (oop)NULL); + if (!accessing_klass.is_null()) { + loader = Handle(THREAD, accessing_klass->class_loader()); + domain = Handle(THREAD, accessing_klass->protection_domain()); + } + + KlassHandle found_klass; + { + ttyUnlocker ttyul; // release tty lock to avoid ordering problems + MutexLocker ml(Compile_lock); + Klass* kls; + if (!require_local) { + kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_(KlassHandle())); + } else { + kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_(KlassHandle())); + } + found_klass = KlassHandle(THREAD, kls); + } + + // If we fail to find an array klass, look again for its element type. + // The element type may be available either locally or via constraints. + // In either case, if we can find the element type in the system dictionary, + // we must build an array type around it. The CI requires array klasses + // to be loaded if their element klasses are loaded, except when memory + // is exhausted. + if (sym->byte_at(0) == '[' && + (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) { + // We have an unloaded array. + // Build it on the fly if the element class exists. + TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, + sym->utf8_length()-1, + CHECK_(KlassHandle())); + + // Get element Klass recursively. + KlassHandle elem_klass = + get_klass_by_name_impl(accessing_klass, + cpool, + elem_sym, + require_local); + if (!elem_klass.is_null()) { + // Now make an array for it + return elem_klass->array_klass(CHECK_(KlassHandle())); + } + } + + if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) { + // Look inside the constant pool for pre-resolved class entries. + for (int i = cpool->length() - 1; i >= 1; i--) { + if (cpool->tag_at(i).is_klass()) { + Klass* kls = cpool->resolved_klass_at(i); + if (kls->name() == sym) { + return kls; + } + } + } + } + + return found_klass(); +} + +// ------------------------------------------------------------------ +KlassHandle JVMCIEnv::get_klass_by_name(KlassHandle& accessing_klass, + Symbol* klass_name, + bool require_local) { + ResourceMark rm; + constantPoolHandle cpool; + return get_klass_by_name_impl(accessing_klass, + cpool, + klass_name, + require_local); +} + +// ------------------------------------------------------------------ +// Implementation of get_klass_by_index. +KlassHandle JVMCIEnv::get_klass_by_index_impl(constantPoolHandle& cpool, + int index, + bool& is_accessible, + KlassHandle& accessor) { + JVMCI_EXCEPTION_CONTEXT; + KlassHandle klass (THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); + Symbol* klass_name = NULL; + if (klass.is_null()) { + // The klass has not been inserted into the constant pool. + // Try to look it up by name. + { + // We have to lock the cpool to keep the oop from being resolved + // while we are accessing it. + MonitorLockerEx ml(cpool->lock()); + + constantTag tag = cpool->tag_at(index); + if (tag.is_klass()) { + // The klass has been inserted into the constant pool + // very recently. + klass = KlassHandle(THREAD, cpool->resolved_klass_at(index)); + } else if (tag.is_symbol()) { + klass_name = cpool->symbol_at(index); + } else { + assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag"); + klass_name = cpool->unresolved_klass_at(index); + } + } + } + + if (klass.is_null()) { + // Not found in constant pool. Use the name to do the lookup. + KlassHandle k = get_klass_by_name_impl(accessor, + cpool, + klass_name, + false); + // Calculate accessibility the hard way. + if (k.is_null()) { + is_accessible = false; + } else if (k->class_loader() != accessor->class_loader() && + get_klass_by_name_impl(accessor, cpool, k->name(), true).is_null()) { + // Loaded only remotely. Not linked yet. + is_accessible = false; + } else { + // Linked locally, and we must also check public/private, etc. + is_accessible = check_klass_accessibility(accessor, k); + } + if (!is_accessible) { + return KlassHandle(); + } + return k; + } + + // It is known to be accessible, since it was found in the constant pool. + is_accessible = true; + return klass; +} + +// ------------------------------------------------------------------ +// Get a klass from the constant pool. +KlassHandle JVMCIEnv::get_klass_by_index(constantPoolHandle& cpool, + int index, + bool& is_accessible, + KlassHandle& accessor) { + ResourceMark rm; + KlassHandle result = get_klass_by_index_impl(cpool, index, is_accessible, accessor); + return result; +} + +// ------------------------------------------------------------------ +// Implementation of get_field_by_index. +// +// Implementation note: the results of field lookups are cached +// in the accessor klass. +void JVMCIEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc, + int index) { + JVMCI_EXCEPTION_CONTEXT; + + assert(klass->is_linked(), "must be linked before using its constant-pool"); + + constantPoolHandle cpool(thread, klass->constants()); + + // Get the field's name, signature, and type. + Symbol* name = cpool->name_ref_at(index); + + int nt_index = cpool->name_and_type_ref_index_at(index); + int sig_index = cpool->signature_ref_index_at(nt_index); + Symbol* signature = cpool->symbol_at(sig_index); + + // Get the field's declared holder. + int holder_index = cpool->klass_ref_index_at(index); + bool holder_is_accessible; + KlassHandle declared_holder = get_klass_by_index(cpool, holder_index, + holder_is_accessible, + klass); + + // The declared holder of this field may not have been loaded. + // Bail out with partial field information. + if (!holder_is_accessible) { + return; + } + + + // Perform the field lookup. + Klass* canonical_holder = + InstanceKlass::cast(declared_holder())->find_field(name, signature, &field_desc); + if (canonical_holder == NULL) { + return; + } + + assert(canonical_holder == field_desc.field_holder(), "just checking"); +} + +// ------------------------------------------------------------------ +// Get a field by index from a klass's constant pool. +void JVMCIEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, int index) { + ResourceMark rm; + return get_field_by_index_impl(accessor, fd, index); +} + +// ------------------------------------------------------------------ +// Perform an appropriate method lookup based on accessor, holder, +// name, signature, and bytecode. +methodHandle JVMCIEnv::lookup_method(instanceKlassHandle& h_accessor, + instanceKlassHandle& h_holder, + Symbol* name, + Symbol* sig, + Bytecodes::Code bc) { + JVMCI_EXCEPTION_CONTEXT; + LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL)); + methodHandle dest_method; + switch (bc) { + case Bytecodes::_invokestatic: + dest_method = + LinkResolver::resolve_static_call_or_null(h_holder, name, sig, h_accessor); + break; + case Bytecodes::_invokespecial: + dest_method = + LinkResolver::resolve_special_call_or_null(h_holder, name, sig, h_accessor); + break; + case Bytecodes::_invokeinterface: + dest_method = + LinkResolver::linktime_resolve_interface_method_or_null(h_holder, name, sig, + h_accessor, true); + break; + case Bytecodes::_invokevirtual: + dest_method = + LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, name, sig, + h_accessor, true); + break; + default: ShouldNotReachHere(); + } + + return dest_method; +} + + +// ------------------------------------------------------------------ +methodHandle JVMCIEnv::get_method_by_index_impl(constantPoolHandle& cpool, + int index, Bytecodes::Code bc, + instanceKlassHandle& accessor) { + if (bc == Bytecodes::_invokedynamic) { + ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index); + bool is_resolved = !cpce->is_f1_null(); + if (is_resolved) { + // Get the invoker Method* from the constant pool. + // (The appendix argument, if any, will be noted in the method's signature.) + Method* adapter = cpce->f1_as_method(); + return methodHandle(adapter); + } + + return NULL; + } + + int holder_index = cpool->klass_ref_index_at(index); + bool holder_is_accessible; + KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); + + // Get the method's name and signature. + Symbol* name_sym = cpool->name_ref_at(index); + Symbol* sig_sym = cpool->signature_ref_at(index); + + if (cpool->has_preresolution() + || (holder() == SystemDictionary::MethodHandle_klass() && + MethodHandles::is_signature_polymorphic_name(holder(), name_sym))) { + // Short-circuit lookups for JSR 292-related call sites. + // That is, do not rely only on name-based lookups, because they may fail + // if the names are not resolvable in the boot class loader (7056328). + switch (bc) { + case Bytecodes::_invokevirtual: + case Bytecodes::_invokeinterface: + case Bytecodes::_invokespecial: + case Bytecodes::_invokestatic: + { + Method* m = ConstantPool::method_at_if_loaded(cpool, index); + if (m != NULL) { + return m; + } + } + break; + } + } + + if (holder_is_accessible) { // Our declared holder is loaded. + instanceKlassHandle lookup = get_instance_klass_for_declared_method_holder(holder); + methodHandle m = lookup_method(accessor, lookup, name_sym, sig_sym, bc); + if (!m.is_null() && + (bc == Bytecodes::_invokestatic + ? InstanceKlass::cast(m->method_holder())->is_not_initialized() + : !InstanceKlass::cast(m->method_holder())->is_loaded())) { + m = NULL; + } + if (!m.is_null()) { + // We found the method. + return m; + } + } + + // Either the declared holder was not loaded, or the method could + // not be found. + + return NULL; +} + +// ------------------------------------------------------------------ +instanceKlassHandle JVMCIEnv::get_instance_klass_for_declared_method_holder(KlassHandle& method_holder) { + // For the case of <array>.clone(), the method holder can be an ArrayKlass* + // instead of an InstanceKlass*. For that case simply pretend that the + // declared holder is Object.clone since that's where the call will bottom out. + if (method_holder->oop_is_instance()) { + return instanceKlassHandle(method_holder()); + } else if (method_holder->oop_is_array()) { + return instanceKlassHandle(SystemDictionary::Object_klass()); + } else { + ShouldNotReachHere(); + } + return NULL; +} + + +// ------------------------------------------------------------------ +methodHandle JVMCIEnv::get_method_by_index(constantPoolHandle& cpool, + int index, Bytecodes::Code bc, + instanceKlassHandle& accessor) { + ResourceMark rm; + return get_method_by_index_impl(cpool, index, bc, accessor); +} + +// ------------------------------------------------------------------ +// Check for changes to the system dictionary during compilation +// class loads, evolution, breakpoints +JVMCIEnv::CodeInstallResult JVMCIEnv::check_for_system_dictionary_modification(Dependencies* dependencies, Handle compiled_code, + JVMCIEnv* env, char** failure_detail) { + // If JVMTI capabilities were enabled during compile, the compilation is invalidated. + if (env != NULL) { + if (!env->_jvmti_can_hotswap_or_post_breakpoint && JvmtiExport::can_hotswap_or_post_breakpoint()) { + *failure_detail = (char*) "Hotswapping or breakpointing was enabled during compilation"; + return JVMCIEnv::dependencies_failed; + } + } + + // Dependencies must be checked when the system dictionary changes + // or if we don't know whether it has changed (i.e., env == NULL). + // In debug mode, always check dependencies. + bool counter_changed = env != NULL && env->_system_dictionary_modification_counter != SystemDictionary::number_of_modifications(); + bool verify_deps = env == NULL || trueInDebug || Debug::ENABLED(); + if (!counter_changed && !verify_deps) { + return JVMCIEnv::ok; + } + + for (Dependencies::DepStream deps(dependencies); deps.next(); ) { + Klass* witness = deps.check_dependency(); + if (witness != NULL) { + // Use a fixed size buffer to prevent the string stream from + // resizing in the context of an inner resource mark. + char* buffer = NEW_RESOURCE_ARRAY(char, O_BUFLEN); + stringStream st(buffer, O_BUFLEN); + deps.print_dependency(witness, true, &st); + *failure_detail = st.as_string(); + if (env == NULL || counter_changed) { + return JVMCIEnv::dependencies_failed; + } else { + // The dependencies were invalid at the time of installation + // without any intervening modification of the system + // dictionary. That means they were invalidly constructed. + return JVMCIEnv::dependencies_invalid; + } + } + if (LogCompilation) { + deps.log_dependency(); + } + } + + return JVMCIEnv::ok; +} + +// ------------------------------------------------------------------ +JVMCIEnv::CodeInstallResult JVMCIEnv::register_method( + methodHandle& method, + nmethod*& nm, + int entry_bci, + CodeOffsets* offsets, + int orig_pc_offset, + CodeBuffer* code_buffer, + int frame_words, + OopMapSet* oop_map_set, + ExceptionHandlerTable* handler_table, + AbstractCompiler* compiler, + DebugInformationRecorder* debug_info, + Dependencies* dependencies, + JVMCIEnv* env, + int compile_id, + bool has_unsafe_access, + Handle installed_code, + Handle compiled_code, + Handle speculation_log) { + JVMCI_EXCEPTION_CONTEXT; + NMethodSweeper::possibly_sweep(); + nm = NULL; + int comp_level = CompLevel_full_optimization; + char* failure_detail = NULL; + JVMCIEnv::CodeInstallResult result; + { + // To prevent compile queue updates. + MutexLocker locker(MethodCompileQueue_lock, THREAD); + + // Prevent SystemDictionary::add_to_hierarchy from running + // and invalidating our dependencies until we install this method. + MutexLocker ml(Compile_lock); + + // Encode the dependencies now, so we can check them right away. + dependencies->encode_content_bytes(); + + // Check for {class loads, evolution, breakpoints} during compilation + result = check_for_system_dictionary_modification(dependencies, compiled_code, env, &failure_detail); + if (result != JVMCIEnv::ok) { + // While not a true deoptimization, it is a preemptive decompile. + MethodData* mdp = method()->method_data(); + if (mdp != NULL) { + mdp->inc_decompile_count(); + if (mdp->decompile_count() > (uint)PerMethodRecompilationCutoff) { + // TODO (chaeubl) enable this in the fastdebug build only once we are more stable + ResourceMark m; + tty->print_cr("WARN: endless recompilation of %s. Method was set to not compilable.", method()->name_and_sig_as_C_string()); + //ShouldNotReachHere(); + } + } + + // All buffers in the CodeBuffer are allocated in the CodeCache. + // If the code buffer is created on each compile attempt + // as in C2, then it must be freed. + //code_buffer->free_blob(); + } else { + ImplicitExceptionTable implicit_tbl; + nm = nmethod::new_nmethod(method, + compile_id, + entry_bci, + offsets, + orig_pc_offset, + debug_info, dependencies, code_buffer, + frame_words, oop_map_set, + handler_table, &implicit_tbl, + compiler, comp_level, installed_code, speculation_log); + + // Free codeBlobs + //code_buffer->free_blob(); + + if (nm == NULL) { + // The CodeCache is full. Print out warning and disable compilation. + { + MutexUnlocker ml(Compile_lock); + MutexUnlocker locker(MethodCompileQueue_lock); + CompileBroker::handle_full_code_cache(); + } + } else { + nm->set_has_unsafe_access(has_unsafe_access); +#ifdef TARGET_ARCH_x86 + // It might be preferable to set this only for methods which + // use vector instructions but we currently don't track this + // and it probably wouldn't make much difference. + nm->set_has_wide_vectors(MaxVectorSize > 16); +#endif + + // Record successful registration. + // (Put nm into the task handle *before* publishing to the Java heap.) + CompileTask* task = env == NULL ? NULL : env->task(); + if (task != NULL) task->set_code(nm); + + if (installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(installed_code())) { + if (entry_bci == InvocationEntryBci) { + if (TieredCompilation) { + // If there is an old version we're done with it + nmethod* old = method->code(); + if (TraceMethodReplacement && old != NULL) { + ResourceMark rm; + char *method_name = method->name_and_sig_as_C_string(); + tty->print_cr("Replacing method %s", method_name); + } + if (old != NULL ) { + old->make_not_entrant(); + } + } + if (TraceNMethodInstalls) { + ResourceMark rm; + char *method_name = method->name_and_sig_as_C_string(); + ttyLocker ttyl; + tty->print_cr("Installing method (%d) %s [entry point: %p]", + comp_level, + method_name, nm->entry_point()); + } + // Allow the code to be executed + method->set_code(method, nm); + } else { + if (TraceNMethodInstalls ) { + ResourceMark rm; + char *method_name = method->name_and_sig_as_C_string(); + ttyLocker ttyl; + tty->print_cr("Installing osr method (%d) %s @ %d", + comp_level, + method_name, + entry_bci); + } + InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); + } + } + } + result = nm != NULL ? JVMCIEnv::ok :JVMCIEnv::cache_full; + } + } + + // String creation must be done outside lock + if (failure_detail != NULL) { + // A failure to allocate the string is silently ignored. + Handle message = java_lang_String::create_from_str(failure_detail, THREAD); + HotSpotCompiledNmethod::set_installationFailureMessage(compiled_code, message()); + } + + // JVMTI -- compiled method notification (must be done outside lock) + if (nm != NULL) { + nm->post_compiled_method_load_event(); + } + + return result; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciEnv.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,171 @@ +/* + * Copyright (c) 1999, 2011, 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. + * + */ + +#ifndef SHARE_VM_JVMCI_JVMCIENV_HPP +#define SHARE_VM_JVMCI_JVMCIENV_HPP + +#include "classfile/systemDictionary.hpp" +#include "code/debugInfoRec.hpp" +#include "code/dependencies.hpp" +#include "code/exceptionHandlerTable.hpp" +#include "compiler/oopMap.hpp" +#include "runtime/thread.hpp" + +class CompileTask; + +// Bring the JVMCI compiler thread into the VM state. +#define JVMCI_VM_ENTRY_MARK \ + JavaThread* thread = JavaThread::current(); \ + ThreadInVMfromNative __tiv(thread); \ + ResetNoHandleMark rnhm; \ + HandleMarkCleaner __hm(thread); \ + Thread* THREAD = thread; \ + debug_only(VMNativeEntryWrapper __vew;) + +#define JVMCI_EXCEPTION_CONTEXT \ + JavaThread* thread=JavaThread::current(); \ + Thread* THREAD = thread; + +// +// This class is the top level broker for requests from the compiler +// to the VM. +class JVMCIEnv : StackObj { + CI_PACKAGE_ACCESS_TO + + friend class CompileBroker; + friend class Dependencies; // for get_object, during logging + +public: + + enum CodeInstallResult { + ok, + dependencies_failed, + dependencies_invalid, + cache_full, + code_too_large + }; + + // Look up a klass by name from a particular class loader (the accessor's). + // If require_local, result must be defined in that class loader, or NULL. + // If !require_local, a result from remote class loader may be reported, + // if sufficient class loader constraints exist such that initiating + // a class loading request from the given loader is bound to return + // the class defined in the remote loader (or throw an error). + // + // Return an unloaded klass if !require_local and no class at all is found. + // + // The CI treats a klass as loaded if it is consistently defined in + // another loader, even if it hasn't yet been loaded in all loaders + // that could potentially see it via delegation. + static KlassHandle get_klass_by_name(KlassHandle& accessing_klass, + Symbol* klass_name, + bool require_local); + + // Constant pool access. + static KlassHandle get_klass_by_index(constantPoolHandle& cpool, + int klass_index, + bool& is_accessible, + KlassHandle& loading_klass); + static void get_field_by_index(instanceKlassHandle& loading_klass, fieldDescriptor& fd, + int field_index); + static methodHandle get_method_by_index(constantPoolHandle& cpool, + int method_index, Bytecodes::Code bc, + instanceKlassHandle& loading_klass); + + JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter); + +private: + CompileTask* _task; + int _system_dictionary_modification_counter; + + // Cache JVMTI state + bool _jvmti_can_hotswap_or_post_breakpoint; + bool _jvmti_can_access_local_variables; + bool _jvmti_can_post_on_exceptions; + + // Implementation methods for loading and constant pool access. + static KlassHandle get_klass_by_name_impl(KlassHandle& accessing_klass, + constantPoolHandle& cpool, + Symbol* klass_name, + bool require_local); + static KlassHandle get_klass_by_index_impl(constantPoolHandle& cpool, + int klass_index, + bool& is_accessible, + KlassHandle& loading_klass); + static void get_field_by_index_impl(instanceKlassHandle& loading_klass, fieldDescriptor& fd, + int field_index); + static methodHandle get_method_by_index_impl(constantPoolHandle& cpool, + int method_index, Bytecodes::Code bc, + instanceKlassHandle& loading_klass); + + // Helper methods + static bool check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass); + static methodHandle lookup_method(instanceKlassHandle& accessor, + instanceKlassHandle& holder, + Symbol* name, + Symbol* sig, + Bytecodes::Code bc); + + private: + + // Is this thread currently in the VM state? + static bool is_in_vm(); + + // Helper routine for determining the validity of a compilation + // with respect to concurrent class loading. + static JVMCIEnv::CodeInstallResult check_for_system_dictionary_modification(Dependencies* target, Handle compiled_code, + JVMCIEnv* env, char** failure_detail); + +public: + CompileTask* task() { return _task; } + + // Register the result of a compilation. + static JVMCIEnv::CodeInstallResult register_method( + methodHandle& target, + nmethod*& nm, + int entry_bci, + CodeOffsets* offsets, + int orig_pc_offset, + CodeBuffer* code_buffer, + int frame_words, + OopMapSet* oop_map_set, + ExceptionHandlerTable* handler_table, + AbstractCompiler* compiler, + DebugInformationRecorder* debug_info, + Dependencies* dependencies, + JVMCIEnv* env, + int compile_id, + bool has_unsafe_access, + Handle installed_code, + Handle compiled_code, + Handle speculation_log); + + // converts the Klass* representing the holder of a method into a + // InstanceKlass*. This is needed since the holder of a method in + // the bytecodes could be an array type. Basically this converts + // array types into java/lang/Object and other types stay as they are. + static instanceKlassHandle get_instance_klass_for_declared_method_holder(KlassHandle& klass); +}; + +#endif // SHARE_VM_JVMCI_JVMCIENV_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciGlobals.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2000, 2010, 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. + * + */ + +#include "precompiled.hpp" +#include "jvmci/jvmciGlobals.hpp" + +JVMCI_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_NOTPRODUCT_FLAG)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciGlobals.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2000, 2012, 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. + * + */ + +#ifndef SHARE_VM_JVMCI_JVMCIGLOBALS_HPP +#define SHARE_VM_JVMCI_JVMCIGLOBALS_HPP + +#include "runtime/globals.hpp" +#ifdef TARGET_ARCH_x86 +# include "jvmciGlobals_x86.hpp" +#endif +#ifdef TARGET_ARCH_sparc +# include "jvmciGlobals_sparc.hpp" +#endif +#ifdef TARGET_ARCH_arm +# include "jvmciGlobals_arm.hpp" +#endif +#ifdef TARGET_ARCH_ppc +# include "jvmciGlobals_ppc.hpp" +#endif + +// +// Defines all global flags used by the JVMCI compiler. Only flags that need +// to be accessible to the JVMCI C++ code should be defined here. All other +// JVMCI flags should be defined in JVMCIOptions.java. +// +#define JVMCI_FLAGS(develop, develop_pd, product, product_pd, notproduct) \ + \ + product(bool, DebugJVMCI, true, \ + "Enable JVMTI for the compiler thread") \ + \ + product(bool, UseJVMCIClassLoader, true, \ + "Load JVMCI classes with separate class loader") \ + \ + COMPILERJVMCI_PRESENT(product(bool, BootstrapJVMCI, true, \ + "Bootstrap JVMCI before running Java main method")) \ + \ + COMPILERJVMCI_PRESENT(product(bool, PrintBootstrap, true, \ + "Print JVMCI bootstrap progress and summary")) \ + \ + COMPILERJVMCI_PRESENT(product(intx, JVMCIThreads, 1, \ + "Force number of JVMCI compiler threads to use")) \ + \ + COMPILERJVMCI_PRESENT(product(intx, JVMCIHostThreads, 1, \ + "Force number of compiler threads for JVMCI host compiler")) \ + \ + JVMCI_ONLY(product(bool, CodeInstallSafepointChecks, true, \ + "Perform explicit safepoint checks while installing code")) \ + \ + NOT_COMPILER2(product_pd(intx, MaxVectorSize, \ + "Max vector size in bytes, " \ + "actual size could be less depending on elements type")) \ + \ + product(intx, TraceJVMCI, 0, \ + "Trace level for JVMCI") \ + \ + product(intx, JVMCICounterSize, 0, \ + "Reserved size for benchmark counters") \ + \ + product(bool, JVMCICountersExcludeCompiler, true, \ + "Exclude JVMCI compiler threads from benchmark counters") \ + \ + product(bool, JVMCIDeferredInitBarriers, true, \ + "Defer write barriers of young objects") \ + \ + product(bool, JVMCIHProfEnabled, false, \ + "Is Heap Profiler enabled") \ + \ + product(bool, JVMCICompileWithC1Only, true, \ + "Only compile JVMCI classes with C1") \ + \ + product(bool, JVMCICompileAppFirst, false, \ + "Prioritize application compilations over JVMCI compilations") \ + \ + develop(bool, JVMCIUseFastLocking, true, \ + "Use fast inlined locking code") \ + \ + develop(bool, JVMCIUseFastNewTypeArray, true, \ + "Use fast inlined type array allocation") \ + \ + develop(bool, JVMCIUseFastNewObjectArray, true, \ + "Use fast inlined object array allocation") \ + \ + product(intx, JVMCINMethodSizeLimit, (80*K)*wordSize, \ + "Maximum size of a compiled method.") \ + \ + notproduct(bool, JVMCIPrintSimpleStubs, false, \ + "Print simple JVMCI stubs") \ + \ + develop(bool, TraceUncollectedSpeculations, false, \ + "Print message when a failed speculation was not collected") \ + + +// Read default values for JVMCI globals + +JVMCI_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_NOTPRODUCT_FLAG) + +#endif // SHARE_VM_JVMCI_JVMCIGLOBALS_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciJavaAccess.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2011, 2012 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. + */ + +#include "precompiled.hpp" +#include "jvmci/jvmciJavaAccess.hpp" +#include "runtime/jniHandles.hpp" +#include "classfile/symbolTable.hpp" +// This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field. +// It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded. + +void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field) { + InstanceKlass* ik = InstanceKlass::cast(klass); + Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name)); + Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature)); + if (name_symbol == NULL || signature_symbol == NULL) { +#ifndef PRODUCT + ik->print_on(tty); +#endif + guarantee(false, err_msg("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string())); + } + + fieldDescriptor fd; + if (!ik->find_field(name_symbol, signature_symbol, &fd)) { + ResourceMark rm; + fatal(err_msg("Invalid layout of %s at %s", name_symbol->as_C_string(), ik->external_name())); + } + guarantee(fd.is_static() == static_field, "static/instance mismatch"); + dest_offset = fd.offset(); +} + +// This piece of macro magic creates the contents of the jvmci_compute_offsets method that initializes the field indices of all the access classes. + +#define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name ""); + +#define END_CLASS } + +#define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field); +#define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false) +#define INT_FIELD(klass, name) FIELD(klass, name, "I", false) +#define BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", false) +#define LONG_FIELD(klass, name) FIELD(klass, name, "J", false) +#define FLOAT_FIELD(klass, name) FIELD(klass, name, "F", false) +#define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false) +#define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true) +#define STATIC_INT_FIELD(klass, name) FIELD(klass, name, "I", true) +#define STATIC_BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", true) + + +void jvmci_compute_offsets() { + COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, OOP_FIELD, OOP_FIELD, STATIC_OOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD) + guarantee(InstalledCode::_address_offset == sizeof(oopDesc), "codeBlob must be first field!"); +} + +#define EMPTY0 +#define EMPTY1(x) +#define EMPTY2(x,y) +#define FIELD2(klass, name) int klass::_##name##_offset = 0; +#define FIELD3(klass, name, sig) FIELD2(klass, name) + +COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2) + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciJavaAccess.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2011, 2014, 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. + */ + +#ifndef SHARE_VM_JVMCI_JVMCI_JAVA_ACCESS_HPP +#define SHARE_VM_JVMCI_JVMCI_JAVA_ACCESS_HPP + +void jvmci_compute_offsets(); + +#include "classfile/systemDictionary.hpp" +#include "oops/instanceMirrorKlass.hpp" + +/* This macro defines the structure of the CompilationResult - classes. + * It will generate classes with accessors similar to javaClasses.hpp, but with specializations for oops, Handles and jni handles. + * + * The public interface of these classes will look like this: + + * class StackSlot : AllStatic { + * public: + * static Klass* klass(); + * static jint index(oop obj); + * static jint index(Handle obj); + * static jint index(jobject obj); + * static void set_index(oop obj, jint x); + * static void set_index(Handle obj, jint x); + * static void set_index(jobject obj, jint x); + * }; + * + */ + +#define COMPILER_CLASSES_DO(start_class, end_class, char_field, int_field, boolean_field, long_field, float_field, oop_field, typeArrayOop_field, objArrayOop_field, static_oop_field, static_int_field, static_boolean_field) \ + start_class(HotSpotResolvedObjectTypeImpl) \ + oop_field(HotSpotResolvedObjectTypeImpl, javaClass, "Ljava/lang/Class;") \ + end_class \ + start_class(HotSpotResolvedJavaMethodImpl) \ + long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \ + end_class \ + start_class(InstalledCode) \ + long_field(InstalledCode, address) \ + long_field(InstalledCode, version) \ + oop_field(InstalledCode, name, "Ljava/lang/String;") \ + end_class \ + start_class(HotSpotInstalledCode) \ + int_field(HotSpotInstalledCode, size) \ + long_field(HotSpotInstalledCode, codeStart) \ + int_field(HotSpotInstalledCode, codeSize) \ + end_class \ + start_class(HotSpotNmethod) \ + boolean_field(HotSpotNmethod, isDefault) \ + end_class \ + start_class(HotSpotCompiledCode) \ + oop_field(HotSpotCompiledCode, comp, "Lcom/oracle/jvmci/code/CompilationResult;") \ + objArrayOop_field(HotSpotCompiledCode, sites, "[Lcom/oracle/jvmci/code/CompilationResult$Site;") \ + objArrayOop_field(HotSpotCompiledCode, exceptionHandlers, "[Lcom/oracle/jvmci/code/CompilationResult$ExceptionHandler;") \ + objArrayOop_field(HotSpotCompiledCode, comments, "[Lcom/oracle/jvmci/hotspot/HotSpotCompiledCode$Comment;") \ + typeArrayOop_field(HotSpotCompiledCode, dataSection, "[B") \ + int_field(HotSpotCompiledCode, dataSectionAlignment) \ + objArrayOop_field(HotSpotCompiledCode, dataSectionPatches, "[Lcom/oracle/jvmci/code/CompilationResult$DataPatch;") \ + end_class \ + start_class(HotSpotCompiledCode_Comment) \ + oop_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;") \ + int_field(HotSpotCompiledCode_Comment, pcOffset) \ + end_class \ + start_class(HotSpotCompiledNmethod) \ + oop_field(HotSpotCompiledNmethod, method, "Lcom/oracle/jvmci/hotspot/HotSpotResolvedJavaMethod;") \ + oop_field(HotSpotCompiledNmethod, installationFailureMessage, "Ljava/lang/String;") \ + int_field(HotSpotCompiledNmethod, entryBCI) \ + int_field(HotSpotCompiledNmethod, id) \ + long_field(HotSpotCompiledNmethod, jvmciEnv) \ + end_class \ + start_class(HotSpotForeignCallTarget) \ + long_field(HotSpotForeignCallTarget, address) \ + end_class \ + start_class(CompilationResult) \ + int_field(CompilationResult, totalFrameSize) \ + int_field(CompilationResult, customStackAreaOffset) \ + oop_field(CompilationResult, name, "Ljava/lang/String;") \ + typeArrayOop_field(CompilationResult, targetCode, "[B") \ + objArrayOop_field(CompilationResult, assumptions, "[Lcom/oracle/jvmci/meta/Assumptions$Assumption;") \ + objArrayOop_field(CompilationResult, methods, "[Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ + int_field(CompilationResult, targetCodeSize) \ + end_class \ + start_class(Assumptions_NoFinalizableSubclass) \ + oop_field(Assumptions_NoFinalizableSubclass, receiverType, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ + end_class \ + start_class(Assumptions_ConcreteSubtype) \ + oop_field(Assumptions_ConcreteSubtype, context, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ + oop_field(Assumptions_ConcreteSubtype, subtype, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ + end_class \ + start_class(Assumptions_LeafType) \ + oop_field(Assumptions_LeafType, context, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ + end_class \ + start_class(Assumptions_ConcreteMethod) \ + oop_field(Assumptions_ConcreteMethod, method, "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ + oop_field(Assumptions_ConcreteMethod, context, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ + oop_field(Assumptions_ConcreteMethod, impl, "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ + end_class \ + start_class(Assumptions_CallSiteTargetValue) \ + oop_field(Assumptions_CallSiteTargetValue, callSite, "Ljava/lang/invoke/CallSite;") \ + oop_field(Assumptions_CallSiteTargetValue, methodHandle, "Ljava/lang/invoke/MethodHandle;") \ + end_class \ + start_class(CompilationResult_Site) \ + int_field(CompilationResult_Site, pcOffset) \ + end_class \ + start_class(CompilationResult_Call) \ + oop_field(CompilationResult_Call, target, "Lcom/oracle/jvmci/meta/InvokeTarget;") \ + oop_field(CompilationResult_Call, debugInfo, "Lcom/oracle/jvmci/code/DebugInfo;") \ + end_class \ + start_class(CompilationResult_DataPatch) \ + oop_field(CompilationResult_DataPatch, reference, "Lcom/oracle/jvmci/code/CompilationResult$Reference;") \ + end_class \ + start_class(CompilationResult_ConstantReference) \ + oop_field(CompilationResult_ConstantReference, constant, "Lcom/oracle/jvmci/meta/VMConstant;") \ + end_class \ + start_class(CompilationResult_DataSectionReference) \ + int_field(CompilationResult_DataSectionReference, offset) \ + end_class \ + start_class(InfopointReason) \ + static_oop_field(InfopointReason, UNKNOWN, "Lcom/oracle/jvmci/code/InfopointReason;") \ + static_oop_field(InfopointReason, SAFEPOINT, "Lcom/oracle/jvmci/code/InfopointReason;") \ + static_oop_field(InfopointReason, CALL, "Lcom/oracle/jvmci/code/InfopointReason;") \ + static_oop_field(InfopointReason, IMPLICIT_EXCEPTION, "Lcom/oracle/jvmci/code/InfopointReason;") \ + static_oop_field(InfopointReason, METHOD_START, "Lcom/oracle/jvmci/code/InfopointReason;") \ + static_oop_field(InfopointReason, METHOD_END, "Lcom/oracle/jvmci/code/InfopointReason;") \ + static_oop_field(InfopointReason, LINE_NUMBER, "Lcom/oracle/jvmci/code/InfopointReason;") \ + end_class \ + start_class(CompilationResult_Infopoint) \ + oop_field(CompilationResult_Infopoint, debugInfo, "Lcom/oracle/jvmci/code/DebugInfo;") \ + oop_field(CompilationResult_Infopoint, reason, "Lcom/oracle/jvmci/code/InfopointReason;") \ + end_class \ + start_class(CompilationResult_ExceptionHandler) \ + int_field(CompilationResult_ExceptionHandler, handlerPos) \ + end_class \ + start_class(CompilationResult_Mark) \ + oop_field(CompilationResult_Mark, id, "Ljava/lang/Object;") \ + end_class \ + start_class(DebugInfo) \ + oop_field(DebugInfo, bytecodePosition, "Lcom/oracle/jvmci/code/BytecodePosition;") \ + oop_field(DebugInfo, referenceMap, "Lcom/oracle/jvmci/code/ReferenceMap;") \ + oop_field(DebugInfo, calleeSaveInfo, "Lcom/oracle/jvmci/code/RegisterSaveLayout;") \ + objArrayOop_field(DebugInfo, virtualObjectMapping, "[Lcom/oracle/jvmci/meta/Value;") \ + end_class \ + start_class(HotSpotReferenceMap) \ + oop_field(HotSpotReferenceMap, registerRefMap, "Lcom/oracle/jvmci/hotspot/HotSpotReferenceMap$HotSpotOopMap;") \ + oop_field(HotSpotReferenceMap, frameRefMap, "Lcom/oracle/jvmci/hotspot/HotSpotReferenceMap$HotSpotOopMap;") \ + end_class \ + start_class(RegisterSaveLayout) \ + objArrayOop_field(RegisterSaveLayout, registers, "[Lcom/oracle/jvmci/code/Register;") \ + typeArrayOop_field(RegisterSaveLayout, slots, "[I") \ + end_class \ + start_class(HotSpotOopMap) \ + typeArrayOop_field(HotSpotOopMap, words, "[J") \ + end_class \ + start_class(BytecodeFrame) \ + objArrayOop_field(BytecodeFrame, values, "[Lcom/oracle/jvmci/meta/Value;") \ + int_field(BytecodeFrame, numLocals) \ + int_field(BytecodeFrame, numStack) \ + int_field(BytecodeFrame, numLocks) \ + boolean_field(BytecodeFrame, rethrowException) \ + boolean_field(BytecodeFrame, duringCall) \ + static_int_field(BytecodeFrame, BEFORE_BCI) \ + end_class \ + start_class(BytecodePosition) \ + oop_field(BytecodePosition, caller, "Lcom/oracle/jvmci/code/BytecodePosition;") \ + oop_field(BytecodePosition, method, "Lcom/oracle/jvmci/meta/ResolvedJavaMethod;") \ + int_field(BytecodePosition, bci) \ + end_class \ + start_class(JavaConstant) \ + end_class \ + start_class(PrimitiveConstant) \ + long_field(PrimitiveConstant, primitive) \ + end_class \ + start_class(RawConstant) \ + long_field(RawConstant, primitive) \ + end_class \ + start_class(NullConstant) \ + end_class \ + start_class(HotSpotCompressedNullConstant) \ + end_class \ + start_class(HotSpotObjectConstantImpl) \ + oop_field(HotSpotObjectConstantImpl, object, "Ljava/lang/Object;") \ + boolean_field(HotSpotObjectConstantImpl, compressed) \ + end_class \ + start_class(HotSpotMetaspaceConstantImpl) \ + long_field(HotSpotMetaspaceConstantImpl, primitive) \ + oop_field(HotSpotMetaspaceConstantImpl, metaspaceObject, "Ljava/lang/Object;") \ + boolean_field(HotSpotMetaspaceConstantImpl, compressed) \ + end_class \ + start_class(Kind) \ + char_field(Kind, typeChar) \ + static_oop_field(Kind, Boolean, "Lcom/oracle/jvmci/meta/Kind;"); \ + static_oop_field(Kind, Byte, "Lcom/oracle/jvmci/meta/Kind;"); \ + static_oop_field(Kind, Char, "Lcom/oracle/jvmci/meta/Kind;"); \ + static_oop_field(Kind, Short, "Lcom/oracle/jvmci/meta/Kind;"); \ + static_oop_field(Kind, Int, "Lcom/oracle/jvmci/meta/Kind;"); \ + static_oop_field(Kind, Long, "Lcom/oracle/jvmci/meta/Kind;"); \ + end_class \ + start_class(LIRKind) \ + oop_field(LIRKind, platformKind, "Lcom/oracle/jvmci/meta/PlatformKind;") \ + int_field(LIRKind, referenceMask) \ + end_class \ + start_class(AbstractValue) \ + oop_field(AbstractValue, kind, "Lcom/oracle/jvmci/meta/Kind;") \ + oop_field(AbstractValue, lirKind, "Lcom/oracle/jvmci/meta/LIRKind;") \ + static_oop_field(AbstractValue, ILLEGAL, "Lcom/oracle/jvmci/meta/AllocatableValue;"); \ + end_class \ + start_class(RegisterValue) \ + oop_field(RegisterValue, reg, "Lcom/oracle/jvmci/code/Register;") \ + end_class \ + start_class(RegisterCategory) \ + oop_field(RegisterCategory, name, "Ljava/lang/String;") \ + int_field(RegisterCategory, referenceMapOffset) \ + int_field(RegisterCategory, referenceMapShift) \ + end_class \ + start_class(code_Register) \ + int_field(code_Register, number) \ + int_field(code_Register, encoding) \ + oop_field(code_Register, registerCategory, "Lcom/oracle/jvmci/code/Register$RegisterCategory;") \ + end_class \ + start_class(StackSlot) \ + int_field(StackSlot, offset) \ + boolean_field(StackSlot, addFrameSize) \ + end_class \ + start_class(VirtualObject) \ + int_field(VirtualObject, id) \ + oop_field(VirtualObject, type, "Lcom/oracle/jvmci/meta/ResolvedJavaType;") \ + objArrayOop_field(VirtualObject, values, "[Lcom/oracle/jvmci/meta/Value;") \ + end_class \ + start_class(StackLockValue) \ + oop_field(StackLockValue, owner, "Lcom/oracle/jvmci/meta/Value;") \ + oop_field(StackLockValue, slot, "Lcom/oracle/jvmci/code/StackSlotValue;") \ + boolean_field(StackLockValue, eliminated) \ + end_class \ + start_class(SpeculationLog) \ + oop_field(SpeculationLog, lastFailed, "Ljava/lang/Object;") \ + end_class \ + start_class(HotSpotStackFrameReference) \ + oop_field(HotSpotStackFrameReference, compilerToVM, "Lcom/oracle/jvmci/hotspot/CompilerToVM;") \ + long_field(HotSpotStackFrameReference, stackPointer) \ + int_field(HotSpotStackFrameReference, frameNumber) \ + int_field(HotSpotStackFrameReference, bci) \ + long_field(HotSpotStackFrameReference, metaspaceMethod) \ + objArrayOop_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;") \ + typeArrayOop_field(HotSpotStackFrameReference, localIsVirtual, "[Z") \ + end_class \ + start_class(Debug) \ + static_boolean_field(Debug, ENABLED) \ + end_class \ + /* end*/ + +#define START_CLASS(name) \ +class name : AllStatic { \ + private: \ + friend class JVMCICompiler; \ + static void check(oop obj, const char* field_name) { \ + assert(obj != NULL, err_msg("NULL field access of %s.%s", #name, field_name)); \ + assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected"); \ + } \ + static void compute_offsets(); \ + public: \ + static Klass* klass() { return SystemDictionary::name##_klass(); } + +#define END_CLASS }; + +#define FIELD(name, type, accessor, cast) \ + static int _##name##_offset; \ + static type name(oop obj) { check(obj, #name); return cast obj->accessor(_##name##_offset); } \ + static type name(Handle& obj) { check(obj(), #name); return cast obj->accessor(_##name##_offset); } \ + static type name(jobject obj) { check(JNIHandles::resolve(obj), #name); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ + static void set_##name(oop obj, type x) { check(obj, #name); obj->accessor##_put(_##name##_offset, x); } \ + static void set_##name(Handle& obj, type x) { check(obj(), #name); obj->accessor##_put(_##name##_offset, x); } \ + static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } + +#define EMPTY_CAST +#define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field, EMPTY_CAST) +#define INT_FIELD(klass, name) FIELD(name, jint, int_field, EMPTY_CAST) +#define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field, EMPTY_CAST) +#define LONG_FIELD(klass, name) FIELD(name, jlong, long_field, EMPTY_CAST) +#define FLOAT_FIELD(klass, name) FIELD(name, jfloat, float_field, EMPTY_CAST) +#define OOP_FIELD(klass, name, signature) FIELD(name, oop, obj_field, EMPTY_CAST) +#define OBJARRAYOOP_FIELD(klass, name, signature) FIELD(name, objArrayOop, obj_field, (objArrayOop)) +#define TYPEARRAYOOP_FIELD(klass, name, signature) FIELD(name, typeArrayOop, obj_field, (typeArrayOop)) +#define STATIC_OOP_FIELD(klassName, name, signature) \ + static int _##name##_offset; \ + static oop name() { \ + InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ + address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ + if (UseCompressedOops) { \ + return oopDesc::load_decode_heap_oop((narrowOop *)addr); \ + } else { \ + return oopDesc::load_decode_heap_oop((oop*)addr); \ + } \ + } \ + static void set_##name(oop x) { \ + InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ + address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ + if (UseCompressedOops) { \ + oop_store((narrowOop *)addr, x); \ + } else { \ + oop_store((oop*)addr, x); \ + } \ + } +#define STATIC_PRIMITIVE_FIELD(klassName, name, jtypename) \ + static int _##name##_offset; \ + static jtypename name() { \ + InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ + address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ + return *((jtypename *)addr); \ + } \ + static void set_##name(jtypename x) { \ + InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ + address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ + *((jtypename *)addr) = x; \ + } + +#define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint) +#define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean) + +COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, TYPEARRAYOOP_FIELD, OBJARRAYOOP_FIELD, STATIC_OOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD) +#undef START_CLASS +#undef END_CLASS +#undef FIELD +#undef CHAR_FIELD +#undef INT_FIELD +#undef BOOLEAN_FIELD +#undef LONG_FIELD +#undef FLOAT_FIELD +#undef OOP_FIELD +#undef TYPEARRAYOOP_FIELD +#undef OBJARRAYOOP_FIELD +#undef STATIC_OOP_FIELD +#undef STATIC_INT_FIELD +#undef STATIC_BOOLEAN_FIELD +#undef EMPTY_CAST + +void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field); + +#endif // SHARE_VM_JVMCI_JVMCI_JAVA_ACCESS_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciRuntime.cpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,1165 @@ +/* + * Copyright (c) 2012, 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. + */ + +#include "precompiled.hpp" +#include "asm/codeBuffer.hpp" +#include "compiler/compileBroker.hpp" +#include "compiler/disassembler.hpp" +#include "jvmci/jvmciRuntime.hpp" +#include "jvmci/jvmciCompilerToVM.hpp" +#include "jvmci/jvmciCompiler.hpp" +#include "jvmci/jvmciJavaAccess.hpp" +#include "jvmci/jvmciEnv.hpp" +#include "memory/oopFactory.hpp" +#include "prims/jvm.h" +#include "runtime/biasedLocking.hpp" +#include "runtime/interfaceSupport.hpp" +#include "runtime/arguments.hpp" +#include "runtime/reflection.hpp" +#include "utilities/debug.hpp" + + jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL; +bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false; +bool JVMCIRuntime::_shutdown_called = false; + +void JVMCIRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) { + uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); + uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; + AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)")); + NOT_LP64(error("check TLAB allocation code for address space conflicts")); + + ensure_jvmci_class_loader_is_initialized(); + + JavaThread* THREAD = JavaThread::current(); + { + ThreadToNativeFromVM trans(THREAD); + + ResourceMark rm; + HandleMark hm; + + jvmci_compute_offsets(); + + // Ensure _non_oop_bits is initialized + Universe::non_oop_word(); + + env->RegisterNatives(c2vmClass, CompilerToVM_methods, CompilerToVM_methods_count()); + } + if (HAS_PENDING_EXCEPTION) { + abort_on_pending_exception(PENDING_EXCEPTION, "Could not register natives"); + } +} + +BufferBlob* JVMCIRuntime::initialize_buffer_blob() { + JavaThread* THREAD = JavaThread::current(); + BufferBlob* buffer_blob = THREAD->get_buffer_blob(); + if (buffer_blob == NULL) { + buffer_blob = BufferBlob::create("JVMCI thread-local CodeBuffer", JVMCINMethodSizeLimit); + if (buffer_blob != NULL) { + THREAD->set_buffer_blob(buffer_blob); + } + } + return buffer_blob; +} + +BasicType JVMCIRuntime::kindToBasicType(jchar ch) { + switch(ch) { + case 'z': return T_BOOLEAN; + case 'b': return T_BYTE; + case 's': return T_SHORT; + case 'c': return T_CHAR; + case 'i': return T_INT; + case 'f': return T_FLOAT; + case 'j': return T_LONG; + case 'd': return T_DOUBLE; + case 'a': return T_OBJECT; + case '-': return T_ILLEGAL; + default: + fatal(err_msg("unexpected Kind: %c", ch)); + break; + } + return T_ILLEGAL; +} + +// Simple helper to see if the caller of a runtime stub which +// entered the VM has been deoptimized + +static bool caller_is_deopted() { + JavaThread* thread = JavaThread::current(); + RegisterMap reg_map(thread, false); + frame runtime_frame = thread->last_frame(); + frame caller_frame = runtime_frame.sender(®_map); + assert(caller_frame.is_compiled_frame(), "must be compiled"); + return caller_frame.is_deoptimized_frame(); +} + +// Stress deoptimization +static void deopt_caller() { + if ( !caller_is_deopted()) { + JavaThread* thread = JavaThread::current(); + RegisterMap reg_map(thread, false); + frame runtime_frame = thread->last_frame(); + frame caller_frame = runtime_frame.sender(®_map); + Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); + assert(caller_is_deopted(), "Must be deoptimized"); + } +} + +JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass)) + JRT_BLOCK; + assert(klass->is_klass(), "not a class"); + instanceKlassHandle h(thread, klass); + h->check_valid_for_instantiation(true, CHECK); + // make sure klass is initialized + h->initialize(CHECK); + // allocate instance and return via TLS + oop obj = h->allocate_instance(CHECK); + thread->set_vm_result(obj); + JRT_BLOCK_END; + + if (JVMCIDeferredInitBarriers) { + new_store_pre_barrier(thread); + } +JRT_END + +JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) + JRT_BLOCK; + // Note: no handle for klass needed since they are not used + // anymore after new_objArray() and no GC can happen before. + // (This may have to change if this code changes!) + assert(array_klass->is_klass(), "not a class"); + oop obj; + if (array_klass->oop_is_typeArray()) { + BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); + obj = oopFactory::new_typeArray(elt_type, length, CHECK); + } else { + Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); + obj = oopFactory::new_objArray(elem_klass, length, CHECK); + } + thread->set_vm_result(obj); + // This is pretty rare but this runtime patch is stressful to deoptimization + // if we deoptimize here so force a deopt to stress the path. + if (DeoptimizeALot) { + static int deopts = 0; + // Alternate between deoptimizing and raising an error (which will also cause a deopt) + if (deopts++ % 2 == 0) { + ResourceMark rm(THREAD); + THROW(vmSymbols::java_lang_OutOfMemoryError()); + } else { + deopt_caller(); + } + } + JRT_BLOCK_END; + + if (JVMCIDeferredInitBarriers) { + new_store_pre_barrier(thread); + } +JRT_END + +void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) { + // After any safepoint, just before going back to compiled code, + // we inform the GC that we will be doing initializing writes to + // this object in the future without emitting card-marks, so + // GC may take any compensating steps. + // NOTE: Keep this code consistent with GraphKit::store_barrier. + + oop new_obj = thread->vm_result(); + if (new_obj == NULL) return; + + assert(Universe::heap()->can_elide_tlab_store_barriers(), + "compiler must check this first"); + // GC may decide to give back a safer copy of new_obj. + new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj); + thread->set_vm_result(new_obj); +} + +JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) + assert(klass->is_klass(), "not a class"); + assert(rank >= 1, "rank must be nonzero"); + oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); + thread->set_vm_result(obj); +JRT_END + +JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length)) + oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); + thread->set_vm_result(obj); +JRT_END + +JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) + instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror)); + + if (klass == NULL) { + ResourceMark rm(THREAD); + THROW(vmSymbols::java_lang_InstantiationException()); + } + + // Create new instance (the receiver) + klass->check_valid_for_instantiation(false, CHECK); + + // Make sure klass gets initialized + klass->initialize(CHECK); + + oop obj = klass->allocate_instance(CHECK); + thread->set_vm_result(obj); +JRT_END + +extern void vm_exit(int code); + +// Enter this method from compiled code handler below. This is where we transition +// to VM mode. This is done as a helper routine so that the method called directly +// from compiled code does not have to transition to VM. This allows the entry +// method to see if the nmethod that we have just looked up a handler for has +// been deoptimized while we were in the vm. This simplifies the assembly code +// cpu directories. +// +// We are entering here from exception stub (via the entry method below) +// If there is a compiled exception handler in this method, we will continue there; +// otherwise we will unwind the stack and continue at the caller of top frame method +// Note: we enter in Java using a special JRT wrapper. This wrapper allows us to +// control the area where we can allow a safepoint. After we exit the safepoint area we can +// check to see if the handler we are going to return is now in a nmethod that has +// been deoptimized. If that is the case we return the deopt blob +// unpack_with_exception entry instead. This makes life for the exception blob easier +// because making that same check and diverting is painful from assembly language. +JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) + // Reset method handle flag. + thread->set_is_method_handle_return(false); + + Handle exception(thread, ex); + nm = CodeCache::find_nmethod(pc); + assert(nm != NULL, "this is not an nmethod"); + // Adjust the pc as needed/ + if (nm->is_deopt_pc(pc)) { + RegisterMap map(thread, false); + frame exception_frame = thread->last_frame().sender(&map); + // if the frame isn't deopted then pc must not correspond to the caller of last_frame + assert(exception_frame.is_deoptimized_frame(), "must be deopted"); + pc = exception_frame.pc(); + } +#ifdef ASSERT + assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); + assert(exception->is_oop(), "just checking"); + // Check that exception is a subclass of Throwable, otherwise we have a VerifyError + if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { + if (ExitVMOnVerifyError) vm_exit(-1); + ShouldNotReachHere(); + } +#endif + + // Check the stack guard pages and reenable them if necessary and there is + // enough space on the stack to do so. Use fast exceptions only if the guard + // pages are enabled. + bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); + if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); + + if (JvmtiExport::can_post_on_exceptions()) { + // To ensure correct notification of exception catches and throws + // we have to deoptimize here. If we attempted to notify the + // catches and throws during this exception lookup it's possible + // we could deoptimize on the way out of the VM and end back in + // the interpreter at the throw site. This would result in double + // notifications since the interpreter would also notify about + // these same catches and throws as it unwound the frame. + + RegisterMap reg_map(thread); + frame stub_frame = thread->last_frame(); + frame caller_frame = stub_frame.sender(®_map); + + // We don't really want to deoptimize the nmethod itself since we + // can actually continue in the exception handler ourselves but I + // don't see an easy way to have the desired effect. + Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); + assert(caller_is_deopted(), "Must be deoptimized"); + + return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); + } + + // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions + if (guard_pages_enabled) { + address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); + if (fast_continuation != NULL) { + // Set flag if return address is a method handle call site. + thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); + return fast_continuation; + } + } + + // If the stack guard pages are enabled, check whether there is a handler in + // the current method. Otherwise (guard pages disabled), force an unwind and + // skip the exception cache update (i.e., just leave continuation==NULL). + address continuation = NULL; + if (guard_pages_enabled) { + + // New exception handling mechanism can support inlined methods + // with exception handlers since the mappings are from PC to PC + + // debugging support + // tracing + if (TraceExceptions) { + ttyLocker ttyl; + ResourceMark rm; + tty->print_cr("Exception <%s> (" INTPTR_FORMAT ") thrown in compiled method <%s> at PC " INTPTR_FORMAT " for thread " INTPTR_FORMAT "", + exception->print_value_string(), p2i((address)exception()), nm->method()->print_value_string(), p2i(pc), p2i(thread)); + } + // for AbortVMOnException flag + NOT_PRODUCT(Exceptions::debug_check_abort(exception)); + + // Clear out the exception oop and pc since looking up an + // exception handler can cause class loading, which might throw an + // exception and those fields are expected to be clear during + // normal bytecode execution. + thread->clear_exception_oop_and_pc(); + + continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); + // If an exception was thrown during exception dispatch, the exception oop may have changed + thread->set_exception_oop(exception()); + thread->set_exception_pc(pc); + + // the exception cache is used only by non-implicit exceptions + if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { + nm->add_handler_for_exception_and_pc(exception, pc, continuation); + } + } + + // Set flag if return address is a method handle call site. + thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); + + if (TraceExceptions) { + ttyLocker ttyl; + ResourceMark rm; + tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT, + p2i(thread), p2i(continuation), p2i(pc)); + } + + return continuation; +JRT_END + +// Enter this method from compiled code only if there is a Java exception handler +// in the method handling the exception. +// We are entering here from exception stub. We don't do a normal VM transition here. +// We do it in a helper. This is so we can check to see if the nmethod we have just +// searched for an exception handler has been deoptimized in the meantime. +address JVMCIRuntime::exception_handler_for_pc(JavaThread* thread) { + oop exception = thread->exception_oop(); + address pc = thread->exception_pc(); + // Still in Java mode + DEBUG_ONLY(ResetNoHandleMark rnhm); + nmethod* nm = NULL; + address continuation = NULL; + { + // Enter VM mode by calling the helper + ResetNoHandleMark rnhm; + continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); + } + // Back in JAVA, use no oops DON'T safepoint + + // Now check to see if the nmethod we were called from is now deoptimized. + // If so we must return to the deopt blob and deoptimize the nmethod + if (nm != NULL && caller_is_deopted()) { + continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); + } + + assert(continuation != NULL, "no handler found"); + return continuation; +} + +JRT_ENTRY(void, JVMCIRuntime::create_null_exception(JavaThread* thread)) + SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException()); + thread->set_vm_result(PENDING_EXCEPTION); + CLEAR_PENDING_EXCEPTION; +JRT_END + +JRT_ENTRY(void, JVMCIRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index)) + char message[jintAsStringSize]; + sprintf(message, "%d", index); + SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message); + thread->set_vm_result(PENDING_EXCEPTION); + CLEAR_PENDING_EXCEPTION; +JRT_END + +JRT_ENTRY_NO_ASYNC(void, JVMCIRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) + if (TraceJVMCI >= 3) { + char type[O_BUFLEN]; + obj->klass()->name()->as_C_string(type, O_BUFLEN); + markOop mark = obj->mark(); + tty->print_cr("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(mark), p2i(lock)); + tty->flush(); + } +#ifdef ASSERT + if (PrintBiasedLockingStatistics) { + Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); + } +#endif + Handle h_obj(thread, obj); + assert(h_obj()->is_oop(), "must be NULL or an object"); + if (UseBiasedLocking) { + // Retry fast entry if bias is revoked to avoid unnecessary inflation + ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK); + } else { + if (JVMCIUseFastLocking) { + // When using fast locking, the compiled code has already tried the fast case + ObjectSynchronizer::slow_enter(h_obj, lock, THREAD); + } else { + ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD); + } + } + if (TraceJVMCI >= 3) { + tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj)); + } +JRT_END + +JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) + assert(thread == JavaThread::current(), "threads must correspond"); + assert(thread->last_Java_sp(), "last_Java_sp must be set"); + // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown + EXCEPTION_MARK; + +#ifdef DEBUG + if (!obj->is_oop()) { + ResetNoHandleMark rhm; + nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); + if (method != NULL) { + tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), p2i(obj)); + } + thread->print_stack_on(tty); + assert(false, "invalid lock object pointer dected"); + } +#endif + + if (JVMCIUseFastLocking) { + // When using fast locking, the compiled code has already tried the fast case + ObjectSynchronizer::slow_exit(obj, lock, THREAD); + } else { + ObjectSynchronizer::fast_exit(obj, lock, THREAD); + } + if (TraceJVMCI >= 3) { + char type[O_BUFLEN]; + obj->klass()->name()->as_C_string(type, O_BUFLEN); + tty->print_cr("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock)); + tty->flush(); + } +JRT_END + +JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, jint flags)) + bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); + bool addr = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); + bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE); + if (!string) { + if (!addr && obj->is_oop_or_null(true)) { + char buf[O_BUFLEN]; + tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj)); + } else { + tty->print(INTPTR_FORMAT, p2i(obj)); + } + } else { + ResourceMark rm; + assert(obj != NULL && java_lang_String::is_instance(obj), "must be"); + char *buf = java_lang_String::as_utf8_string(obj); + tty->print_raw(buf); + } + if (newline) { + tty->cr(); + } +JRT_END + +JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj)) + thread->satb_mark_queue().enqueue(obj); +JRT_END + +JRT_LEAF(void, JVMCIRuntime::write_barrier_post(JavaThread* thread, void* card_addr)) + thread->dirty_card_queue().enqueue(card_addr); +JRT_END + +JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child)) + bool ret = true; + if(!Universe::heap()->is_in_closed_subset(parent)) { + tty->print_cr("Parent Object "INTPTR_FORMAT" not in heap", p2i(parent)); + parent->print(); + ret=false; + } + if(!Universe::heap()->is_in_closed_subset(child)) { + tty->print_cr("Child Object "INTPTR_FORMAT" not in heap", p2i(child)); + child->print(); + ret=false; + } + return (jint)ret; +JRT_END + +JRT_ENTRY(void, JVMCIRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value)) + ResourceMark rm; + const char *error_msg = where == 0L ? "<internal JVMCI error>" : (char*) (address) where; + char *detail_msg = NULL; + if (format != 0L) { + const char* buf = (char*) (address) format; + size_t detail_msg_length = strlen(buf) * 2; + detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); + jio_snprintf(detail_msg, detail_msg_length, buf, value); + } + report_vm_error(__FILE__, __LINE__, error_msg, detail_msg); +JRT_END + +JRT_LEAF(oopDesc*, JVMCIRuntime::load_and_clear_exception(JavaThread* thread)) + oop exception = thread->exception_oop(); + assert(exception != NULL, "npe"); + thread->set_exception_oop(NULL); + thread->set_exception_pc(0); + return exception; +JRT_END + +JRT_LEAF(void, JVMCIRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3)) + ResourceMark rm; + assert(format != NULL && java_lang_String::is_instance(format), "must be"); + char *buf = java_lang_String::as_utf8_string(format); + tty->print(buf, v1, v2, v3); +JRT_END + +static void decipher(jlong v, bool ignoreZero) { + if (v != 0 || !ignoreZero) { + void* p = (void *)(address) v; + CodeBlob* cb = CodeCache::find_blob(p); + if (cb) { + if (cb->is_nmethod()) { + char buf[O_BUFLEN]; + tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin())); + return; + } + cb->print_value_on(tty); + return; + } + if (Universe::heap()->is_in(p)) { + oop obj = oop(p); + obj->print_value_on(tty); + return; + } + tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v); + } +} + +JRT_LEAF(void, JVMCIRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) + ResourceMark rm; + char *buf = (char*) (address) format; + if (vmError) { + if (buf != NULL) { + fatal(err_msg(buf, v1, v2, v3)); + } else { + fatal("<anonymous error>"); + } + } else if (buf != NULL) { + tty->print(buf, v1, v2, v3); + } else { + assert(v2 == 0, "v2 != 0"); + assert(v3 == 0, "v3 != 0"); + decipher(v1, false); + } +JRT_END + +JRT_LEAF(void, JVMCIRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) + union { + jlong l; + jdouble d; + jfloat f; + } uu; + uu.l = value; + switch (typeChar) { + case 'z': tty->print(value == 0 ? "false" : "true"); break; + case 'b': tty->print("%d", (jbyte) value); break; + case 'c': tty->print("%c", (jchar) value); break; + case 's': tty->print("%d", (jshort) value); break; + case 'i': tty->print("%d", (jint) value); break; + case 'f': tty->print("%f", uu.f); break; + case 'j': tty->print(JLONG_FORMAT, value); break; + case 'd': tty->print("%lf", uu.d); break; + default: assert(false, "unknown typeChar"); break; + } + if (newline) { + tty->cr(); + } +JRT_END + +JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj)) + return (jint) obj->identity_hash(); +JRT_END + +JRT_ENTRY(jboolean, JVMCIRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted)) + // Ensure that the C++ Thread and OSThread structures aren't freed before we operate. + // This locking requires thread_in_vm which is why this method cannot be JRT_LEAF. + Handle receiverHandle(thread, receiver); + MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock); + JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle()); + if (receiverThread == NULL) { + // The other thread may exit during this process, which is ok so return false. + return JNI_FALSE; + } else { + return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0); + } +JRT_END + +JRT_ENTRY(jint, JVMCIRuntime::test_deoptimize_call_int(JavaThread* thread, int value)) + deopt_caller(); + return value; +JRT_END + +// private static void Factory.init() +JVM_ENTRY(void, JVM_InitJVMCIClassLoader(JNIEnv *env, jclass c, jobject loader_handle)) + SystemDictionary::init_jvmci_loader(JNIHandles::resolve(loader_handle)); + SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID; + SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK); +JVM_END + +// private static JVMCIRuntime JVMCI.initializeRuntime() +JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c)) + JVMCIRuntime::initialize_HotSpotJVMCIRuntime(); + return JVMCIRuntime::get_HotSpotJVMCIRuntime_jobject(); +JVM_END + +// private static String[] Services.getServiceImpls(Class service) +JVM_ENTRY(jobject, JVM_GetJVMCIServiceImpls(JNIEnv *env, jclass c, jclass serviceClass)) + HandleMark hm; + ResourceMark rm; + KlassHandle serviceKlass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(serviceClass))); + return JNIHandles::make_local(THREAD, JVMCIRuntime::get_service_impls(serviceKlass, THREAD)()); +JVM_END + +// private static TruffleRuntime Truffle.createRuntime() +JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c)) + JVMCIRuntime::ensure_jvmci_class_loader_is_initialized(); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", CHECK_NULL); + KlassHandle klass = JVMCIRuntime::resolve_or_fail(name, CHECK_NULL); + + TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", CHECK_NULL); + TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/truffle/api/TruffleRuntime;", CHECK_NULL); + JavaValue result(T_OBJECT); + JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL); + return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); +JVM_END + +// private static NativeFunctionInterfaceRuntime.createInterface() +JVM_ENTRY(jobject, JVM_CreateNativeFunctionInterface(JNIEnv *env, jclass c)) + JVMCIRuntime::ensure_jvmci_class_loader_is_initialized(); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", CHECK_NULL); + KlassHandle klass = JVMCIRuntime::resolve_or_fail(name, CHECK_NULL); + + TempNewSymbol makeInstance = SymbolTable::new_symbol("createNativeFunctionInterface", CHECK_NULL); + TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/nfi/api/NativeFunctionInterface;", CHECK_NULL); + JavaValue result(T_OBJECT); + JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL); + return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); +JVM_END + +void JVMCIRuntime::check_generated_sources_sha1(TRAPS) { + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/sourcegen/GeneratedSourcesSha1", CHECK_ABORT); + KlassHandle klass = load_required_class(name); + fieldDescriptor fd; + if (!InstanceKlass::cast(klass())->find_field(vmSymbols::value_name(), vmSymbols::string_signature(), true, &fd)) { + THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), "GeneratedSourcesSha1.value"); + } + + Symbol* value = java_lang_String::as_symbol(klass->java_mirror()->obj_field(fd.offset()), CHECK); + if (!value->equals(_generated_sources_sha1)) { + char buf[200]; + jio_snprintf(buf, sizeof(buf), "Generated sources SHA1 check failed (%s != %s) - need to rebuild the VM", value->as_C_string(), _generated_sources_sha1); + THROW_MSG(vmSymbols::java_lang_InternalError(), buf); + } +} + +Handle JVMCIRuntime::callInitializer(const char* className, const char* methodName, const char* returnType) { + guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); + Thread* THREAD = Thread::current(); + check_generated_sources_sha1(CHECK_ABORT_(Handle())); + + TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_ABORT_(Handle())); + KlassHandle klass = load_required_class(name); + TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_ABORT_(Handle())); + TempNewSymbol sig = SymbolTable::new_symbol(returnType, CHECK_ABORT_(Handle())); + JavaValue result(T_OBJECT); + JavaCalls::call_static(&result, klass, runtime, sig, CHECK_ABORT_(Handle())); + return Handle((oop)result.get_jobject()); +} + +void JVMCIRuntime::initialize_HotSpotJVMCIRuntime() { + if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { +#ifdef ASSERT + // This should only be called in the context of the JVMCI class being initialized + Thread* THREAD = Thread::current(); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/runtime/JVMCI", CHECK_ABORT); + instanceKlassHandle klass = InstanceKlass::cast(load_required_class(name)); + assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD), + "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); +#endif + + Handle result = callInitializer("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", "runtime", + "()Lcom/oracle/jvmci/hotspot/HotSpotJVMCIRuntime;"); + _HotSpotJVMCIRuntime_initialized = true; + _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); + } +} + +void JVMCIRuntime::initialize_JVMCI() { + if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { + callInitializer("com/oracle/jvmci/runtime/JVMCI", "getRuntime", "()Lcom/oracle/jvmci/runtime/JVMCIRuntime;"); + } + assert(_HotSpotJVMCIRuntime_initialized == true, "what?"); +} + +// private static void CompilerToVMImpl.init() +JVM_ENTRY(void, JVM_InitializeJVMCINatives(JNIEnv *env, jclass c2vmClass)) + JVMCIRuntime::initialize_natives(env, c2vmClass); +JVM_END + +// private static OptionsParsed[] HotSpotOptions.parseVMOptions(Class) +JVM_ENTRY(jobject, JVM_ParseJVMCIOptions(JNIEnv *env, jclass c, jobject optionsParsedClass_obj)) + HandleMark hm; + KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c))); + JVMCIRuntime::parse_arguments(hotSpotOptionsClass, CHECK_NULL); + KlassHandle optionsParsedClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(optionsParsedClass_obj))); + return JNIHandles::make_local(THREAD, JVMCIRuntime::get_service_impls(optionsParsedClass, THREAD)()); +JVM_END + + +void JVMCIRuntime::ensure_jvmci_class_loader_is_initialized() { + // This initialization code is guarded by a static pointer to the Factory class. + // Once it is non-null, the JVMCI class loader and well known JVMCI classes are + // guaranteed to have been initialized. By going through the static + // initializer of Factory, we can rely on class initialization semantics to + // synchronize threads racing to do the initialization. + static Klass* _FactoryKlass = NULL; + if (_FactoryKlass == NULL) { + Thread* THREAD = Thread::current(); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/loader/Factory", CHECK_ABORT); + KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, THREAD); + if (HAS_PENDING_EXCEPTION) { + static volatile int seen_error = 0; + if (!seen_error && Atomic::cmpxchg(1, &seen_error, 0) == 0) { + // Only report the failure on the first thread that hits it + abort_on_pending_exception(PENDING_EXCEPTION, "JVMCI classes are not available"); + } else { + CLEAR_PENDING_EXCEPTION; + // Give first thread time to report the error. + os::sleep(THREAD, 100, false); + vm_abort(false); + } + } + + // We cannot use jvmciJavaAccess for this because we are currently in the + // process of initializing that mechanism. + TempNewSymbol field_name = SymbolTable::new_symbol("useJVMCIClassLoader", CHECK_ABORT); + fieldDescriptor field_desc; + if (klass->find_field(field_name, vmSymbols::bool_signature(), &field_desc) == NULL) { + ResourceMark rm; + fatal(err_msg("Invalid layout of %s at %s", field_name->as_C_string(), klass->external_name())); + } + + InstanceKlass* ik = InstanceKlass::cast(klass()); + address addr = ik->static_field_addr(field_desc.offset() - InstanceMirrorKlass::offset_of_static_fields()); + *((jboolean *) addr) = (jboolean) UseJVMCIClassLoader; + klass->initialize(CHECK_ABORT); + _FactoryKlass = klass(); + } +} + +jint JVMCIRuntime::check_arguments(TRAPS) { + KlassHandle nullHandle; + parse_arguments(nullHandle, THREAD); + if (HAS_PENDING_EXCEPTION) { + // Errors in parsing JVMCI arguments cause exceptions. + // We now load and initialize HotSpotOptions which in turn + // causes argument parsing to be redone with better error messages. + CLEAR_PENDING_EXCEPTION; + TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/jvmci/hotspot/HotSpotOptions;", CHECK_ABORT_(JNI_ERR)); + instanceKlassHandle hotSpotOptionsClass = resolve_or_fail(name, CHECK_ABORT_(JNI_ERR)); + + parse_arguments(hotSpotOptionsClass, THREAD); + assert(HAS_PENDING_EXCEPTION, "must be"); + + ResourceMark rm; + Handle exception = PENDING_EXCEPTION; + CLEAR_PENDING_EXCEPTION; + oop message = java_lang_Throwable::message(exception); + if (message != NULL) { + tty->print_cr("Error parsing JVMCI options: %s", java_lang_String::as_utf8_string(message)); + } else { + call_printStackTrace(exception, THREAD); + } + return JNI_ERR; + } + return JNI_OK; +} + +void JVMCIRuntime::parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS) { + ResourceMark rm(THREAD); + + // Process option overrides from jvmci.options first + parse_jvmci_options_file(hotSpotOptionsClass, CHECK); + + // Now process options on the command line + int numOptions = Arguments::num_jvmci_args(); + for (int i = 0; i < numOptions; i++) { + char* arg = Arguments::jvmci_args_array()[i]; + parse_argument(hotSpotOptionsClass, arg, CHECK); + } +} + +void JVMCIRuntime::check_required_value(const char* name, size_t name_len, const char* value, TRAPS) { + if (value == NULL) { + char buf[200]; + jio_snprintf(buf, sizeof(buf), "Must use '-G:%.*s=<value>' format for %.*s option", name_len, name, name_len, name); + THROW_MSG(vmSymbols::java_lang_InternalError(), buf); + } +} + +void JVMCIRuntime::parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS) { + ensure_jvmci_class_loader_is_initialized(); + char first = arg[0]; + char* name; + size_t name_len; + bool recognized = true; + if (first == '+' || first == '-') { + name = arg + 1; + name_len = strlen(name); + recognized = set_option_bool(hotSpotOptionsClass, name, name_len, first, CHECK); + } else { + char* sep = strchr(arg, '='); + name = arg; + char* value = NULL; + if (sep != NULL) { + name_len = sep - name; + value = sep + 1; + } else { + name_len = strlen(name); + } + recognized = set_option(hotSpotOptionsClass, name, name_len, value, CHECK); + } + + if (!recognized) { + bool throw_err = hotSpotOptionsClass.is_null(); + if (!hotSpotOptionsClass.is_null()) { + set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), ' ', Handle(), 0L); + if (!HAS_PENDING_EXCEPTION) { + throw_err = true; + } + } + + if (throw_err) { + char buf[200]; + jio_snprintf(buf, sizeof(buf), "Unrecognized JVMCI option %.*s", name_len, name); + THROW_MSG(vmSymbols::java_lang_InternalError(), buf); + } + } +} + +void JVMCIRuntime::parse_jvmci_options_file(KlassHandle hotSpotOptionsClass, TRAPS) { + const char* home = Arguments::get_java_home(); + size_t path_len = strlen(home) + strlen("/lib/jvmci.options") + 1; + char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); + char sep = os::file_separator()[0]; + sprintf(path, "%s%clib%cjvmci.options", home, sep, sep); + + struct stat st; + if (os::stat(path, &st) == 0) { + int file_handle = os::open(path, 0, 0); + if (file_handle != -1) { + char* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, st.st_size); + int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); + if (num_read == -1) { + warning("Error reading file %s due to %s", path, strerror(errno)); + } else if (num_read != st.st_size) { + warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path); + } + os::close(file_handle); + if (num_read == st.st_size) { + char* line = buffer; + int lineNo = 1; + while (line - buffer < num_read) { + char* nl = strchr(line, '\n'); + if (nl != NULL) { + *nl = '\0'; + } + parse_argument(hotSpotOptionsClass, line, THREAD); + if (HAS_PENDING_EXCEPTION) { + warning("Error in %s:%d", path, lineNo); + return; + } + if (nl != NULL) { + line = nl + 1; + lineNo++; + } else { + // File without newline at the end + break; + } + } + } + } else { + warning("Error opening file %s due to %s", path, strerror(errno)); + } + } +} + +jlong JVMCIRuntime::parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS) { + check_required_value(name, name_len, value, CHECK_(0L)); + union { + jint i; + jlong l; + double d; + } uu; + uu.l = 0L; + char dummy; + switch (spec) { + case 'd': + case 'f': { + if (sscanf(value, "%lf%c", &uu.d, &dummy) == 1) { + return uu.l; + } + break; + } + case 'i': { + if (sscanf(value, "%d%c", &uu.i, &dummy) == 1) { + return (jlong)uu.i; + } + break; + } + default: + ShouldNotReachHere(); + } + ResourceMark rm(THREAD); + char buf[200]; + bool missing = strlen(value) == 0; + if (missing) { + jio_snprintf(buf, sizeof(buf), "Missing %s value for JVMCI option %.*s", (spec == 'i' ? "numeric" : "float/double"), name_len, name); + } else { + jio_snprintf(buf, sizeof(buf), "Invalid %s value for JVMCI option %.*s: %s", (spec == 'i' ? "numeric" : "float/double"), name_len, name, value); + } + THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L); +} + +void JVMCIRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) { + Thread* THREAD = Thread::current(); + Handle name_handle; + if (name != NULL) { + if (strlen(name) > name_len) { + // Temporarily replace '=' with NULL to create the Java string for the option name + char save = name[name_len]; + name[name_len] = '\0'; + name_handle = java_lang_String::create_from_str(name, THREAD); + name[name_len] = '='; + if (HAS_PENDING_EXCEPTION) { + return; + } + } else { + assert(strlen(name) == name_len, "must be"); + name_handle = java_lang_String::create_from_str(name, CHECK); + } + } + + TempNewSymbol setOption = SymbolTable::new_symbol("setOption", CHECK); + TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/jvmci/options/OptionValue;CLjava/lang/String;J)V", CHECK); + JavaValue result(T_VOID); + JavaCallArguments args; + args.push_oop(name_handle()); + args.push_oop(option()); + args.push_int(spec); + args.push_oop(stringValue()); + args.push_long(primitiveValue); + JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK); +} + +Handle JVMCIRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) { + TempNewSymbol name = SymbolTable::new_symbol(declaringClass, CHECK_NH); + Klass* klass = resolve_or_fail(name, CHECK_NH); + + // The class has been loaded so the field and signature should already be in the symbol + // table. If they're not there, the field doesn't exist. + TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName)); + TempNewSymbol signame = SymbolTable::probe(fieldSig, (int)strlen(fieldSig)); + if (fieldname == NULL || signame == NULL) { + THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle()); + } + // Make sure class is initialized before handing id's out to fields + klass->initialize(CHECK_NH); + + fieldDescriptor fd; + if (!InstanceKlass::cast(klass)->find_field(fieldname, signame, true, &fd)) { + THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle()); + } + + Handle ret = klass->java_mirror()->obj_field(fd.offset()); + return ret; +} + +Handle JVMCIRuntime::create_Service(const char* name, TRAPS) { + TempNewSymbol kname = SymbolTable::new_symbol(name, CHECK_NH); + Klass* k = resolve_or_fail(kname, CHECK_NH); + instanceKlassHandle klass(THREAD, k); + klass->initialize(CHECK_NH); + klass->check_valid_for_instantiation(true, CHECK_NH); + JavaValue result(T_VOID); + instanceHandle service = klass->allocate_instance_handle(CHECK_NH); + JavaCalls::call_special(&result, service, klass, vmSymbols::object_initializer_name(), vmSymbols::void_method_signature(), THREAD); + return service; +} + +void JVMCIRuntime::shutdown() { + if (_HotSpotJVMCIRuntime_instance != NULL) { + _shutdown_called = true; + JavaThread* THREAD = JavaThread::current(); + HandleMark hm(THREAD); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", CHECK_ABORT); + KlassHandle klass = load_required_class(name); + JavaValue result(T_VOID); + JavaCallArguments args; + args.push_oop(get_HotSpotJVMCIRuntime()); + JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT); + + JNIHandles::destroy_global(_HotSpotJVMCIRuntime_instance); + _HotSpotJVMCIRuntime_instance = NULL; + } +} + +void JVMCIRuntime::call_printStackTrace(Handle exception, Thread* thread) { + assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected"); + JavaValue result(T_VOID); + JavaCalls::call_virtual(&result, + exception, + KlassHandle(thread, + SystemDictionary::Throwable_klass()), + vmSymbols::printStackTrace_name(), + vmSymbols::void_method_signature(), + thread); +} + +void JVMCIRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) { + Thread* THREAD = Thread::current(); + CLEAR_PENDING_EXCEPTION; + tty->print_raw_cr(message); + call_printStackTrace(exception, THREAD); + + // Give other aborting threads to also print their stack traces. + // This can be very useful when debugging class initialization + // failures. + os::sleep(THREAD, 200, false); + + vm_abort(dump_core); +} + +Klass* JVMCIRuntime::resolve_or_null(Symbol* name, TRAPS) { + return SystemDictionary::resolve_or_null(name, SystemDictionary::jvmci_loader(), Handle(), CHECK_NULL); +} + +Klass* JVMCIRuntime::resolve_or_fail(Symbol* name, TRAPS) { + return SystemDictionary::resolve_or_fail(name, SystemDictionary::jvmci_loader(), Handle(), true, CHECK_NULL); +} + +Klass* JVMCIRuntime::load_required_class(Symbol* name) { + Klass* klass = resolve_or_null(name, Thread::current()); + if (klass == NULL) { + tty->print_cr("Could not load class %s", name->as_C_string()); + vm_abort(false); + } + return klass; +} + +Handle JVMCIRuntime::get_service_impls(KlassHandle serviceKlass, TRAPS) { + const char* home = Arguments::get_java_home(); + const char* serviceName = serviceKlass->external_name(); + + size_t path_len = strlen(home) + strlen("/lib/jvmci/services/") + strlen(serviceName) + 1; + char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); + char sep = os::file_separator()[0]; + sprintf(path, "%s%clib%cjvmci%cservices%c%s", home, sep, sep, sep, sep, serviceName); + struct stat st; + if (os::stat(path, &st) == 0) { + int file_handle = os::open(path, 0, 0); + if (file_handle != -1) { + char* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, st.st_size + 1); + int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); + if (num_read == -1) { + warning("Error reading file %s due to %s", path, strerror(errno)); + } else if (num_read != st.st_size) { + warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path); + } + os::close(file_handle); + if (num_read == st.st_size) { + buffer[num_read] = '\0'; + GrowableArray<char*>* implNames = new GrowableArray<char*>(); + char* line = buffer; + while (line - buffer < num_read) { + // find line end (\r, \n or \r\n) + char* nextline = NULL; + char* cr = strchr(line, '\r'); + char* lf = strchr(line, '\n'); + if (cr != NULL && lf != NULL) { + char* min = MIN2(cr, lf); + *min = '\0'; + if (lf == cr + 1) { + nextline = lf + 1; + } else { + nextline = min + 1; + } + } else if (cr != NULL) { + *cr = '\0'; + nextline = cr + 1; + } else if (lf != NULL) { + *lf = '\0'; + nextline = lf + 1; + } + // trim left + while (*line == ' ' || *line == '\t') line++; + char* end = line + strlen(line); + // trim right + while (end > line && (*(end -1) == ' ' || *(end -1) == '\t')) end--; + *end = '\0'; + // skip comments and empty lines + if (*line != '#' && strlen(line) > 0) { + // Turn all '.'s into '/'s + for (size_t index = 0; line[index] != '\0'; index++) { + if (line[index] == '.') { + line[index] = '/'; + } + } + implNames->append(line); + } + if (nextline != NULL) { + line = nextline; + } else { + // File without newline at the end + break; + } + } + + objArrayOop servicesOop = oopFactory::new_objArray(serviceKlass(), implNames->length(), CHECK_NH); + objArrayHandle services(THREAD, servicesOop); + for (int i = 0; i < implNames->length(); ++i) { + char* implName = implNames->at(i); + Handle service = create_Service(implName, CHECK_NH); + services->obj_at_put(i, service()); + } + return services; + } + } else { + warning("Error opening file %s due to %s", path, strerror(errno)); + } + } else { + warning("Error opening file %s due to %s", path, strerror(errno)); + } + return Handle(); +} + +#include "graalRuntime.inline.hpp"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/jvmciRuntime.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,292 @@ +/* + * Copyright (c) 2012, 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. + */ + +#ifndef SHARE_VM_JVMCI_JVMCI_RUNTIME_HPP +#define SHARE_VM_JVMCI_JVMCI_RUNTIME_HPP + +#include "interpreter/interpreter.hpp" +#include "memory/allocation.hpp" +#include "runtime/deoptimization.hpp" + +class JVMCIRuntime: public CHeapObj<mtCompiler> { + private: + + static jobject _HotSpotJVMCIRuntime_instance; + static bool _HotSpotJVMCIRuntime_initialized; + static const char* _generated_sources_sha1; + + static bool _shutdown_called; + + /** + * Reads the OptionValue object from a specified static field. + * + * @throws LinkageError if the field could not be resolved + */ + static Handle get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS); + + /** + * Parses the string form of a numeric, float or double option into a jlong (using raw bits for floats/doubles). + * + * @param spec 'i', 'f' or 'd' (see HotSpotOptions.setOption()) + * @param name option name + * @param name_len length of option name + * @param value string value to parse + * @throws InternalError if value could not be parsed according to spec + */ + static jlong parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS); + + /** + * Loads default option value overrides from a <jre_home>/lib/jvmci.options if it exists. Each + * line in this file must have the format of a JVMCI command line option without the + * leading "-G:" prefix. These option values are set prior to processing of any JVMCI + * options present on the command line. + */ + static void parse_jvmci_options_file(KlassHandle hotSpotOptionsClass, TRAPS); + + /** + * Parses a given argument and sets the denoted JVMCI option. + * + * @throws InternalError if there was a problem parsing or setting the option + */ + static void parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS); + + /** + * Searches for a Boolean JVMCI option denoted by a given name and sets it value. + * + * The definition of this method is in jvmciRuntime.inline.hpp + * which is generated by com.oracle.jvmci.hotspot.sourcegen.GenJVMCIRuntimeInlineHpp. + * + * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option + * @param name option name + * @param name_len length of option name + * @param value '+' to set the option, '-' to reset the option + * @returns true if the option was found + * @throws InternalError if there was a problem setting the option's value + */ + static bool set_option_bool(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, char value, TRAPS); + + /** + * Searches for a JVMCI option denoted by a given name and sets it value. + * + * The definition of this method is in jvmciRuntime.inline.hpp + * which is generated by com.oracle.jvmci.hotspot.sourcegen.GenJVMCIRuntimeInlineHpp. + * + * @param hotSpotOptionsClass the HotSpotOptions klass or NULL if only checking for valid option + * @param name option name + * @param name_len length of option name + * @returns true if the option was found + * @throws InternalError if there was a problem setting the option's value + */ + static bool set_option(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, const char* value, TRAPS); + + /** + * Raises an InternalError for an option that expects a value but was specified without a "=<value>" prefix. + */ + static void check_required_value(const char* name, size_t name_len, const char* value, TRAPS); + + /** + * Java call to HotSpotOptions.setOption(String name, OptionValue<?> option, char spec, String stringValue, long primitiveValue) + * + * @param name option name + * @param name_len length of option name + */ + static void set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue); + + /** + * Instantiates a service object, calls its default constructor and returns it. + * + * @param name the name of a class implementing com.oracle.jvmci.api.runtime.Service + */ + static Handle create_Service(const char* name, TRAPS); + + /** + * Checks that _generated_sources_sha1 equals GeneratedSourcesSha1.value. + */ + static void check_generated_sources_sha1(TRAPS); + + public: + + /** + * Ensures that the JVMCI class loader is initialized and the well known JVMCI classes are loaded. + */ + static void ensure_jvmci_class_loader_is_initialized(); + + static void initialize_natives(JNIEnv *env, jclass c2vmClass); + + static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; } + + /** + * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary + */ + static Handle get_HotSpotJVMCIRuntime() { + initialize_JVMCI(); + return Handle(JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance)); + } + + static jobject get_HotSpotJVMCIRuntime_jobject() { + initialize_JVMCI(); + assert(_HotSpotJVMCIRuntime_initialized, "must be"); + return _HotSpotJVMCIRuntime_instance; + } + + static Handle callInitializer(const char* className, const char* methodName, const char* returnType); + + /** + * Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime() + */ + static void initialize_JVMCI(); + + /** + * Explicitly initialize HotSpotJVMCIRuntime itself + */ + static void initialize_HotSpotJVMCIRuntime(); + + static void shutdown(); + + static bool shutdown_called() { + return _shutdown_called; + } + + /** + * Given an interface representing a JVMCI service (i.e. sub-interface of + * com.oracle.jvmci.api.runtime.Service), gets an array of objects, one per + * known implementation of the service. + * + * The definition of this method is in jvmciRuntime.inline.hpp + * which is generated by com.oracle.jvmci.hotspot.sourcegen.GenJVMCIRuntimeInlineHpp. + */ + static Handle get_service_impls(KlassHandle serviceKlass, TRAPS); + + /** + * Aborts the VM due to an unexpected exception. + */ + static void abort_on_pending_exception(Handle exception, const char* message, bool dump_core = false); + + /** + * Calls Throwable.printStackTrace() on a given exception. + */ + static void call_printStackTrace(Handle exception, Thread* thread); + +#define CHECK_ABORT THREAD); \ + if (HAS_PENDING_EXCEPTION) { \ + char buf[256]; \ + jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ + JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \ + return; \ + } \ + (void)(0 + +#define CHECK_ABORT_(result) THREAD); \ + if (HAS_PENDING_EXCEPTION) { \ + char buf[256]; \ + jio_snprintf(buf, 256, "Uncaught exception at %s:%d", __FILE__, __LINE__); \ + JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \ + return result; \ + } \ + (void)(0 + + /** + * Same as SystemDictionary::resolve_or_null but uses the JVMCI loader. + */ + static Klass* resolve_or_null(Symbol* name, TRAPS); + + /** + * Same as SystemDictionary::resolve_or_fail but uses the JVMCI loader. + */ + static Klass* resolve_or_fail(Symbol* name, TRAPS); + + /** + * Loads a given JVMCI class and aborts the VM if it fails. + */ + static Klass* load_required_class(Symbol* name); + + static BufferBlob* initialize_buffer_blob(); + + /** + * Checks that all JVMCI specific VM options presented by the launcher are recognized + * and formatted correctly. To set relevant Java fields from the option, parse_arguments() + * must be called. This method makes no Java calls apart from creating exception objects + * if there is an errors in the JVMCI options. + */ + static jint check_arguments(TRAPS); + + /** + * Parses the JVMCI specific VM options that were presented by the launcher and sets + * the relevants Java fields. + */ + static void parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS); + + static BasicType kindToBasicType(jchar ch); + + // The following routines are all called from compiled JVMCI code + + static void new_instance(JavaThread* thread, Klass* klass); + static void new_array(JavaThread* thread, Klass* klass, jint length); + static void new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims); + static void dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length); + static void dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror); + static jboolean thread_is_interrupted(JavaThread* thread, oopDesc* obj, jboolean clear_interrupted); + static void vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3); + static jint identity_hash_code(JavaThread* thread, oopDesc* obj); + static address exception_handler_for_pc(JavaThread* thread); + static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock); + static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock); + static void create_null_exception(JavaThread* thread); + static void create_out_of_bounds_exception(JavaThread* thread, jint index); + static void vm_error(JavaThread* thread, jlong where, jlong format, jlong value); + static oopDesc* load_and_clear_exception(JavaThread* thread); + static void log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3); + static void log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline); + // Note: Must be kept in sync with constants in com.oracle.jvmci.replacements.Log + enum { + LOG_OBJECT_NEWLINE = 0x01, + LOG_OBJECT_STRING = 0x02, + LOG_OBJECT_ADDRESS = 0x04 + }; + static void log_object(JavaThread* thread, oopDesc* msg, jint flags); + static void write_barrier_pre(JavaThread* thread, oopDesc* obj); + static void write_barrier_post(JavaThread* thread, void* card); + static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child); + static void new_store_pre_barrier(JavaThread* thread); + + // Test only function + static int test_deoptimize_call_int(JavaThread* thread, int value); +}; + +// Tracing macros + +#define IF_TRACE_jvmci_1 if (!(TraceJVMCI >= 1)) ; else +#define IF_TRACE_jvmci_2 if (!(TraceJVMCI >= 2)) ; else +#define IF_TRACE_jvmci_3 if (!(TraceJVMCI >= 3)) ; else +#define IF_TRACE_jvmci_4 if (!(TraceJVMCI >= 4)) ; else +#define IF_TRACE_jvmci_5 if (!(TraceJVMCI >= 5)) ; else + +// using commas and else to keep one-instruction semantics + +#define TRACE_jvmci_1 if (!(TraceJVMCI >= 1 && (tty->print("TraceJVMCI-1: "), true))) ; else tty->print_cr +#define TRACE_jvmci_2 if (!(TraceJVMCI >= 2 && (tty->print(" TraceJVMCI-2: "), true))) ; else tty->print_cr +#define TRACE_jvmci_3 if (!(TraceJVMCI >= 3 && (tty->print(" TraceJVMCI-3: "), true))) ; else tty->print_cr +#define TRACE_jvmci_4 if (!(TraceJVMCI >= 4 && (tty->print(" TraceJVMCI-4: "), true))) ; else tty->print_cr +#define TRACE_jvmci_5 if (!(TraceJVMCI >= 5 && (tty->print(" TraceJVMCI-5: "), true))) ; else tty->print_cr + +#endif // SHARE_VM_JVMCI_JVMCI_RUNTIME_HPP
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/vm/jvmci/vmStructs_jvmci.hpp Thu May 28 15:36:48 2015 +0200 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2013, 2014, 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. + * + */ + +#ifndef SHARE_VM_JVMCI_VMSTRUCTS_JVMCI_HPP +#define SHARE_VM_JVMCI_VMSTRUCTS_JVMCI_HPP + +#include "compiler/abstractCompiler.hpp" +#include "jvmci/jvmciCodeInstaller.hpp" +#include "jvmci/jvmciCompilerToVM.hpp" +#include "jvmci/jvmciEnv.hpp" + +#define VM_STRUCTS_JVMCI(nonstatic_field, static_field) \ + nonstatic_field(ThreadShadow, _pending_deoptimization, int) \ + nonstatic_field(ThreadShadow, _pending_failed_speculation, oop) \ + nonstatic_field(ThreadShadow, _pending_transfer_to_interpreter, bool) \ + nonstatic_field(MethodData, _jvmci_ir_size, int) \ + nonstatic_field(JVMCIEnv, _task, CompileTask*) \ + nonstatic_field(JVMCIEnv, _jvmti_can_hotswap_or_post_breakpoint, bool) \ + +#define VM_TYPES_JVMCI(declare_type, declare_toplevel_type) \ + declare_toplevel_type(JVMCIEnv) \ + +#define VM_INT_CONSTANTS_JVMCI(declare_constant, declare_preprocessor_constant) \ + declare_constant(Deoptimization::Reason_unreached0) \ + declare_constant(Deoptimization::Reason_type_checked_inlining) \ + declare_constant(Deoptimization::Reason_optimized_type_check) \ + declare_constant(Deoptimization::Reason_aliasing) \ + declare_constant(Deoptimization::Reason_transfer_to_interpreter) \ + declare_constant(Deoptimization::Reason_not_compiled_exception_handler) \ + declare_constant(Deoptimization::Reason_unresolved) \ + declare_constant(Deoptimization::Reason_jsr_mismatch) \ + declare_constant(JVMCIEnv::ok) \ + declare_constant(JVMCIEnv::dependencies_failed) \ + declare_constant(JVMCIEnv::dependencies_invalid) \ + declare_constant(JVMCIEnv::cache_full) \ + declare_constant(JVMCIEnv::code_too_large) \ + \ + declare_preprocessor_constant("JVM_ACC_SYNTHETIC", JVM_ACC_SYNTHETIC) \ + declare_preprocessor_constant("JVM_RECOGNIZED_FIELD_MODIFIERS", JVM_RECOGNIZED_FIELD_MODIFIERS) \ + \ + declare_constant(CompilerToVM::KLASS_TAG) \ + declare_constant(CompilerToVM::SYMBOL_TAG) \ + \ + declare_constant(CodeInstaller::VERIFIED_ENTRY) \ + declare_constant(CodeInstaller::UNVERIFIED_ENTRY) \ + declare_constant(CodeInstaller::OSR_ENTRY) \ + declare_constant(CodeInstaller::EXCEPTION_HANDLER_ENTRY) \ + declare_constant(CodeInstaller::DEOPT_HANDLER_ENTRY) \ + declare_constant(CodeInstaller::INVOKEINTERFACE) \ + declare_constant(CodeInstaller::INVOKEVIRTUAL) \ + declare_constant(CodeInstaller::INVOKESTATIC) \ + declare_constant(CodeInstaller::INVOKESPECIAL) \ + declare_constant(CodeInstaller::INLINE_INVOKE) \ + declare_constant(CodeInstaller::POLL_NEAR) \ + declare_constant(CodeInstaller::POLL_RETURN_NEAR) \ + declare_constant(CodeInstaller::POLL_FAR) \ + declare_constant(CodeInstaller::POLL_RETURN_FAR) \ + declare_constant(CodeInstaller::CARD_TABLE_SHIFT) \ + declare_constant(CodeInstaller::CARD_TABLE_ADDRESS) \ + declare_constant(CodeInstaller::INVOKE_INVALID) \ + \ + declare_constant(Method::invalid_vtable_index) \ + +#endif // SHARE_VM_JVMCI_VMSTRUCTS_JVMCI_HPP
--- a/src/share/vm/memory/referenceProcessor.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/memory/referenceProcessor.cpp Thu May 28 15:36:48 2015 +0200 @@ -57,7 +57,7 @@ java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock); _always_clear_soft_ref_policy = new AlwaysClearPolicy(); -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) _default_soft_ref_policy = new LRUMaxHeapPolicy(); #else _default_soft_ref_policy = new LRUCurrentHeapPolicy();
--- a/src/share/vm/oops/instanceKlass.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/oops/instanceKlass.cpp Thu May 28 15:36:48 2015 +0200 @@ -61,9 +61,9 @@ #include "services/threadService.hpp" #include "utilities/dtrace.hpp" #include "utilities/macros.hpp" -#ifdef GRAAL +#ifdef JVMCI #include "classfile/javaAssertions.hpp" -#include "graal/graalRuntime.hpp" +#include "jvmci/jvmciRuntime.hpp" #endif #if INCLUDE_ALL_GCS #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.inline.hpp"
--- a/src/share/vm/oops/method.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/oops/method.cpp Thu May 28 15:36:48 2015 +0200 @@ -218,7 +218,7 @@ Thread* myThread = Thread::current(); methodHandle h_this(myThread, this); -#if defined(ASSERT) && !defined(GRAAL) +#if defined(ASSERT) && !defined(JVMCI) bool has_capability = myThread->is_VM_thread() || myThread->is_ConcurrentGC_thread() || myThread->is_GC_task_thread();
--- a/src/share/vm/oops/methodData.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/oops/methodData.cpp Thu May 28 15:36:48 2015 +0200 @@ -420,7 +420,7 @@ } } -#ifdef GRAAL +#ifdef JVMCI void VirtualCallData::clean_weak_klass_links(BoolObjectClosure* is_alive_cl) { ReceiverTypeData::clean_weak_klass_links(is_alive_cl); for (uint row = 0; row < method_row_limit(); row++) { @@ -440,7 +440,7 @@ } } } -#endif // GRAAL +#endif // JVMCI #ifndef PRODUCT void ReceiverTypeData::print_receiver_data_on(outputStream* st) const { @@ -449,7 +449,7 @@ for (row = 0; row < row_limit(); row++) { if (receiver(row) != NULL) entries++; } -#ifdef GRAAL +#ifdef JVMCI st->print_cr("count(%u) nonprofiled_count(%u) entries(%u)", count(), nonprofiled_count(), entries); #else st->print_cr("count(%u) entries(%u)", count(), entries); @@ -473,7 +473,7 @@ print_receiver_data_on(st); } -#ifdef GRAAL +#ifdef JVMCI void VirtualCallData::print_method_data_on(outputStream* st) const { uint row; int entries = 0; @@ -501,7 +501,7 @@ void VirtualCallData::print_data_on(outputStream* st, const char* extra) const { print_shared(st, "VirtualCallData", extra); print_receiver_data_on(st); -#ifdef GRAAL +#ifdef JVMCI print_method_data_on(st); #endif } @@ -740,7 +740,7 @@ } int MethodData::bytecode_cell_count(Bytecodes::Code code) { -#if defined(COMPILER1) && !(defined(COMPILER2) || defined(GRAAL)) +#if defined(COMPILER1) && !(defined(COMPILER2) || defined(JVMCI)) return no_profile_data; #else switch (code) { @@ -869,7 +869,7 @@ return false; } -#ifdef GRAAL +#ifdef JVMCI int MethodData::compute_extra_data_count(int data_size, int empty_bc_count, bool needs_speculative_traps) { if (!ProfileTraps) return 0; @@ -929,7 +929,7 @@ while ((c = stream.next()) >= 0) { int size_in_bytes = compute_data_size(&stream); data_size += size_in_bytes; - if (size_in_bytes == 0 GRAAL_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1; + if (size_in_bytes == 0 JVMCI_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1; needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c); } int object_size = in_bytes(data_offset()) + data_size; @@ -963,7 +963,7 @@ // the segment in bytes. int MethodData::initialize_data(BytecodeStream* stream, int data_index) { -#if defined(COMPILER1) && !(defined(COMPILER2) || defined(GRAAL)) +#if defined(COMPILER1) && !(defined(COMPILER2) || defined(JVMCI)) return 0; #else int cell_count = -1; @@ -1176,7 +1176,7 @@ while ((c = stream.next()) >= 0) { int size_in_bytes = initialize_data(&stream, data_size); data_size += size_in_bytes; - if (size_in_bytes == 0 GRAAL_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1; + if (size_in_bytes == 0 JVMCI_ONLY(&& Bytecodes::can_trap(c))) empty_bc_count += 1; needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c); } _data_size = data_size; @@ -1236,7 +1236,7 @@ _num_blocks = 0; _would_profile = unknown; -#ifdef GRAAL +#ifdef JVMCI _jvmci_ir_size = 0; #endif
--- a/src/share/vm/oops/methodData.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/oops/methodData.hpp Thu May 28 15:36:48 2015 +0200 @@ -543,7 +543,7 @@ // saw a null operand (cast/aastore/instanceof) null_seen_flag = DataLayout::first_flag + 0 -#ifdef GRAAL +#ifdef JVMCI // bytecode threw any exception , exception_seen_flag = null_seen_flag + 1 #endif @@ -570,7 +570,7 @@ bool null_seen() { return flag_at(null_seen_flag); } void set_null_seen() { set_flag_at(null_seen_flag); } -#ifdef GRAAL +#ifdef JVMCI // true if an exception was thrown at the specific BCI bool exception_seen() { return flag_at(exception_seen_flag); } void set_exception_seen() { set_flag_at(exception_seen_flag); } @@ -1179,17 +1179,17 @@ class ReceiverTypeData : public CounterData { protected: enum { -#ifdef GRAAL +#ifdef JVMCI // Description of the different counters // ReceiverTypeData for instanceof/checkcast/aastore: // C1/C2: count is incremented on type overflow and decremented for failed type checks - // Graal: count decremented for failed type checks and nonprofiled_count is incremented on type overflow - // TODO (chaeubl): in fact, Graal should also increment the count for failed type checks to mimic the C1/C2 behavior + // JVMCI: count decremented for failed type checks and nonprofiled_count is incremented on type overflow + // TODO (chaeubl): in fact, JVMCI should also increment the count for failed type checks to mimic the C1/C2 behavior // VirtualCallData for invokevirtual/invokeinterface: // C1/C2: count is incremented on type overflow - // Graal: count is incremented on type overflow, nonprofiled_count is incremented on method overflow - - // Graal is interested in knowing the percentage of type checks involving a type not explicitly in the profile + // JVMCI: count is incremented on type overflow, nonprofiled_count is incremented on method overflow + + // JVMCI is interested in knowing the percentage of type checks involving a type not explicitly in the profile nonprofiled_count_off_set = counter_cell_count, receiver0_offset, #else @@ -1209,7 +1209,7 @@ virtual bool is_ReceiverTypeData() const { return true; } static int static_cell_count() { - return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count GRAAL_ONLY(+ 1); + return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count JVMCI_ONLY(+ 1); } virtual int cell_count() const { @@ -1271,9 +1271,9 @@ set_count(0); set_receiver(row, NULL); set_receiver_count(row, 0); -#ifdef GRAAL +#ifdef JVMCI if (!this->is_VirtualCallData()) { - // if this is a ReceiverTypeData for Graal, the nonprofiled_count + // if this is a ReceiverTypeData for JVMCI, the nonprofiled_count // must also be reset (see "Description of the different counters" above) set_nonprofiled_count(0); } @@ -1287,7 +1287,7 @@ static ByteSize receiver_count_offset(uint row) { return cell_offset(receiver_count_cell_index(row)); } -#ifdef GRAAL +#ifdef JVMCI static ByteSize nonprofiled_receiver_count_offset() { return cell_offset(nonprofiled_count_off_set); } @@ -1364,7 +1364,7 @@ static int static_cell_count() { // At this point we could add more profile state, e.g., for arguments. // But for now it's the same size as the base record type. - return ReceiverTypeData::static_cell_count() GRAAL_ONLY(+ (uint) MethodProfileWidth * receiver_type_row_cell_count); + return ReceiverTypeData::static_cell_count() JVMCI_ONLY(+ (uint) MethodProfileWidth * receiver_type_row_cell_count); } virtual int cell_count() const { @@ -1386,7 +1386,7 @@ } #endif // CC_INTERP -#ifdef GRAAL +#ifdef JVMCI static ByteSize method_offset(uint row) { return cell_offset(method_cell_index(row)); } @@ -1442,7 +1442,7 @@ #endif #ifndef PRODUCT -#ifdef GRAAL +#ifdef JVMCI void print_method_data_on(outputStream* st) const; #endif void print_data_on(outputStream* st, const char* extra = NULL) const; @@ -2165,7 +2165,7 @@ // Whole-method sticky bits and flags enum { - _trap_hist_limit = 20 GRAAL_ONLY(+5), // decoupled from Deoptimization::Reason_LIMIT + _trap_hist_limit = 20 JVMCI_ONLY(+5), // decoupled from Deoptimization::Reason_LIMIT _trap_hist_mask = max_jubyte, _extra_data_count = 4 // extra DataLayout headers, for trap history }; // Public flag values @@ -2210,7 +2210,7 @@ enum WouldProfile {unknown, no_profile, profile}; WouldProfile _would_profile; -#ifdef GRAAL +#ifdef JVMCI // Support for HotSpotMethodData.setCompiledIRSize(int) int _jvmci_ir_size; #endif @@ -2491,7 +2491,7 @@ // Return (uint)-1 for overflow. uint trap_count(int reason) const { - assert((uint)reason < GRAAL_ONLY(2*) _trap_hist_limit, "oob"); + assert((uint)reason < JVMCI_ONLY(2*) _trap_hist_limit, "oob"); return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1; } // For loops: @@ -2500,7 +2500,7 @@ uint inc_trap_count(int reason) { // Count another trap, anywhere in this method. assert(reason >= 0, "must be single trap"); - assert((uint)reason < GRAAL_ONLY(2*) _trap_hist_limit, "oob"); + assert((uint)reason < JVMCI_ONLY(2*) _trap_hist_limit, "oob"); uint cnt1 = 1 + _trap_hist._array[reason]; if ((cnt1 & _trap_hist_mask) != 0) { // if no counter overflow... _trap_hist._array[reason] = cnt1;
--- a/src/share/vm/opto/superword.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/opto/superword.hpp Thu May 28 15:36:48 2015 +0200 @@ -201,7 +201,7 @@ static const SWNodeInfo initial; }; -// Graal: OrderedPair is moved up to deal with compilation issues on Windows +// JVMCI: OrderedPair is moved up to deal with compilation issues on Windows //------------------------------OrderedPair--------------------------- // Ordered pair of Node*. class OrderedPair VALUE_OBJ_CLASS_SPEC {
--- a/src/share/vm/precompiled/precompiled.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/precompiled/precompiled.hpp Thu May 28 15:36:48 2015 +0200 @@ -295,9 +295,9 @@ # include "c1/c1_ValueType.hpp" # include "c1/c1_globals.hpp" #endif // COMPILER1 -#ifdef GRAAL -# include "graal/graalGlobals.hpp" -#endif // GRAAL +#ifdef JVMCI +# include "jvmci/jvmciGlobals.hpp" +#endif // JVMCI #if INCLUDE_ALL_GCS # include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp" # include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp"
--- a/src/share/vm/prims/jni.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/prims/jni.cpp Thu May 28 15:36:48 2015 +0200 @@ -33,9 +33,9 @@ #include "classfile/vmSymbols.hpp" #include "interpreter/linkResolver.hpp" #include "utilities/macros.hpp" -#ifdef GRAAL -#include "graal/graalCompiler.hpp" -#include "graal/graalRuntime.hpp" +#ifdef JVMCI +#include "jvmci/jvmciCompiler.hpp" +#include "jvmci/jvmciRuntime.hpp" #endif #if INCLUDE_ALL_GCS #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp" @@ -5209,27 +5209,27 @@ *vm = (JavaVM *)(&main_vm); *(JNIEnv**)penv = thread->jni_environment(); -#if defined(GRAAL) - // We turn off CompileTheWorld so that compilation requests are not ignored during bootstrap or that Graal can be compiled by C1/C2. +#if defined(JVMCI) + // We turn off CompileTheWorld so that compilation requests are not ignored during bootstrap or that JVMCI can be compiled by C1/C2. bool doCTW = CompileTheWorld; CompileTheWorld = false; #endif -#ifdef COMPILERGRAAL - // Graal is initialized on a CompilerThread - if (FLAG_IS_DEFAULT(BootstrapGraal) ? !TieredCompilation : BootstrapGraal) { - GraalCompiler::instance()->bootstrap(); +#ifdef COMPILERJVMCI + // JVMCI is initialized on a CompilerThread + if (FLAG_IS_DEFAULT(BootstrapJVMCI) ? !TieredCompilation : BootstrapJVMCI) { + JVMCICompiler::instance()->bootstrap(); } -#elif defined(GRAAL) +#elif defined(JVMCI) if (doCTW) { // required for hosted CTW. CompilationPolicy::completed_vm_startup(); } #endif -#if defined(GRAAL) +#if defined(JVMCI) if (doCTW) { - GraalCompiler::instance()->compile_the_world(); + JVMCICompiler::instance()->compile_the_world(); } #endif
--- a/src/share/vm/prims/jvm.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/prims/jvm.cpp Thu May 28 15:36:48 2015 +0200 @@ -383,8 +383,8 @@ const char* compiler_name = "HotSpot " CSIZE "Client Compiler"; #elif defined(COMPILER2) const char* compiler_name = "HotSpot " CSIZE "Server Compiler"; -#elif defined(GRAAL) - const char* compiler_name = "HotSpot " CSIZE "Graal Compiler"; +#elif defined(JVMCI) + const char* compiler_name = "HotSpot " CSIZE "JVMCI Compiler"; #else const char* compiler_name = ""; #endif // compilers @@ -2362,7 +2362,7 @@ ResourceMark rm(THREAD); const char* name = k->name()->as_C_string(); - bool system_class = k->class_loader() == NULL GRAAL_ONLY(|| SystemDictionary::graal_loader() == k->class_loader()); + bool system_class = k->class_loader() == NULL JVMCI_ONLY(|| SystemDictionary::jvmci_loader() == k->class_loader()); return JavaAssertions::enabled(name, system_class); JVM_END
--- a/src/share/vm/prims/nativeLookup.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/prims/nativeLookup.cpp Thu May 28 15:36:48 2015 +0200 @@ -126,17 +126,17 @@ void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls); void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass); void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass); -#ifdef GRAAL - void JNICALL JVM_InitGraalClassLoader(JNIEnv *env, jclass c, jobject loader); - void JNICALL JVM_InitializeGraalNatives(JNIEnv *env, jclass compilerToVMClass); +#ifdef JVMCI + void JNICALL JVM_InitJVMCIClassLoader(JNIEnv *env, jclass c, jobject loader); + void JNICALL JVM_InitializeJVMCINatives(JNIEnv *env, jclass compilerToVMClass); jobject JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c); - jobject JNICALL JVM_GetGraalRuntime(JNIEnv *env, jclass c); - jobject JNICALL JVM_GetGraalServiceImpls(JNIEnv *env, jclass c, jclass serviceClass); + jobject JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c); + jobject JNICALL JVM_GetJVMCIServiceImpls(JNIEnv *env, jclass c, jclass serviceClass); jobject JNICALL JVM_CreateTruffleRuntime(JNIEnv *env, jclass c); jobject JNICALL JVM_CreateNativeFunctionInterface(JNIEnv *env, jclass c); - jboolean JNICALL JVM_ParseGraalOptions(JNIEnv *env, jclass hotspotOptionsClass); -#ifdef COMPILERGRAAL - void JNICALL JVM_PrintAndResetGraalCompRate(JNIEnv *env, jclass c); + jboolean JNICALL JVM_ParseJVMCIOptions(JNIEnv *env, jclass hotspotOptionsClass); +#ifdef COMPILERJVMCI + void JNICALL JVM_PrintAndResetJVMCICompRate(JNIEnv *env, jclass c); #endif #endif } @@ -149,14 +149,14 @@ { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, { CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) }, { CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) }, -#ifdef GRAAL - { CC"Java_com_oracle_graal_hotspot_loader_Factory_init", NULL, FN_PTR(JVM_InitGraalClassLoader) }, +#ifdef JVMCI + { CC"Java_com_oracle_jvmci_hotspot_loader_Factory_init", NULL, FN_PTR(JVM_InitJVMCIClassLoader) }, { CC"Java_com_oracle_jvmci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) }, - { CC"Java_com_oracle_jvmci_runtime_Services_getServiceImpls", NULL, FN_PTR(JVM_GetGraalServiceImpls) }, + { CC"Java_com_oracle_jvmci_runtime_Services_getServiceImpls", NULL, FN_PTR(JVM_GetJVMCIServiceImpls) }, { CC"Java_com_oracle_truffle_api_Truffle_createRuntime", NULL, FN_PTR(JVM_CreateTruffleRuntime) }, { CC"Java_com_oracle_nfi_NativeFunctionInterfaceRuntime_createInterface", NULL, FN_PTR(JVM_CreateNativeFunctionInterface) }, - { CC"Java_com_oracle_jvmci_hotspot_CompilerToVMImpl_init", NULL, FN_PTR(JVM_InitializeGraalNatives) }, - { CC"Java_com_oracle_jvmci_hotspot_HotSpotOptions_parseVMOptions", NULL, FN_PTR(JVM_ParseGraalOptions) }, + { CC"Java_com_oracle_jvmci_hotspot_CompilerToVMImpl_init", NULL, FN_PTR(JVM_InitializeJVMCINatives) }, + { CC"Java_com_oracle_jvmci_hotspot_HotSpotOptions_parseVMOptions", NULL, FN_PTR(JVM_ParseJVMCIOptions) }, #endif }; @@ -187,7 +187,7 @@ // gets found the first time around - otherwise an infinite loop can occure. This is // another VM/library dependency Handle loader(THREAD, method->method_holder()->class_loader()); - if (loader.is_null() GRAAL_ONLY(|| loader() == SystemDictionary::graal_loader())) { + if (loader.is_null() JVMCI_ONLY(|| loader() == SystemDictionary::jvmci_loader())) { entry = lookup_special_native(jni_name); if (entry == NULL) { entry = (address) os::dll_lookup(os::native_java_library(), jni_name);
--- a/src/share/vm/runtime/advancedThresholdPolicy.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/advancedThresholdPolicy.cpp Thu May 28 15:36:48 2015 +0200 @@ -161,8 +161,8 @@ // Called with the queue locked and with at least one element CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) { -#ifdef COMPILERGRAAL - CompileTask *max_non_graal_task = NULL; +#ifdef COMPILERJVMCI + CompileTask *max_non_jvmci_task = NULL; #endif CompileTask *max_task = NULL; Method* max_method = NULL; @@ -194,16 +194,16 @@ max_method = method; } } -#ifdef COMPILERGRAAL - if (GraalCompileAppFirst && (task->comp_level() == CompLevel_full_optimization || !method->has_compiled_code()) && - SystemDictionary::graal_loader() != NULL && - method->method_holder()->class_loader() != SystemDictionary::graal_loader()) { - if (max_non_graal_task == NULL) { - max_non_graal_task = task; +#ifdef COMPILERJVMCI + if (JVMCICompileAppFirst && (task->comp_level() == CompLevel_full_optimization || !method->has_compiled_code()) && + SystemDictionary::jvmci_loader() != NULL && + method->method_holder()->class_loader() != SystemDictionary::jvmci_loader()) { + if (max_non_jvmci_task == NULL) { + max_non_jvmci_task = task; } else { // Select a method with a higher rate - if (compare_methods(method, max_non_graal_task->method())) { - max_non_graal_task = task; + if (compare_methods(method, max_non_jvmci_task->method())) { + max_non_jvmci_task = task; } } } @@ -211,9 +211,9 @@ task = next_task; } -#ifdef COMPILERGRAAL - if (max_non_graal_task != NULL) { - max_task = max_non_graal_task; +#ifdef COMPILERJVMCI + if (max_non_jvmci_task != NULL) { + max_task = max_non_jvmci_task; max_method = max_task->method(); } #endif @@ -373,11 +373,11 @@ if (common(p, method, CompLevel_full_profile, disable_feedback) == CompLevel_full_optimization) { next_level = CompLevel_full_optimization; } else if ((this->*p)(i, b, cur_level)) { -#ifdef COMPILERGRAAL - // Since Graal takes a while to warm up, its queue inevitably backs up during - // early VM execution. As of 2014-06-13, Graal's inliner assumes that the root +#ifdef COMPILERJVMCI + // Since JVMCI takes a while to warm up, its queue inevitably backs up during + // early VM execution. As of 2014-06-13, JVMCI's inliner assumes that the root // compilation method and all potential inlinees have mature profiles (which - // includes type profiling). If it sees immature profiles, Graal's inliner + // includes type profiling). If it sees immature profiles, JVMCI's inliner // can perform pathologically bad (e.g., causing OutOfMemoryErrors due to // exploring/inlining too many graphs). Since a rewrite of the inliner is // in progress, we simply disable the dialing back heuristic for now and will
--- a/src/share/vm/runtime/arguments.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/arguments.cpp Thu May 28 15:36:48 2015 +0200 @@ -95,9 +95,9 @@ int Arguments::_num_jvm_flags = 0; char** Arguments::_jvm_args_array = NULL; int Arguments::_num_jvm_args = 0; -#ifdef GRAAL -char** Arguments::_graal_args_array = NULL; -int Arguments::_num_graal_args = 0; +#ifdef JVMCI +char** Arguments::_jvmci_args_array = NULL; +int Arguments::_num_jvmci_args = 0; #endif char* Arguments::_java_command = NULL; SystemProperty* Arguments::_system_properties = NULL; @@ -189,13 +189,6 @@ PropertyList_add(&_system_properties, new SystemProperty("java.vm.version", VM_Version::vm_release(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.name", VM_Version::vm_name(), false)); PropertyList_add(&_system_properties, new SystemProperty("java.vm.info", VM_Version::vm_info_string(), true)); -#ifdef GRAAL -#ifdef GRAAL_VERSION - PropertyList_add(&_system_properties, new SystemProperty("graal.version", GRAAL_VERSION, true)); -#else - PropertyList_add(&_system_properties, new SystemProperty("graal.version", "unknown", true)); -#endif -#endif // following are JVMTI agent writeable properties. // Properties values are set to NULL and they are @@ -817,9 +810,9 @@ void Arguments::build_jvm_flags(const char* arg) { add_string(&_jvm_flags_array, &_num_jvm_flags, arg); } -#ifdef GRAAL -void Arguments::add_graal_arg(const char* arg) { - add_string(&_graal_args_array, &_num_graal_args, arg); +#ifdef JVMCI +void Arguments::add_jvmci_arg(const char* arg) { + add_string(&_jvmci_args_array, &_num_jvmci_args, arg); } #endif @@ -1127,7 +1120,7 @@ } } -#if defined(COMPILER2) || defined(GRAAL) || defined(_LP64) || !INCLUDE_CDS +#if defined(COMPILER2) || defined(JVMCI) || defined(_LP64) || !INCLUDE_CDS // Conflict: required to use shared spaces (-Xshare:on), but // incompatible command line options were chosen. @@ -1177,7 +1170,7 @@ * the minimum number of compiler threads is 2. */ int Arguments::get_min_number_of_compiler_threads() { -#if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK) && !defined(COMPILERGRAAL) +#if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK) && !defined(COMPILERJVMCI) return 0; // case 1 #else if (!TieredCompilation || (TieredStopAtLevel < CompLevel_full_optimization)) { @@ -1501,7 +1494,7 @@ // the only value that can override MaxHeapSize if we are // to use UseCompressedOops is InitialHeapSize. size_t max_heap_size = MAX2(MaxHeapSize, InitialHeapSize); - // Set default on graal with sparc to not use compressed oops as long they are not implemented + // Set default on jvmci with sparc to not use compressed oops as long they are not implemented if (max_heap_size <= max_heap_for_compressed_oops()) { #if !defined(COMPILER1) || defined(TIERED) if (FLAG_IS_DEFAULT(UseCompressedOops)) { @@ -1595,7 +1588,7 @@ void Arguments::set_ergonomics_flags() { select_gc(); -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) // Shared spaces work fine with other GCs but causes bytecode rewriting // to be disabled, which hurts interpreter performance and decreases // server performance. When -server is specified, keep the default off @@ -1679,7 +1672,7 @@ void Arguments::set_g1_gc_flags() { assert(UseG1GC, "Error"); -#if defined(COMPILER1) || defined(GRAAL) +#if defined(COMPILER1) || defined(JVMCI) FastTLABRefill = false; #endif FLAG_SET_DEFAULT(ParallelGCThreads, @@ -2446,7 +2439,7 @@ } #endif } -#ifdef GRAAL +#ifdef JVMCI if (UseG1GC) { if (IgnoreUnrecognizedVMOptions) { FLAG_SET_CMDLINE(bool, UseG1GC, true); @@ -2459,7 +2452,7 @@ } if (!ScavengeRootsInCode) { - warning("forcing ScavengeRootsInCode non-zero because Graal is enabled"); + warning("forcing ScavengeRootsInCode non-zero because JVMCI is enabled"); ScavengeRootsInCode = 1; } if (TypeProfileLevel != 0) { @@ -2783,9 +2776,9 @@ return JNI_ERR; } #endif // !INCLUDE_JVMTI -#if defined(GRAAL) +#if defined(JVMCI) if (strcmp(name, "hprof") == 0) { - FLAG_SET_CMDLINE(bool, GraalHProfEnabled, true); + FLAG_SET_CMDLINE(bool, JVMCIHProfEnabled, true); } #endif add_init_library(name, options); @@ -2810,9 +2803,9 @@ return JNI_ERR; } #endif // !INCLUDE_JVMTI -#if defined(GRAAL) +#if defined(JVMCI) if (valid_hprof_or_jdwp_agent(name, is_absolute_path)) { - FLAG_SET_CMDLINE(bool, GraalHProfEnabled, true); + FLAG_SET_CMDLINE(bool, JVMCIHProfEnabled, true); } #endif @@ -3389,13 +3382,13 @@ } } } -#ifdef GRAAL +#ifdef JVMCI else if (match_option(option, "-G:", &tail)) { // -G:XXX - // Option for the Graal compiler. + // Option for the JVMCI compiler. if (PrintVMOptions) { - tty->print_cr("Graal option %s", tail); + tty->print_cr("JVMCI option %s", tail); } - Arguments::add_graal_arg(tail); + Arguments::add_jvmci_arg(tail); // Unknown option } @@ -3615,24 +3608,22 @@ // This must be done after all -D arguments have been processed. scp_p->expand_endorsed(); -#ifdef GRAAL - if (!UseGraalClassLoader) { - // Append lib/graal/graal*.jar to boot class path - char graalDir[JVM_MAXPATHLEN]; +#ifdef JVMCI + if (!UseJVMCIClassLoader) { + // Append lib/jvmci/*.jar to boot class path + char jvmciDir[JVM_MAXPATHLEN]; const char* fileSep = os::file_separator(); - jio_snprintf(graalDir, sizeof(graalDir), "%s%slib%sgraal", Arguments::get_java_home(), fileSep, fileSep); - DIR* dir = os::opendir(graalDir); + jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci", Arguments::get_java_home(), fileSep, fileSep); + DIR* dir = os::opendir(jvmciDir); if (dir != NULL) { struct dirent *entry; - char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(graalDir), mtInternal); + char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal); while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL) { const char* name = entry->d_name; const char* ext = name + strlen(name) - 4; - if (ext > name && strcmp(ext, ".jar") == 0 - && strlen(name) > strlen("graal") - && strncmp(name, "graal", strlen("graal")) == 0) { + if (ext > name && strcmp(ext, ".jar") == 0) { char fileName[JVM_MAXPATHLEN]; - jio_snprintf(fileName, sizeof(fileName), "%s%s%s", graalDir, fileSep, name); + jio_snprintf(fileName, sizeof(fileName), "%s%s%s", jvmciDir, fileSep, name); scp_p->add_suffix(fileName); scp_assembly_required = true; } @@ -3668,7 +3659,7 @@ FLAG_SET_ERGO(uintx, InitialTenuringThreshold, MaxTenuringThreshold); } -#if !defined(COMPILER2) && !defined(COMPILERGRAAL) +#if !defined(COMPILER2) && !defined(COMPILERJVMCI) // Don't degrade server performance for footprint if (FLAG_IS_DEFAULT(UseLargePages) && MaxHeapSize < LargePageHeapSizeThreshold) { @@ -4138,9 +4129,9 @@ #ifdef COMPILER1 || !UseFastLocking #endif // COMPILER1 -#ifdef GRAAL - || !GraalUseFastLocking -#endif // GRAAL +#ifdef JVMCI + || !JVMCIUseFastLocking +#endif // JVMCI ) { if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) { // flag set to true on command line; warn the user that they
--- a/src/share/vm/runtime/arguments.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/arguments.hpp Thu May 28 15:36:48 2015 +0200 @@ -246,10 +246,10 @@ // an array containing all jvm arguments specified in the command line static char** _jvm_args_array; static int _num_jvm_args; -#ifdef GRAAL - // an array containing all Graal arguments specified in the command line - static char** _graal_args_array; - static int _num_graal_args; +#ifdef JVMCI + // an array containing all JVMCI arguments specified in the command line + static char** _jvmci_args_array; + static int _num_jvmci_args; #endif // string containing all java command (class/jarfile name and app args) static char* _java_command; @@ -410,8 +410,8 @@ // methods to build strings from individual args static void build_jvm_args(const char* arg); static void build_jvm_flags(const char* arg); -#ifdef GRAAL - static void add_graal_arg(const char* arg); +#ifdef JVMCI + static void add_jvmci_arg(const char* arg); #endif static void add_string(char*** bldarray, int* count, const char* arg); static const char* build_resource_string(char** args, int count); @@ -492,9 +492,9 @@ // return a char* array containing all options static char** jvm_flags_array() { return _jvm_flags_array; } static char** jvm_args_array() { return _jvm_args_array; } -#ifdef GRAAL - static char** graal_args_array() { return _graal_args_array; } - static int num_graal_args() { return _num_graal_args; } +#ifdef JVMCI + static char** jvmci_args_array() { return _jvmci_args_array; } + static int num_jvmci_args() { return _num_jvmci_args; } #endif static int num_jvm_flags() { return _num_jvm_flags; } static int num_jvm_args() { return _num_jvm_args; }
--- a/src/share/vm/runtime/compilationPolicy.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/compilationPolicy.cpp Thu May 28 15:36:48 2015 +0200 @@ -200,7 +200,7 @@ // - if neither is defined - always return zero. int NonTieredCompPolicy::compiler_count(CompLevel comp_level) { assert(!TieredCompilation, "This policy should not be used with TieredCompilation"); -#if defined(COMPILER2) || defined(COMPILERGRAAL) +#if defined(COMPILER2) || defined(COMPILERJVMCI) if (is_c2_compile(comp_level)) { return _compiler_count; } else {
--- a/src/share/vm/runtime/deoptimization.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/deoptimization.cpp Thu May 28 15:36:48 2015 +0200 @@ -92,9 +92,9 @@ PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC -#ifdef GRAAL -#include "graal/graalRuntime.hpp" -#include "graal/graalJavaAccess.hpp" +#ifdef JVMCI +#include "jvmci/jvmciRuntime.hpp" +#include "jvmci/jvmciJavaAccess.hpp" #endif @@ -225,7 +225,7 @@ bool realloc_failures = false; -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) // Reallocate the non-escaping objects and restore their fields. Then // relock objects if synchronization on them was eliminated. #ifdef COMPILER2 @@ -313,7 +313,7 @@ } } #endif // COMPILER2 -#endif // COMPILER2 || GRAAL +#endif // COMPILER2 || JVMCI // Ensure that no safepoint is taken after pointers have been stored // in fields of rematerialized objects. If a safepoint occurs from here on @@ -321,7 +321,7 @@ No_Safepoint_Verifier no_safepoint; vframeArray* array = create_vframeArray(thread, deoptee, &map, chunk, realloc_failures); -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) if (realloc_failures) { pop_frames_failed_reallocs(thread, array); } @@ -776,7 +776,7 @@ } -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS) { Handle pending_exception(thread->pending_exception()); const char* exception_file = thread->exception_file(); @@ -1111,7 +1111,7 @@ } } #endif -#endif // COMPILER2 || GRAAL +#endif // COMPILER2 || JVMCI vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures) { Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp()); @@ -1171,7 +1171,7 @@ return array; } -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) void Deoptimization::pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array) { // Reallocation of some scalar replaced objects failed. Record // that we need to pop all the interpreter frames for the @@ -1361,7 +1361,7 @@ JRT_END -#if defined(COMPILER2) || defined(SHARK) || defined(GRAAL) +#if defined(COMPILER2) || defined(SHARK) || defined(JVMCI) void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int index, TRAPS) { // in case of an unresolved klass entry, load the class. if (constant_pool->tag_at(index).is_unresolved_klass()) { @@ -1424,8 +1424,8 @@ thread->inc_in_deopt_handler(); // We need to update the map if we have biased locking. -#ifdef GRAAL - // (lstadler) Graal might need to get an exception from the stack, which in turn requires the register map to be valid +#ifdef JVMCI + // (lstadler) JVMCI might need to get an exception from the stack, which in turn requires the register map to be valid RegisterMap reg_map(thread, true); #else RegisterMap reg_map(thread, UseBiasedLocking); @@ -1448,7 +1448,7 @@ DeoptReason reason = trap_request_reason(trap_request); DeoptAction action = trap_request_action(trap_request); -#ifdef GRAAL +#ifdef JVMCI int debug_id = trap_request_debug_id(trap_request); #endif jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1 @@ -1462,8 +1462,8 @@ if (TraceDeoptimization) { ttyLocker ttyl; - tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=%d, method=%s" GRAAL_ONLY(", debug_id=%d"), trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string() -#ifdef GRAAL + tty->print_cr(" bci=%d pc=" INTPTR_FORMAT ", relative_pc=%d, method=%s" JVMCI_ONLY(", debug_id=%d"), trap_scope->bci(), fr.pc(), fr.pc() - nm->code_begin(), trap_scope->method()->name_and_sig_as_C_string() +#ifdef JVMCI , debug_id #endif ); @@ -1471,9 +1471,9 @@ methodHandle trap_method = trap_scope->method(); int trap_bci = trap_scope->bci(); -#ifdef GRAAL +#ifdef JVMCI oop speculation = thread->pending_failed_speculation(); - if (nm->is_compiled_by_graal()) { + if (nm->is_compiled_by_jvmci()) { if (speculation != NULL) { oop speculation_log = nm->speculation_log(); if (speculation_log != NULL) { @@ -1534,8 +1534,8 @@ bool create_if_missing = ProfileTraps RTM_OPT_ONLY( || UseRTMLocking ); methodHandle profiled_method; -#ifdef GRAAL - if (nm->is_compiled_by_graal()) { +#ifdef JVMCI + if (nm->is_compiled_by_jvmci()) { profiled_method = nm->method(); } else { profiled_method = trap_method; @@ -1604,29 +1604,29 @@ tty->print("Uncommon trap occurred in"); nm->method()->print_short_name(tty); tty->print(" compiler=%s compile_id=%d", nm->compiler() == NULL ? "" : nm->compiler()->name(), nm->compile_id()); -#ifdef GRAAL - oop installedCode = nm->graal_installed_code(); +#ifdef JVMCI + oop installedCode = nm->jvmci_installed_code(); if (installedCode != NULL) { oop installedCodeName = NULL; if (installedCode->is_a(InstalledCode::klass())) { installedCodeName = InstalledCode::name(installedCode); } if (installedCodeName != NULL) { - tty->print(" (Graal: installedCodeName=%s) ", java_lang_String::as_utf8_string(installedCodeName)); + tty->print(" (JVMCI: installedCodeName=%s) ", java_lang_String::as_utf8_string(installedCodeName)); } else { - tty->print(" (Graal: installed code has no name) "); + tty->print(" (JVMCI: installed code has no name) "); } - } else if (nm->is_compiled_by_graal()) { - tty->print(" (Graal: no installed code) "); + } else if (nm->is_compiled_by_jvmci()) { + tty->print(" (JVMCI: no installed code) "); } -#endif //GRAAL - tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" GRAAL_ONLY(" debug_id=%d"), +#endif //JVMCI + tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"), fr.pc(), os::current_thread_id(), trap_reason_name(reason), trap_action_name(action), unloaded_class_index -#ifdef GRAAL +#ifdef JVMCI , debug_id #endif ); @@ -1764,8 +1764,8 @@ bool maybe_prior_trap = false; bool maybe_prior_recompile = false; pdata = query_update_method_data(trap_mdo, trap_bci, reason, true, -#ifdef GRAAL - nm->is_compiled_by_graal() && nm->is_osr_method(), +#ifdef JVMCI + nm->is_compiled_by_jvmci() && nm->is_osr_method(), #endif nm->method(), //outputs: @@ -1913,7 +1913,7 @@ int trap_bci, Deoptimization::DeoptReason reason, bool update_total_trap_count, -#ifdef GRAAL +#ifdef JVMCI bool is_osr, #endif Method* compiled_method, @@ -1926,7 +1926,7 @@ uint this_trap_count = 0; if (update_total_trap_count) { uint idx = reason; -#ifdef GRAAL +#ifdef JVMCI if (is_osr) { idx += Reason_LIMIT; } @@ -2000,12 +2000,12 @@ bool ignore_maybe_prior_trap; bool ignore_maybe_prior_recompile; assert(!reason_is_speculate(reason), "reason speculate only used by compiler"); - // Graal uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts - bool update_total_counts = GRAAL_ONLY(false) NOT_GRAAL(true); + // JVMCI uses the total counts to determine if deoptimizations are happening too frequently -> do not adjust total counts + bool update_total_counts = JVMCI_ONLY(false) NOT_JVMCI(true); query_update_method_data(trap_mdo, trap_bci, (DeoptReason)reason, update_total_counts, -#ifdef GRAAL +#ifdef JVMCI false, #endif NULL, @@ -2124,12 +2124,12 @@ // Note: Keep this in sync. with enum DeoptReason. "none", "null_check", - "null_assert" GRAAL_ONLY("_or_unreached0"), + "null_assert" JVMCI_ONLY("_or_unreached0"), "range_check", "class_check", "array_check", - "intrinsic" GRAAL_ONLY("_or_type_checked_inlining"), - "bimorphic" GRAAL_ONLY("_or_optimized_type_check"), + "intrinsic" JVMCI_ONLY("_or_type_checked_inlining"), + "bimorphic" JVMCI_ONLY("_or_optimized_type_check"), "unloaded", "uninitialized", "unreached", @@ -2142,7 +2142,7 @@ "speculate_class_check", "rtm_state_change", "unstable_if" -#ifdef GRAAL +#ifdef JVMCI "aliasing", "transfer_to_interpreter", "not_compiled_exception_handler", @@ -2181,21 +2181,21 @@ jint unloaded_class_index = trap_request_index(trap_request); const char* reason = trap_reason_name(trap_request_reason(trap_request)); const char* action = trap_action_name(trap_request_action(trap_request)); -#ifdef GRAAL +#ifdef JVMCI int debug_id = trap_request_debug_id(trap_request); #endif size_t len; if (unloaded_class_index < 0) { - len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" GRAAL_ONLY(" debug_id='%d'"), + len = jio_snprintf(buf, buflen, "reason='%s' action='%s'" JVMCI_ONLY(" debug_id='%d'"), reason, action -#ifdef GRAAL +#ifdef JVMCI ,debug_id #endif ); } else { - len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" GRAAL_ONLY(" debug_id='%d'"), + len = jio_snprintf(buf, buflen, "reason='%s' action='%s' index='%d'" JVMCI_ONLY(" debug_id='%d'"), reason, action, unloaded_class_index -#ifdef GRAAL +#ifdef JVMCI ,debug_id #endif ); @@ -2295,7 +2295,7 @@ if (xtty != NULL) xtty->tail("statistics"); } } -#else // COMPILER2 || SHARK || GRAAL +#else // COMPILER2 || SHARK || JVMCI // Stubs for C1 only system. @@ -2331,4 +2331,4 @@ return buf; } -#endif // COMPILER2 || SHARK || GRAAL +#endif // COMPILER2 || SHARK || JVMCI
--- a/src/share/vm/runtime/deoptimization.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/deoptimization.hpp Thu May 28 15:36:48 2015 +0200 @@ -42,11 +42,11 @@ Reason_many = -1, // indicates presence of several reasons Reason_none = 0, // indicates absence of a relevant deopt. // Next 7 reasons are recorded per bytecode in DataLayout::trap_bits. - // This is more complicated for Graal as Graal may deoptimize to *some* bytecode before the - // bytecode that actually caused the deopt (with inlining, Graal may even deoptimize to a + // This is more complicated for JVMCI as JVMCI may deoptimize to *some* bytecode before the + // bytecode that actually caused the deopt (with inlining, JVMCI may even deoptimize to a // bytecode in another method): // - bytecode y in method b() causes deopt - // - Graal deoptimizes to bytecode x in method a() + // - JVMCI deoptimizes to bytecode x in method a() // -> the deopt reason will be recorded for method a() at bytecode x Reason_null_check, // saw unexpected null or zero divisor (@bci) Reason_null_assert, // saw unexpected non-null or non-zero (@bci) @@ -56,7 +56,7 @@ Reason_intrinsic, // saw unexpected operand to intrinsic (@bci) Reason_bimorphic, // saw unexpected object class in bimorphic inlining (@bci) -#ifdef GRAAL +#ifdef JVMCI Reason_unreached0 = Reason_null_assert, Reason_type_checked_inlining = Reason_intrinsic, Reason_optimized_type_check = Reason_bimorphic, @@ -75,7 +75,7 @@ Reason_speculate_class_check, // saw unexpected object class from type speculation Reason_rtm_state_change, // rtm state change detected Reason_unstable_if, // a branch predicted always false was taken -#ifdef GRAAL +#ifdef JVMCI Reason_aliasing, // optimistic assumption about aliasing failed Reason_transfer_to_interpreter, // explicit transferToInterpreter() Reason_not_compiled_exception_handler, @@ -138,8 +138,8 @@ // executing in a particular CodeBlob if UseBiasedLocking is enabled static void revoke_biases_of_monitors(CodeBlob* cb); -#if defined(COMPILER2) || defined(GRAAL) -GRAAL_ONLY(public:) +#if defined(COMPILER2) || defined(JVMCI) +JVMCI_ONLY(public:) // Support for restoring non-escaping objects static bool realloc_objects(JavaThread* thread, frame* fr, GrowableArray<ScopeValue*>* objects, TRAPS); @@ -149,7 +149,7 @@ static void relock_objects(GrowableArray<MonitorInfo*>* monitors, JavaThread* thread, bool realloc_failures); static void pop_frames_failed_reallocs(JavaThread* thread, vframeArray* array); NOT_PRODUCT(static void print_objects(GrowableArray<ScopeValue*>* objects, bool realloc_failures);) -#endif // COMPILER2 || GRAAL +#endif // COMPILER2 || JVMCI public: static vframeArray* create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk, bool realloc_failures); @@ -312,8 +312,8 @@ } static int make_trap_request(DeoptReason reason, DeoptAction action, int index = -1) { -#if defined(COMPILERGRAAL) && !defined(COMPILER1) && !defined(COMPILER2) - assert(index == -1, "Graal does not use index"); +#if defined(COMPILERJVMCI) && !defined(COMPILER1) && !defined(COMPILER2) + assert(index == -1, "JVMCI does not use index"); #endif assert((1 << _reason_bits) >= Reason_LIMIT, "enough bits"); @@ -395,7 +395,7 @@ int trap_bci, DeoptReason reason, bool update_total_trap_count, -#ifdef GRAAL +#ifdef JVMCI bool is_osr, #endif Method* compiled_method,
--- a/src/share/vm/runtime/frame.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/frame.cpp Thu May 28 15:36:48 2015 +0200 @@ -734,10 +734,10 @@ nm->compile_id(), (nm->is_osr_method() ? "%" : ""), ((nm->compiler() != NULL) ? nm->compiler()->name() : ""), buf, m->code_size(), _pc, _cb->code_begin(), _pc - _cb->code_begin()); -#ifdef GRAAL - char* graalName = nm->graal_installed_code_name(buf, buflen); - if (graalName != NULL) { - st->print(" (%s)", graalName); +#ifdef JVMCI + char* jvmciName = nm->jvmci_installed_code_name(buf, buflen); + if (jvmciName != NULL) { + st->print(" (%s)", jvmciName); } #endif } else {
--- a/src/share/vm/runtime/globals.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/globals.cpp Thu May 28 15:36:48 2015 +0200 @@ -38,8 +38,8 @@ #ifdef COMPILER1 #include "c1/c1_globals.hpp" #endif -#ifdef GRAAL -#include "graal/graalGlobals.hpp" +#ifdef JVMCI +#include "jvmci/jvmciGlobals.hpp" #endif #ifdef COMPILER2 #include "opto/c2_globals.hpp" @@ -358,7 +358,7 @@ Data data[] = { { KIND_C1, "C1" }, - { KIND_GRAAL, "Graal" }, + { KIND_JVMCI, "JVMCI" }, { KIND_C2, "C2" }, { KIND_ARCH, "ARCH" }, { KIND_SHARK, "SHARK" }, @@ -458,11 +458,11 @@ #define C1_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, #define C1_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C1 | Flag::KIND_NOT_PRODUCT) }, -#define GRAAL_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_GRAAL | Flag::KIND_PRODUCT) }, -#define GRAAL_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_GRAAL | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, -#define GRAAL_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_GRAAL | Flag::KIND_DEVELOP) }, -#define GRAAL_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_GRAAL | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, -#define GRAAL_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_GRAAL | Flag::KIND_NOT_PRODUCT) }, +#define JVMCI_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT) }, +#define JVMCI_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, +#define JVMCI_DEVELOP_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP) }, +#define JVMCI_PD_DEVELOP_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_DEVELOP | Flag::KIND_PLATFORM_DEPENDENT) }, +#define JVMCI_NOTPRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), NAME(name), NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_JVMCI | Flag::KIND_NOT_PRODUCT) }, #define C2_PRODUCT_FLAG_STRUCT( type, name, value, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT) }, #define C2_PD_PRODUCT_FLAG_STRUCT( type, name, doc) { #type, XSTR(name), &name, NOT_PRODUCT_ARG(doc) Flag::Flags(Flag::DEFAULT | Flag::KIND_C2 | Flag::KIND_PRODUCT | Flag::KIND_PLATFORM_DEPENDENT) }, @@ -494,8 +494,8 @@ #ifdef COMPILER1 C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, C1_PD_DEVELOP_FLAG_STRUCT, C1_PRODUCT_FLAG_STRUCT, C1_PD_PRODUCT_FLAG_STRUCT, C1_DIAGNOSTIC_FLAG_STRUCT, C1_NOTPRODUCT_FLAG_STRUCT) #endif -#ifdef GRAAL - GRAAL_FLAGS(GRAAL_DEVELOP_FLAG_STRUCT, GRAAL_PD_DEVELOP_FLAG_STRUCT, GRAAL_PRODUCT_FLAG_STRUCT, GRAAL_PD_PRODUCT_FLAG_STRUCT, GRAAL_NOTPRODUCT_FLAG_STRUCT) +#ifdef JVMCI + JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_STRUCT, JVMCI_PD_DEVELOP_FLAG_STRUCT, JVMCI_PRODUCT_FLAG_STRUCT, JVMCI_PD_PRODUCT_FLAG_STRUCT, JVMCI_NOTPRODUCT_FLAG_STRUCT) #endif #ifdef COMPILER2 C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, C2_PD_DEVELOP_FLAG_STRUCT, C2_PRODUCT_FLAG_STRUCT, C2_PD_PRODUCT_FLAG_STRUCT, C2_DIAGNOSTIC_FLAG_STRUCT, C2_EXPERIMENTAL_FLAG_STRUCT, C2_NOTPRODUCT_FLAG_STRUCT)
--- a/src/share/vm/runtime/globals.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/globals.hpp Thu May 28 15:36:48 2015 +0200 @@ -129,20 +129,20 @@ # include "c1_globals_bsd.hpp" #endif #endif -#ifdef COMPILERGRAAL +#ifdef COMPILERJVMCI #ifdef TARGET_ARCH_x86 -# include "graalGlobals_x86.hpp" +# include "jvmciGlobals_x86.hpp" #endif #ifdef TARGET_ARCH_sparc -# include "graalGlobals_sparc.hpp" +# include "jvmciGlobals_sparc.hpp" #endif #ifdef TARGET_ARCH_arm -# include "graalGlobals_arm.hpp" +# include "jvmciGlobals_arm.hpp" #endif #ifdef TARGET_ARCH_ppc -# include "graalGlobals_ppc.hpp" +# include "jvmciGlobals_ppc.hpp" #endif -#endif // COMPILERGRAAL +#endif // COMPILERJVMCI #ifdef COMPILER2 #ifdef TARGET_ARCH_x86 # include "c2_globals_x86.hpp" @@ -178,7 +178,7 @@ #endif #endif -#if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK) && !defined(COMPILERGRAAL) +#if !defined(COMPILER1) && !defined(COMPILER2) && !defined(SHARK) && !defined(COMPILERJVMCI) define_pd_global(bool, BackgroundCompilation, false); define_pd_global(bool, UseTLAB, false); define_pd_global(bool, CICompileOSR, false); @@ -210,7 +210,7 @@ #define CI_COMPILER_COUNT 0 #else -#if defined(COMPILER2) || defined(COMPILERGRAAL) +#if defined(COMPILER2) || defined(COMPILERJVMCI) #define CI_COMPILER_COUNT 2 #else #define CI_COMPILER_COUNT 1 @@ -253,7 +253,7 @@ KIND_SHARK = 1 << 15, KIND_LP64_PRODUCT = 1 << 16, KIND_COMMERCIAL = 1 << 17, - KIND_GRAAL = 1 << 18, + KIND_JVMCI = 1 << 18, KIND_MASK = ~VALUE_ORIGIN_MASK }; @@ -998,7 +998,7 @@ product(bool, PrintNMethodStatistics, false, \ "Print a summary statistic for the generated nmethods") \ \ - product(bool, ShareDebugInfo, IS_GRAAL_DEFINED, \ + product(bool, ShareDebugInfo, IS_JVMCI_DEFINED, \ "Always tries to share similar debug info inside a nmethod") \ \ diagnostic(bool, PrintNMethods, false, \ @@ -2713,11 +2713,11 @@ "Delay invoking the compiler until main application class is " \ "loaded") \ \ - NOT_GRAAL(develop(bool, CompileTheWorld, false, \ + NOT_JVMCI(develop(bool, CompileTheWorld, false, \ "Compile all methods in all classes in bootstrap class path " \ "(stress test)")) \ \ - GRAAL_ONLY(product(bool, CompileTheWorld, false, \ + JVMCI_ONLY(product(bool, CompileTheWorld, false, \ "Compile all methods in all classes in bootstrap class path " \ "(stress test)")) \ \
--- a/src/share/vm/runtime/globals_extension.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/globals_extension.hpp Thu May 28 15:36:48 2015 +0200 @@ -57,11 +57,11 @@ #define C1_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), #define C1_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), -#define GRAAL_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), -#define GRAAL_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), -#define GRAAL_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), -#define GRAAL_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), -#define GRAAL_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define JVMCI_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define JVMCI_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), +#define JVMCI_DEVELOP_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), +#define JVMCI_PD_DEVELOP_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), +#define JVMCI_NOTPRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_PRODUCT_FLAG_MEMBER(type, name, value, doc) FLAG_MEMBER(name), #define C2_PD_PRODUCT_FLAG_MEMBER(type, name, doc) FLAG_MEMBER(name), @@ -86,8 +86,8 @@ #ifdef COMPILER1 C1_FLAGS(C1_DEVELOP_FLAG_MEMBER, C1_PD_DEVELOP_FLAG_MEMBER, C1_PRODUCT_FLAG_MEMBER, C1_PD_PRODUCT_FLAG_MEMBER, C1_DIAGNOSTIC_FLAG_MEMBER, C1_NOTPRODUCT_FLAG_MEMBER) #endif -#ifdef GRAAL - GRAAL_FLAGS(GRAAL_DEVELOP_FLAG_MEMBER, GRAAL_PD_DEVELOP_FLAG_MEMBER, GRAAL_PRODUCT_FLAG_MEMBER, GRAAL_PD_PRODUCT_FLAG_MEMBER, GRAAL_NOTPRODUCT_FLAG_MEMBER) +#ifdef JVMCI + JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_MEMBER, JVMCI_PD_DEVELOP_FLAG_MEMBER, JVMCI_PRODUCT_FLAG_MEMBER, JVMCI_PD_PRODUCT_FLAG_MEMBER, JVMCI_NOTPRODUCT_FLAG_MEMBER) #endif #ifdef COMPILER2 C2_FLAGS(C2_DEVELOP_FLAG_MEMBER, C2_PD_DEVELOP_FLAG_MEMBER, C2_PRODUCT_FLAG_MEMBER, C2_PD_PRODUCT_FLAG_MEMBER, C2_DIAGNOSTIC_FLAG_MEMBER, C2_EXPERIMENTAL_FLAG_MEMBER, C2_NOTPRODUCT_FLAG_MEMBER) @@ -118,11 +118,11 @@ #define C1_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), #define C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), -#define GRAAL_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), -#define GRAAL_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), -#define GRAAL_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), -#define GRAAL_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), -#define GRAAL_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define JVMCI_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define JVMCI_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define JVMCI_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define JVMCI_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE(type, name, doc) FLAG_MEMBER_WITH_TYPE(name,type), +#define JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), #ifdef _LP64 #define RUNTIME_LP64_PRODUCT_FLAG_MEMBER_WITH_TYPE(type, name, value, doc) FLAG_MEMBER_WITH_TYPE(name,type), @@ -180,12 +180,12 @@ C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE) #endif -#ifdef GRAAL - GRAAL_FLAGS(GRAAL_DEVELOP_FLAG_MEMBER_WITH_TYPE, - GRAAL_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE, - GRAAL_PRODUCT_FLAG_MEMBER_WITH_TYPE, - GRAAL_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, - GRAAL_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE) +#ifdef JVMCI + JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_MEMBER_WITH_TYPE, + JVMCI_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE, + JVMCI_PRODUCT_FLAG_MEMBER_WITH_TYPE, + JVMCI_PD_PRODUCT_FLAG_MEMBER_WITH_TYPE, + JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE) #endif #ifdef COMPILER2 C2_FLAGS(C2_DEVELOP_FLAG_MEMBER_WITH_TYPE,
--- a/src/share/vm/runtime/java.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/java.cpp Thu May 28 15:36:48 2015 +0200 @@ -30,9 +30,9 @@ #include "compiler/compileBroker.hpp" #include "compiler/compilerOracle.hpp" #include "interpreter/bytecodeHistogram.hpp" -#ifdef GRAAL -#include "graal/graalCompiler.hpp" -#include "graal/graalRuntime.hpp" +#ifdef JVMCI +#include "jvmci/jvmciCompiler.hpp" +#include "jvmci/jvmciRuntime.hpp" #endif #include "memory/genCollectedHeap.hpp" #include "memory/oopFactory.hpp" @@ -490,8 +490,8 @@ } } -#ifdef GRAAL - GraalRuntime::shutdown(); +#ifdef JVMCI + JVMCIRuntime::shutdown(); #endif // The only difference between this and Win32's _onexit procs is that
--- a/src/share/vm/runtime/javaCalls.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/javaCalls.cpp Thu May 28 15:36:48 2015 +0200 @@ -40,9 +40,9 @@ #include "runtime/signature.hpp" #include "runtime/stubRoutines.hpp" #include "runtime/thread.inline.hpp" -#ifdef GRAAL -#include "graal/graalJavaAccess.hpp" -#include "graal/graalRuntime.hpp" +#ifdef JVMCI +#include "jvmci/jvmciJavaAccess.hpp" +#include "jvmci/jvmciRuntime.hpp" #endif // ----------------------------------------------------- @@ -343,7 +343,7 @@ CHECK_UNHANDLED_OOPS_ONLY(thread->clear_unhandled_oops();) -#ifdef GRAAL +#ifdef JVMCI nmethod* nm = args->alternative_target(); if (nm == NULL) { #endif @@ -353,7 +353,7 @@ args->verify(method, result->get_type(), thread); } else debug_only(args->verify(method, result->get_type(), thread)); -#ifdef GRAAL +#ifdef JVMCI } #else @@ -418,10 +418,10 @@ os::bang_stack_shadow_pages(); } -#ifdef GRAAL +#ifdef JVMCI if (nm != NULL) { if (nm->is_alive()) { - ((JavaThread*) THREAD)->set_graal_alternate_call_target(nm->verified_entry_point()); + ((JavaThread*) THREAD)->set_jvmci_alternate_call_target(nm->verified_entry_point()); entry_point = method->adapter()->get_i2c_entry(); } else { THROW(vmSymbols::com_oracle_jvmci_code_InvalidInstalledCodeException());
--- a/src/share/vm/runtime/javaCalls.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/javaCalls.hpp Thu May 28 15:36:48 2015 +0200 @@ -100,7 +100,7 @@ int _size; int _max_size; bool _start_at_zero; // Support late setting of receiver -#ifdef GRAAL +#ifdef JVMCI nmethod* _alternative_target; // Nmethod that should be called instead of normal target #endif @@ -112,7 +112,7 @@ _max_size = _default_size; _size = 0; _start_at_zero = false; - GRAAL_ONLY(_alternative_target = NULL;) + JVMCI_ONLY(_alternative_target = NULL;) } public: @@ -134,13 +134,13 @@ _max_size = max_size; _size = 0; _start_at_zero = false; - GRAAL_ONLY(_alternative_target = NULL;) + JVMCI_ONLY(_alternative_target = NULL;) } else { initialize(); } } -#ifdef GRAAL +#ifdef JVMCI void set_alternative_target(nmethod* target) { _alternative_target = target; }
--- a/src/share/vm/runtime/os.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/os.cpp Thu May 28 15:36:48 2015 +0200 @@ -1189,8 +1189,8 @@ "%/lib/jce.jar:" "%/lib/charsets.jar:" "%/lib/jfr.jar:" -#ifdef GRAAL - "%/lib/graal-loader.jar:" +#ifdef JVMCI + "%/lib/jvmci-loader.jar:" #endif #ifndef NO_TRUFFLE_JAR "%/lib/truffle.jar:"
--- a/src/share/vm/runtime/os.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/os.hpp Thu May 28 15:36:48 2015 +0200 @@ -104,7 +104,7 @@ class os: AllStatic { friend class VMStructs; friend class MallocTracker; -#ifdef GRAAL +#ifdef JVMCI friend class Arguments; // need access to format_boot_path #endif
--- a/src/share/vm/runtime/rframe.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/rframe.cpp Thu May 28 15:36:48 2015 +0200 @@ -152,7 +152,7 @@ void RFrame::print(const char* kind) { #ifndef PRODUCT -#if defined(COMPILER2) || defined(GRAAL) +#if defined(COMPILER2) || defined(JVMCI) int cnt = top_method()->interpreter_invocation_count(); #else int cnt = top_method()->invocation_count();
--- a/src/share/vm/runtime/sharedRuntime.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/sharedRuntime.cpp Thu May 28 15:36:48 2015 +0200 @@ -111,8 +111,8 @@ _resolve_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_virtual_call_C), "resolve_virtual_call"); _resolve_static_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_static_call_C), "resolve_static_call"); -#if defined(COMPILER2) || defined(GRAAL) - // Vectors are generated only by C2 and Graal. +#if defined(COMPILER2) || defined(JVMCI) + // Vectors are generated only by C2 and JVMCI. bool support_wide = is_wide_vector(MaxVectorSize); if (support_wide) { _polling_page_vectors_safepoint_handler_blob = generate_handler_blob(CAST_FROM_FN_PTR(address, SafepointSynchronize::handle_polling_page_exception), POLL_AT_VECTOR_LOOP); @@ -488,8 +488,8 @@ // Reset method handle flag. thread->set_is_method_handle_return(false); -#ifdef GRAAL - // Graal's ExceptionHandlerStub expects the thread local exception PC to be clear +#ifdef JVMCI + // JVMCI's ExceptionHandlerStub expects the thread local exception PC to be clear // and other exception handler continuations do not read it thread->set_exception_pc(NULL); #endif @@ -650,8 +650,8 @@ assert(nm != NULL, "must exist"); ResourceMark rm; -#ifdef GRAAL - if (nm->is_compiled_by_graal()) { +#ifdef JVMCI + if (nm->is_compiled_by_jvmci()) { // lookup exception handler for this pc int catch_pco = ret_pc - nm->code_begin(); ExceptionHandlerTable table(nm); @@ -795,10 +795,10 @@ throw_and_post_jvmti_exception(thread, exception); JRT_END -#ifdef GRAAL +#ifdef JVMCI address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, nmethod* nm, int deopt_reason) { assert(deopt_reason > Deoptimization::Reason_none && deopt_reason < Deoptimization::Reason_LIMIT, "invalid deopt reason"); - thread->set_graal_implicit_exception_pc(pc); + thread->set_jvmci_implicit_exception_pc(pc); thread->set_pending_deoptimization(Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret)); return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); } @@ -901,8 +901,8 @@ #ifndef PRODUCT _implicit_null_throws++; #endif -#ifdef GRAAL - if (nm->is_compiled_by_graal() && nm->pc_desc_at(pc) != NULL) { +#ifdef JVMCI + if (nm->is_compiled_by_jvmci() && nm->pc_desc_at(pc) != NULL) { // If there's no PcDesc then we'll die way down inside of // deopt instead of just getting normal error reporting, // so only go there if it will succeed. @@ -910,7 +910,7 @@ } else { #endif target_pc = nm->continuation_for_implicit_exception(pc); -#ifdef GRAAL +#ifdef JVMCI } #endif // If there's an unexpected fault, target_pc might be NULL, @@ -928,13 +928,13 @@ #ifndef PRODUCT _implicit_div0_throws++; #endif -#ifdef GRAAL - if (nm->is_compiled_by_graal() && nm->pc_desc_at(pc) != NULL) { +#ifdef JVMCI + if (nm->is_compiled_by_jvmci() && nm->pc_desc_at(pc) != NULL) { return deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_div0_check); } else { #endif target_pc = nm->continuation_for_implicit_exception(pc); -#ifdef GRAAL +#ifdef JVMCI } #endif // If there's an unexpected fault, target_pc might be NULL, @@ -1013,7 +1013,7 @@ JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* thread, oopDesc* obj)) -#ifdef GRAAL +#ifdef JVMCI if (!obj->klass()->has_finalizer()) { return; }
--- a/src/share/vm/runtime/sharedRuntime.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/sharedRuntime.hpp Thu May 28 15:36:48 2015 +0200 @@ -193,7 +193,7 @@ static address continuation_for_implicit_exception(JavaThread* thread, address faulting_pc, ImplicitExceptionKind exception_kind); -#ifdef GRAAL +#ifdef JVMCI static address deoptimize_for_implicit_exception(JavaThread* thread, address pc, nmethod* nm, int deopt_reason); #endif
--- a/src/share/vm/runtime/simpleThresholdPolicy.inline.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/simpleThresholdPolicy.inline.hpp Thu May 28 15:36:48 2015 +0200 @@ -58,10 +58,10 @@ method->is_constant_getter()) { return true; } -#ifdef COMPILERGRAAL - if (TieredCompilation && GraalCompileWithC1Only && - SystemDictionary::graal_loader() != NULL && - method->method_holder()->class_loader() == SystemDictionary::graal_loader()) { +#ifdef COMPILERJVMCI + if (TieredCompilation && JVMCICompileWithC1Only && + SystemDictionary::jvmci_loader() != NULL && + method->method_holder()->class_loader() == SystemDictionary::jvmci_loader()) { return true; } #endif
--- a/src/share/vm/runtime/sweeper.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/sweeper.cpp Thu May 28 15:36:48 2015 +0200 @@ -241,7 +241,7 @@ void NMethodSweeper::possibly_sweep() { assert(JavaThread::current()->thread_state() == _thread_in_vm, "must run in vm mode"); // Only compiler threads are allowed to sweep - if (!MethodFlushing || !sweep_in_progress() NOT_GRAAL(|| !Thread::current()->is_Compiler_thread()) GRAAL_ONLY(|| !Thread::current()->is_Java_thread())) { + if (!MethodFlushing || !sweep_in_progress() NOT_JVMCI(|| !Thread::current()->is_Compiler_thread()) JVMCI_ONLY(|| !Thread::current()->is_Java_thread())) { return; } @@ -458,14 +458,14 @@ class NMethodMarker: public StackObj { private: -#ifdef GRAAL +#ifdef JVMCI JavaThread* _thread; #else CompilerThread* _thread; #endif public: NMethodMarker(nmethod* nm) { -#ifdef GRAAL +#ifdef JVMCI _thread = JavaThread::current(); #else _thread = CompilerThread::current();
--- a/src/share/vm/runtime/thread.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/thread.cpp Thu May 28 15:36:48 2015 +0200 @@ -29,9 +29,9 @@ #include "classfile/vmSymbols.hpp" #include "code/scopeDesc.hpp" #include "compiler/compileBroker.hpp" -#ifdef GRAAL -#include "graal/graalCompiler.hpp" -#include "graal/graalRuntime.hpp" +#ifdef JVMCI +#include "jvmci/jvmciCompiler.hpp" +#include "jvmci/jvmciRuntime.hpp" #endif #include "interpreter/interpreter.hpp" #include "interpreter/linkResolver.hpp" @@ -843,7 +843,7 @@ active_handles()->oops_do(f); // Do oop for ThreadShadow f->do_oop((oop*)&_pending_exception); -#ifdef GRAAL +#ifdef JVMCI f->do_oop((oop*)&_pending_failed_speculation); #endif handle_area()->oops_do(f); @@ -1426,32 +1426,32 @@ // ======= JavaThread ======== -#ifdef GRAAL - -jlong* JavaThread::_graal_old_thread_counters; - -bool graal_counters_include(JavaThread* thread) { +#ifdef JVMCI + +jlong* JavaThread::_jvmci_old_thread_counters; + +bool jvmci_counters_include(JavaThread* thread) { oop threadObj = thread->threadObj(); - return !GraalCountersExcludeCompiler || !thread->is_Compiler_thread(); + return !JVMCICountersExcludeCompiler || !thread->is_Compiler_thread(); } void JavaThread::collect_counters(typeArrayOop array) { - if (GraalCounterSize > 0) { + if (JVMCICounterSize > 0) { MutexLocker tl(Threads_lock); for (int i = 0; i < array->length(); i++) { - array->long_at_put(i, _graal_old_thread_counters[i]); + array->long_at_put(i, _jvmci_old_thread_counters[i]); } for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { - if (graal_counters_include(tp)) { + if (jvmci_counters_include(tp)) { for (int i = 0; i < array->length(); i++) { - array->long_at_put(i, array->long_at(i) + tp->_graal_counters[i]); + array->long_at_put(i, array->long_at(i) + tp->_jvmci_counters[i]); } } } } } -#endif // GRAAL +#endif // JVMCI // A JavaThread is a normal Java thread @@ -1486,16 +1486,16 @@ _in_deopt_handler = 0; _doing_unsafe_access = false; _stack_guard_state = stack_guard_unused; -#ifdef GRAAL - _graal_alternate_call_target = NULL; - _graal_implicit_exception_pc = NULL; - if (GraalCounterSize > 0) { - _graal_counters = NEW_C_HEAP_ARRAY(jlong, GraalCounterSize, mtInternal); - memset(_graal_counters, 0, sizeof(jlong) * GraalCounterSize); +#ifdef JVMCI + _jvmci_alternate_call_target = NULL; + _jvmci_implicit_exception_pc = NULL; + if (JVMCICounterSize > 0) { + _jvmci_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); + memset(_jvmci_counters, 0, sizeof(jlong) * JVMCICounterSize); } else { - _graal_counters = NULL; + _jvmci_counters = NULL; } -#endif // GRAAL +#endif // JVMCI (void)const_cast<oop&>(_exception_oop = NULL); _exception_pc = 0; _exception_handler_pc = 0; @@ -1676,16 +1676,16 @@ if (_thread_profiler != NULL) delete _thread_profiler; if (_thread_stat != NULL) delete _thread_stat; -#ifdef GRAAL - if (GraalCounterSize > 0) { - if (graal_counters_include(this)) { - for (int i = 0; i < GraalCounterSize; i++) { - _graal_old_thread_counters[i] += _graal_counters[i]; +#ifdef JVMCI + if (JVMCICounterSize > 0) { + if (jvmci_counters_include(this)) { + for (int i = 0; i < JVMCICounterSize; i++) { + _jvmci_old_thread_counters[i] += _jvmci_counters[i]; } } - FREE_C_HEAP_ARRAY(jlong, _graal_counters, mtInternal); + FREE_C_HEAP_ARRAY(jlong, _jvmci_counters, mtInternal); } -#endif // GRAAL +#endif // JVMCI } @@ -3304,9 +3304,9 @@ #endif } -#ifdef COMPILERGRAAL +#ifdef COMPILERJVMCI bool CompilerThread::can_call_java() const { - return _compiler != NULL && _compiler->is_graal(); + return _compiler != NULL && _compiler->is_jvmci(); } #endif @@ -3449,14 +3449,14 @@ // Initialize global data structures and create system classes in heap vm_init_globals(); -#ifdef GRAAL - if (GraalCounterSize > 0) { - JavaThread::_graal_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, GraalCounterSize, mtInternal); - memset(JavaThread::_graal_old_thread_counters, 0, sizeof(jlong) * GraalCounterSize); +#ifdef JVMCI + if (JVMCICounterSize > 0) { + JavaThread::_jvmci_old_thread_counters = NEW_C_HEAP_ARRAY(jlong, JVMCICounterSize, mtInternal); + memset(JavaThread::_jvmci_old_thread_counters, 0, sizeof(jlong) * JVMCICounterSize); } else { - JavaThread::_graal_old_thread_counters = NULL; + JavaThread::_jvmci_old_thread_counters = NULL; } -#endif // GRAAL +#endif // JVMCI // Attach the main thread to this os thread JavaThread* main_thread = new JavaThread(); @@ -3702,8 +3702,8 @@ Chunk::start_chunk_pool_cleaner_task(); } -#ifdef GRAAL - status = GraalRuntime::check_arguments(main_thread); +#ifdef JVMCI + status = JVMCIRuntime::check_arguments(main_thread); if (status != JNI_OK) { *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again return status; @@ -3711,7 +3711,7 @@ #endif // initialize compiler(s) -#if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(COMPILERGRAAL) +#if defined(COMPILER1) || defined(COMPILER2) || defined(SHARK) || defined(COMPILERJVMCI) CompileBroker::compilation_init(); #endif @@ -4129,11 +4129,11 @@ delete thread; -#ifdef GRAAL - if (GraalCounterSize > 0) { - FREE_C_HEAP_ARRAY(jlong, JavaThread::_graal_old_thread_counters, mtInternal); +#ifdef JVMCI + if (JVMCICounterSize > 0) { + FREE_C_HEAP_ARRAY(jlong, JavaThread::_jvmci_old_thread_counters, mtInternal); } -#endif // GRAAL +#endif // JVMCI // exit_globals() will delete tty exit_globals();
--- a/src/share/vm/runtime/thread.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/thread.hpp Thu May 28 15:36:48 2015 +0200 @@ -916,17 +916,17 @@ private: -#ifdef GRAAL - address _graal_alternate_call_target; - address _graal_implicit_exception_pc; // pc at which the most recent implicit exception occurred +#ifdef JVMCI + address _jvmci_alternate_call_target; + address _jvmci_implicit_exception_pc; // pc at which the most recent implicit exception occurred - jlong* _graal_counters; + jlong* _jvmci_counters; public: - static jlong* _graal_old_thread_counters; + static jlong* _jvmci_old_thread_counters; static void collect_counters(typeArrayOop array); private: -#endif // GRAAL +#endif // JVMCI nmethod* _scanned_nmethod; // nmethod being scanned by the sweeper @@ -1301,9 +1301,9 @@ MemRegion deferred_card_mark() const { return _deferred_card_mark; } void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; } -#ifdef GRAAL - void set_graal_alternate_call_target(address a) { _graal_alternate_call_target = a; } - void set_graal_implicit_exception_pc(address a) { _graal_implicit_exception_pc = a; } +#ifdef JVMCI + void set_jvmci_alternate_call_target(address a) { _jvmci_alternate_call_target = a; } + void set_jvmci_implicit_exception_pc(address a) { _jvmci_implicit_exception_pc = a; } #endif // Exception handling for compiled methods @@ -1399,11 +1399,11 @@ static ByteSize thread_state_offset() { return byte_offset_of(JavaThread, _thread_state ); } static ByteSize saved_exception_pc_offset() { return byte_offset_of(JavaThread, _saved_exception_pc ); } static ByteSize osthread_offset() { return byte_offset_of(JavaThread, _osthread ); } -#ifdef GRAAL - static ByteSize graal_alternate_call_target_offset() { return byte_offset_of(JavaThread, _graal_alternate_call_target); } - static ByteSize graal_implicit_exception_pc_offset() { return byte_offset_of(JavaThread, _graal_implicit_exception_pc); } - static ByteSize graal_counters_offset() { return byte_offset_of(JavaThread, _graal_counters ); } -#endif // GRAAL +#ifdef JVMCI + static ByteSize jvmci_alternate_call_target_offset() { return byte_offset_of(JavaThread, _jvmci_alternate_call_target); } + static ByteSize jvmci_implicit_exception_pc_offset() { return byte_offset_of(JavaThread, _jvmci_implicit_exception_pc); } + static ByteSize jvmci_counters_offset() { return byte_offset_of(JavaThread, _jvmci_counters ); } +#endif // JVMCI static ByteSize exception_oop_offset() { return byte_offset_of(JavaThread, _exception_oop ); } static ByteSize exception_pc_offset() { return byte_offset_of(JavaThread, _exception_pc ); } static ByteSize exception_handler_pc_offset() { return byte_offset_of(JavaThread, _exception_handler_pc); } @@ -1875,7 +1875,7 @@ bool is_Compiler_thread() const { return true; } -#ifdef COMPILERGRAAL +#ifdef COMPILERJVMCI virtual bool can_call_java() const; #else virtual bool can_call_java() const { return false; }
--- a/src/share/vm/runtime/vframe.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/vframe.cpp Thu May 28 15:36:48 2015 +0200 @@ -357,7 +357,7 @@ InterpreterOopMap oop_mask; // oopmap for current bci - if ((TraceDeoptimization && Verbose) GRAAL_ONLY( || PrintDeoptimizationDetails)) { + if ((TraceDeoptimization && Verbose) JVMCI_ONLY( || PrintDeoptimizationDetails)) { methodHandle m_h(Thread::current(), method()); OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); } else {
--- a/src/share/vm/runtime/vmStructs.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/vmStructs.cpp Thu May 28 15:36:48 2015 +0200 @@ -70,7 +70,7 @@ #include "oops/constMethod.hpp" #include "oops/constantPool.hpp" #include "oops/cpCache.hpp" -#ifdef GRAAL +#ifdef JVMCI #include "oops/fieldStreams.hpp" #endif #include "oops/instanceClassLoaderKlass.hpp" @@ -106,9 +106,9 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/hashtable.hpp" #include "utilities/macros.hpp" -#ifdef GRAAL -# include "graal/graalRuntime.hpp" -# include "graal/vmStructs_graal.hpp" +#ifdef JVMCI +# include "jvmci/jvmciRuntime.hpp" +# include "jvmci/vmStructs_jvmci.hpp" #endif #ifdef TARGET_ARCH_x86 # include "vmStructs_x86.hpp" @@ -3030,8 +3030,8 @@ GENERATE_C1_UNCHECKED_STATIC_VM_STRUCT_ENTRY, GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY) -#ifdef GRAAL - VM_STRUCTS_GRAAL(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, +#ifdef JVMCI + VM_STRUCTS_JVMCI(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, GENERATE_STATIC_VM_STRUCT_ENTRY) #endif @@ -3079,8 +3079,8 @@ GENERATE_C2_VM_TYPE_ENTRY, GENERATE_C2_TOPLEVEL_VM_TYPE_ENTRY) -#ifdef GRAAL - VM_TYPES_GRAAL(GENERATE_VM_TYPE_ENTRY, +#ifdef JVMCI + VM_TYPES_JVMCI(GENERATE_VM_TYPE_ENTRY, GENERATE_TOPLEVEL_VM_TYPE_ENTRY) #endif @@ -3126,8 +3126,8 @@ GENERATE_C2_VM_INT_CONSTANT_ENTRY, GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) -#ifdef GRAAL - VM_INT_CONSTANTS_GRAAL(GENERATE_VM_INT_CONSTANT_ENTRY, +#ifdef JVMCI + VM_INT_CONSTANTS_JVMCI(GENERATE_VM_INT_CONSTANT_ENTRY, GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY) #endif @@ -3478,7 +3478,7 @@ #endif -#ifdef GRAAL +#ifdef JVMCI // Emit intialization code for HotSpotVMConfig. It's placed here so // it can take advantage of the relaxed access checking enjoyed by // VMStructs.
--- a/src/share/vm/runtime/vmStructs.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/vmStructs.hpp Thu May 28 15:36:48 2015 +0200 @@ -126,7 +126,7 @@ static void test(); #endif -#ifdef GRAAL +#ifdef JVMCI // The definition of this method is generated by // com.oracle.jvmci.hotspotvmconfig.HotSpotVMConfigProcessor. static void initHotSpotVMConfig(oop config);
--- a/src/share/vm/runtime/vm_version.cpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/runtime/vm_version.cpp Thu May 28 15:36:48 2015 +0200 @@ -112,11 +112,11 @@ #ifndef VMTYPE #ifdef TIERED - #ifdef COMPILERGRAAL - #define VMTYPE "Graal" - #else // COMPILERGRAAL + #ifdef COMPILERJVMCI + #define VMTYPE "JVMCI" + #else // COMPILERJVMCI #define VMTYPE "Server" - #endif // COMPILERGRAAL + #endif // COMPILERJVMCI #else // TIERED #ifdef ZERO #ifdef SHARK @@ -127,7 +127,7 @@ #else // ZERO #define VMTYPE COMPILER1_PRESENT("Client") \ COMPILER2_PRESENT("Server") \ - COMPILERGRAAL_PRESENT("Graal") + COMPILERJVMCI_PRESENT("JVMCI") #endif // ZERO #endif // TIERED #endif
--- a/src/share/vm/utilities/exceptions.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/utilities/exceptions.hpp Thu May 28 15:36:48 2015 +0200 @@ -61,7 +61,7 @@ friend class VMStructs; protected: -#ifdef GRAAL +#ifdef JVMCI int _pending_deoptimization; oop _pending_failed_speculation; bool _pending_monitorenter; @@ -85,7 +85,7 @@ bool has_pending_exception() const { return _pending_exception != NULL; } const char* exception_file() const { return _exception_file; } int exception_line() const { return _exception_line; } -#ifdef GRAAL +#ifdef JVMCI int pending_deoptimization() const { return _pending_deoptimization; } oop pending_failed_speculation() const { return _pending_failed_speculation; } bool has_pending_monitorenter() const { return _pending_monitorenter; } @@ -93,7 +93,7 @@ // Code generation support static ByteSize pending_exception_offset() { return byte_offset_of(ThreadShadow, _pending_exception); } -#ifdef GRAAL +#ifdef JVMCI static ByteSize pending_deoptimization_offset() { return byte_offset_of(ThreadShadow, _pending_deoptimization); } static ByteSize pending_monitorenter_offset() { return byte_offset_of(ThreadShadow, _pending_monitorenter); } static ByteSize pending_failed_speculation_offset() { return byte_offset_of(ThreadShadow, _pending_failed_speculation); } @@ -112,7 +112,7 @@ ThreadShadow() : _pending_exception(NULL), _exception_file(NULL), _exception_line(0) -#ifdef GRAAL +#ifdef JVMCI , _pending_monitorenter(false), _pending_deoptimization(-1), _pending_failed_speculation(NULL), _pending_transfer_to_interpreter(false) #endif {}
--- a/src/share/vm/utilities/globalDefinitions.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/utilities/globalDefinitions.hpp Thu May 28 15:36:48 2015 +0200 @@ -894,20 +894,20 @@ CompLevel_simple = 1, // C1 CompLevel_limited_profile = 2, // C1, invocation & backedge counters CompLevel_full_profile = 3, // C1, invocation & backedge counters + mdo - CompLevel_full_optimization = 4, // C2, Shark or Graal + CompLevel_full_optimization = 4, // C2, Shark or JVMCI -#if defined(COMPILER2) || defined(SHARK) || defined(COMPILERGRAAL) - CompLevel_highest_tier = CompLevel_full_optimization, // pure C2 and tiered or Graal and tiered +#if defined(COMPILER2) || defined(SHARK) || defined(COMPILERJVMCI) + CompLevel_highest_tier = CompLevel_full_optimization, // pure C2 and tiered or JVMCI and tiered #elif defined(COMPILER1) - CompLevel_highest_tier = CompLevel_simple, // pure C1 or Graal + CompLevel_highest_tier = CompLevel_simple, // pure C1 or JVMCI #else CompLevel_highest_tier = CompLevel_none, #endif #if defined(TIERED) CompLevel_initial_compile = CompLevel_full_profile // tiered -#elif defined(COMPILER1) || defined(COMPILERGRAAL) - CompLevel_initial_compile = CompLevel_simple // pure C1 or Graal +#elif defined(COMPILER1) || defined(COMPILERJVMCI) + CompLevel_initial_compile = CompLevel_simple // pure C1 or JVMCI #elif defined(COMPILER2) || defined(SHARK) CompLevel_initial_compile = CompLevel_full_optimization // pure C2 #else
--- a/src/share/vm/utilities/macros.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/utilities/macros.hpp Thu May 28 15:36:48 2015 +0200 @@ -166,7 +166,7 @@ // COMPILER1 variant #ifdef COMPILER1 -#if defined(COMPILER2) || defined(COMPILERGRAAL) +#if defined(COMPILER2) || defined(COMPILERJVMCI) #define TIERED #endif #define COMPILER1_PRESENT(code) code @@ -183,27 +183,27 @@ #define NOT_COMPILER2(code) code #endif // COMPILER2 -#ifdef COMPILERGRAAL -#define COMPILERGRAAL_PRESENT(code) code -#define NOT_COMPILERGRAAL(code) -#else // COMPILERGRAAL -#define COMPILERGRAAL_PRESENT(code) -#define NOT_COMPILERGRAAL(code) code -#endif // COMPILERGRAAL +#ifdef COMPILERJVMCI +#define COMPILERJVMCI_PRESENT(code) code +#define NOT_COMPILERJVMCI(code) +#else // COMPILERJVMCI +#define COMPILERJVMCI_PRESENT(code) +#define NOT_COMPILERJVMCI(code) code +#endif // COMPILERJVMCI -#if defined(COMPILERGRAAL) && !defined(GRAAL) -#error "COMPILERGRAAL needs GRAAL to be defined" +#if defined(COMPILERJVMCI) && !defined(JVMCI) +#error "COMPILERJVMCI needs JVMCI to be defined" #endif -#ifdef GRAAL -#define GRAAL_ONLY(code) code -#define NOT_GRAAL(code) -#define IS_GRAAL_DEFINED true -#else // GRAAL -#define GRAAL_ONLY(code) -#define NOT_GRAAL(code) code -#define IS_GRAAL_DEFINED false -#endif // GRAAL +#ifdef JVMCI +#define JVMCI_ONLY(code) code +#define NOT_JVMCI(code) +#define IS_JVMCI_DEFINED true +#else // JVMCI +#define JVMCI_ONLY(code) +#define NOT_JVMCI(code) code +#define IS_JVMCI_DEFINED false +#endif // JVMCI #ifdef TIERED #define TIERED_ONLY(code) code
--- a/src/share/vm/utilities/top.hpp Wed May 27 13:43:27 2015 +0200 +++ b/src/share/vm/utilities/top.hpp Thu May 28 15:36:48 2015 +0200 @@ -42,8 +42,8 @@ #ifdef COMPILER2 #include "opto/c2_globals.hpp" #endif -#ifdef GRAAL -#include "graal/graalGlobals.hpp" +#ifdef JVMCI +#include "jvmci/jvmciGlobals.hpp" #endif // THIS FILE IS INTESIONALLY LEFT EMPTY