Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 443c18a830cd
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a2e6f8c0e101
Choose a head ref
  • 6 commits
  • 35 files changed
  • 1 contributor

Commits on Sep 16, 2015

  1. Copy the full SHA
    e5cdc2b View commit details
  2. 2
    Copy the full SHA
    eb907ac View commit details
  3. [Truffle] Binding cannot be allocated.

    * So no setter is required.
    * #dup and #clone are overriden like in MRI.
    * The Binding should only be shallow-copied so we keep the same frame.
    eregon committed Sep 16, 2015
    Copy the full SHA
    d048964 View commit details
  4. [Truffle] Add Binding#eval.

    eregon committed Sep 16, 2015
    1
    Copy the full SHA
    8e00e3e View commit details
  5. Copy the full SHA
    419eb49 View commit details
  6. [Truffle] Fix Kernel#local_variables.

    * Fix Binding#local_variable_set when the variable is not defined.
    eregon committed Sep 16, 2015
    Copy the full SHA
    a2e6f8c View commit details
Showing with 240 additions and 370 deletions.
  1. +0 −2 spec/truffle/tags/core/binding/eval_tags.txt
  2. +0 −1 spec/truffle/tags/core/binding/local_variable_set_tags.txt
  3. +0 −2 spec/truffle/tags/core/binding/location_tags.txt
  4. +22 −8 tool/jt.rb
  5. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  6. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/control/TraceNode.java
  7. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/BasicObjectNodes.java
  8. +18 −31 truffle/src/main/java/org/jruby/truffle/nodes/core/BindingNodes.java
  9. +35 −11 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  10. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
  11. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/SetTopLevelBindingNode.java
  12. +3 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
  13. +23 −62 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBooleanDispatchNode.java
  14. +17 −37 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedDispatchNode.java
  15. +27 −47 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedMethodMissingDispatchNode.java
  16. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedReturnMissingDispatchNode.java
  17. +15 −35 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedBoxedSymbolDispatchNode.java
  18. +0 −8 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedDispatchNode.java
  19. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedForeignDispatchNode.java
  20. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedForeignGlobalDispatchNode.java
  21. +17 −37 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedSingletonDispatchNode.java
  22. +13 −32 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CachedUnboxedDispatchNode.java
  23. +2 −3 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/CallDispatchHeadNode.java
  24. +2 −5 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchHeadNode.java
  25. +0 −4 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchHeadNodeFactory.java
  26. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/DoesRespondDispatchHeadNode.java
  27. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/RespondToNode.java
  28. +7 −10 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java
  29. +8 −8 truffle/src/main/java/org/jruby/truffle/nodes/interop/InteropNode.java
  30. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/FixnumPrimitiveNodes.java
  31. +2 −1 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  32. +1 −7 truffle/src/main/java/org/jruby/truffle/runtime/layouts/BindingLayout.java
  33. +2 −2 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/AttachmentsManager.java
  34. +1 −0 truffle/src/main/ruby/core.rb
  35. +13 −0 truffle/src/main/ruby/core/binding.rb
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/binding/eval_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/binding/local_variable_set_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/binding/location_tags.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
fails:Binding#eval inherits __LINE__ from the enclosing scope
fails:Binding#eval preserves __LINE__ across multiple calls to eval
fails:Binding#eval increments __LINE__ on each line of a multiline eval
fails:Binding#eval starts with a __LINE__ of 1 if a filename is passed
fails:Binding#eval starts with a __LINE__ from the third argument if passed
fails:Binding#eval inherits __FILE__ from the enclosing scope
fails:Binding#eval uses the __FILE__ that is passed in
30 changes: 22 additions & 8 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -318,7 +318,7 @@ def test(*args)

case path
when nil
test_specs
test_specs('run')
test_mri
when 'pe' then test_pe(*rest)
when 'specs' then test_specs(*rest)
@@ -327,7 +327,7 @@ def test(*args)
if File.expand_path(path).start_with?("#{JRUBY_DIR}/test")
test_mri(*args)
else
test_specs(*args)
test_specs('run', *args)
end
end
end
@@ -337,10 +337,24 @@ def test_pe(*args)
end
private :test_pe

def test_specs(*args)
def test_specs(command, *args)
env_vars = {}
options = []

options = %w[--excl-tag fails]
case command
when 'run'
options += %w[--excl-tag fails]
when 'tag'
options += %w[--add fails --fail]
when 'untag'
options += %w[--del fails --pass]
command = 'tag'
when 'tag_all'
options += %w[--unguarded --all --dry-run --add fails]
command = 'tag'
else
raise command
end

if args.first == 'fast'
args.shift
@@ -360,26 +374,26 @@ def test_specs(*args)
options << "-T#{JEXCEPTION}"
end

mspec env_vars, 'run', *options, *args
mspec env_vars, command, *options, *args
end
private :test_specs

def tag(path, *args)
return tag_all(*args) if path == 'all'
mspec 'tag', '--add', 'fails', '--fail', path, *args
test_specs('tag', path, *args)
end

# Add tags to all given examples without running them. Useful to avoid file exclusions.
def tag_all(*args)
mspec 'tag', *%w[--unguarded --all --dry-run --add fails], *args
test_specs('tag_all', *args)
end
private :tag_all

def untag(path, *args)
puts
puts "WARNING: untag is currently not very reliable - run `jt test #{[path,*args] * ' '}` after and manually annotate any new failures"
puts
mspec 'tag', '--del', 'fails', '--pass', path, *args
test_specs('untag', path, *args)
end

def bench(command, *args)
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ protected Object ruby(VirtualFrame frame, String expression, Object... arguments

protected Object rubyWithSelf(Object self, String expression, Object... arguments) {
final MaterializedFrame evalFrame = setupFrame(self, arguments);
final DynamicObject binding = Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), self, evalFrame);
final DynamicObject binding = Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), evalFrame);
return getContext().eval(expression, binding, true, "inline-ruby", this);
}

Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
import org.jruby.RubyString;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.ProcNodes;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.util.StringSupport;
@@ -84,7 +83,7 @@ public void trace(VirtualFrame frame) {
file,
line,
context.getCoreLibrary().getNilObject(),
Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), RubyArguments.getSelf(frame.getArguments()), frame.materialize()),
Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), frame.materialize()),
context.getCoreLibrary().getNilObject()
};

Original file line number Diff line number Diff line change
@@ -235,7 +235,6 @@ public SendNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);

dispatchNode = new CallDispatchHeadNode(context, true,
false,
MissingBehavior.CALL_METHOD_MISSING);
}

Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.FrameDescriptor;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.locals.ReadFrameSlotNode;
import org.jruby.truffle.nodes.locals.ReadFrameSlotNodeGen;
@@ -32,37 +32,26 @@
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.ArrayOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.methods.InternalMethod;

@CoreClass(name = "Binding")
public abstract class BindingNodes {

@CoreMethod(names = "initialize_copy", required = 1)
public abstract static class InitializeCopyNode extends CoreMethodArrayArgumentsNode {
@CoreMethod(names = { "dup", "clone" })
public abstract static class DupNode extends UnaryCoreMethodNode {

@Child private AllocateObjectNode allocateObjectNode;

public InitializeCopyNode(RubyContext context, SourceSection sourceSection) {
public DupNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
allocateObjectNode = AllocateObjectNodeGen.create(context, sourceSection, null, null);
}

@Specialization(guards = "isRubyBinding(from)")
public Object initializeCopy(DynamicObject self, DynamicObject from) {
if (self == from) {
return self;
}

final Object[] arguments = Layouts.BINDING.getFrame(from).getArguments();
final InternalMethod method = RubyArguments.getMethod(arguments);
final Object boundSelf = RubyArguments.getSelf(arguments);
final DynamicObject boundBlock = RubyArguments.getBlock(arguments);
final Object[] userArguments = RubyArguments.extractUserArguments(arguments);

final Object[] copiedArguments = RubyArguments.pack(method, Layouts.BINDING.getFrame(from), boundSelf, boundBlock, userArguments);
final MaterializedFrame copiedFrame = Truffle.getRuntime().createMaterializedFrame(copiedArguments);

Layouts.BINDING.setSelf(self, Layouts.BINDING.getSelf(from));
Layouts.BINDING.setFrame(self, copiedFrame);

return self;
@Specialization
public DynamicObject dup(DynamicObject binding) {
DynamicObject copy = allocateObjectNode.allocate(
Layouts.BASIC_OBJECT.getLogicalClass(binding),
Layouts.BINDING.getFrame(binding));
return copy;
}

}
@@ -189,16 +178,16 @@ public LocalVariableSetNode(RubyContext context, SourceSection sourceSection) {
}, limit = "getCacheLimit()")
public Object localVariableSetCached(DynamicObject binding, DynamicObject symbol, Object value,
@Cached("symbol") DynamicObject cachedSymbol,
@Cached("getFrameDescriptor(binding)") FrameDescriptor cachedFrameDescriptor,
@Cached("createWriteNode(findFrameSlot(binding, symbol))") WriteFrameSlotNode writeLocalVariableNode) {
@Cached("createWriteNode(findFrameSlot(binding, symbol))") WriteFrameSlotNode writeLocalVariableNode,
@Cached("getFrameDescriptor(binding)") FrameDescriptor cachedFrameDescriptor) {
return writeLocalVariableNode.executeWrite(Layouts.BINDING.getFrame(binding), value);
}

@TruffleBoundary
@Specialization(guards = {"isRubySymbol(symbol)", "!isLastLine(symbol)"})
public Object localVariableSetUncached(DynamicObject binding, DynamicObject symbol, Object value) {
final MaterializedFrame frame = Layouts.BINDING.getFrame(binding);
final FrameSlot frameSlot = frame.getFrameDescriptor().findFrameSlot(Layouts.SYMBOL.getString(symbol));
final FrameSlot frameSlot = findFrameSlot(binding, symbol);
frame.setObject(frameSlot, value);
return value;
}
@@ -282,16 +271,14 @@ public DynamicObject localVariables(DynamicObject binding) {
@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends CoreMethodArrayArgumentsNode {

@Child private AllocateObjectNode allocateObjectNode;

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
allocateObjectNode = AllocateObjectNodeGen.create(context, sourceSection, null, null);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
return allocateObjectNode.allocate(rubyClass, null, null);
throw new RaiseException(getContext().getCoreLibrary().typeErrorAllocatorUndefinedFor(rubyClass, this));
}

}
46 changes: 35 additions & 11 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -294,7 +294,7 @@ public DynamicObject binding() {
final MaterializedFrame callerFrame = RubyCallStack.getCallerFrame(getContext())
.getFrame(FrameInstance.FrameAccess.MATERIALIZE, false).materialize();

return Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), RubyArguments.getSelf(callerFrame.getArguments()), callerFrame);
return Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), callerFrame);
}
}

@@ -547,8 +547,8 @@ public Object evalNoBindingCached(
) {
final DynamicObject callerBinding = getCallerBinding(frame);

final Object callerSelf = Layouts.BINDING.getSelf(callerBinding);
final MaterializedFrame parentFrame = Layouts.BINDING.getFrame(callerBinding);
final Object callerSelf = RubyArguments.getSelf(parentFrame.getArguments());

final InternalMethod method = new InternalMethod(
cachedRootNode.getRootNode().getSharedMethodInfo(),
@@ -580,7 +580,7 @@ public Object evalNoBindingUncached(VirtualFrame frame, DynamicObject source, No
"isNil(noBinding)",
"isRubyString(filename)"
})
public Object evalNilBinding(VirtualFrame frame, DynamicObject source, Object noBinding,
public Object evalNilBinding(VirtualFrame frame, DynamicObject source, DynamicObject noBinding,
DynamicObject filename, int lineNumber) {
return evalNoBindingUncached(frame, source, NotProvided.INSTANCE, NotProvided.INSTANCE, NotProvided.INSTANCE);
}
@@ -594,6 +594,16 @@ public Object evalBinding(DynamicObject source, DynamicObject binding, NotProvid
return getContext().eval(Layouts.STRING.getByteList(source), binding, false, this);
}

@Specialization(guards = {
"isRubyString(source)",
"isRubyBinding(binding)",
"isNil(noFilename)",
"isNil(noLineNumber)"
})
public Object evalBinding(DynamicObject source, DynamicObject binding, DynamicObject noFilename, DynamicObject noLineNumber) {
return evalBinding(source, binding, NotProvided.INSTANCE, NotProvided.INSTANCE);
}

@TruffleBoundary
@Specialization(guards = {
"isRubyString(source)",
@@ -604,6 +614,16 @@ public Object evalBindingFilename(DynamicObject source, DynamicObject binding, D
return getContext().eval(Layouts.STRING.getByteList(source), binding, false, filename.toString(), this);
}

@Specialization(guards = {
"isRubyString(source)",
"isRubyBinding(binding)",
"isRubyString(filename)",
"isNil(noLineNumber)"
})
public Object evalBindingFilename(DynamicObject source, DynamicObject binding, DynamicObject filename, DynamicObject noLineNumber) {
return evalBindingFilename(source, binding, filename, NotProvided.INSTANCE);
}

@TruffleBoundary
@Specialization(guards = {
"isRubyString(source)",
@@ -1204,16 +1224,21 @@ public LocalVariablesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject localVariables() {
CompilerDirectives.transferToInterpreter();

final DynamicObject array = Layouts.ARRAY.createArray(getContext().getCoreLibrary().getArrayFactory(), null, 0);

for (Object name : RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_ONLY, false).getFrameDescriptor().getIdentifiers()) {
if (name instanceof String) {
ArrayOperations.append(array, getSymbol((String) name));
Frame frame = RubyCallStack.getCallerFrame(getContext()).getFrame(FrameInstance.FrameAccess.READ_ONLY, false);

while (frame != null) {
for (Object name : frame.getFrameDescriptor().getIdentifiers()) {
if (name instanceof String) {
ArrayOperations.append(array, getSymbol((String) name));
}
}

frame = RubyArguments.getDeclarationFrame(frame.getArguments());
}

return array;
@@ -1442,7 +1467,6 @@ public PublicSendNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);

dispatchNode = new CallDispatchHeadNode(context, false,
false,
MissingBehavior.CALL_METHOD_MISSING);
}

@@ -1614,8 +1638,8 @@ public abstract static class RespondToNode extends CoreMethodNode {
public RespondToNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);

dispatch = new DoesRespondDispatchHeadNode(context, false, false, MissingBehavior.RETURN_MISSING, null);
dispatchIgnoreVisibility = new DoesRespondDispatchHeadNode(context, true, false, MissingBehavior.RETURN_MISSING, null);
dispatch = new DoesRespondDispatchHeadNode(context, false, MissingBehavior.RETURN_MISSING, null);
dispatchIgnoreVisibility = new DoesRespondDispatchHeadNode(context, true, MissingBehavior.RETURN_MISSING, null);
}

public abstract boolean executeDoesRespondTo(VirtualFrame frame, Object object, Object name, boolean includeProtectedAndPrivate);
Original file line number Diff line number Diff line change
@@ -213,7 +213,7 @@ public BindingNode(RubyContext context, SourceSection sourceSection) {
public Object binding(DynamicObject proc) {
final MaterializedFrame frame = Layouts.PROC.getDeclarationFrame(proc);

return Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), RubyArguments.getSelf(frame.getArguments()), frame);
return Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), frame);
}

}
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;

@@ -25,7 +25,7 @@ public SetTopLevelBindingNode(RubyContext context, SourceSection sourceSection)

@Override
public Object execute(VirtualFrame frame) {
final DynamicObject binding = Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), RubyArguments.getSelf(frame.getArguments()), frame.materialize());
final DynamicObject binding = Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), frame.materialize());
Layouts.MODULE.getFields(getContext().getCoreLibrary().getObjectClass()).setConstant(this, "TOPLEVEL_BINDING", binding);
return nil();
}
Original file line number Diff line number Diff line change
@@ -22,14 +22,15 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;

import jnr.posix.SpawnFileAction;

import org.jcodings.specific.UTF8Encoding;
import org.jruby.Ruby;
import org.jruby.RubyGC;
import org.jruby.RubyString;
import org.jruby.ext.rbconfig.RbConfigLibrary;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.BacktraceFormatter;
@@ -89,7 +90,7 @@ public MaterializedFrame visitFrame(FrameInstance frameInstance) {

});

return Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), RubyArguments.getSelf(frame.getArguments()), frame);
return Layouts.BINDING.createBinding(getContext().getCoreLibrary().getBindingFactory(), frame);
}

}
Loading