Search in sources :

Example 11 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class AArch64GraphBuilderPlugins method register.

public static void register(Plugins plugins, BytecodeProvider bytecodeProvider) {
    InvocationPlugins invocationPlugins = plugins.getInvocationPlugins();
    invocationPlugins.defer(new Runnable() {

        @Override
        public void run() {
            registerIntegerLongPlugins(invocationPlugins, AArch64IntegerSubstitutions.class, JavaKind.Int, bytecodeProvider);
            registerIntegerLongPlugins(invocationPlugins, AArch64LongSubstitutions.class, JavaKind.Long, bytecodeProvider);
            registerMathPlugins(invocationPlugins);
        }
    });
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)

Example 12 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class AMD64GraphBuilderPlugins method register.

public static void register(Plugins plugins, BytecodeProvider replacementsBytecodeProvider, AMD64 arch, boolean arithmeticStubs) {
    InvocationPlugins invocationPlugins = plugins.getInvocationPlugins();
    invocationPlugins.defer(new Runnable() {

        @Override
        public void run() {
            registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, JavaKind.Int, arch, replacementsBytecodeProvider);
            registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, JavaKind.Long, arch, replacementsBytecodeProvider);
            registerUnsafePlugins(invocationPlugins, replacementsBytecodeProvider);
            registerStringPlugins(invocationPlugins, arch, replacementsBytecodeProvider);
            registerStringLatin1Plugins(invocationPlugins, replacementsBytecodeProvider);
            registerStringUTF16Plugins(invocationPlugins, replacementsBytecodeProvider);
            registerMathPlugins(invocationPlugins, arch, arithmeticStubs, replacementsBytecodeProvider);
            registerArraysEqualsPlugins(invocationPlugins, replacementsBytecodeProvider);
        }
    });
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) LongSubstitutions(org.graalvm.compiler.replacements.LongSubstitutions) IntegerSubstitutions(org.graalvm.compiler.replacements.IntegerSubstitutions)

Example 13 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class GraalUtil method getGraph.

public static StructuredGraph getGraph(GraalState graal, ResolvedJavaMethod javaMethod, boolean useProfilingInfo) {
    StructuredGraph graph = new StructuredGraph.Builder(graal.options, graal.debug, AllowAssumptions.YES).useProfilingInfo(useProfilingInfo).method(javaMethod).build();
    PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
    graphBuilderSuite.appendPhase(new GraphBuilderPhase(GraphBuilderConfiguration.getDefault(new Plugins(new InvocationPlugins()))));
    graphBuilderSuite.apply(graph, new HighTierContext(graal.providers, graphBuilderSuite, OptimisticOptimizations.ALL));
    return graph;
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) PhaseSuite(org.graalvm.compiler.phases.PhaseSuite) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 14 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class CheckGraalIntrinsics method test.

@Test
@SuppressWarnings("try")
public void test() throws ClassNotFoundException {
    HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
    HotSpotProviders providers = rt.getHostBackend().getProviders();
    Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins();
    InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins();
    HotSpotVMConfigStore store = rt.getVMConfig().getStore();
    List<VMIntrinsicMethod> intrinsics = store.getIntrinsics();
    List<String> missing = new ArrayList<>();
    EconomicMap<String, List<Binding>> bindings = invocationPlugins.getBindings(true);
    for (VMIntrinsicMethod intrinsic : intrinsics) {
        InvocationPlugin plugin = findPlugin(bindings, intrinsic);
        if (plugin == null) {
            ResolvedJavaMethod method = resolveIntrinsic(providers.getMetaAccess(), intrinsic);
            if (method != null) {
                IntrinsicMethod intrinsicMethod = providers.getConstantReflection().getMethodHandleAccess().lookupMethodHandleIntrinsic(method);
                if (intrinsicMethod != null) {
                    continue;
                }
            }
            String m = String.format("%s.%s%s", intrinsic.declaringClass, intrinsic.name, intrinsic.descriptor);
            if (!TO_BE_INVESTIGATED.contains(m) && !IGNORE.contains(m)) {
                missing.add(m);
            }
        }
    }
    if (!missing.isEmpty()) {
        Collections.sort(missing);
        String missingString = missing.stream().collect(Collectors.joining(String.format("%n    ")));
        fail("missing Graal intrinsics for:%n    %s", missingString);
    }
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) VMIntrinsicMethod(jdk.vm.ci.hotspot.VMIntrinsicMethod) IntrinsicMethod(jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod) RuntimeProvider(org.graalvm.compiler.runtime.RuntimeProvider) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) ArrayList(java.util.ArrayList) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ArrayList(java.util.ArrayList) List(java.util.List) HotSpotVMConfigStore(jdk.vm.ci.hotspot.HotSpotVMConfigStore) VMIntrinsicMethod(jdk.vm.ci.hotspot.VMIntrinsicMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins) GraalTest(org.graalvm.compiler.test.GraalTest) Test(org.junit.Test)

Example 15 with InvocationPlugins

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins in project graal by oracle.

the class UnsafeAutomaticSubstitutionProcessor method init.

public void init(MetaAccessProvider originalMetaAccess) {
    ResolvedJavaMethod atomicIntegerFieldUpdaterNewUpdaterMethod;
    ResolvedJavaMethod atomicLongFieldUpdaterNewUpdaterMethod;
    ResolvedJavaMethod atomicReferenceFieldUpdaterNewUpdaterMethod;
    try {
        Method unsafeObjectFieldOffset = sun.misc.Unsafe.class.getMethod("objectFieldOffset", java.lang.reflect.Field.class);
        unsafeObjectFieldOffsetMethod = originalMetaAccess.lookupJavaMethod(unsafeObjectFieldOffset);
        Method unsafeArrayBaseOffset = sun.misc.Unsafe.class.getMethod("arrayBaseOffset", java.lang.Class.class);
        unsafeArrayBaseOffsetMethod = originalMetaAccess.lookupJavaMethod(unsafeArrayBaseOffset);
        Method unsafeArrayIndexScale = sun.misc.Unsafe.class.getMethod("arrayIndexScale", java.lang.Class.class);
        unsafeArrayIndexScaleMethod = originalMetaAccess.lookupJavaMethod(unsafeArrayIndexScale);
        Method classGetDeclaredField = java.lang.Class.class.getMethod("getDeclaredField", String.class);
        classGetDeclaredFieldMethod = originalMetaAccess.lookupJavaMethod(classGetDeclaredField);
        Method integerNumberOfLeadingZeros = java.lang.Integer.class.getMethod("numberOfLeadingZeros", int.class);
        integerNumberOfLeadingZerosMethod = originalMetaAccess.lookupJavaMethod(integerNumberOfLeadingZeros);
        Method atomicIntegerFieldUpdaterNewUpdater = java.util.concurrent.atomic.AtomicIntegerFieldUpdater.class.getMethod("newUpdater", Class.class, String.class);
        atomicIntegerFieldUpdaterNewUpdaterMethod = originalMetaAccess.lookupJavaMethod(atomicIntegerFieldUpdaterNewUpdater);
        Method atomicLongFieldUpdaterNewUpdater = java.util.concurrent.atomic.AtomicLongFieldUpdater.class.getMethod("newUpdater", Class.class, String.class);
        atomicLongFieldUpdaterNewUpdaterMethod = originalMetaAccess.lookupJavaMethod(atomicLongFieldUpdaterNewUpdater);
        Method atomicReferenceFieldUpdaterNewUpdater = java.util.concurrent.atomic.AtomicReferenceFieldUpdater.class.getMethod("newUpdater", Class.class, Class.class, String.class);
        atomicReferenceFieldUpdaterNewUpdaterMethod = originalMetaAccess.lookupJavaMethod(atomicReferenceFieldUpdaterNewUpdater);
    } catch (NoSuchMethodException e) {
        throw VMError.shouldNotReachHere(e);
    }
    /*
         * Create the GraphBuilderPhase which builds the graph for the static initializers.
         * 
         * The builder phase will inline the first level callees to detect cases where the offset
         * computation is performed by methods that wrap over the unsafe API. There are two
         * exceptions:
         * 
         * 1. Don't inline the invokes that we are trying to match.
         * 
         * 2. Don't inline Atomic*FieldUpdater.newUpdater() methods as they lead to false errors.
         * These methods reach calls to Unsafe.objectFieldOffset() whose value is recomputed by
         * RecomputeFieldValue.Kind.AtomicFieldUpdaterOffset.
         */
    ResolvedJavaMethod[] neverInline = { unsafeObjectFieldOffsetMethod, unsafeArrayBaseOffsetMethod, unsafeArrayIndexScaleMethod, classGetDeclaredFieldMethod, integerNumberOfLeadingZerosMethod, atomicIntegerFieldUpdaterNewUpdaterMethod, atomicLongFieldUpdaterNewUpdaterMethod, atomicReferenceFieldUpdaterNewUpdaterMethod };
    StaticInitializerInlineInvokePlugin inlineInvokePlugin = new StaticInitializerInlineInvokePlugin(neverInline);
    Plugins plugins = new Plugins(new InvocationPlugins());
    plugins.appendInlineInvokePlugin(inlineInvokePlugin);
    builderPhase = new GraphBuilderPhase(GraphBuilderConfiguration.getDefault(plugins));
    /*
         * Analyzing certain classes leads to false errors. We disable reporting for those classes
         * by default.
         */
    try {
        supressWarnings.add(originalMetaAccess.lookupJavaType(Class.forName("sun.security.provider.ByteArrayAccess")));
    } catch (ClassNotFoundException e) {
        throw VMError.shouldNotReachHere(e);
    }
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Method(java.lang.reflect.Method) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Aggregations

InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)23 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)13 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)12 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)9 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)9 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)9 OptionValues (org.graalvm.compiler.options.OptionValues)9 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)7 RuntimeProvider (org.graalvm.compiler.runtime.RuntimeProvider)7 Method (java.lang.reflect.Method)6 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)6 DebugContext (org.graalvm.compiler.debug.DebugContext)6 PhaseSuite (org.graalvm.compiler.phases.PhaseSuite)6 Providers (org.graalvm.compiler.phases.util.Providers)6 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)5 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BailoutException (jdk.vm.ci.code.BailoutException)2 HotSpotVMConfigStore (jdk.vm.ci.hotspot.HotSpotVMConfigStore)2