# HG changeset patch # User Doug Simon # Date 1432329980 -7200 # Node ID 07b088d61d5dea01722f8fb7d3ae0fd0427fbc97 # Parent 1da7aef31a08653ea26a95f49c94d7d62439f860 added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53) diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java --- a/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/Graal.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -22,42 +22,50 @@ */ package com.oracle.graal.api.runtime; +import java.util.*; + import sun.reflect.*; +/** + * Access point for {@linkplain #getRuntime() retrieving} the single {@link GraalRuntime} instance. + */ public class Graal { - private static final GraalRuntime runtime; + private static final GraalRuntime runtime = initializeRuntime(); - private static native GraalRuntime initializeRuntime(); + private static GraalRuntime initializeRuntime() { + for (GraalRuntimeFactory factory : Services.load(GraalRuntimeFactory.class)) { + return factory.getRuntime(); + } + return new InvalidGraalRuntime(); + } + /** + * Gets the singleton {@link GraalRuntime} instance available to the application. + */ public static GraalRuntime getRuntime() { return runtime; } - static { - GraalRuntime rt; - try { - rt = initializeRuntime(); - } catch (UnsatisfiedLinkError e) { - rt = new InvalidGraalRuntime(); - } - runtime = rt; - } - + /** + * Gets a capability provided by the {@link GraalRuntime} instance available to the application. + * + * @throws UnsupportedOperationException if the capability is not available + */ @CallerSensitive public static T getRequiredCapability(Class clazz) { T t = getRuntime().getCapability(clazz); if (t == null) { String javaHome = System.getProperty("java.home"); String vmName = System.getProperty("java.vm.name"); - StringBuilder errorMessage = new StringBuilder(); + Formatter errorMessage = new Formatter(); if (runtime.getClass() == InvalidGraalRuntime.class) { - errorMessage.append(String.format("The VM does not support the Graal API.\n")); + errorMessage.format("The VM does not support the Graal API.%n"); } else { - errorMessage.append(String.format("The VM does not expose required Graal capability %s.\n", clazz.getName())); + errorMessage.format("The VM does not expose required Graal capability %s.%n", clazz.getName()); } - errorMessage.append(String.format("Currently used Java home directory is %s.\n", javaHome)); - errorMessage.append(String.format("Currently used VM configuration is: %s", vmName)); + errorMessage.format("Currently used Java home directory is %s.%n", javaHome); + errorMessage.format("Currently used VM configuration is: %s", vmName); throw new UnsupportedOperationException(errorMessage.toString()); } return t; diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/GraalRuntimeFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.runtime/src/com/oracle/graal/api/runtime/GraalRuntimeFactory.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.runtime; + +public interface GraalRuntimeFactory extends Service { + + GraalRuntime getRuntime(); +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -64,6 +64,14 @@ return providers.getCodeCache(); } + public MetaAccessProvider getMetaAccess() { + return providers.getMetaAccess(); + } + + public ConstantReflectionProvider getConstantReflection() { + return providers.getConstantReflection(); + } + public ForeignCallsProvider getForeignCalls() { return providers.getForeignCalls(); } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot.amd64/src/META-INF/services/com.oracle.graal.hotspot.jvmci.HotSpotJVMCIBackendFactory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.amd64/src/META-INF/services/com.oracle.graal.hotspot.jvmci.HotSpotJVMCIBackendFactory Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,1 @@ +com.oracle.graal.hotspot.amd64.jvmci.AMD64HotSpotJVMCIBackendFactory diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -22,7 +22,7 @@ */ package com.oracle.graal.hotspot.amd64; -import static com.oracle.graal.hotspot.InitTimer.*; +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; import java.util.*; @@ -38,93 +38,23 @@ import com.oracle.graal.hotspot.word.*; import com.oracle.graal.phases.util.*; import com.oracle.graal.replacements.amd64.*; +import com.oracle.jvmci.runtime.*; @ServiceProvider(HotSpotBackendFactory.class) public class AMD64HotSpotBackendFactory implements HotSpotBackendFactory { - protected Architecture createArchitecture(HotSpotVMConfig config) { - return new AMD64(computeFeatures(config), computeFlags(config)); - } - - protected EnumSet computeFeatures(HotSpotVMConfig config) { - // Configure the feature set using the HotSpot flag settings. - EnumSet features = EnumSet.noneOf(AMD64.CPUFeature.class); - assert config.useSSE >= 2 : "minimum config for x64"; - features.add(AMD64.CPUFeature.SSE); - features.add(AMD64.CPUFeature.SSE2); - if ((config.x86CPUFeatures & config.cpuSSE3) != 0) { - features.add(AMD64.CPUFeature.SSE3); - } - if ((config.x86CPUFeatures & config.cpuSSSE3) != 0) { - features.add(AMD64.CPUFeature.SSSE3); - } - if ((config.x86CPUFeatures & config.cpuSSE4A) != 0) { - features.add(AMD64.CPUFeature.SSE4a); - } - if ((config.x86CPUFeatures & config.cpuSSE41) != 0) { - features.add(AMD64.CPUFeature.SSE4_1); - } - if ((config.x86CPUFeatures & config.cpuSSE42) != 0) { - features.add(AMD64.CPUFeature.SSE4_2); - } - if ((config.x86CPUFeatures & config.cpuAVX) != 0) { - features.add(AMD64.CPUFeature.AVX); - } - if ((config.x86CPUFeatures & config.cpuAVX2) != 0) { - features.add(AMD64.CPUFeature.AVX2); - } - if ((config.x86CPUFeatures & config.cpuERMS) != 0) { - features.add(AMD64.CPUFeature.ERMS); - } - if ((config.x86CPUFeatures & config.cpuLZCNT) != 0) { - features.add(AMD64.CPUFeature.LZCNT); - } - if ((config.x86CPUFeatures & config.cpuPOPCNT) != 0) { - features.add(AMD64.CPUFeature.POPCNT); - } - if ((config.x86CPUFeatures & config.cpuAES) != 0) { - features.add(AMD64.CPUFeature.AES); - } - if ((config.x86CPUFeatures & config.cpu3DNOWPREFETCH) != 0) { - features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); - } - if ((config.x86CPUFeatures & config.cpuBMI1) != 0) { - features.add(AMD64.CPUFeature.BMI1); - } - return features; - } - - protected EnumSet computeFlags(HotSpotVMConfig config) { - EnumSet flags = EnumSet.noneOf(AMD64.Flag.class); - if (config.useCountLeadingZerosInstruction) { - flags.add(AMD64.Flag.UseCountLeadingZerosInstruction); - } - if (config.useCountTrailingZerosInstruction) { - flags.add(AMD64.Flag.UseCountTrailingZerosInstruction); - } - return flags; - } - - protected TargetDescription createTarget(HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - @Override - public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotBackend host) { + public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, JVMCIBackend jvmci, HotSpotBackend host) { assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); HotSpotProviders providers; HotSpotRegistersProvider registers; - RegisterConfig regConfig; - HotSpotCodeCacheProvider codeCache; - HotSpotConstantReflectionProvider constantReflection; + HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache(); + TargetDescription target = codeCache.getTarget(); + HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection(); HotSpotHostForeignCallsProvider foreignCalls; Value[] nativeABICallerSaveRegisters; - HotSpotMetaAccessProvider metaAccess; + HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess(); HotSpotLoweringProvider lowerer; HotSpotSnippetReflectionProvider snippetReflection; HotSpotReplacementsImpl replacements; @@ -136,18 +66,6 @@ try (InitTimer rt = timer("create HotSpotRegisters provider")) { registers = createRegisters(); } - try (InitTimer rt = timer("create MetaAccess provider")) { - metaAccess = createMetaAccess(runtime); - } - try (InitTimer rt = timer("create RegisterConfig")) { - regConfig = createRegisterConfig(runtime, target); - } - try (InitTimer rt = timer("create CodeCache provider")) { - codeCache = createCodeCache(runtime, target, regConfig); - } - try (InitTimer rt = timer("create ConstantReflection provider")) { - constantReflection = createConstantReflection(runtime); - } try (InitTimer rt = timer("create NativeABICallerSaveRegisters")) { nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(runtime.getConfig(), codeCache.getRegisterConfig()); } @@ -215,22 +133,6 @@ return new AMD64HotSpotForeignCallsProvider(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters); } - protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotGraalRuntimeProvider runtime) { - return new HotSpotConstantReflectionProvider(runtime); - } - - protected RegisterConfig createRegisterConfig(HotSpotGraalRuntimeProvider runtime, TargetDescription target) { - return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig()); - } - - protected HotSpotCodeCacheProvider createCodeCache(HotSpotGraalRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); - } - - protected HotSpotMetaAccessProvider createMetaAccess(HotSpotGraalRuntimeProvider runtime) { - return new HotSpotMetaAccessProvider(runtime); - } - protected HotSpotSuitesProvider createSuites(HotSpotGraalRuntimeProvider runtime, Plugins plugins) { return new HotSpotSuitesProvider(runtime, plugins); } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/jvmci/AMD64HotSpotJVMCIBackendFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/jvmci/AMD64HotSpotJVMCIBackendFactory.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.amd64.jvmci; + +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; + +import java.util.*; + +import com.oracle.graal.amd64.*; +import com.oracle.graal.api.code.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.amd64.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.jvmci.runtime.*; + +public class AMD64HotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { + + protected Architecture createArchitecture(HotSpotVMConfig config) { + return new AMD64(computeFeatures(config), computeFlags(config)); + } + + protected EnumSet computeFeatures(HotSpotVMConfig config) { + // Configure the feature set using the HotSpot flag settings. + EnumSet features = EnumSet.noneOf(AMD64.CPUFeature.class); + assert config.useSSE >= 2 : "minimum config for x64"; + features.add(AMD64.CPUFeature.SSE); + features.add(AMD64.CPUFeature.SSE2); + if ((config.x86CPUFeatures & config.cpuSSE3) != 0) { + features.add(AMD64.CPUFeature.SSE3); + } + if ((config.x86CPUFeatures & config.cpuSSSE3) != 0) { + features.add(AMD64.CPUFeature.SSSE3); + } + if ((config.x86CPUFeatures & config.cpuSSE4A) != 0) { + features.add(AMD64.CPUFeature.SSE4a); + } + if ((config.x86CPUFeatures & config.cpuSSE41) != 0) { + features.add(AMD64.CPUFeature.SSE4_1); + } + if ((config.x86CPUFeatures & config.cpuSSE42) != 0) { + features.add(AMD64.CPUFeature.SSE4_2); + } + if ((config.x86CPUFeatures & config.cpuAVX) != 0) { + features.add(AMD64.CPUFeature.AVX); + } + if ((config.x86CPUFeatures & config.cpuAVX2) != 0) { + features.add(AMD64.CPUFeature.AVX2); + } + if ((config.x86CPUFeatures & config.cpuERMS) != 0) { + features.add(AMD64.CPUFeature.ERMS); + } + if ((config.x86CPUFeatures & config.cpuLZCNT) != 0) { + features.add(AMD64.CPUFeature.LZCNT); + } + if ((config.x86CPUFeatures & config.cpuPOPCNT) != 0) { + features.add(AMD64.CPUFeature.POPCNT); + } + if ((config.x86CPUFeatures & config.cpuAES) != 0) { + features.add(AMD64.CPUFeature.AES); + } + if ((config.x86CPUFeatures & config.cpu3DNOWPREFETCH) != 0) { + features.add(AMD64.CPUFeature.AMD_3DNOW_PREFETCH); + } + if ((config.x86CPUFeatures & config.cpuBMI1) != 0) { + features.add(AMD64.CPUFeature.BMI1); + } + return features; + } + + protected EnumSet computeFlags(HotSpotVMConfig config) { + EnumSet flags = EnumSet.noneOf(AMD64.Flag.class); + if (config.useCountLeadingZerosInstruction) { + flags.add(AMD64.Flag.UseCountLeadingZerosInstruction); + } + if (config.useCountTrailingZerosInstruction) { + flags.add(AMD64.Flag.UseCountTrailingZerosInstruction); + } + return flags; + } + + protected TargetDescription createTarget(HotSpotVMConfig config) { + final int stackFrameAlignment = 16; + final int implicitNullCheckLimit = 4096; + final boolean inlineObjects = true; + return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + } + + protected AMD64HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { + return new AMD64HotSpotBackend(runtime, providers); + } + + protected HotSpotConstantReflectionProvider createConstantReflection(HotSpotJVMCIRuntimeProvider runtime) { + return new HotSpotConstantReflectionProvider(runtime); + } + + protected RegisterConfig createRegisterConfig(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target) { + return new AMD64HotSpotRegisterConfig(target.arch, runtime.getConfig()); + } + + protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { + return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); + } + + protected HotSpotMetaAccessProvider createMetaAccess(HotSpotJVMCIRuntimeProvider runtime) { + return new HotSpotMetaAccessProvider(runtime); + } + + public String getArchitecture() { + return "AMD64"; + } + + public String getGraalRuntimeName() { + return "basic"; + } + + @Override + public String toString() { + return getGraalRuntimeName() + ":" + getArchitecture(); + } + + public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { + + assert host == null; + TargetDescription target = createTarget(runtime.getConfig()); + + RegisterConfig regConfig; + HotSpotCodeCacheProvider codeCache; + HotSpotConstantReflectionProvider constantReflection; + HotSpotMetaAccessProvider metaAccess; + try (InitTimer t = timer("create providers")) { + try (InitTimer rt = timer("create MetaAccess provider")) { + metaAccess = createMetaAccess(runtime); + } + try (InitTimer rt = timer("create RegisterConfig")) { + regConfig = createRegisterConfig(runtime, target); + } + try (InitTimer rt = timer("create CodeCache provider")) { + codeCache = createCodeCache(runtime, target, regConfig); + } + try (InitTimer rt = timer("create ConstantReflection provider")) { + constantReflection = createConstantReflection(runtime); + } + } + try (InitTimer rt = timer("instantiate backend")) { + return createBackend(metaAccess, codeCache, constantReflection); + } + } + + protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection) { + return new JVMCIBackend(metaAccess, codeCache, constantReflection); + } + + public String getJVMCIRuntimeName() { + return "basic"; + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot.sparc/src/META-INF/services/com.oracle.graal.hotspot.jvmci.HotSpotJVMCIBackendFactory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.sparc/src/META-INF/services/com.oracle.graal.hotspot.jvmci.HotSpotJVMCIBackendFactory Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,1 @@ +com.oracle.graal.hotspot.sparc.jvmci.SPARCHotSpotJVMCIBackendFactory diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -36,31 +36,20 @@ import com.oracle.graal.phases.util.*; import com.oracle.graal.replacements.sparc.*; import com.oracle.graal.sparc.*; -import com.oracle.graal.sparc.SPARC.CPUFeature; +import com.oracle.jvmci.runtime.*; @ServiceProvider(HotSpotBackendFactory.class) public class SPARCHotSpotBackendFactory implements HotSpotBackendFactory { - protected Architecture createArchitecture(HotSpotVMConfig config) { - return new SPARC(computeFeatures(config)); - } - - protected TargetDescription createTarget(HotSpotVMConfig config) { - final int stackFrameAlignment = 16; - final int implicitNullCheckLimit = 4096; - final boolean inlineObjects = true; - return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); - } - - public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotBackend host) { + @Override + public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, JVMCIBackend jvmci, HotSpotBackend host) { assert host == null; - TargetDescription target = createTarget(runtime.getConfig()); HotSpotRegistersProvider registers = createRegisters(); - HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); - RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, runtime.getConfig()); - HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); - HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); + HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess(); + HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache(); + TargetDescription target = codeCache.getTarget(); + HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection(); Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(runtime.getConfig(), codeCache.getRegisterConfig()); HotSpotForeignCallsProvider foreignCalls = new SPARCHotSpotForeignCallsProvider(runtime, metaAccess, codeCache, nativeABICallerSaveRegisters); LoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers, target); @@ -91,10 +80,6 @@ return new HotSpotSuitesProvider(runtime, plugins); } - protected HotSpotCodeCacheProvider createCodeCache(HotSpotGraalRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { - return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); - } - protected SPARCHotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { return new SPARCHotSpotBackend(runtime, providers); } @@ -104,23 +89,6 @@ return new SPARCHotSpotLoweringProvider(runtime, metaAccess, foreignCalls, registers, target); } - protected EnumSet computeFeatures(HotSpotVMConfig config) { - EnumSet features = EnumSet.noneOf(CPUFeature.class); - if ((config.sparcFeatures & config.vis1Instructions) != 0) { - features.add(CPUFeature.VIS1); - } - if ((config.sparcFeatures & config.vis2Instructions) != 0) { - features.add(CPUFeature.VIS2); - } - if ((config.sparcFeatures & config.vis3Instructions) != 0) { - features.add(CPUFeature.VIS3); - } - if ((config.sparcFeatures & config.cbcondInstructions) != 0) { - features.add(CPUFeature.CBCOND); - } - return features; - } - protected HotSpotRegistersProvider createRegisters() { return new HotSpotRegisters(SPARC.g2, SPARC.g6, SPARC.sp); } @@ -139,10 +107,12 @@ return nativeABICallerSaveRegisters; } + @Override public String getArchitecture() { return "SPARC"; } + @Override public String getGraalRuntimeName() { return "basic"; } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/jvmci/SPARCHotSpotJVMCIBackendFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/jvmci/SPARCHotSpotJVMCIBackendFactory.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.sparc.jvmci; + +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.hotspot.sparc.*; +import com.oracle.graal.sparc.*; +import com.oracle.graal.sparc.SPARC.CPUFeature; +import com.oracle.jvmci.runtime.*; + +public class SPARCHotSpotJVMCIBackendFactory implements HotSpotJVMCIBackendFactory { + + protected Architecture createArchitecture(HotSpotVMConfig config) { + return new SPARC(computeFeatures(config)); + } + + protected TargetDescription createTarget(HotSpotVMConfig config) { + final int stackFrameAlignment = 16; + final int implicitNullCheckLimit = 4096; + final boolean inlineObjects = true; + return new HotSpotTargetDescription(createArchitecture(config), true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); + } + + protected HotSpotCodeCacheProvider createCodeCache(HotSpotJVMCIRuntimeProvider runtime, TargetDescription target, RegisterConfig regConfig) { + return new HotSpotCodeCacheProvider(runtime, runtime.getConfig(), target, regConfig); + } + + protected SPARCHotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { + return new SPARCHotSpotBackend(runtime, providers); + } + + protected EnumSet computeFeatures(HotSpotVMConfig config) { + EnumSet features = EnumSet.noneOf(CPUFeature.class); + if ((config.sparcFeatures & config.vis1Instructions) != 0) { + features.add(CPUFeature.VIS1); + } + if ((config.sparcFeatures & config.vis2Instructions) != 0) { + features.add(CPUFeature.VIS2); + } + if ((config.sparcFeatures & config.vis3Instructions) != 0) { + features.add(CPUFeature.VIS3); + } + if ((config.sparcFeatures & config.cbcondInstructions) != 0) { + features.add(CPUFeature.CBCOND); + } + return features; + } + + public String getArchitecture() { + return "SPARC"; + } + + public String getGraalRuntimeName() { + return "basic"; + } + + @Override + public String toString() { + return getGraalRuntimeName() + ":" + getArchitecture(); + } + + public JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host) { + assert host == null; + TargetDescription target = createTarget(runtime.getConfig()); + + HotSpotMetaAccessProvider metaAccess = new HotSpotMetaAccessProvider(runtime); + RegisterConfig regConfig = new SPARCHotSpotRegisterConfig(target, runtime.getConfig()); + HotSpotCodeCacheProvider codeCache = createCodeCache(runtime, target, regConfig); + HotSpotConstantReflectionProvider constantReflection = new HotSpotConstantReflectionProvider(runtime); + try (InitTimer rt = timer("instantiate backend")) { + return createBackend(metaAccess, codeCache, constantReflection); + } + } + + protected JVMCIBackend createBackend(HotSpotMetaAccessProvider metaAccess, HotSpotCodeCacheProvider codeCache, HotSpotConstantReflectionProvider constantReflection) { + return new JVMCIBackend(metaAccess, codeCache, constantReflection); + } + + public String getJVMCIRuntimeName() { + return "basic"; + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/DataPatchTest.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -28,7 +28,6 @@ import com.oracle.graal.api.replacements.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.jvmci.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.nodes.CompressionNode.CompressionOp; @@ -71,7 +70,7 @@ test("narrowOopSnippet"); } - private static final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); + private static final HotSpotVMConfig config = HotSpotJVMCIRuntime.runtime().getConfig(); private static boolean initReplacements = false; @Before diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/META-INF/services/com.oracle.graal.api.runtime.GraalRuntimeFactory --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/META-INF/services/com.oracle.graal.api.runtime.GraalRuntimeFactory Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,1 @@ +com.oracle.graal.hotspot.HotSpotGraalRuntime$HotSpotGraalRuntimeFactory diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -29,7 +29,7 @@ import static com.oracle.graal.compiler.common.UnsafeAccess.*; import static com.oracle.graal.debug.Debug.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; -import static com.oracle.graal.hotspot.InitTimer.*; +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; import static com.oracle.graal.hotspot.meta.HotSpotSuitesProvider.*; import static com.oracle.graal.nodes.StructuredGraph.*; diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackendFactory.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackendFactory.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotBackendFactory.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,11 +23,12 @@ package com.oracle.graal.hotspot; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.hotspot.HotSpotGraalRuntime.Options; +import com.oracle.graal.hotspot.jvmci.HotSpotJVMCIRuntime.Options; +import com.oracle.jvmci.runtime.*; public interface HotSpotBackendFactory extends Service { - HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, HotSpotBackend host); + HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, JVMCIBackend jvmciBackend, HotSpotBackend host); /** * Gets the CPU architecture of this backend. @@ -35,7 +36,7 @@ String getArchitecture(); /** - * Gets the name of the {@link Options#GraalRuntime GraalRuntime} in which the backend created + * Gets the name of the {@link Options#JVMCIRuntime JVMCIRuntime} in which the backend created * by this factory should be used. */ String getGraalRuntimeName(); diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkage.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -94,7 +94,8 @@ boolean needsJavaFrameAnchor(); - CompilationResult getStubCompilationResult(final Backend backend); - - Stub getStub(); + /** + * Gets the VM symbol associated with the target {@linkplain #getAddress() address} of the call. + */ + String getSymbol(); } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotForeignCallLinkageImpl.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -234,11 +234,7 @@ return canDeoptimize() || transition == Transition.LEAF_SP; } - public CompilationResult getStubCompilationResult(final Backend backend) { - return stub.getCompilationResult(backend); - } - - public Stub getStub() { - return stub; + public String getSymbol() { + return stub == null ? null : stub.toString(); } } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -27,7 +27,7 @@ import static com.oracle.graal.compiler.common.UnsafeAccess.*; import static com.oracle.graal.hotspot.CompileTheWorld.Options.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.Options.*; -import static com.oracle.graal.hotspot.InitTimer.*; +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; import java.lang.reflect.*; import java.util.*; @@ -48,34 +48,33 @@ import com.oracle.graal.hotspot.debug.*; import com.oracle.graal.hotspot.events.*; import com.oracle.graal.hotspot.jvmci.*; -import com.oracle.graal.hotspot.logging.*; +import com.oracle.graal.hotspot.jvmci.logging.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.options.*; import com.oracle.graal.printer.*; import com.oracle.graal.replacements.*; import com.oracle.graal.runtime.*; +import com.oracle.jvmci.runtime.*; //JaCoCo Exclude /** * Singleton class holding the instance of the {@link GraalRuntime}. */ -public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider, HotSpotProxified { +public final class HotSpotGraalRuntime implements HotSpotGraalRuntimeProvider, HotSpotProxified, HotSpotVMEventListener { private static final HotSpotGraalRuntime instance; static { - try (InitTimer t = timer("initialize HotSpotOptions")) { - HotSpotOptions.initialize(); - } + try (InitTimer t0 = timer("HotSpotGraalRuntime.")) { + try (InitTimer t = timer("HotSpotGraalRuntime.")) { + instance = new HotSpotGraalRuntime(); + } - try (InitTimer t = timer("HotSpotGraalRuntime.")) { - instance = new HotSpotGraalRuntime(); - } - - try (InitTimer t = timer("HotSpotGraalRuntime.completeInitialization")) { - // Why deferred initialization? See comment in completeInitialization(). - instance.completeInitialization(); + try (InitTimer t = timer("HotSpotGraalRuntime.completeInitialization")) { + // Why deferred initialization? See comment in completeInitialization(). + instance.completeInitialization(); + } } } @@ -87,75 +86,9 @@ return instance; } - /** - * Do deferred initialization. - */ - public void completeInitialization() { - TTY.initialize(Options.LogFile.getStream(compilerToVm)); - - // Proxies for the VM/Compiler interfaces cannot be initialized - // in the constructor as proxy creation causes static - // initializers to be executed for all the types involved in the - // proxied methods. Some of these static initializers (e.g. in - // HotSpotMethodData) rely on the static 'instance' field being set - // to retrieve configuration details. - CompilerToVM toVM = this.compilerToVm; - - if (CountingProxy.ENABLED) { - toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); - } - if (Logger.ENABLED) { - toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); - } - - this.compilerToVm = toVM; - - if (Log.getValue() == null && !areScopedMetricsOrTimersEnabled() && Dump.getValue() == null && Verify.getValue() == null) { - if (MethodFilter.getValue() != null) { - TTY.println("WARNING: Ignoring MethodFilter option since Log, Meter, Time, TrackMemUse, Dump and Verify options are all null"); - } - } - - if (Debug.isEnabled()) { - DebugEnvironment.initialize(TTY.cachedOut); - - String summary = DebugValueSummary.getValue(); - if (summary != null) { - switch (summary) { - case "Name": - case "Partial": - case "Complete": - case "Thread": - break; - default: - throw new GraalInternalError("Unsupported value for DebugSummaryValue: %s", summary); - } - } - } - - if (Debug.areUnconditionalMetricsEnabled() || Debug.areUnconditionalTimersEnabled() || (Debug.isEnabled() && areScopedMetricsOrTimersEnabled())) { - // This must be created here to avoid loading the DebugValuesPrinter class - // during shutdown() which in turn can cause a deadlock - debugValuesPrinter = new DebugValuesPrinter(); - } - - // Complete initialization of backends - try (InitTimer st = timer(hostBackend.getTarget().arch.getName(), ".completeInitialization")) { - hostBackend.completeInitialization(); - } - for (HotSpotBackend backend : backends.values()) { - if (backend != hostBackend) { - try (InitTimer st = timer(backend.getTarget().arch.getName(), ".completeInitialization")) { - backend.completeInitialization(); - } - } - } - - BenchmarkCounters.initialize(toVM); - - assert checkArrayIndexScaleInvariants(); - - runtimeStartTime = System.nanoTime(); + @Override + public HotSpotJVMCIRuntimeProvider getJVMCIRuntime() { + return jvmciRuntime; } private boolean checkArrayIndexScaleInvariants() { @@ -175,9 +108,6 @@ // @formatter:off @Option(help = "The runtime configuration to use", type = OptionType.Expert) static final OptionValue GraalRuntime = new OptionValue<>(""); - - @Option(help = "File to which logging is sent. A %p in the name will be replaced with a string identifying the process, usually the process id.", type = OptionType.Expert) - public static final PrintStreamOption LogFile = new PrintStreamOption(); // @formatter:on } @@ -187,6 +117,8 @@ HotSpotBackendFactory nonBasic = null; int nonBasicCount = 0; + assert GraalRuntime.getValue().equals(HotSpotJVMCIRuntime.Options.JVMCIRuntime.getValue()); + for (HotSpotBackendFactory factory : Services.load(HotSpotBackendFactory.class)) { if (factory.getArchitecture().equalsIgnoreCase(architecture)) { if (factory.getGraalRuntimeName().equals(GraalRuntime.getValue())) { @@ -255,9 +187,6 @@ return unsafe.getInt(object, offset) & 0xFFFFFFFFL; } - protected/* final */CompilerToVM compilerToVm; - - protected final HotSpotVMConfig config; private final HotSpotBackend hostBackend; private DebugValuesPrinter debugValuesPrinter; @@ -280,13 +209,23 @@ private final Map, HotSpotBackend> backends = new HashMap<>(); - private HotSpotGraalRuntime() { - CompilerToVM toVM = new CompilerToVMImpl(); - compilerToVm = toVM; - try (InitTimer t = timer("HotSpotVMConfig")) { - config = new HotSpotVMConfig(compilerToVm); + private final HotSpotJVMCIRuntime jvmciRuntime; + + public static class HotSpotGraalRuntimeFactory implements GraalRuntimeFactory { + + @Override + public GraalRuntime getRuntime() { + return runtime(); } + } + + private HotSpotGraalRuntime() { + + jvmciRuntime = (HotSpotJVMCIRuntime) JVMCI.getRuntime(); + jvmciRuntime.registerVMEventListener(this); + + HotSpotVMConfig config = getConfig(); CompileTheWorld.Options.overrideWithNativeOptions(config); // Only set HotSpotPrintInlining if it still has its default value (false). @@ -305,10 +244,10 @@ factory = findFactory(hostArchitecture); } try (InitTimer t = timer("create backend:", hostArchitecture)) { - hostBackend = registerBackend(factory.createBackend(this, null)); + hostBackend = registerBackend(factory.createBackend(this, jvmciRuntime.getHostJVMCIBackend(), null)); } - String[] gpuArchitectures = getGPUArchitectureNames(compilerToVm); + String[] gpuArchitectures = getGPUArchitectureNames(getCompilerToVM()); for (String arch : gpuArchitectures) { try (InitTimer t = timer("find factory:", arch)) { factory = findFactory(arch); @@ -317,7 +256,7 @@ throw new GraalInternalError("No backend available for specified GPU architecture \"%s\"", arch); } try (InitTimer t = timer("create backend:", arch)) { - registerBackend(factory.createBackend(this, hostBackend)); + registerBackend(factory.createBackend(this, null, hostBackend)); } } @@ -326,6 +265,59 @@ } } + /** + * Do deferred initialization. + */ + private void completeInitialization() { + + if (Log.getValue() == null && !areScopedMetricsOrTimersEnabled() && Dump.getValue() == null && Verify.getValue() == null) { + if (MethodFilter.getValue() != null) { + TTY.println("WARNING: Ignoring MethodFilter option since Log, Meter, Time, TrackMemUse, Dump and Verify options are all null"); + } + } + + if (Debug.isEnabled()) { + DebugEnvironment.initialize(TTY.cachedOut); + + String summary = DebugValueSummary.getValue(); + if (summary != null) { + switch (summary) { + case "Name": + case "Partial": + case "Complete": + case "Thread": + break; + default: + throw new GraalInternalError("Unsupported value for DebugSummaryValue: %s", summary); + } + } + } + + if (Debug.areUnconditionalMetricsEnabled() || Debug.areUnconditionalTimersEnabled() || (Debug.isEnabled() && areScopedMetricsOrTimersEnabled())) { + // This must be created here to avoid loading the DebugValuesPrinter class + // during shutdown() which in turn can cause a deadlock + debugValuesPrinter = new DebugValuesPrinter(); + } + + // Complete initialization of backends + try (InitTimer st = timer(hostBackend.getTarget().arch.getName(), ".completeInitialization")) { + hostBackend.completeInitialization(); + } + for (HotSpotBackend backend : backends.values()) { + if (backend != hostBackend) { + try (InitTimer st = timer(backend.getTarget().arch.getName(), ".completeInitialization")) { + backend.completeInitialization(); + } + } + } + + BenchmarkCounters.initialize(getCompilerToVM()); + + assert checkArrayIndexScaleInvariants(); + + runtimeStartTime = System.nanoTime(); + } + private HotSpotBackend registerBackend(HotSpotBackend backend) { Class arch = backend.getTarget().arch.getClass(); HotSpotBackend oldValue = backends.put(arch, backend); @@ -365,37 +357,6 @@ } } - public HotSpotVMConfig getConfig() { - return config; - } - - public TargetDescription getTarget() { - return hostBackend.getTarget(); - } - - public CompilerToVM getCompilerToVM() { - return compilerToVm; - } - - public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { - Objects.requireNonNull(accessingType, "cannot resolve type without an accessing class"); - // If the name represents a primitive type we can short-circuit the lookup. - if (name.length() == 1) { - Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - return fromClass(kind.toJavaClass()); - } - - // Resolve non-primitive types in the VM. - HotSpotResolvedObjectTypeImpl hsAccessingType = (HotSpotResolvedObjectTypeImpl) accessingType; - final long metaspaceKlass = compilerToVm.lookupType(name, hsAccessingType.mirror(), resolve); - - if (metaspaceKlass == 0L) { - assert resolve == false; - return HotSpotUnresolvedJavaType.create(this, name); - } - return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); - } - public HotSpotProviders getHostProviders() { return getHostBackend().getProviders(); } @@ -410,7 +371,7 @@ private final EventProvider eventProvider; private EventProvider createEventProvider() { - if (config.flightRecorder) { + if (getConfig().flightRecorder) { Iterable sl = Services.load(EventProvider.class); EventProvider singleProvider = null; for (EventProvider ep : sl) { @@ -508,13 +469,14 @@ final long[] initialMetaMethods = toMeta(initialMethods); final long[] matchingMetaMethods = toMeta(matchingMethods); - HotSpotStackFrameReference current = compilerToVm.getNextStackFrame(null, initialMetaMethods, initialSkip); + CompilerToVM compilerToVM = getCompilerToVM(); + HotSpotStackFrameReference current = compilerToVM.getNextStackFrame(null, initialMetaMethods, initialSkip); while (current != null) { T result = visitor.visitFrame(current); if (result != null) { return result; } - current = compilerToVm.getNextStackFrame(current, matchingMetaMethods, 0); + current = compilerToVM.getNextStackFrame(current, matchingMetaMethods, 0); } return null; } @@ -542,14 +504,12 @@ CompilationStatistics.clear(phase); } - /** - * Called from the VM. - */ - @SuppressWarnings("unused") - private void compileTheWorld() throws Throwable { + @Override + public void notifyCompileTheWorld() throws Throwable { + CompilerToVM compilerToVM = runtime().getJVMCIRuntime().getCompilerToVM(); int iterations = CompileTheWorld.Options.CompileTheWorldIterations.getValue(); for (int i = 0; i < iterations; i++) { - getCompilerToVM().resetCompilationStatistics(); + compilerToVM.resetCompilationStatistics(); TTY.println("CompileTheWorld : iteration " + i); CompileTheWorld ctw = new CompileTheWorld(CompileTheWorldClasspath.getValue(), new Config(CompileTheWorldConfig.getValue()), CompileTheWorldStartAt.getValue(), CompileTheWorldStopAt.getValue(), CompileTheWorldMethodFilter.getValue(), CompileTheWorldExcludeMethodFilter.getValue(), CompileTheWorldVerbose.getValue()); @@ -558,13 +518,8 @@ System.exit(0); } - /** - * Shuts down the runtime. - * - * Called from the VM. - */ - @SuppressWarnings("unused") - private void shutdown() throws Exception { + @Override + public void notifyShutdown() { if (debugValuesPrinter != null) { debugValuesPrinter.printDebugValues(); } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntimeProvider.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -37,11 +37,19 @@ */ public interface HotSpotGraalRuntimeProvider extends GraalRuntime, RuntimeProvider, StackIntrospection { - HotSpotVMConfig getConfig(); + HotSpotJVMCIRuntimeProvider getJVMCIRuntime(); + + default HotSpotVMConfig getConfig() { + return getJVMCIRuntime().getConfig(); + } - TargetDescription getTarget(); + default TargetDescription getTarget() { + return getHostBackend().getTarget(); + } - CompilerToVM getCompilerToVM(); + default CompilerToVM getCompilerToVM() { + return getJVMCIRuntime().getCompilerToVM(); + } /** * Converts a name to a Java type. This method attempts to resolve {@code name} to a @@ -56,7 +64,9 @@ * @throws LinkageError if {@code resolve == true} and the resolution failed * @throws NullPointerException if {@code accessingClass} is {@code null} */ - JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve); + default JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { + return getJVMCIRuntime().lookupType(name, accessingType, resolve); + } HotSpotProviders getHostProviders(); diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotHostBackend.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -23,7 +23,7 @@ package com.oracle.graal.hotspot; import static com.oracle.graal.compiler.common.GraalOptions.*; -import static com.oracle.graal.hotspot.InitTimer.*; +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/InitTimer.java Tue May 19 23:16:07 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +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; - -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.jvmci.*; - -import edu.umd.cs.findbugs.annotations.*; - -/** - * A facility for timing a step in the runtime initialization sequence. This exists separate from - * {@link DebugTimer} as it must be independent from all other Graal code so as to not perturb the - * initialization sequence. - */ -public final class InitTimer implements AutoCloseable { - final String name; - final long start; - - private InitTimer(String name) { - this.name = name; - this.start = System.currentTimeMillis(); - System.out.println("START: " + SPACES.substring(0, timerDepth * 2) + name); - assert Thread.currentThread() == initializingThread : Thread.currentThread() + " != " + initializingThread; - timerDepth++; - } - - @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field") - public void close() { - final long end = System.currentTimeMillis(); - timerDepth--; - System.out.println(" DONE: " + SPACES.substring(0, timerDepth * 2) + name + " [" + (end - start) + " ms]"); - } - - public static InitTimer timer(String name) { - return ENABLED ? new InitTimer(name) : null; - } - - public static InitTimer timer(String name, Object suffix) { - return ENABLED ? new InitTimer(name + suffix) : null; - } - - /** - * Specifies if initialization timing is enabled. This can only be set via a system property as - * the timing facility is used to time initialization of {@link HotSpotOptions}. - */ - private static final boolean ENABLED = Boolean.getBoolean("graal.runtime.TimeInit"); - - public static int timerDepth = 0; - public static final String SPACES = " "; - - /** - * Used to assert the invariant that all initialization happens on the same thread. - */ - public static final Thread initializingThread; - static { - if (ENABLED) { - initializingThread = Thread.currentThread(); - System.out.println("INITIALIZING THREAD: " + initializingThread); - } else { - initializingThread = null; - } - } -} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/CompilerToVMImpl.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/CompilerToVMImpl.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -23,10 +23,9 @@ package com.oracle.graal.hotspot.jvmci; -import static com.oracle.graal.hotspot.InitTimer.*; +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; import com.oracle.graal.api.code.*; -import com.oracle.graal.hotspot.*; /** * Entries into the HotSpot VM from Java code. diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotCodeCacheProvider.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -40,7 +40,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.printer.*; @@ -49,12 +48,12 @@ */ public class HotSpotCodeCacheProvider implements CodeCacheProvider { - protected final HotSpotGraalRuntimeProvider runtime; + protected final HotSpotJVMCIRuntimeProvider runtime; public final HotSpotVMConfig config; protected final TargetDescription target; protected final RegisterConfig regConfig; - public HotSpotCodeCacheProvider(HotSpotGraalRuntimeProvider runtime, HotSpotVMConfig config, TargetDescription target, RegisterConfig regConfig) { + public HotSpotCodeCacheProvider(HotSpotJVMCIRuntimeProvider runtime, HotSpotVMConfig config, TargetDescription target, RegisterConfig regConfig) { this.runtime = runtime; this.config = config; this.target = target; diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantPool.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -23,15 +23,15 @@ package com.oracle.graal.hotspot.jvmci; import static com.oracle.graal.compiler.common.UnsafeAccess.*; -import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; +import static com.oracle.graal.hotspot.jvmci.HotSpotJVMCIRuntime.*; import java.lang.invoke.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.bytecode.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.meta.*; + +//import com.oracle.graal.hotspot.meta.*; /** * Implementation of {@link ConstantPool} for HotSpot. @@ -225,7 +225,7 @@ */ private long getEntryAt(int index) { assertBounds(index); - return unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + return unsafe.getAddress(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -236,7 +236,7 @@ */ private int getIntAt(int index) { assertTag(index, JVM_CONSTANT.Integer); - return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -247,7 +247,7 @@ */ private long getLongAt(int index) { assertTag(index, JVM_CONSTANT.Long); - return unsafe.getLong(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + return unsafe.getLong(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -258,7 +258,7 @@ */ private float getFloatAt(int index) { assertTag(index, JVM_CONSTANT.Float); - return unsafe.getFloat(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + return unsafe.getFloat(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -269,7 +269,7 @@ */ private double getDoubleAt(int index) { assertTag(index, JVM_CONSTANT.Double); - return unsafe.getDouble(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + return unsafe.getDouble(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -280,7 +280,7 @@ */ private int getNameAndTypeAt(int index) { assertTag(index, JVM_CONSTANT.NameAndType); - return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + return unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); } /** @@ -361,7 +361,7 @@ */ private int getUncachedKlassRefIndexAt(int index) { assert getTagAt(index) == JVM_CONSTANT.Fieldref || getTagAt(index) == JVM_CONSTANT.MethodRef || getTagAt(index) == JVM_CONSTANT.InterfaceMethodref; - final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getTarget().wordSize); + final int refIndex = unsafe.getInt(metaspaceConstantPool + runtime().getConfig().constantPoolSize + index * runtime().getHostJVMCIBackend().getTarget().wordSize); // klass ref index is in the low 16-bits. return refIndex & 0xFFFF; } @@ -452,7 +452,7 @@ * @param metaspacePointer either a metaspace Klass or a metaspace Symbol */ private static JavaType getJavaType(final long metaspacePointer) { - HotSpotGraalRuntimeProvider runtime = runtime(); + HotSpotJVMCIRuntime runtime = runtime(); HotSpotVMConfig config = runtime.getConfig(); if ((metaspacePointer & config.compilerToVMSymbolTag) != 0) { final long metaspaceSymbol = metaspacePointer & ~config.compilerToVMSymbolTag; diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantReflectionProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantReflectionProvider.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotConstantReflectionProvider.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -32,7 +32,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.options.*; import com.oracle.graal.replacements.*; @@ -44,11 +43,11 @@ public class HotSpotConstantReflectionProvider implements ConstantReflectionProvider, HotSpotProxified { private static final String SystemClassName = "Ljava/lang/System;"; - protected final HotSpotGraalRuntimeProvider runtime; + protected final HotSpotJVMCIRuntimeProvider runtime; protected final HotSpotMethodHandleAccessProvider methodHandleAccess; protected final HotSpotMemoryAccessProviderImpl memoryAccess; - public HotSpotConstantReflectionProvider(HotSpotGraalRuntimeProvider runtime) { + public HotSpotConstantReflectionProvider(HotSpotJVMCIRuntimeProvider runtime) { this.runtime = runtime; this.methodHandleAccess = new HotSpotMethodHandleAccessProvider(this); this.memoryAccess = new HotSpotMemoryAccessProviderImpl(runtime); @@ -210,7 +209,7 @@ if (constant instanceof HotSpotObjectConstant) { Object obj = ((HotSpotObjectConstantImpl) constant).object(); if (obj instanceof Class) { - return runtime.getHostProviders().getMetaAccess().lookupJavaType((Class) obj); + return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType((Class) obj); } } if (constant instanceof HotSpotMetaspaceConstant) { diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotForeignCallTarget.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotForeignCallTarget.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotForeignCallTarget.java Fri May 22 23:26:20 2015 +0200 @@ -19,7 +19,8 @@ * 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.jvmci; + */ +package com.oracle.graal.hotspot.jvmci; import com.oracle.graal.api.meta.*; diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIBackendFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIBackendFactory.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.runtime.*; +import com.oracle.jvmci.runtime.*; + +public interface HotSpotJVMCIBackendFactory extends Service { + + JVMCIBackend createJVMCIBackend(HotSpotJVMCIRuntimeProvider runtime, JVMCIBackend host); + + /** + * Gets the CPU architecture of this backend. + */ + String getArchitecture(); + + String getJVMCIRuntimeName(); +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci; + +import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import static com.oracle.graal.hotspot.jvmci.InitTimer.*; + +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.jvmci.logging.*; +import com.oracle.graal.options.*; +import com.oracle.jvmci.runtime.*; + +//JaCoCo Exclude + +public final class HotSpotJVMCIRuntime implements HotSpotJVMCIRuntimeProvider, HotSpotProxified { + + private static final HotSpotJVMCIRuntime instance; + + static { + try (InitTimer t0 = timer("HotSpotJVMCIRuntime.")) { + try (InitTimer t = timer("initialize HotSpotOptions")) { + HotSpotOptions.initialize(); + } + + try (InitTimer t = timer("HotSpotJVMCIRuntime.")) { + instance = new HotSpotJVMCIRuntime(); + } + + try (InitTimer t = timer("HotSpotJVMCIRuntime.completeInitialization")) { + // Why deferred initialization? See comment in completeInitialization(). + instance.completeInitialization(); + } + } + } + + /** + * Gets the singleton {@link HotSpotJVMCIRuntime} object. + */ + public static HotSpotJVMCIRuntime runtime() { + assert instance != null; + return instance; + } + + /** + * Do deferred initialization. + */ + public void completeInitialization() { + TTY.initialize(Options.LogFile.getStream(compilerToVm)); + + // Proxies for the VM/Compiler interfaces cannot be initialized + // in the constructor as proxy creation causes static + // initializers to be executed for all the types involved in the + // proxied methods. Some of these static initializers (e.g. in + // HotSpotMethodData) rely on the static 'instance' field being set + // to retrieve configuration details. + CompilerToVM toVM = this.compilerToVm; + + if (CountingProxy.ENABLED) { + toVM = CountingProxy.getProxy(CompilerToVM.class, toVM); + } + if (Logger.ENABLED) { + toVM = LoggingProxy.getProxy(CompilerToVM.class, toVM); + } + + this.compilerToVm = toVM; + } + + public static class Options { + + // @formatter:off + @Option(help = "The JVMCI runtime configuration to use", type = OptionType.Expert) + public static final OptionValue JVMCIRuntime = new OptionValue<>(""); + + @Option(help = "File to which logging is sent. A %p in the name will be replaced with a string identifying the process, usually the process id.", type = OptionType.Expert) + public static final PrintStreamOption LogFile = new PrintStreamOption(); + // @formatter:on + } + + public static HotSpotJVMCIBackendFactory findFactory(String architecture) { + HotSpotJVMCIBackendFactory basic = null; + HotSpotJVMCIBackendFactory selected = null; + HotSpotJVMCIBackendFactory nonBasic = null; + int nonBasicCount = 0; + + for (HotSpotJVMCIBackendFactory factory : Services.load(HotSpotJVMCIBackendFactory.class)) { + if (factory.getArchitecture().equalsIgnoreCase(architecture)) { + if (factory.getJVMCIRuntimeName().equals(Options.JVMCIRuntime.getValue())) { + assert selected == null || checkFactoryOverriding(selected, factory); + selected = factory; + } + if (factory.getJVMCIRuntimeName().equals("basic")) { + assert basic == null || checkFactoryOverriding(basic, factory); + basic = factory; + } else { + nonBasic = factory; + nonBasicCount++; + } + } + } + + if (selected != null) { + return selected; + } else { + if (!Options.JVMCIRuntime.getValue().equals("")) { + // Fail fast if a non-default value for JVMCIRuntime was specified + // and the corresponding factory is not available + throw new InternalError(String.format("Specified runtime \"%s\" not available for the %s architecture", Options.JVMCIRuntime.getValue(), architecture)); + } else if (nonBasicCount == 1) { + // If there is exactly one non-basic runtime, select this one. + return nonBasic; + } else { + return basic; + } + } + } + + /** + * Checks that a factory overriding is valid. A factory B can only override/replace a factory A + * if the B.getClass() is a subclass of A.getClass(). This models the assumption that B is + * extends the behavior of A and has therefore understood the behavior expected of A. + * + * @param baseFactory + * @param overridingFactory + */ + private static boolean checkFactoryOverriding(HotSpotJVMCIBackendFactory baseFactory, HotSpotJVMCIBackendFactory overridingFactory) { + return baseFactory.getClass().isAssignableFrom(overridingFactory.getClass()); + } + + /** + * Gets the kind of a word value on the {@linkplain #getHostJVMCIBackend() host} backend. + */ + public static Kind getHostWordKind() { + return instance.getHostJVMCIBackend().getCodeCache().getTarget().wordKind; + } + + /** + * Reads a klass pointer from a constant object. + */ + public static long unsafeReadKlassPointer(Object object) { + return instance.getCompilerToVM().readUnsafeKlassPointer(object); + } + + /** + * Reads a word value from a given object. + */ + public static long unsafeReadWord(Object object, long offset) { + if (getHostWordKind() == Kind.Long) { + return unsafe.getLong(object, offset); + } + return unsafe.getInt(object, offset) & 0xFFFFFFFFL; + } + + protected/* final */CompilerToVM compilerToVm; + + protected final HotSpotVMConfig config; + private final JVMCIBackend hostBackend; + + /** + * Graal mirrors are stored as a {@link ClassValue} associated with the {@link Class} of the + * type. This data structure stores both {@link HotSpotResolvedObjectType} and + * {@link HotSpotResolvedPrimitiveType} types. + */ + private final ClassValue graalMirrors = new ClassValue() { + @Override + protected ResolvedJavaType computeValue(Class javaClass) { + if (javaClass.isPrimitive()) { + Kind kind = Kind.fromJavaClass(javaClass); + return new HotSpotResolvedPrimitiveType(kind); + } else { + return new HotSpotResolvedObjectTypeImpl(javaClass); + } + } + }; + + private final Map, JVMCIBackend> backends = new HashMap<>(); + + private HotSpotJVMCIRuntime() { + CompilerToVM toVM = new CompilerToVMImpl(); + compilerToVm = toVM; + try (InitTimer t = timer("HotSpotVMConfig")) { + config = new HotSpotVMConfig(compilerToVm); + } + + if (Boolean.valueOf(System.getProperty("graal.printconfig"))) { + printConfig(config); + } + + String hostArchitecture = config.getHostArchitectureName(); + + HotSpotJVMCIBackendFactory factory; + try (InitTimer t = timer("find factory:", hostArchitecture)) { + factory = findFactory(hostArchitecture); + } + try (InitTimer t = timer("create JVMCI backend:", hostArchitecture)) { + hostBackend = registerBackend(factory.createJVMCIBackend(this, null)); + } + } + + private JVMCIBackend registerBackend(JVMCIBackend backend) { + Class arch = backend.getCodeCache().getTarget().arch.getClass(); + JVMCIBackend oldValue = backends.put(arch, backend); + assert oldValue == null : "cannot overwrite existing backend for architecture " + arch.getSimpleName(); + return backend; + } + + public ResolvedJavaType fromClass(Class javaClass) { + return graalMirrors.get(javaClass); + } + + private static void printConfig(HotSpotVMConfig config) { + Field[] fields = config.getClass().getDeclaredFields(); + Map sortedFields = new TreeMap<>(); + for (Field f : fields) { + f.setAccessible(true); + sortedFields.put(f.getName(), f); + } + for (Field f : sortedFields.values()) { + try { + Logger.info(String.format("%9s %-40s = %s", f.getType().getSimpleName(), f.getName(), Logger.pretty(f.get(config)))); + } catch (Exception e) { + } + } + } + + public HotSpotVMConfig getConfig() { + return config; + } + + public CompilerToVM getCompilerToVM() { + return compilerToVm; + } + + public JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve) { + Objects.requireNonNull(accessingType, "cannot resolve type without an accessing class"); + // If the name represents a primitive type we can short-circuit the lookup. + if (name.length() == 1) { + Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); + return fromClass(kind.toJavaClass()); + } + + // Resolve non-primitive types in the VM. + HotSpotResolvedObjectTypeImpl hsAccessingType = (HotSpotResolvedObjectTypeImpl) accessingType; + final long metaspaceKlass = compilerToVm.lookupType(name, hsAccessingType.mirror(), resolve); + + if (metaspaceKlass == 0L) { + assert resolve == false; + return HotSpotUnresolvedJavaType.create(this, name); + } + return HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(metaspaceKlass); + } + + public JVMCIBackend getHostJVMCIBackend() { + return hostBackend; + } + + public JVMCIBackend getJVMCIBackend(Class arch) { + assert arch != Architecture.class; + return backends.get(arch); + } + + public Map, JVMCIBackend> getBackends() { + return Collections.unmodifiableMap(backends); + } + + private HotSpotVMEventListener vmEventListener; + + public void registerVMEventListener(HotSpotVMEventListener l) { + assert vmEventListener == null : "cannot register multiple HotSpotVMEventListeners"; + vmEventListener = l; + } + + /** + * Called from the VM. + */ + @SuppressWarnings("unused") + private void compileTheWorld() throws Throwable { + if (vmEventListener != null) { + vmEventListener.notifyCompileTheWorld(); + } + } + + /** + * Shuts down the runtime. + * + * Called from the VM. + */ + @SuppressWarnings("unused") + private void shutdown() throws Exception { + if (vmEventListener != null) { + vmEventListener.notifyShutdown(); + } + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntimeProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntimeProvider.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; +import com.oracle.jvmci.runtime.*; + +//JaCoCo Exclude + +/** + * Configuration information for the HotSpot Graal runtime. + */ +public interface HotSpotJVMCIRuntimeProvider extends JVMCIRuntime { + + HotSpotVMConfig getConfig(); + + CompilerToVM getCompilerToVM(); + + /** + * Converts a name to a Java type. This method attempts to resolve {@code name} to a + * {@link ResolvedJavaType}. + * + * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format + * @param accessingType the context of resolution which must be non-null + * @param resolve specifies whether resolution failure results in an unresolved type being + * return or a {@link LinkageError} being thrown + * @return a Java type for {@code name} which is guaranteed to be of type + * {@link ResolvedJavaType} if {@code resolve == true} + * @throws LinkageError if {@code resolve == true} and the resolution failed + * @throws NullPointerException if {@code accessingClass} is {@code null} + */ + JavaType lookupType(String name, HotSpotResolvedObjectType accessingType, boolean resolve); + + /** + * Gets the Graal mirror for a {@link Class} object. + * + * @return the {@link ResolvedJavaType} corresponding to {@code javaClass} + */ + ResolvedJavaType fromClass(Class clazz); +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMemoryAccessProviderImpl.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -24,19 +24,19 @@ import static com.oracle.graal.compiler.common.UnsafeAccess.*; +import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.*; +import com.oracle.graal.hotspot.jvmci.HotSpotVMConfig.CompressEncoding; /** * HotSpot implementation of {@link MemoryAccessProvider}. */ public class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, HotSpotProxified { - protected final HotSpotGraalRuntimeProvider runtime; + protected final HotSpotJVMCIRuntimeProvider runtime; - public HotSpotMemoryAccessProviderImpl(HotSpotGraalRuntimeProvider runtime) { + public HotSpotMemoryAccessProviderImpl(HotSpotJVMCIRuntimeProvider runtime) { this.runtime = runtime; } @@ -202,12 +202,13 @@ @Override public Constant readKlassPointerConstant(Constant base, long displacement) { - long klass = readRawValue(base, displacement, runtime.getTarget().wordSize * 8); + TargetDescription target = runtime.getHostJVMCIBackend().getCodeCache().getTarget(); + long klass = readRawValue(base, displacement, target.wordSize * 8); if (klass == 0) { return JavaConstant.NULL_POINTER; } HotSpotResolvedObjectType metaKlass = HotSpotResolvedObjectTypeImpl.fromMetaspaceKlass(klass); - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime.getTarget().wordKind, klass, metaKlass, false); + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(target.wordKind, klass, metaKlass, false); } @Override @@ -223,8 +224,9 @@ @Override public Constant readMethodPointerConstant(Constant base, long displacement) { - long method = readRawValue(base, displacement, runtime.getTarget().wordSize * 8); + TargetDescription target = runtime.getHostJVMCIBackend().getCodeCache().getTarget(); + long method = readRawValue(base, displacement, target.wordSize * 8); HotSpotResolvedJavaMethod metaMethod = HotSpotResolvedJavaMethodImpl.fromMetaspace(method); - return HotSpotMetaspaceConstantImpl.forMetaspaceObject(runtime.getTarget().wordKind, method, metaMethod, false); + return HotSpotMetaspaceConstantImpl.forMetaspaceObject(target.wordKind, method, metaMethod, false); } } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMetaAccessProvider.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -40,9 +40,9 @@ */ public class HotSpotMetaAccessProvider implements MetaAccessProvider, HotSpotProxified { - protected final HotSpotGraalRuntimeProvider runtime; + protected final HotSpotJVMCIRuntimeProvider runtime; - public HotSpotMetaAccessProvider(HotSpotGraalRuntimeProvider runtime) { + public HotSpotMetaAccessProvider(HotSpotJVMCIRuntimeProvider runtime) { this.runtime = runtime; } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodUnresolved.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotMethodUnresolved.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.api.meta.*; + +/** + * Implementation of {@link JavaMethod} for unresolved HotSpot methods. + */ +public final class HotSpotMethodUnresolved extends HotSpotMethod { + + private final Signature signature; + protected JavaType holder; + + public HotSpotMethodUnresolved(String name, Signature signature, JavaType holder) { + super(name); + this.holder = holder; + this.signature = signature; + } + + @Override + public Signature getSignature() { + return signature; + } + + @Override + public JavaType getDeclaringClass() { + return holder; + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof HotSpotMethodUnresolved)) { + return false; + } + HotSpotMethodUnresolved that = (HotSpotMethodUnresolved) obj; + return this.name.equals(that.name) && this.signature.equals(that.signature) && this.holder.equals(that.holder); + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectType.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectType.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -24,7 +24,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.Assumptions.AssumptionResult; -import com.oracle.graal.hotspot.*; /** * Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. @@ -73,7 +72,7 @@ * Performs a fast-path check that this type is resolved in the context of a given accessing * class. A negative result does not mean this type is not resolved with respect to * {@code accessingClass}. That can only be determined by - * {@linkplain HotSpotGraalRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) + * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) * re-resolving} the type. */ boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass); diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotResolvedObjectTypeImpl.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -111,7 +111,7 @@ * Gets the metaspace Klass for this type. */ public long getMetaspaceKlass() { - if (HotSpotGraalRuntime.getHostWordKind() == Kind.Long) { + if (HotSpotJVMCIRuntime.getHostWordKind() == Kind.Long) { return unsafe.getLong(javaClass, (long) runtime().getConfig().klassOffset); } return unsafe.getInt(javaClass, (long) runtime().getConfig().klassOffset) & 0xFFFFFFFFL; @@ -761,7 +761,7 @@ * Performs a fast-path check that this type is resolved in the context of a given accessing * class. A negative result does not mean this type is not resolved with respect to * {@code accessingClass}. That can only be determined by - * {@linkplain HotSpotGraalRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) + * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) * re-resolving} the type. */ public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) { diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotSignature.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -26,7 +26,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; /** * Represents a method signature. @@ -38,9 +37,9 @@ private final String originalString; private ResolvedJavaType[] parameterTypes; private ResolvedJavaType returnTypeCache; - private final HotSpotGraalRuntimeProvider runtime; + private final HotSpotJVMCIRuntimeProvider runtime; - public HotSpotSignature(HotSpotGraalRuntimeProvider runtime, String signature) { + public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, String signature) { this.runtime = runtime; assert signature.length() > 0; this.originalString = signature; @@ -62,7 +61,7 @@ } } - public HotSpotSignature(HotSpotGraalRuntimeProvider runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { + public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, ResolvedJavaType returnType, ResolvedJavaType... parameterTypes) { this.runtime = runtime; this.parameterTypes = parameterTypes.clone(); this.returnTypeCache = returnType; @@ -127,10 +126,10 @@ return true; } - private static JavaType getUnresolvedOrPrimitiveType(HotSpotGraalRuntimeProvider runtime, String name) { + private static JavaType getUnresolvedOrPrimitiveType(HotSpotJVMCIRuntimeProvider runtime, String name) { if (name.length() == 1) { Kind kind = Kind.fromPrimitiveOrVoidTypeChar(name.charAt(0)); - return runtime.getHostProviders().getMetaAccess().lookupJavaType(kind.toJavaClass()); + return runtime.getHostJVMCIBackend().getMetaAccess().lookupJavaType(kind.toJavaClass()); } return new HotSpotUnresolvedJavaType(name, runtime); } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotUnresolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotUnresolvedJavaType.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotUnresolvedJavaType.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -23,16 +23,15 @@ package com.oracle.graal.hotspot.jvmci; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; /** * Implementation of {@link JavaType} for unresolved HotSpot classes. */ public class HotSpotUnresolvedJavaType extends HotSpotJavaType { - private final HotSpotGraalRuntimeProvider runtime; + private final HotSpotJVMCIRuntimeProvider runtime; - public HotSpotUnresolvedJavaType(String name, HotSpotGraalRuntimeProvider runtime) { + public HotSpotUnresolvedJavaType(String name, HotSpotJVMCIRuntimeProvider runtime) { super(name); assert name.charAt(0) == '[' || name.charAt(name.length() - 1) == ';' : name; this.runtime = runtime; @@ -41,7 +40,7 @@ /** * Creates an unresolved type for a valid {@link JavaType#getName() type name}. */ - public static HotSpotUnresolvedJavaType create(HotSpotGraalRuntimeProvider runtime, String name) { + public static HotSpotUnresolvedJavaType create(HotSpotJVMCIRuntimeProvider runtime, String name) { return new HotSpotUnresolvedJavaType(name, runtime); } diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMConfig.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -28,7 +28,6 @@ import java.util.*; import com.oracle.graal.compiler.common.*; -import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspotvmconfig.*; //JaCoCo Exclude @@ -260,7 +259,7 @@ /** * Gets the host architecture name for the purpose of finding the corresponding - * {@linkplain HotSpotBackendFactory backend}. + * {@linkplain HotSpotJVMCIBackendFactory backend}. */ public String getHostArchitectureName() { String arch = System.getProperty("os.arch"); diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMEventListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/HotSpotVMEventListener.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci; + +public interface HotSpotVMEventListener { + + /** + * Notifies this client that HotSpot is running in CompileTheWorld mode and the JVMCI compiler + * should now perform its version of CompileTheWorld. + */ + void notifyCompileTheWorld() throws Throwable; + + /** + * Notifies this client that the VM is shutting down. + */ + void notifyShutdown(); +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/InitTimer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/InitTimer.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci; + +import com.oracle.graal.debug.*; + +import edu.umd.cs.findbugs.annotations.*; + +/** + * A facility for timing a step in the runtime initialization sequence. This exists separate from + * {@link DebugTimer} as it must be independent from all other Graal code so as to not perturb the + * initialization sequence. + */ +public final class InitTimer implements AutoCloseable { + final String name; + final long start; + + private InitTimer(String name) { + this.name = name; + this.start = System.currentTimeMillis(); + System.out.println("START: " + SPACES.substring(0, timerDepth * 2) + name); + assert Thread.currentThread() == initializingThread : Thread.currentThread() + " != " + initializingThread; + timerDepth++; + } + + @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only the initializing thread accesses this field") + public void close() { + final long end = System.currentTimeMillis(); + timerDepth--; + System.out.println(" DONE: " + SPACES.substring(0, timerDepth * 2) + name + " [" + (end - start) + " ms]"); + } + + public static InitTimer timer(String name) { + return ENABLED ? new InitTimer(name) : null; + } + + public static InitTimer timer(String name, Object suffix) { + return ENABLED ? new InitTimer(name + suffix) : null; + } + + /** + * Specifies if initialization timing is enabled. This can only be set via a system property as + * the timing facility is used to time initialization of {@link HotSpotOptions}. + */ + private static final boolean ENABLED = Boolean.getBoolean("jvmci.runtime.TimeInit"); + + public static int timerDepth = 0; + public static final String SPACES = " "; + + /** + * Used to assert the invariant that all initialization happens on the same thread. + */ + public static final Thread initializingThread; + static { + if (ENABLED) { + initializingThread = Thread.currentThread(); + System.out.println("INITIALIZING THREAD: " + initializingThread); + } else { + initializingThread = null; + } + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/CountingProxy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/CountingProxy.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci.logging; + +import java.lang.reflect.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +import com.oracle.graal.debug.*; + +/** + * A java.lang.reflect proxy that hierarchically logs all method invocations along with their + * parameters and return values. + */ +public class CountingProxy implements InvocationHandler { + + public static final boolean ENABLED = Boolean.valueOf(System.getProperty("graal.countcalls")); + + private T delegate; + + private ConcurrentHashMap calls = new ConcurrentHashMap<>(); + + public CountingProxy(T delegate) { + assert ENABLED; + TTY.println("Counting proxy for " + delegate.getClass().getSimpleName() + " created"); + this.delegate = delegate; + proxies.add(this); + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + int argCount = args == null ? 0 : args.length; + if (method.getParameterTypes().length != argCount) { + throw new RuntimeException("wrong parameter count"); + } + final Object result; + if (!calls.containsKey(method)) { + calls.putIfAbsent(method, new AtomicLong(0)); + } + AtomicLong count = calls.get(method); + count.incrementAndGet(); + try { + if (args == null) { + result = method.invoke(delegate); + } else { + result = method.invoke(delegate, args); + } + } catch (InvocationTargetException e) { + throw e.getCause(); + } + return result; + } + + public static T getProxy(Class interf, T delegate) { + Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); + Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new CountingProxy<>(delegate)); + return interf.cast(obj); + } + + private static ArrayList> proxies = new ArrayList<>(); + + static { + if (ENABLED) { + Runtime.getRuntime().addShutdownHook(new Thread() { + + @Override + public void run() { + for (CountingProxy proxy : proxies) { + proxy.print(); + } + } + }); + } + } + + protected void print() { + long sum = 0; + for (Map.Entry entry : calls.entrySet()) { + Method method = entry.getKey(); + long count = entry.getValue().get(); + sum += count; + TTY.println(delegate.getClass().getSimpleName() + "." + method.getName() + ": " + count); + } + TTY.println(delegate.getClass().getSimpleName() + " calls: " + sum); + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/Logger.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/Logger.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci.logging; + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; + +import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.jvmci.*; + +/** + * Scoped logging class used to display the call hierarchy of {@link CompilerToVM} calls. + */ +public class Logger { + + public static final boolean ENABLED = Boolean.valueOf(System.getProperty("graal.debug")); + private static final int SPACING = 4; + private static final ThreadLocal loggerTL; + + private Deque openStack = new LinkedList<>(); + private boolean open = false; + private int level = 0; + + private static final PrintStream out; + + static { + if (ENABLED) { + loggerTL = new ThreadLocal() { + + @Override + protected Logger initialValue() { + return new Logger(); + } + }; + } else { + loggerTL = null; + } + + PrintStream ps = null; + String filename = System.getProperty("graal.info_file"); + if (filename != null && !"".equals(filename)) { + try { + ps = new PrintStream(new FileOutputStream(filename)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + ps = null; + } + } + out = ps; + if (out != null) { + out.println("start: " + new Date()); + } + } + + public static void info(String message) { + if (ENABLED) { + log(message); + } else { + TTY.println(message); + } + if (out != null) { + out.println(message); + out.flush(); + } + } + + public static void log(String message) { + if (ENABLED) { + Logger logger = loggerTL.get(); + for (String line : message.split("\n")) { + if (logger.open) { + TTY.println("..."); + logger.open = false; + } + TTY.print(space(logger.level)); + TTY.println(line); + } + } + } + + public static void startScope(String message) { + if (ENABLED) { + Logger logger = loggerTL.get(); + if (logger.open) { + TTY.println("..."); + logger.open = false; + } + TTY.print(space(logger.level)); + TTY.print(message); + logger.openStack.push(logger.open); + logger.open = true; + logger.level++; + } + } + + public static void endScope(String message) { + if (ENABLED) { + Logger logger = loggerTL.get(); + logger.level--; + if (logger.open) { + TTY.println(message); + } else { + TTY.println(space(logger.level) + "..." + message); + } + logger.open = logger.openStack.pop(); + } + } + + private static String[] spaces = new String[50]; + + private static String space(int count) { + assert count >= 0; + String result; + if (count >= spaces.length || spaces[count] == null) { + StringBuilder str = new StringBuilder(); + for (int i = 0; i < count * SPACING; i++) { + str.append(' '); + } + result = str.toString(); + if (count < spaces.length) { + spaces[count] = result; + } + } else { + result = spaces[count]; + } + return result; + } + + public static String pretty(Object value) { + if (value == null) { + return "null"; + } + + Class klass = value.getClass(); + if (value instanceof Void) { + return "void"; + } else if (value instanceof String) { + return "\"" + value + "\""; + } else if (value instanceof Method) { + return "method \"" + ((Method) value).getName() + "\""; + } else if (value instanceof Class) { + return "class \"" + ((Class) value).getSimpleName() + "\""; + } else if (value instanceof Integer) { + if ((Integer) value < 10) { + return value.toString(); + } + return value + " (0x" + Integer.toHexString((Integer) value) + ")"; + } else if (value instanceof Long) { + if ((Long) value < 10 && (Long) value > -10) { + return value + "l"; + } + return value + "l (0x" + Long.toHexString((Long) value) + "l)"; + } else if (klass.isArray()) { + StringBuilder str = new StringBuilder(); + int dimensions = 0; + while (klass.isArray()) { + dimensions++; + klass = klass.getComponentType(); + } + int length = Array.getLength(value); + str.append(klass.getSimpleName()).append('[').append(length).append(']'); + for (int i = 1; i < dimensions; i++) { + str.append("[]"); + } + str.append(" {"); + for (int i = 0; i < length; i++) { + str.append(pretty(Array.get(value, i))); + if (i < length - 1) { + str.append(", "); + } + } + str.append('}'); + return str.toString(); + } + + return value.toString(); + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/LoggingProxy.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/LoggingProxy.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci.logging; + +import java.lang.reflect.*; + +/** + * A java.lang.reflect proxy that hierarchically logs all method invocations along with their + * parameters and return values. + */ +public class LoggingProxy implements InvocationHandler { + + private T delegate; + + public LoggingProxy(T delegate) { + this.delegate = delegate; + } + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + int argCount = args == null ? 0 : args.length; + if (method.getParameterTypes().length != argCount) { + throw new RuntimeException("wrong parameter count"); + } + StringBuilder str = new StringBuilder(); + str.append(method.getReturnType().getSimpleName() + " " + method.getDeclaringClass().getSimpleName() + "." + method.getName() + "("); + for (int i = 0; i < argCount; i++) { + str.append(i == 0 ? "" : ", "); + str.append(Logger.pretty(args[i])); + } + str.append(")"); + Logger.startScope(str.toString()); + final Object result; + try { + if (args == null) { + result = method.invoke(delegate); + } else { + result = method.invoke(delegate, args); + } + } catch (InvocationTargetException e) { + Logger.endScope(" = Exception " + e.getMessage()); + throw e.getCause(); + } + Logger.endScope(" = " + Logger.pretty(result)); + return result; + } + + /** + * The object returned by this method will implement all interfaces that are implemented by + * delegate. + */ + public static T getProxy(Class interf, T delegate) { + Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); + Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new LoggingProxy<>(delegate)); + return interf.cast(obj); + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/ProxyUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/ProxyUtil.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.jvmci.logging; + +import java.util.*; + +public final class ProxyUtil { + + public static Class[] getAllInterfaces(Class clazz) { + HashSet> interfaces = new HashSet<>(); + getAllInterfaces(clazz, interfaces); + return interfaces.toArray(new Class[interfaces.size()]); + } + + private static void getAllInterfaces(Class clazz, HashSet> interfaces) { + for (Class iface : clazz.getInterfaces()) { + if (!interfaces.contains(iface)) { + interfaces.add(iface); + getAllInterfaces(iface, interfaces); + } + } + if (clazz.getSuperclass() != null) { + getAllInterfaces(clazz.getSuperclass(), interfaces); + } + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/jvmci/logging/package-info.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011, 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. + */ +/** + * Logging framework for the HotSpot CRI implementation. + */ +package com.oracle.graal.hotspot.jvmci.logging; + diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/CountingProxy.java Tue May 19 23:16:07 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +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. - */ -package com.oracle.graal.hotspot.logging; - -import java.lang.reflect.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -import com.oracle.graal.debug.*; - -/** - * A java.lang.reflect proxy that hierarchically logs all method invocations along with their - * parameters and return values. - */ -public class CountingProxy implements InvocationHandler { - - public static final boolean ENABLED = Boolean.valueOf(System.getProperty("graal.countcalls")); - - private T delegate; - - private ConcurrentHashMap calls = new ConcurrentHashMap<>(); - - public CountingProxy(T delegate) { - assert ENABLED; - TTY.println("Counting proxy for " + delegate.getClass().getSimpleName() + " created"); - this.delegate = delegate; - proxies.add(this); - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - int argCount = args == null ? 0 : args.length; - if (method.getParameterTypes().length != argCount) { - throw new RuntimeException("wrong parameter count"); - } - final Object result; - if (!calls.containsKey(method)) { - calls.putIfAbsent(method, new AtomicLong(0)); - } - AtomicLong count = calls.get(method); - count.incrementAndGet(); - try { - if (args == null) { - result = method.invoke(delegate); - } else { - result = method.invoke(delegate, args); - } - } catch (InvocationTargetException e) { - throw e.getCause(); - } - return result; - } - - public static T getProxy(Class interf, T delegate) { - Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); - Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new CountingProxy<>(delegate)); - return interf.cast(obj); - } - - private static ArrayList> proxies = new ArrayList<>(); - - static { - if (ENABLED) { - Runtime.getRuntime().addShutdownHook(new Thread() { - - @Override - public void run() { - for (CountingProxy proxy : proxies) { - proxy.print(); - } - } - }); - } - } - - protected void print() { - long sum = 0; - for (Map.Entry entry : calls.entrySet()) { - Method method = entry.getKey(); - long count = entry.getValue().get(); - sum += count; - TTY.println(delegate.getClass().getSimpleName() + "." + method.getName() + ": " + count); - } - TTY.println(delegate.getClass().getSimpleName() + " calls: " + sum); - } -} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/Logger.java Tue May 19 23:16:07 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,199 +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. - */ -package com.oracle.graal.hotspot.logging; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -import com.oracle.graal.debug.*; -import com.oracle.graal.hotspot.jvmci.*; - -/** - * Scoped logging class used to display the call hierarchy of {@link CompilerToVM} calls. - */ -public class Logger { - - public static final boolean ENABLED = Boolean.valueOf(System.getProperty("graal.debug")); - private static final int SPACING = 4; - private static final ThreadLocal loggerTL; - - private Deque openStack = new LinkedList<>(); - private boolean open = false; - private int level = 0; - - private static final PrintStream out; - - static { - if (ENABLED) { - loggerTL = new ThreadLocal() { - - @Override - protected Logger initialValue() { - return new Logger(); - } - }; - } else { - loggerTL = null; - } - - PrintStream ps = null; - String filename = System.getProperty("graal.info_file"); - if (filename != null && !"".equals(filename)) { - try { - ps = new PrintStream(new FileOutputStream(filename)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - ps = null; - } - } - out = ps; - if (out != null) { - out.println("start: " + new Date()); - } - } - - public static void info(String message) { - if (ENABLED) { - log(message); - } else { - TTY.println(message); - } - if (out != null) { - out.println(message); - out.flush(); - } - } - - public static void log(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - for (String line : message.split("\n")) { - if (logger.open) { - TTY.println("..."); - logger.open = false; - } - TTY.print(space(logger.level)); - TTY.println(line); - } - } - } - - public static void startScope(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - if (logger.open) { - TTY.println("..."); - logger.open = false; - } - TTY.print(space(logger.level)); - TTY.print(message); - logger.openStack.push(logger.open); - logger.open = true; - logger.level++; - } - } - - public static void endScope(String message) { - if (ENABLED) { - Logger logger = loggerTL.get(); - logger.level--; - if (logger.open) { - TTY.println(message); - } else { - TTY.println(space(logger.level) + "..." + message); - } - logger.open = logger.openStack.pop(); - } - } - - private static String[] spaces = new String[50]; - - private static String space(int count) { - assert count >= 0; - String result; - if (count >= spaces.length || spaces[count] == null) { - StringBuilder str = new StringBuilder(); - for (int i = 0; i < count * SPACING; i++) { - str.append(' '); - } - result = str.toString(); - if (count < spaces.length) { - spaces[count] = result; - } - } else { - result = spaces[count]; - } - return result; - } - - public static String pretty(Object value) { - if (value == null) { - return "null"; - } - - Class klass = value.getClass(); - if (value instanceof Void) { - return "void"; - } else if (value instanceof String) { - return "\"" + value + "\""; - } else if (value instanceof Method) { - return "method \"" + ((Method) value).getName() + "\""; - } else if (value instanceof Class) { - return "class \"" + ((Class) value).getSimpleName() + "\""; - } else if (value instanceof Integer) { - if ((Integer) value < 10) { - return value.toString(); - } - return value + " (0x" + Integer.toHexString((Integer) value) + ")"; - } else if (value instanceof Long) { - if ((Long) value < 10 && (Long) value > -10) { - return value + "l"; - } - return value + "l (0x" + Long.toHexString((Long) value) + "l)"; - } else if (klass.isArray()) { - StringBuilder str = new StringBuilder(); - int dimensions = 0; - while (klass.isArray()) { - dimensions++; - klass = klass.getComponentType(); - } - int length = Array.getLength(value); - str.append(klass.getSimpleName()).append('[').append(length).append(']'); - for (int i = 1; i < dimensions; i++) { - str.append("[]"); - } - str.append(" {"); - for (int i = 0; i < length; i++) { - str.append(pretty(Array.get(value, i))); - if (i < length - 1) { - str.append(", "); - } - } - str.append('}'); - return str.toString(); - } - - return value.toString(); - } -} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/LoggingProxy.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/LoggingProxy.java Tue May 19 23:16:07 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +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. - */ -package com.oracle.graal.hotspot.logging; - -import java.lang.reflect.*; - -/** - * A java.lang.reflect proxy that hierarchically logs all method invocations along with their - * parameters and return values. - */ -public class LoggingProxy implements InvocationHandler { - - private T delegate; - - public LoggingProxy(T delegate) { - this.delegate = delegate; - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - int argCount = args == null ? 0 : args.length; - if (method.getParameterTypes().length != argCount) { - throw new RuntimeException("wrong parameter count"); - } - StringBuilder str = new StringBuilder(); - str.append(method.getReturnType().getSimpleName() + " " + method.getDeclaringClass().getSimpleName() + "." + method.getName() + "("); - for (int i = 0; i < argCount; i++) { - str.append(i == 0 ? "" : ", "); - str.append(Logger.pretty(args[i])); - } - str.append(")"); - Logger.startScope(str.toString()); - final Object result; - try { - if (args == null) { - result = method.invoke(delegate); - } else { - result = method.invoke(delegate, args); - } - } catch (InvocationTargetException e) { - Logger.endScope(" = Exception " + e.getMessage()); - throw e.getCause(); - } - Logger.endScope(" = " + Logger.pretty(result)); - return result; - } - - /** - * The object returned by this method will implement all interfaces that are implemented by - * delegate. - */ - public static T getProxy(Class interf, T delegate) { - Class[] interfaces = ProxyUtil.getAllInterfaces(delegate.getClass()); - Object obj = Proxy.newProxyInstance(interf.getClassLoader(), interfaces, new LoggingProxy<>(delegate)); - return interf.cast(obj); - } -} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/ProxyUtil.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/ProxyUtil.java Tue May 19 23:16:07 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +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. - */ -package com.oracle.graal.hotspot.logging; - -import java.util.*; - -public final class ProxyUtil { - - public static Class[] getAllInterfaces(Class clazz) { - HashSet> interfaces = new HashSet<>(); - getAllInterfaces(clazz, interfaces); - return interfaces.toArray(new Class[interfaces.size()]); - } - - private static void getAllInterfaces(Class clazz, HashSet> interfaces) { - for (Class iface : clazz.getInterfaces()) { - if (!interfaces.contains(iface)) { - interfaces.add(iface); - getAllInterfaces(iface, interfaces); - } - } - if (clazz.getSuperclass() != null) { - getAllInterfaces(clazz.getSuperclass(), interfaces); - } - } -} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/package-info.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/logging/package-info.java Tue May 19 23:16:07 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +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. - */ -/** - * Logging framework for the HotSpot CRI implementation. - */ -package com.oracle.graal.hotspot.logging; - diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotHostForeignCallsProvider.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -24,6 +24,7 @@ import static com.oracle.graal.api.code.CallingConvention.Type.*; import static com.oracle.graal.api.meta.LocationIdentity.*; +import static com.oracle.graal.compiler.target.Backend.*; import static com.oracle.graal.hotspot.HotSpotBackend.*; import static com.oracle.graal.hotspot.HotSpotBackend.Options.*; import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*; diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodUnresolved.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodUnresolved.java Tue May 19 23:16:07 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +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. - */ -package com.oracle.graal.hotspot.meta; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.jvmci.*; - -/** - * Implementation of {@link JavaMethod} for unresolved HotSpot methods. - */ -public final class HotSpotMethodUnresolved extends HotSpotMethod { - - private final Signature signature; - protected JavaType holder; - - public HotSpotMethodUnresolved(String name, Signature signature, JavaType holder) { - super(name); - this.holder = holder; - this.signature = signature; - } - - @Override - public Signature getSignature() { - return signature; - } - - @Override - public JavaType getDeclaringClass() { - return holder; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof HotSpotMethodUnresolved)) { - return false; - } - HotSpotMethodUnresolved that = (HotSpotMethodUnresolved) obj; - return this.name.equals(that.name) && this.signature.equals(that.signature) && this.holder.equals(that.holder); - } -} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Tue May 19 23:16:07 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ForeignCallStub.java Fri May 22 23:26:20 2015 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -123,7 +123,7 @@ for (int i = 0; i < arguments.length; i++) { parameters[i] = metaAccess.lookupJavaType(arguments[i]); } - return new HotSpotSignature(runtime, metaAccess.lookupJavaType(d.getResultType()), parameters); + return new HotSpotSignature(runtime.getJVMCIRuntime(), metaAccess.lookupJavaType(d.getResultType()), parameters); } public String getName() { diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.jvmci.runtime/src/com/oracle/jvmci/runtime/JVMCI.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.runtime/src/com/oracle/jvmci/runtime/JVMCI.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.jvmci.runtime; + +import java.util.*; + +public class JVMCI { + + private static final JVMCIRuntime runtime; + + private static native JVMCIRuntime initializeRuntime(); + + /** + * Gets the singleton {@link JVMCIRuntime} instance available to the application. + * + * @throws UnsupportedOperationException if JVMCI is not supported + */ + public static JVMCIRuntime getRuntime() { + if (runtime == null) { + String javaHome = System.getProperty("java.home"); + String vmName = System.getProperty("java.vm.name"); + Formatter errorMessage = new Formatter(); + errorMessage.format("The VM does not support the JVMCI API.%n"); + errorMessage.format("Currently used Java home directory is %s.%n", javaHome); + errorMessage.format("Currently used VM configuration is: %s", vmName); + throw new UnsupportedOperationException(errorMessage.toString()); + } + return runtime; + } + + static { + JVMCIRuntime rt = null; + try { + rt = initializeRuntime(); + } catch (UnsatisfiedLinkError e) { + } + runtime = rt; + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.jvmci.runtime/src/com/oracle/jvmci/runtime/JVMCIBackend.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.runtime/src/com/oracle/jvmci/runtime/JVMCIBackend.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.jvmci.runtime; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; + +/** + * A JVMCI backend encapsulates the capabilities needed by a Java based compiler for compiling and + * installing code for a single compute unit within a JVM. In a JVM with support for heterogeneous + * computing, more than one backend may be exposed. + */ +public class JVMCIBackend { + + private final MetaAccessProvider metaAccess; + private final CodeCacheProvider codeCache; + private final ConstantReflectionProvider constantReflection; + + public JVMCIBackend(MetaAccessProvider metaAccess, CodeCacheProvider codeCache, ConstantReflectionProvider constantReflection) { + this.metaAccess = metaAccess; + this.codeCache = codeCache; + this.constantReflection = constantReflection; + } + + public MetaAccessProvider getMetaAccess() { + return metaAccess; + } + + public CodeCacheProvider getCodeCache() { + return codeCache; + } + + public ConstantReflectionProvider getConstantReflection() { + return constantReflection; + } + + public TargetDescription getTarget() { + return codeCache.getTarget(); + } +} diff -r 1da7aef31a08 -r 07b088d61d5d graal/com.oracle.jvmci.runtime/src/com/oracle/jvmci/runtime/JVMCIRuntime.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.jvmci.runtime/src/com/oracle/jvmci/runtime/JVMCIRuntime.java Fri May 22 23:26:20 2015 +0200 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.jvmci.runtime; + +import com.oracle.graal.api.code.*; + +/** + * Interface for accessing the {@link JVMCI} APIs supported by the runtime. + */ +public interface JVMCIRuntime { + + /** + * Gets the host JVMCI backend. + */ + JVMCIBackend getHostJVMCIBackend(); + + /** + * Gets the backend for a given architecture. + * + * @param arch a specific architecture class + */ + JVMCIBackend getJVMCIBackend(Class arch); +} diff -r 1da7aef31a08 -r 07b088d61d5d make/defs.make --- a/make/defs.make Tue May 19 23:16:07 2015 +0200 +++ b/make/defs.make Fri May 22 23:26:20 2015 +0200 @@ -369,6 +369,8 @@ 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.graal.hotspot.jvmci.HotSpotJVMCIBackendFactory .PHONY: $(HS_ALT_MAKE)/defs.make diff -r 1da7aef31a08 -r 07b088d61d5d mx/suite.py --- a/mx/suite.py Tue May 19 23:16:07 2015 +0200 +++ b/mx/suite.py Fri May 22 23:26:20 2015 +0200 @@ -167,6 +167,17 @@ "javaCompliance" : "1.7", }, + "com.oracle.jvmci.runtime" : { + "subDir" : "graal", + "sourceDirs" : ["src"], + "dependencies" : [ + "com.oracle.graal.api.code" + ], + "checkstyle" : "com.oracle.graal.graph", + "javaCompliance" : "1.8", + "workingSets" : "API,Graal", + }, + "com.oracle.graal.api.collections" : { "subDir" : "graal", "sourceDirs" : ["src"], @@ -302,6 +313,7 @@ "subDir" : "graal", "sourceDirs" : ["src"], "dependencies" : [ + "com.oracle.jvmci.runtime", "com.oracle.graal.replacements", "com.oracle.graal.runtime", "com.oracle.graal.printer", diff -r 1da7aef31a08 -r 07b088d61d5d src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Tue May 19 23:16:07 2015 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Fri May 22 23:26:20 2015 +0200 @@ -316,7 +316,6 @@ GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotObjectConstantImpl, "com/oracle/graal/hotspot/jvmci/HotSpotObjectConstantImpl")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotMetaspaceConstantImpl, "com/oracle/graal/hotspot/jvmci/HotSpotMetaspaceConstantImpl")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_jvmci_HotSpotStackFrameReference, "com/oracle/graal/hotspot/jvmci/HotSpotStackFrameReference")) \ - GRAAL_ONLY(template(com_oracle_graal_hotspot_HotSpotGraalRuntime, "com/oracle/graal/hotspot/HotSpotGraalRuntime")) \ GRAAL_ONLY(template(com_oracle_graal_hotspot_CompilationTask, "com/oracle/graal/hotspot/CompilationTask")) \ GRAAL_ONLY(template(com_oracle_graal_api_meta_JavaConstant, "com/oracle/graal/api/meta/JavaConstant")) \ GRAAL_ONLY(template(com_oracle_graal_api_meta_PrimitiveConstant, "com/oracle/graal/api/meta/PrimitiveConstant")) \ diff -r 1da7aef31a08 -r 07b088d61d5d src/share/vm/compiler/compileBroker.cpp --- a/src/share/vm/compiler/compileBroker.cpp Tue May 19 23:16:07 2015 +0200 +++ b/src/share/vm/compiler/compileBroker.cpp Fri May 22 23:26:20 2015 +0200 @@ -1340,9 +1340,9 @@ } } - // Don't allow blocking compilation requests to Graal - // if Graal itself is not yet initialized - if (!GraalRuntime::is_HotSpotGraalRuntime_initialized() && compiler(comp_level)->is_graal()) { + // 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()) { blocking = false; } diff -r 1da7aef31a08 -r 07b088d61d5d src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Tue May 19 23:16:07 2015 +0200 +++ b/src/share/vm/graal/graalCompiler.cpp Fri May 22 23:26:20 2015 +0200 @@ -158,11 +158,11 @@ void GraalCompiler::compile_the_world() { HandleMark hm; JavaThread* THREAD = JavaThread::current(); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/jvmci/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_HotSpotGraalRuntime()); + args.push_oop(GraalRuntime::get_HotSpotJVMCIRuntime()); JavaCalls::call_special(&result, klass, compileTheWorld, vmSymbols::void_method_signature(), &args, CHECK_ABORT); } diff -r 1da7aef31a08 -r 07b088d61d5d src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Tue May 19 23:16:07 2015 +0200 +++ b/src/share/vm/graal/graalRuntime.cpp Fri May 22 23:26:20 2015 +0200 @@ -38,8 +38,8 @@ #include "runtime/reflection.hpp" #include "utilities/debug.hpp" -jobject GraalRuntime::_HotSpotGraalRuntime_instance = NULL; -bool GraalRuntime::_HotSpotGraalRuntime_initialized = false; + jobject GraalRuntime::_HotSpotJVMCIRuntime_instance = NULL; +bool GraalRuntime::_HotSpotJVMCIRuntime_initialized = false; bool GraalRuntime::_shutdown_called = false; void GraalRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) { @@ -625,10 +625,10 @@ SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_GRAAL_WKID, scan, CHECK); JVM_END -// private static GraalRuntime Graal.initializeRuntime() -JVM_ENTRY(jobject, JVM_GetGraalRuntime(JNIEnv *env, jclass c)) - GraalRuntime::initialize_HotSpotGraalRuntime(); - return GraalRuntime::get_HotSpotGraalRuntime_jobject(); +// 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) @@ -682,7 +682,7 @@ } Handle GraalRuntime::callInitializer(const char* className, const char* methodName, const char* returnType) { - guarantee(!_HotSpotGraalRuntime_initialized, "cannot reinitialize HotSpotGraalRuntime"); + guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); Thread* THREAD = Thread::current(); check_generated_sources_sha1(CHECK_ABORT_(Handle())); @@ -695,29 +695,29 @@ return Handle((oop)result.get_jobject()); } -void GraalRuntime::initialize_HotSpotGraalRuntime() { - if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) { +void GraalRuntime::initialize_HotSpotJVMCIRuntime() { + if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { #ifdef ASSERT - // This should only be called in the context of the Graal class being initialized + // 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/graal/api/runtime/Graal", CHECK_ABORT); + 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), - "HotSpotGraalRuntime initialization should only be triggered through Graal initialization"); + "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization"); #endif - Handle result = callInitializer("com/oracle/graal/hotspot/HotSpotGraalRuntime", "runtime", - "()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;"); - _HotSpotGraalRuntime_initialized = true; - _HotSpotGraalRuntime_instance = JNIHandles::make_global(result()); + Handle result = callInitializer("com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime", "runtime", + "()Lcom/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime;"); + _HotSpotJVMCIRuntime_initialized = true; + _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result()); } } -void GraalRuntime::initialize_Graal() { - if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) { - callInitializer("com/oracle/graal/api/runtime/Graal", "getRuntime", "()Lcom/oracle/graal/api/runtime/GraalRuntime;"); +void GraalRuntime::initialize_JVMCI() { + if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { + callInitializer("com/oracle/jvmci/runtime/JVMCI", "getRuntime", "()Lcom/oracle/jvmci/runtime/JVMCIRuntime;"); } - assert(_HotSpotGraalRuntime_initialized == true, "what?"); + assert(_HotSpotJVMCIRuntime_initialized == true, "what?"); } // private static void CompilerToVMImpl.init() @@ -1015,19 +1015,19 @@ } void GraalRuntime::shutdown() { - if (_HotSpotGraalRuntime_instance != NULL) { + if (_HotSpotJVMCIRuntime_instance != NULL) { _shutdown_called = true; JavaThread* THREAD = JavaThread::current(); HandleMark hm(THREAD); - TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", CHECK_ABORT); + TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/jvmci/HotSpotJVMCIRuntime", CHECK_ABORT); KlassHandle klass = load_required_class(name); JavaValue result(T_VOID); JavaCallArguments args; - args.push_oop(get_HotSpotGraalRuntime()); + args.push_oop(get_HotSpotJVMCIRuntime()); JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT); - JNIHandles::destroy_global(_HotSpotGraalRuntime_instance); - _HotSpotGraalRuntime_instance = NULL; + JNIHandles::destroy_global(_HotSpotJVMCIRuntime_instance); + _HotSpotJVMCIRuntime_instance = NULL; } } diff -r 1da7aef31a08 -r 07b088d61d5d src/share/vm/graal/graalRuntime.hpp --- a/src/share/vm/graal/graalRuntime.hpp Tue May 19 23:16:07 2015 +0200 +++ b/src/share/vm/graal/graalRuntime.hpp Fri May 22 23:26:20 2015 +0200 @@ -31,8 +31,8 @@ class GraalRuntime: public CHeapObj { private: - static jobject _HotSpotGraalRuntime_instance; - static bool _HotSpotGraalRuntime_initialized; + static jobject _HotSpotJVMCIRuntime_instance; + static bool _HotSpotJVMCIRuntime_initialized; static const char* _generated_sources_sha1; static bool _shutdown_called; @@ -133,33 +133,33 @@ static void initialize_natives(JNIEnv *env, jclass c2vmClass); - static bool is_HotSpotGraalRuntime_initialized() { return _HotSpotGraalRuntime_initialized; } + static bool is_HotSpotJVMCIRuntime_initialized() { return _HotSpotJVMCIRuntime_initialized; } /** - * Gets the singleton HotSpotGraalRuntime instance, initializing it if necessary + * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary */ - static Handle get_HotSpotGraalRuntime() { - initialize_Graal(); - return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance)); + static Handle get_HotSpotJVMCIRuntime() { + initialize_JVMCI(); + return Handle(JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance)); } - static jobject get_HotSpotGraalRuntime_jobject() { - initialize_Graal(); - assert(_HotSpotGraalRuntime_initialized, "must be"); - return _HotSpotGraalRuntime_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 HotSpotGraalRuntime through Graal.runtime() + * Trigger initialization of HotSpotJVMCIRuntime through JVMCI.getRuntime() */ - static void initialize_Graal(); + static void initialize_JVMCI(); /** - * Explicitly initialize HotSpotGraalRuntime itself + * Explicitly initialize HotSpotJVMCIRuntime itself */ - static void initialize_HotSpotGraalRuntime(); + static void initialize_HotSpotJVMCIRuntime(); static void shutdown(); diff -r 1da7aef31a08 -r 07b088d61d5d src/share/vm/prims/nativeLookup.cpp --- a/src/share/vm/prims/nativeLookup.cpp Tue May 19 23:16:07 2015 +0200 +++ b/src/share/vm/prims/nativeLookup.cpp Fri May 22 23:26:20 2015 +0200 @@ -129,6 +129,7 @@ #ifdef GRAAL void JNICALL JVM_InitGraalClassLoader(JNIEnv *env, jclass c, jobject loader); void JNICALL JVM_InitializeGraalNatives(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_CreateTruffleRuntime(JNIEnv *env, jclass c); @@ -150,7 +151,7 @@ { 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) }, - { CC"Java_com_oracle_graal_api_runtime_Graal_initializeRuntime", NULL, FN_PTR(JVM_GetGraalRuntime) }, + { CC"Java_com_oracle_jvmci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) }, { CC"Java_com_oracle_graal_api_runtime_Services_getServiceImpls", NULL, FN_PTR(JVM_GetGraalServiceImpls) }, { 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) },