changeset 20877:5d9bad7192f8

disable String.equals intrinsic if RegisterPressure is enabled
author Doug Simon <doug.simon@oracle.com>
date Thu, 09 Apr 2015 21:23:24 +0200
parents 9ea32f3fc8ce
children 673e0b242d4d
files graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java
diffstat 2 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Thu Apr 09 19:17:51 2015 +0200
+++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java	Thu Apr 09 21:23:24 2015 +0200
@@ -202,7 +202,7 @@
     public static final OptionValue<Boolean> HotSpotPrintInlining = new OptionValue<>(false);
 
     // Register allocator debugging
-    @Option(help = "Comma separated list of register that the allocation is limited to.", type = OptionType.Debug)
+    @Option(help = "Comma separated list of registers that register allocation is limited to.", type = OptionType.Debug)
     public static final OptionValue<String> RegisterPressure = new OptionValue<>(null);
 
     @Option(help = "", type = OptionType.Debug)
--- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java	Thu Apr 09 19:17:51 2015 +0200
+++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/StandardGraphBuilderPlugins.java	Thu Apr 09 21:23:24 2015 +0200
@@ -23,6 +23,7 @@
 package com.oracle.graal.replacements;
 
 import static com.oracle.graal.api.code.MemoryBarriers.*;
+import static com.oracle.graal.compiler.common.GraalOptions.*;
 
 import java.lang.reflect.*;
 import java.util.*;
@@ -96,17 +97,23 @@
     }
 
     private static void registerStringPlugins(InvocationPlugins plugins) {
-        Registration r = new Registration(plugins, String.class);
-        r.registerMethodSubstitution(StringSubstitutions.class, "equals", Receiver.class, Object.class);
+        /*
+         * AMD64's String.equals substitution needs about 8 registers so we disable it if there is
+         * some artificial register pressure.
+         */
+        if (RegisterPressure.getValue() == null) {
+            Registration r = new Registration(plugins, String.class);
+            r.registerMethodSubstitution(StringSubstitutions.class, "equals", Receiver.class, Object.class);
 
-        r = new Registration(plugins, StringSubstitutions.class);
-        r.register1("getValue", String.class, new InvocationPlugin() {
-            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
-                ResolvedJavaField field = b.getMetaAccess().lookupJavaField(STRING_VALUE_FIELD);
-                b.addPush(new LoadFieldNode(value, field));
-                return true;
-            }
-        });
+            r = new Registration(plugins, StringSubstitutions.class);
+            r.register1("getValue", String.class, new InvocationPlugin() {
+                public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
+                    ResolvedJavaField field = b.getMetaAccess().lookupJavaField(STRING_VALUE_FIELD);
+                    b.addPush(new LoadFieldNode(value, field));
+                    return true;
+                }
+            });
+        }
     }
 
     private static void registerArraysPlugins(InvocationPlugins plugins) {