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: ac35b66bcf7e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6f2a3985e805
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 5, 2016

  1. Copy the full SHA
    c90244f View commit details
  2. [Truffle] The Rubinius-only method __instance_variables__ needs to be…

    … on BasicObject, not Kernel.
    nirvdrum committed Jan 5, 2016
    Copy the full SHA
    473754f View commit details
  3. Copy the full SHA
    6f2a398 View commit details
1 change: 0 additions & 1 deletion spec/truffle/tags/core/marshal/dump_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:Marshal.dump with an Object dumps a BasicObject subclass if it defines respond_to?
fails:Marshal.dump with a Time dumps the zone and the offset
fails:Marshal.dump with a Time dumps the zone, but not the offset if zone is UTC
fails:Marshal.dump with an Exception dumps the message for the exception
Original file line number Diff line number Diff line change
@@ -36,9 +36,14 @@
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.ArrayOperations;
import org.jruby.truffle.runtime.core.StringOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.methods.InternalMethod;

import java.util.Arrays;
import java.util.List;

@CoreClass(name = "BasicObject")
public abstract class BasicObjectNodes {

@@ -183,6 +188,37 @@ public Object instanceExec(Object receiver, Object[] arguments, NotProvided bloc

}

@RubiniusOnly
@CoreMethod(names = "__instance_variables__")
public abstract static class InstanceVariablesNode extends CoreMethodArrayArgumentsNode {

public InstanceVariablesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public abstract DynamicObject executeObject(DynamicObject self);

@TruffleBoundary
@Specialization
public DynamicObject instanceVariables(DynamicObject self) {
List<Object> keys = self.getShape().getKeyList();
final Object[] instanceVariableNames = keys.toArray(new Object[keys.size()]);

Arrays.sort(instanceVariableNames);

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

for (Object name : instanceVariableNames) {
if (name instanceof String) {
ArrayOperations.append(array, getSymbol((String) name));
}
}

return array;
}

}

@CoreMethod(names = "method_missing", needsBlock = true, rest = true, optional = 1, visibility = Visibility.PRIVATE)
public abstract static class MethodMissingNode extends CoreMethodArrayArgumentsNode {

33 changes: 14 additions & 19 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -1102,30 +1102,19 @@ public Object removeInstanceVariable(DynamicObject object, String name) {

}

@CoreMethod(names = { "instance_variables", "__instance_variables__" })
@CoreMethod(names = "instance_variables")
public abstract static class InstanceVariablesNode extends CoreMethodArrayArgumentsNode {

@Child private BasicObjectNodes.InstanceVariablesNode instanceVariablesNode;

public InstanceVariablesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
instanceVariablesNode = BasicObjectNodesFactory.InstanceVariablesNodeFactory.create(context, sourceSection, new RubyNode[] {});
}

@TruffleBoundary
@Specialization
public DynamicObject instanceVariables(DynamicObject self) {
List<Object> keys = self.getShape().getKeyList();
final Object[] instanceVariableNames = keys.toArray(new Object[keys.size()]);

Arrays.sort(instanceVariableNames);

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

for (Object name : instanceVariableNames) {
if (name instanceof String) {
ArrayOperations.append(array, getSymbol((String) name));
}
}

return array;
public DynamicObject instanceVariables(VirtualFrame frame, DynamicObject self) {
return instanceVariablesNode.executeObject(self);
}

}
@@ -1614,6 +1603,7 @@ public abstract static class RespondToNode extends CoreMethodNode {

@Child private DoesRespondDispatchHeadNode dispatch;
@Child private DoesRespondDispatchHeadNode dispatchIgnoreVisibility;
@Child private DoesRespondDispatchHeadNode dispatchRespondToMissing;
@Child private CallDispatchHeadNode respondToMissingNode;
private final ConditionProfile ignoreVisibilityProfile = ConditionProfile.createBinaryProfile();

@@ -1622,6 +1612,7 @@ public RespondToNode(RubyContext context, SourceSection sourceSection) {

dispatch = new DoesRespondDispatchHeadNode(context, false);
dispatchIgnoreVisibility = new DoesRespondDispatchHeadNode(context, true);
dispatchRespondToMissing = new DoesRespondDispatchHeadNode(context, true);
}

public abstract boolean executeDoesRespondTo(VirtualFrame frame, Object object, Object name, boolean includeProtectedAndPrivate);
@@ -1643,8 +1634,10 @@ public boolean doesRespondToString(VirtualFrame frame, Object object, DynamicObj

if (ret) {
return true;
} else {
} else if (dispatchRespondToMissing.doesRespondTo(frame, "respond_to_missing?", object)) {
return respondToMissing(frame, object, name, includeProtectedAndPrivate);
} else {
return false;
}
}

@@ -1660,8 +1653,10 @@ public boolean doesRespondToSymbol(VirtualFrame frame, Object object, DynamicObj

if (ret) {
return true;
} else {
} else if (dispatchRespondToMissing.doesRespondTo(frame, "respond_to_missing?", object)) {
return respondToMissing(frame, object, name, includeProtectedAndPrivate);
} else {
return false;
}
}