Skip to content

Commit

Permalink
Showing 11 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -226,7 +226,13 @@ public class Options {
public static final Option<Integer> TRUFFLE_ARRAY_SMALL = integer(TRUFFLE, "truffle.array.small", 3, "Maximum size of an Array to consider small for optimisations.");
public static final Option<Integer> TRUFFLE_HASH_PACKED_ARRAY_MAX = integer(TRUFFLE, "truffle.hash.packed_array.max", 3, "Maximum size of a Hash to consider using the packed array storage strategy for.");

public static final Option<Integer> TRUFFLE_METHOD_LOOKUP_CACHE = integer(TRUFFLE, "truffle.method_lookup.cache", 8, "Constant lookup cache size");
public static final Option<Integer> TRUFFLE_DISPATCH_CACHE = integer(TRUFFLE, "truffle.dispatch.cache", 8, "Dispatch (various forms of method call) cache size.");
public static final Option<Integer> TRUFFLE_YIELD_CACHE = integer(TRUFFLE, "truffle.yield.cache", 8, "Yield cache size.");
public static final Option<Integer> TRUFFLE_TO_PROC_CACHE = integer(TRUFFLE, "truffle.to_proc.cache", 8, "Method#to_proc cache size");
public static final Option<Integer> TRUFFLE_IS_A_CACHE = integer(TRUFFLE, "truffle.is_a.cache", 8, "Kernel#is_a? and #kind_of? cache size");
public static final Option<Integer> TRUFFLE_BIND_CACHE = integer(TRUFFLE, "truffle.bind.cache", 8, "Test for being able to bind a method to a module cache size");
public static final Option<Integer> TRUFFLE_CONSTANT_LOOKUP_CACHE = integer(TRUFFLE, "truffle.constant_lookup.cache", 8, "Constant lookup cache size");

public static final Option<Boolean> TRUFFLE_CORE_ALWAYS_CLONE = bool(TRUFFLE, "truffle.core.always_clone", true, "Always clone built-in core methods.");
public static final Option<Boolean> TRUFFLE_YIELD_ALWAYS_CLONE = bool(TRUFFLE, "truffle.yield.always_clone", true, "Always clone yields.");
4 changes: 0 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -171,10 +171,6 @@ protected NativeSockets nativeSockets() {
return getContext().getNativeSockets();
}

protected int getCacheLimit() {
return getContext().getOptions().DISPATCH_CACHE;
}

// Helper methods for caching

protected DynamicObjectFactory getInstanceFactory(DynamicObject rubyClass) {
Original file line number Diff line number Diff line change
@@ -105,4 +105,8 @@ protected boolean isVisible(DynamicObject module, RubyConstant constant) {
return ignoreVisibility || constant == null || constant.isVisibleTo(getContext(), LexicalScope.NONE, module);
}

protected int getCacheLimit() {
return getContext().getOptions().CONSTANT_LOOKUP_CACHE;
}

}
Original file line number Diff line number Diff line change
@@ -1121,6 +1121,10 @@ protected DynamicObject getMetaClass(VirtualFrame frame, Object object) {
return metaClassNode.executeMetaClass(frame, object);
}

protected int getCacheLimit() {
return getContext().getOptions().IS_A_CACHE;
}

}

@CoreMethod(names = "lambda", isModuleFunction = true, needsBlock = true)
Original file line number Diff line number Diff line change
@@ -270,6 +270,10 @@ protected CallTarget method2proc(DynamicObject methodObject) {
return Truffle.getRuntime().createCallTarget(newRootNode);
}

protected int getCacheLimit() {
return getContext().getOptions().TO_PROC_CACHE;
}

}

private static class SetReceiverNode extends RubyNode {
Original file line number Diff line number Diff line change
@@ -50,4 +50,8 @@ protected Object callMethodUncached(VirtualFrame frame, InternalMethod method, O
return indirectCallNode.call(frame, method.getCallTarget(), frameArguments);
}

protected int getCacheLimit() {
return getContext().getOptions().DISPATCH_CACHE;
}

}
Original file line number Diff line number Diff line change
@@ -55,4 +55,8 @@ protected boolean canBindMethodTo(DynamicObject declaringModule, DynamicObject m
return ModuleOperations.canBindMethodTo(declaringModule, module);
}

protected int getCacheLimit() {
return getContext().getOptions().BIND_CACHE;
}

}
Original file line number Diff line number Diff line change
@@ -80,4 +80,8 @@ protected InternalMethod doLookup(DynamicObject selfMetaClass, String name) {
return method;
}

protected int getCacheLimit() {
return getContext().getOptions().METHOD_LOOKUP_CACHE;
}

}
Original file line number Diff line number Diff line change
@@ -108,4 +108,8 @@ protected InternalMethod doLookup(InternalMethod currentMethod, DynamicObject se
return superMethod;
}

protected int getCacheLimit() {
return getContext().getOptions().METHOD_LOOKUP_CACHE;
}

}
Original file line number Diff line number Diff line change
@@ -93,4 +93,8 @@ protected CallNodeWrapperNode createBlockCallNode(CallTarget callTarget) {
return callNodeWrapperNode;
}

protected int getCacheLimit() {
return getContext().getOptions().YIELD_CACHE;
}

}
6 changes: 6 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/runtime/Options.java
Original file line number Diff line number Diff line change
@@ -28,7 +28,13 @@ public class Options {

// Caches

public final int METHOD_LOOKUP_CACHE = org.jruby.util.cli.Options.TRUFFLE_METHOD_LOOKUP_CACHE.load();
public final int DISPATCH_CACHE = org.jruby.util.cli.Options.TRUFFLE_DISPATCH_CACHE.load();
public final int YIELD_CACHE = org.jruby.util.cli.Options.TRUFFLE_YIELD_CACHE.load();
public final int TO_PROC_CACHE = org.jruby.util.cli.Options.TRUFFLE_TO_PROC_CACHE.load();
public final int IS_A_CACHE = org.jruby.util.cli.Options.TRUFFLE_IS_A_CACHE.load();
public final int BIND_CACHE = org.jruby.util.cli.Options.TRUFFLE_BIND_CACHE.load();
public final int CONSTANT_LOOKUP_CACHE = org.jruby.util.cli.Options.TRUFFLE_CONSTANT_LOOKUP_CACHE.load();

// Cloning and inlining

0 comments on commit 6820636

Please sign in to comment.