Skip to content

Commit

Permalink
Showing 9 changed files with 54 additions and 17 deletions.
2 changes: 2 additions & 0 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -64,6 +64,8 @@ verify that JRuby is still fully functional.

### Hacking the Build System

for a general overview of the different directories and maven artifacts see [JRuby Build)](https://github.com/jruby/jruby/wiki/JRuby-Build----Some-Inside-Info)

For this only the ***pom.rb*** needs to edited. using mvn-3.3.x or the maven wrapper `./mvnw` will generate the pom.xml file where needed. For the jar files of the build those pom.xml will be generated for some use-cases, i.e. some IDEs need them.

To regenerate the pom.xml just run `./mvnw` which will create them.
21 changes: 14 additions & 7 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -226,13 +226,20 @@ 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<Integer> TRUFFLE_DEFAULT_CACHE = integer(TRUFFLE, "truffle.default_cache", 8, "Default size for caches.");

public static final Option<Integer> TRUFFLE_METHOD_LOOKUP_CACHE = integer(TRUFFLE, "truffle.method_lookup.cache", TRUFFLE_DEFAULT_CACHE.load(), "Constant lookup cache size");
public static final Option<Integer> TRUFFLE_DISPATCH_CACHE = integer(TRUFFLE, "truffle.dispatch.cache", TRUFFLE_DEFAULT_CACHE.load(), "Dispatch (various forms of method call) cache size.");
public static final Option<Integer> TRUFFLE_YIELD_CACHE = integer(TRUFFLE, "truffle.yield.cache", TRUFFLE_DEFAULT_CACHE.load(), "Yield cache size.");
public static final Option<Integer> TRUFFLE_METHOD_TO_PROC_CACHE = integer(TRUFFLE, "truffle.to_proc.cache", TRUFFLE_DEFAULT_CACHE.load(), "Method#to_proc cache size");
public static final Option<Integer> TRUFFLE_IS_A_CACHE = integer(TRUFFLE, "truffle.is_a.cache", TRUFFLE_DEFAULT_CACHE.load(), "Kernel#is_a? and #kind_of? cache size");
public static final Option<Integer> TRUFFLE_BIND_CACHE = integer(TRUFFLE, "truffle.bind.cache", TRUFFLE_DEFAULT_CACHE.load(), "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", TRUFFLE_DEFAULT_CACHE.load(), "Constant lookup cache size");
public static final Option<Integer> TRUFFLE_BINDING_LOCAL_VARIABLE_CACHE = integer(TRUFFLE, "truffle.binding_local_variable.cache", TRUFFLE_DEFAULT_CACHE.load(), "Binding#local_variable_get/set cache size");
public static final Option<Integer> TRUFFLE_SYMBOL_TO_PROC_CACHE = integer(TRUFFLE, "truffle.symbol_to_proc.cache", TRUFFLE_DEFAULT_CACHE.load(), "Symbol#to_proc cache size");
public static final Option<Integer> TRUFFLE_ALLOCATE_CLASS_CACHE = integer(TRUFFLE, "truffle.allocate_class.cache", TRUFFLE_DEFAULT_CACHE.load(), "Allocation size class cache size");
public static final Option<Integer> TRUFFLE_PACK_CACHE = integer(TRUFFLE, "truffle.pack.cache", TRUFFLE_DEFAULT_CACHE.load(), "Array#pack cache size");
public static final Option<Integer> TRUFFLE_EVAL_CACHE = integer(TRUFFLE, "truffle.eval.cache", TRUFFLE_DEFAULT_CACHE.load(), "eval 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.");
Original file line number Diff line number Diff line change
@@ -81,9 +81,8 @@ public LocalVariableGetNode(RubyContext context, SourceSection sourceSection) {
"isRubySymbol(symbol)",
"symbol == cachedSymbol",
"!isLastLine(cachedSymbol)",
"getFrameDescriptor(binding) == cachedFrameDescriptor"

})
"getFrameDescriptor(binding) == cachedFrameDescriptor",
}, limit = "getCacheLimit()")
public Object localVariableGetCached(DynamicObject binding, DynamicObject symbol,
@Cached("symbol") DynamicObject cachedSymbol,
@Cached("getFrameDescriptor(binding)") FrameDescriptor cachedFrameDescriptor,
@@ -166,6 +165,10 @@ protected boolean isLastLine(DynamicObject symbol) {
return symbol == dollarUnderscore;
}

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

}

@CoreMethod(names = "local_variable_set", required = 2)
@@ -183,7 +186,7 @@ public LocalVariableSetNode(RubyContext context, SourceSection sourceSection) {
"!isLastLine(symbol)",
"getFrameDescriptor(binding) == cachedFrameDescriptor",
"symbol == cachedSymbol"
})
}, limit = "getCacheLimit()")
public Object localVariableSetCached(DynamicObject binding, DynamicObject symbol, Object value,
@Cached("symbol") DynamicObject cachedSymbol,
@Cached("getFrameDescriptor(binding)") FrameDescriptor cachedFrameDescriptor,
@@ -242,6 +245,10 @@ protected WriteFrameSlotNode createWriteNode(FrameSlot frameSlot) {
protected boolean isLastLine(DynamicObject symbol) {
return symbol == dollarUnderscore;
}

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

@CoreMethod(names = "local_variables")
Original file line number Diff line number Diff line change
@@ -531,7 +531,7 @@ public RubyRootNode getRootNode() {
"isRubyString(source)",
"byteListsEqual(source, cachedSource)",
"!parseDependsOnDeclarationFrame(cachedRootNode)"
})
}, limit = "getCacheLimit()")
public Object evalNoBindingCached(
VirtualFrame frame,
DynamicObject source,
@@ -647,6 +647,10 @@ protected CallTarget createCallTarget(RootNodeWrapper rootNode) {
return Truffle.getRuntime().createCallTarget(rootNode.rootNode);
}

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

}

@CoreMethod(names = "exec", isModuleFunction = true, required = 1, rest = true)
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ protected CallTarget method2proc(DynamicObject methodObject) {
}

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

}
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ public ToProcNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = "cachedSymbol == symbol")
@Specialization(guards = "cachedSymbol == symbol", limit = "getCacheLimit()")
public DynamicObject toProcCached(DynamicObject symbol,
@Cached("symbol") DynamicObject cachedSymbol,
@Cached("createProc(symbol)") DynamicObject cachedProc) {
@@ -157,6 +157,10 @@ null, getContext().getCoreLibrary().getNilObject(),
null);
}

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

}

@CoreMethod(names = "to_s")
Original file line number Diff line number Diff line change
@@ -2446,7 +2446,7 @@ public PackNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization(guards = {"isRubyString(format)", "byteListsEqual(format, cachedFormat)"})
@Specialization(guards = {"isRubyString(format)", "byteListsEqual(format, cachedFormat)"}, limit = "getCacheLimit()")
public DynamicObject packCached(
VirtualFrame frame,
DynamicObject array,
@@ -2570,6 +2570,10 @@ protected CallTarget compileFormat(DynamicObject format) {
}
}

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

}

@CoreMethod(names = "pop", raiseIfFrozenSelf = true, optional = 1)
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public DynamicObject allocate(DynamicObject classToAllocate, Object... values) {
@Specialization(guards = {
"cachedClassToAllocate == classToAllocate",
"!cachedIsSingleton"
})
}, limit = "getCacheLimit()")
public DynamicObject allocateCached(
DynamicObject classToAllocate,
Object[] values,
@@ -67,4 +67,8 @@ protected boolean isSingleton(DynamicObject classToAllocate) {
return Layouts.CLASS.getIsSingleton(classToAllocate);
}

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

}
7 changes: 6 additions & 1 deletion truffle/src/main/java/org/jruby/truffle/runtime/Options.java
Original file line number Diff line number Diff line change
@@ -31,10 +31,15 @@ public class Options {
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 METHOD_TO_PROC_CACHE = org.jruby.util.cli.Options.TRUFFLE_METHOD_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();
public final int BINDING_LOCAL_VARIABLE_CACHE = org.jruby.util.cli.Options.TRUFFLE_BINDING_LOCAL_VARIABLE_CACHE.load();
public final int SYMBOL_TO_PROC_CACHE = org.jruby.util.cli.Options.TRUFFLE_SYMBOL_TO_PROC_CACHE.load();
public final int ALLOCATE_CLASS_CACHE = org.jruby.util.cli.Options.TRUFFLE_ALLOCATE_CLASS_CACHE.load();
public final int PACK_CACHE = org.jruby.util.cli.Options.TRUFFLE_PACK_CACHE.load();
public final int EVAL_CACHE = org.jruby.util.cli.Options.TRUFFLE_EVAL_CACHE.load();

// Cloning and inlining

0 comments on commit 392f93a

Please sign in to comment.