Skip to content
Browse files
[Truffle] Make an option for Proc#binding.
  • Loading branch information
eregon committed Oct 27, 2014
1 parent 2c54178 commit 75c938b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
@@ -53,7 +53,12 @@ public BindingNode(BindingNode prev) {

public RubyBinding binding(RubyProc proc) {
public Object binding(RubyProc proc) {
if (!RubyProc.PROC_BINDING) {
getContext().getWarnings().warn("Proc#binding disabled, returning nil. Use -Xtruffle.proc.binding=true to enable it.");
return getContext().getCoreLibrary().getNilObject();

final MaterializedFrame frame = proc.getDeclarationFrame();

return new RubyBinding(getContext().getCoreLibrary().getBindingClass(),
@@ -17,12 +17,15 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.methods.*;
import org.jruby.truffle.runtime.subsystems.ObjectSpaceManager;
import org.jruby.util.cli.Options;

* Represents the Ruby {@code Proc} class.
public class RubyProc extends RubyObject implements MethodLike {

public static final boolean PROC_BINDING = Options.TRUFFLE_PROC_BINDING.load();

* The class from which we create the object that is {@code Proc}. A subclass of
* {@link RubyClass} so that we can override {@link RubyClass#newInstance} and allocate a
@@ -38,7 +38,7 @@ public class TranslatorEnvironment {
private final boolean neverAssignInParentScope;

protected final TranslatorEnvironment parent;
private boolean needsDeclarationFrame = true;
private boolean needsDeclarationFrame = RubyProc.PROC_BINDING;
private final SharedMethodInfo sharedMethodInfo;

private final String namedMethodName;
@@ -132,6 +132,7 @@ public class Options {
public static final Option<Boolean> TRUFFLE_RUNTIME_VERSION_CHECK = bool(TRUFFLE, "truffle.runtime.version_check", true, "Check the version of Truffle supplied by the JVM before starting.");
public static final Option<Boolean> TRUFFLE_TRACE = bool(TRUFFLE, "truffle.trace", true, "Install trace probes needed for set_trace_func.");
public static final Option<Boolean> TRUFFLE_OBJECTSPACE = bool(TRUFFLE, "truffle.object_space", true, "Install safepoints needed for ObjectSpace.");
public static final Option<Boolean> TRUFFLE_PROC_BINDING = bool(TRUFFLE, "truffle.proc.binding", true, "Implements Proc#binding.");
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_java", false, "Print Java exceptions at the point of translating them to Ruby exceptions.");
public static final Option<Integer> TRUFFLE_ARRAYS_UNINITIALIZED_SIZE = integer(TRUFFLE, "truffle.arrays.uninitialized_size", 32, "How large an array to allocate when we have no other information to go on.");
public static final Option<Boolean> TRUFFLE_ARRAYS_OPTIMISTIC_LONG = bool(TRUFFLE, "truffle.arrays.optimistic.long", true, "If we allocate an int[] for an Array and it has been converted to a long[], directly allocate a long[] next time.");

0 comments on commit 75c938b

Please sign in to comment.