Permalink
Browse files

Disable ClassValue use for now, since it's static and sticky.

  • Loading branch information...
1 parent b2626f0 commit 4ba14a0920ee8a8777bbc3675be13c9e8ac9d0c9 @headius headius committed May 16, 2012
Showing with 16 additions and 6 deletions.
  1. +15 −6 src/org/jruby/javasupport/JavaSupport.java
  2. +1 −0 src/org/jruby/util/cli/Options.java
@@ -54,6 +54,7 @@
import org.jruby.javasupport.util.ObjectProxyCache;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.WeakIdentityHashMap;
+import org.jruby.util.cli.Options;
public class JavaSupport {
private static final Map<String,Class> PRIMITIVE_CLASSES = new HashMap<String,Class>();
@@ -89,19 +90,27 @@ public IRubyObject allocateProxy(Object javaObject, RubyClass clazz) {
static {
Constructor<? extends ProxyCache> constructor = null;
- try {
- // try to load the ClassValue class. If it succeeds, we can use our
- // ClassValue-based cache.
- Class.forName("java.lang.ClassValue");
- constructor = (Constructor<ProxyCache>)Class.forName("org.jruby.java.proxies.ClassValueProxyCache").getConstructor(Ruby.class);
+
+ if (Options.INVOKEDYNAMIC_CLASS_VALUES.load()) {
+ try {
+ // try to load the ClassValue class. If it succeeds, we can use our
+ // ClassValue-based cache.
+ Class.forName("java.lang.ClassValue");
+ constructor = (Constructor<ProxyCache>)Class.forName("org.jruby.java.proxies.ClassValueProxyCache").getConstructor(Ruby.class);
+ }
+ catch (Exception ex) {
+ // fall through to Map version
+ }
}
- catch (Exception ex) {
+
+ if (constructor == null) {
try {
constructor = MapBasedProxyCache.class.getConstructor(Ruby.class);
} catch (Exception ex2) {
throw new RuntimeException(ex2);
}
}
+
PROXY_CACHE_CONSTRUCTOR = constructor;
}
@@ -76,6 +76,7 @@
public static final Option<Boolean> INVOKEDYNAMIC_CACHE_CONSTANTS = bool(INVOKEDYNAMIC, "invokedynamic.cache.constants", true, "Use invokedynamic to load constants.");
public static final Option<Boolean> INVOKEDYNAMIC_CACHE_LITERALS = bool(INVOKEDYNAMIC, "invokedynamic.cache.literals", true, "Use invokedynamic to load literals.");
public static final Option<Boolean> INVOKEDYNAMIC_CACHE_IVARS = bool(INVOKEDYNAMIC, "invokedynamic.cache.ivars", true, "Use invokedynamic to get/set instance variables.");
+ public static final Option<Boolean> INVOKEDYNAMIC_CLASS_VALUES = bool(INVOKEDYNAMIC, "invokedynamic.class.values", false, "Use ClassValue to store class-specific data.");
public static final Option<Integer> JIT_THRESHOLD = integer(JIT, "jit.threshold", Constants.JIT_THRESHOLD, "Set the JIT threshold to the specified method invocation count.");
public static final Option<Integer> JIT_MAX = integer(JIT, "jit.max", Constants.JIT_MAX_METHODS_LIMIT, "Set the max count of active methods eligible for JIT-compilation.");

0 comments on commit 4ba14a0

Please sign in to comment.