changeset 22704:78293834a24b

Conditionally register invocation plugins that require deoptimization so that VM can decide to be deoptimization-free
author Christian Wimmer <christian.wimmer@oracle.com>
date Fri, 25 Sep 2015 14:52:23 -0700
parents d5793a653996
children 89520cbb9633
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java
diffstat 2 files changed, 26 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java	Fri Sep 25 11:24:55 2015 -0700
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotGraphBuilderPlugins.java	Fri Sep 25 14:52:23 2015 -0700
@@ -93,7 +93,7 @@
         registerStableOptionPlugins(invocationPlugins, snippetReflection);
         registerAESPlugins(invocationPlugins, config);
         registerCRC32Plugins(invocationPlugins, config);
-        StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, invocationPlugins, !config.useHeapProfiler);
+        StandardGraphBuilderPlugins.registerInvocationPlugins(metaAccess, invocationPlugins, !config.useHeapProfiler, true);
 
         return plugins;
     }
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java	Fri Sep 25 11:24:55 2015 -0700
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java	Fri Sep 25 14:52:23 2015 -0700
@@ -62,10 +62,10 @@
     }
     // @formatter:on
 
-    public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean useBoxingPlugins) {
+    public static void registerInvocationPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins, boolean useBoxingPlugins, boolean allowDeoptimization) {
         registerObjectPlugins(plugins);
         registerClassPlugins(plugins);
-        registerMathPlugins(plugins);
+        registerMathPlugins(plugins, allowDeoptimization);
         registerUnsignedMathPlugins(plugins);
         registerCharacterPlugins(plugins);
         registerShortPlugins(plugins);
@@ -278,28 +278,30 @@
         });
     }
 
-    private static void registerMathPlugins(InvocationPlugins plugins) {
+    private static void registerMathPlugins(InvocationPlugins plugins, boolean allowDeoptimization) {
         Registration r = new Registration(plugins, Math.class);
-        for (Kind kind : new Kind[]{Kind.Int, Kind.Long}) {
-            Class<?> type = kind.toJavaClass();
-            r.register2("addExact", type, type, new InvocationPlugin() {
-                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
-                    b.addPush(kind, new IntegerAddExactNode(x, y));
-                    return true;
-                }
-            });
-            r.register2("subtractExact", type, type, new InvocationPlugin() {
-                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
-                    b.addPush(kind, new IntegerSubExactNode(x, y));
-                    return true;
-                }
-            });
-            r.register2("multiplyExact", type, type, new InvocationPlugin() {
-                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
-                    b.addPush(kind, new IntegerMulExactNode(x, y));
-                    return true;
-                }
-            });
+        if (allowDeoptimization) {
+            for (Kind kind : new Kind[]{Kind.Int, Kind.Long}) {
+                Class<?> type = kind.toJavaClass();
+                r.register2("addExact", type, type, new InvocationPlugin() {
+                    public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
+                        b.addPush(kind, new IntegerAddExactNode(x, y));
+                        return true;
+                    }
+                });
+                r.register2("subtractExact", type, type, new InvocationPlugin() {
+                    public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
+                        b.addPush(kind, new IntegerSubExactNode(x, y));
+                        return true;
+                    }
+                });
+                r.register2("multiplyExact", type, type, new InvocationPlugin() {
+                    public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
+                        b.addPush(kind, new IntegerMulExactNode(x, y));
+                        return true;
+                    }
+                });
+            }
         }
         r.register1("abs", Float.TYPE, new InvocationPlugin() {
             public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {