# HG changeset patch # User Doug Simon # Date 1428421279 -7200 # Node ID 63e4f33dce8424b4eb1f2cea2e35cb8aadd0f8a9 # Parent a2cd0e7072e22c0835b9a5286d623c7fb35866a6 moved registration of AMD64 specific plugins to AMD64GraphBuilderPlugins diff -r a2cd0e7072e2 -r 63e4f33dce84 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 Apr 07 17:32:26 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackendFactory.java Tue Apr 07 17:41:19 2015 +0200 @@ -188,7 +188,7 @@ protected Plugins createGraphBuilderPlugins(HotSpotGraalRuntimeProvider runtime, TargetDescription target, HotSpotConstantReflectionProvider constantReflection, HotSpotHostForeignCallsProvider foreignCalls, HotSpotMetaAccessProvider metaAccess, HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes, HotSpotStampProvider stampProvider) { - Plugins plugins = HotSpotGraphBuilderPlugins.create(runtime.getConfig(), wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements, target.arch); + Plugins plugins = HotSpotGraphBuilderPlugins.create(runtime.getConfig(), wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements); AMD64GraphBuilderPlugins.register(plugins, (AMD64) target.arch); return plugins; } diff -r a2cd0e7072e2 -r 63e4f33dce84 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 Apr 07 17:32:26 2015 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackendFactory.java Tue Apr 07 17:41:19 2015 +0200 @@ -69,7 +69,7 @@ HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(p, snippetReflection, runtime.getConfig(), target); HotSpotDisassemblerProvider disassembler = new HotSpotDisassemblerProvider(runtime); HotSpotWordTypes wordTypes = new HotSpotWordTypes(metaAccess, target.wordKind); - Plugins plugins = createGraphBuilderPlugins(runtime, target, metaAccess, constantReflection, foreignCalls, stampProvider, snippetReflection, replacements, wordTypes); + Plugins plugins = createGraphBuilderPlugins(runtime, metaAccess, constantReflection, foreignCalls, stampProvider, snippetReflection, replacements, wordTypes); replacements.setGraphBuilderPlugins(plugins); HotSpotSuitesProvider suites = createSuites(runtime, plugins); HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, foreignCalls, lowerer, replacements, disassembler, suites, registers, snippetReflection, @@ -78,10 +78,10 @@ return createBackend(runtime, providers); } - protected Plugins createGraphBuilderPlugins(HotSpotGraalRuntimeProvider runtime, TargetDescription target, HotSpotMetaAccessProvider metaAccess, - HotSpotConstantReflectionProvider constantReflection, HotSpotForeignCallsProvider foreignCalls, HotSpotStampProvider stampProvider, - HotSpotSnippetReflectionProvider snippetReflection, HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes) { - Plugins plugins = HotSpotGraphBuilderPlugins.create(runtime.getConfig(), wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements, target.arch); + protected Plugins createGraphBuilderPlugins(HotSpotGraalRuntimeProvider runtime, HotSpotMetaAccessProvider metaAccess, HotSpotConstantReflectionProvider constantReflection, + HotSpotForeignCallsProvider foreignCalls, HotSpotStampProvider stampProvider, HotSpotSnippetReflectionProvider snippetReflection, + HotSpotReplacementsImpl replacements, HotSpotWordTypes wordTypes) { + Plugins plugins = HotSpotGraphBuilderPlugins.create(runtime.getConfig(), wordTypes, metaAccess, constantReflection, snippetReflection, foreignCalls, stampProvider, replacements); SPARCGraphBuilderPlugins.register(plugins); return plugins; } diff -r a2cd0e7072e2 -r 63e4f33dce84 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Tue Apr 07 17:32:26 2015 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java Tue Apr 07 17:41:19 2015 +0200 @@ -58,14 +58,13 @@ /** * Creates a {@link Plugins} object that should be used when running on HotSpot. - * * @param constantReflection * @param snippetReflection * @param foreignCalls * @param stampProvider */ public static Plugins create(HotSpotVMConfig config, HotSpotWordTypes wordTypes, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, - SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, StampProvider stampProvider, ReplacementsImpl replacements, Architecture arch) { + SnippetReflectionProvider snippetReflection, ForeignCallsProvider foreignCalls, StampProvider stampProvider, ReplacementsImpl replacements) { InvocationPlugins invocationPlugins = new HotSpotInvocationPlugins(config, metaAccess, constantReflection.getMethodHandleAccess()); Plugins plugins = new Plugins(invocationPlugins); @@ -85,7 +84,7 @@ registerCallSitePlugins(invocationPlugins); registerReflectionPlugins(invocationPlugins); registerStableOptionPlugins(invocationPlugins); - StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, arch, invocationPlugins, !config.useHeapProfiler); + StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, invocationPlugins, !config.useHeapProfiler); return plugins; } diff -r a2cd0e7072e2 -r 63e4f33dce84 graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64GraphBuilderPlugins.java --- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64GraphBuilderPlugins.java Tue Apr 07 17:32:26 2015 +0200 +++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64GraphBuilderPlugins.java Tue Apr 07 17:41:19 2015 +0200 @@ -22,6 +22,9 @@ */ package com.oracle.graal.replacements.amd64; +import static com.oracle.graal.replacements.nodes.MathIntrinsicNode.Operation.*; +import sun.misc.*; + import com.oracle.graal.amd64.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.graphbuilderconf.GraphBuilderConfiguration.Plugins; @@ -29,7 +32,9 @@ import com.oracle.graal.graphbuilderconf.InvocationPlugins.Receiver; import com.oracle.graal.graphbuilderconf.InvocationPlugins.Registration; import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.java.*; import com.oracle.graal.replacements.*; +import com.oracle.graal.replacements.nodes.*; public class AMD64GraphBuilderPlugins { @@ -37,6 +42,8 @@ InvocationPlugins invocationPlugins = plugins.getInvocationPlugins(); registerIntegerLongPlugins(invocationPlugins, IntegerSubstitutions.class, Kind.Int, arch); registerIntegerLongPlugins(invocationPlugins, LongSubstitutions.class, Kind.Long, arch); + registerUnsafePlugins(invocationPlugins); + registerMathPlugins(invocationPlugins); } private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class substituteDeclaringClass, Kind kind, AMD64 arch) { @@ -75,4 +82,46 @@ } } + private static void registerMathPlugins(InvocationPlugins plugins) { + Registration r = new Registration(plugins, Math.class); + r.register1("log", Double.TYPE, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { + b.push(Kind.Double, b.recursiveAppend(MathIntrinsicNode.create(value, LOG))); + return true; + } + }); + r.register1("log10", Double.TYPE, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { + b.push(Kind.Double, b.recursiveAppend(MathIntrinsicNode.create(value, LOG10))); + return true; + } + }); + } + + private static void registerUnsafePlugins(InvocationPlugins plugins) { + Registration r = new Registration(plugins, Unsafe.class); + + for (Kind kind : new Kind[]{Kind.Int, Kind.Long, Kind.Object}) { + Class javaClass = kind == Kind.Object ? Object.class : kind.toJavaClass(); + + r.register4("getAndSet" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) { + // Emits a null-check for the otherwise unused receiver + unsafe.get(); + b.addPush(kind.getStackKind(), new AtomicReadAndWriteNode(object, offset, value, kind, LocationIdentity.any())); + return true; + } + }); + if (kind != Kind.Object) { + r.register4("getAndAdd" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() { + public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode delta) { + // Emits a null-check for the otherwise unused receiver + unsafe.get(); + b.addPush(kind.getStackKind(), new AtomicReadAndAddNode(object, offset, delta, LocationIdentity.any())); + return true; + } + }); + } + } + } } diff -r a2cd0e7072e2 -r 63e4f33dce84 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Tue Apr 07 17:32:26 2015 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java Tue Apr 07 17:41:19 2015 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.replacements; import static com.oracle.graal.api.code.MemoryBarriers.*; -import static com.oracle.graal.replacements.nodes.MathIntrinsicNode.Operation.*; import sun.misc.*; import com.oracle.graal.api.code.*; @@ -57,10 +56,10 @@ } // @formatter:on - public static void registerInvocationPlugins(MetaAccessProvider metaAccess, Architecture arch, InvocationPlugins plugins, boolean useBoxingPlugins) { + public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean useBoxingPlugins) { registerObjectPlugins(plugins); registerClassPlugins(plugins); - registerMathPlugins(arch, plugins); + registerMathPlugins(plugins); registerUnsignedMathPlugins(plugins); registerCharacterPlugins(plugins); registerShortPlugins(plugins); @@ -68,7 +67,7 @@ registerIntegerLongPlugins(plugins, Kind.Long); registerFloatPlugins(plugins); registerDoublePlugins(plugins); - registerUnsafePlugins(arch, plugins); + registerUnsafePlugins(plugins); registerEdgesPlugins(metaAccess, plugins); registerGraalDirectivesPlugins(plugins); if (useBoxingPlugins) { @@ -79,7 +78,7 @@ } } - private static void registerUnsafePlugins(Architecture arch, InvocationPlugins plugins) { + private static void registerUnsafePlugins(InvocationPlugins plugins) { Registration r = new Registration(plugins, Unsafe.class); for (Kind kind : Kind.values()) { if ((kind.isPrimitive() && kind != Kind.Void) || kind == Kind.Object) { @@ -119,39 +118,9 @@ return true; } }); - - if (getAndSetEnabled(arch)) { - r.register4("getAndSet" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() { - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode value) { - // Emits a null-check for the otherwise unused receiver - unsafe.get(); - b.addPush(kind.getStackKind(), new AtomicReadAndWriteNode(object, offset, value, kind, LocationIdentity.any())); - return true; - } - }); - if (kind != Kind.Object) { - r.register4("getAndAdd" + kind.name(), Receiver.class, Object.class, long.class, javaClass, new InvocationPlugin() { - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unsafe, ValueNode object, ValueNode offset, ValueNode delta) { - // Emits a null-check for the otherwise unused receiver - unsafe.get(); - b.addPush(kind.getStackKind(), new AtomicReadAndAddNode(object, offset, delta, LocationIdentity.any())); - return true; - } - }); - } - } } } - /** - * Determines if the platform includes such for intrinsifying the {@link Unsafe#getAndSetInt} - * method family. - */ - public static boolean getAndSetEnabled(Architecture arch) { - // FIXME should return whether the current compilation target supports these - return arch.getName().equals("AMD64"); - } - private static void registerIntegerLongPlugins(InvocationPlugins plugins, Kind kind) { Class declaringClass = kind.toBoxedJavaClass(); Class type = kind.toJavaClass(); @@ -242,7 +211,7 @@ }); } - private static void registerMathPlugins(Architecture arch, InvocationPlugins plugins) { + private static void registerMathPlugins(InvocationPlugins plugins) { Registration r = new Registration(plugins, Math.class); for (Kind kind : new Kind[]{Kind.Int, Kind.Long}) { Class type = kind.toJavaClass(); @@ -294,20 +263,6 @@ return true; } }); - if (getAndSetEnabled(arch)) { - r.register1("log", Double.TYPE, new InvocationPlugin() { - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { - b.push(Kind.Double, b.recursiveAppend(MathIntrinsicNode.create(value, LOG))); - return true; - } - }); - r.register1("log10", Double.TYPE, new InvocationPlugin() { - public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) { - b.push(Kind.Double, b.recursiveAppend(MathIntrinsicNode.create(value, LOG10))); - return true; - } - }); - } } public static class UnsignedMathPlugin implements InvocationPlugin {