summaryrefslogtreecommitdiff
path: root/src/jvm
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2010-04-18 10:06:16 -0400
committerRich Hickey <richhickey@gmail.com>2010-04-18 10:06:16 -0400
commit19dd3c593e7a29cbca514c6ab7424ff22e353cc6 (patch)
treece71e1c27b7ab772c5487b26702917c1e37276e1 /src/jvm
parenta8e92018ce0ce32fc59fae2072369a8671fdea62 (diff)
Remove perf hacks from MethodImplCache, restore new reduce impl
Diffstat (limited to 'src/jvm')
-rw-r--r--src/jvm/clojure/lang/AFunction.java3
-rw-r--r--src/jvm/clojure/lang/MethodImplCache.java11
2 files changed, 2 insertions, 12 deletions
diff --git a/src/jvm/clojure/lang/AFunction.java b/src/jvm/clojure/lang/AFunction.java
index 260bbb3e..baa11e1d 100644
--- a/src/jvm/clojure/lang/AFunction.java
+++ b/src/jvm/clojure/lang/AFunction.java
@@ -16,8 +16,7 @@ import java.util.Comparator;
public abstract class AFunction extends AFn implements IObj, Comparator, Fn{
-//note - this is not even volatile by design
-public MethodImplCache __methodImplCache;
+public volatile MethodImplCache __methodImplCache;
public int compare(Object o1, Object o2){
try
diff --git a/src/jvm/clojure/lang/MethodImplCache.java b/src/jvm/clojure/lang/MethodImplCache.java
index a8670a57..8d18a3b6 100644
--- a/src/jvm/clojure/lang/MethodImplCache.java
+++ b/src/jvm/clojure/lang/MethodImplCache.java
@@ -19,10 +19,6 @@ public final int shift;
public final int mask;
public final Object[] table; //[class, fn. class, fn ...]
-//these are not volatile by design
-public Object lastClass;
-public IFn lastImpl;
-
public MethodImplCache(IPersistentMap protocol, Keyword methodk){
this(protocol, methodk, 0, 0, RT.EMPTY_ARRAY);
}
@@ -33,18 +29,13 @@ public MethodImplCache(IPersistentMap protocol, Keyword methodk, int shift, int
this.shift = shift;
this.mask = mask;
this.table = table;
- this.lastClass = this;
}
public IFn fnFor(Class c){
- if(c == lastClass)
- return lastImpl;
int idx = ((Util.hash(c) >> shift) & mask) << 1;
if(idx < table.length && table[idx] == c)
{
- lastClass = c;
- return lastImpl =
- (IFn) table[idx + 1];
+ return (IFn) table[idx + 1];
}
return null;
}