changeset 11254:80c0b5c2ec08

macro node for System.identityHashCode
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 07 Aug 2013 18:35:59 +0200
parents 252958589b2b
children fe5ce6520b6c
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java	Wed Aug 07 18:35:38 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/SystemSubstitutions.java	Wed Aug 07 18:35:59 2013 +0200
@@ -29,8 +29,10 @@
 import com.oracle.graal.api.replacements.*;
 import com.oracle.graal.graph.Node.ConstantNodeParameter;
 import com.oracle.graal.graph.Node.NodeIntrinsic;
+import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.replacements.nodes.*;
 
 /**
  * Substitutions for {@link java.lang.System} methods.
@@ -54,6 +56,19 @@
         return callLong(JAVA_TIME_NANOS);
     }
 
+    public static class SystemIdentityHashCodeNode extends PureFunctionMacroNode {
+
+        public SystemIdentityHashCodeNode(Invoke invoke) {
+            super(invoke);
+        }
+
+        @Override
+        protected Constant evaluate(Constant param, MetaAccessProvider metaAccess) {
+            return param.isNull() ? null : Constant.forInt(System.identityHashCode(param.asObject()));
+        }
+    }
+
+    @MacroSubstitution(macro = SystemIdentityHashCodeNode.class)
     @MethodSubstitution
     public static int identityHashCode(Object x) {
         if (probability(NOT_FREQUENT_PROBABILITY, x == null)) {