8055913: Node.hashCode() delegates to Object.hashCode() and is hot
authorattila
Tue, 26 Aug 2014 11:32:12 +0200
changeset 26244 4f3e221fd4ad
parent 26243 438aba09d465
child 26245 136ee2110f57
8055913: Node.hashCode() delegates to Object.hashCode() and is hot Reviewed-by: lagergren, sundar
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Node.java
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Node.java	Tue Aug 26 11:31:31 2014 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Node.java	Tue Aug 26 11:32:12 2014 +0200
@@ -178,12 +178,15 @@
 
     @Override
     public final boolean equals(final Object other) {
-        return super.equals(other);
+        return this == other;
     }
 
     @Override
     public final int hashCode() {
-        return super.hashCode();
+        // NOTE: we aren't delegating to Object.hashCode as it still requires trip to the VM for initializing,
+        // it touches the object header and/or stores the identity hashcode somewhere, etc. There's several
+        // places in the compiler pipeline that store nodes in maps, so this can get hot.
+        return Long.hashCode(token);
     }
 
     /**