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

Commits on Dec 6, 2015

  1. Copy the full SHA
    cedd436 View commit details
  2. Copy the full SHA
    ddf5e93 View commit details
  3. Copy the full SHA
    a8d1bd4 View commit details
Original file line number Diff line number Diff line change
@@ -407,7 +407,7 @@ public DynamicObject generateAccessor(VirtualFrame frame, DynamicObject module,
final SelfNode self = new SelfNode(getContext(), sourceSection);
final RubyNode accessInstanceVariable;
if (isGetter) {
accessInstanceVariable = new ReadInstanceVariableNode(getContext(), sourceSection, ivar, self, false);
accessInstanceVariable = new ReadInstanceVariableNode(getContext(), sourceSection, ivar, self);
} else {
ReadPreArgumentNode readArgument = new ReadPreArgumentNode(getContext(), sourceSection, 0, MissingArgumentBehaviour.RUNTIME_ERROR);
accessInstanceVariable = new WriteInstanceVariableNode(getContext(), sourceSection, ivar, self, readArgument);
Original file line number Diff line number Diff line change
@@ -14,25 +14,19 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.ThreadLocalObjectNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.objects.ReadInstanceVariableNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.StringOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.util.StringSupport;

public class ReadLastBacktraceNode extends RubyNode {

@Child private ReadInstanceVariableNode getLastExceptionNode;
@Child private ReadThreadLocalGlobalVariableNode getLastExceptionNode;
@Child private CallDispatchHeadNode getBacktraceNode;

public ReadLastBacktraceNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
getLastExceptionNode = new ReadInstanceVariableNode(getContext(), getSourceSection(), "$!",
new ThreadLocalObjectNode(getContext(), getSourceSection()),
true);
getLastExceptionNode = new ReadThreadLocalGlobalVariableNode(context, sourceSection, "$!");
getBacktraceNode = DispatchHeadNodeFactory.createMethodCall(getContext());
}

Original file line number Diff line number Diff line change
@@ -14,25 +14,21 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.ThreadLocalObjectNode;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.objects.ReadInstanceVariableNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;

public class UpdateLastBacktraceNode extends RubyNode {

@Child private RubyNode child;
@Child private ReadInstanceVariableNode getLastExceptionNode;
@Child private ReadThreadLocalGlobalVariableNode getLastExceptionNode;
@Child private CallDispatchHeadNode setBacktraceNode;

public UpdateLastBacktraceNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection);
this.child = child;
getLastExceptionNode = new ReadInstanceVariableNode(getContext(), getSourceSection(), "$!",
new ThreadLocalObjectNode(getContext(), getSourceSection()),
true);
getLastExceptionNode = new ReadThreadLocalGlobalVariableNode(context, sourceSection, "$!");
setBacktraceNode = DispatchHeadNodeFactory.createMethodCall(getContext());
}

Original file line number Diff line number Diff line change
@@ -317,7 +317,7 @@ private static class InteropInstanceVariableReadNode extends InteropNode {
public InteropInstanceVariableReadNode(RubyContext context, SourceSection sourceSection, String name, int labelIndex) {
super(context, sourceSection);
this.name = name;
this.read = new ReadInstanceVariableNode(context, sourceSection, name, new RubyInteropReceiverNode(context, sourceSection), false);
this.read = new ReadInstanceVariableNode(context, sourceSection, name, new RubyInteropReceiverNode(context, sourceSection));
this.labelIndex = labelIndex;
}

Original file line number Diff line number Diff line change
@@ -19,16 +19,16 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;

public class ReadInstanceVariableNode extends RubyNode {

@Child private RubyNode receiver;
@Child private ReadHeadObjectFieldNode readNode;

private final BranchProfile primitiveProfile = BranchProfile.create();
private final ConditionProfile objectProfile = ConditionProfile.createBinaryProfile();

public ReadInstanceVariableNode(RubyContext context, SourceSection sourceSection, String name, RubyNode receiver, boolean isGlobal) {
public ReadInstanceVariableNode(RubyContext context, SourceSection sourceSection, String name, RubyNode receiver) {
super(context, sourceSection);
this.receiver = receiver;
readNode = ReadHeadObjectFieldNodeGen.create(name, nil());
@@ -38,10 +38,9 @@ public ReadInstanceVariableNode(RubyContext context, SourceSection sourceSection
public Object execute(VirtualFrame frame) {
final Object receiverObject = receiver.execute(frame);

if (receiverObject instanceof DynamicObject) {
if (objectProfile.profile(receiverObject instanceof DynamicObject)) {
return readNode.execute((DynamicObject) receiverObject);
} else {
primitiveProfile.enter();
return nil();
}
}
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

@@ -23,7 +22,6 @@
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.StringOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.util.StringSupport;

public class WriteInstanceVariableNode extends RubyNode {

@@ -38,66 +36,6 @@ public WriteInstanceVariableNode(RubyContext context, SourceSection sourceSectio
writeNode = WriteHeadObjectFieldNodeGen.create(name);
}

@Override
public int executeInteger(VirtualFrame frame) throws UnexpectedResultException {
final Object object = receiver.execute(frame);

if (object instanceof DynamicObject) {
try {
final int value = rhs.executeInteger(frame);

writeNode.execute((DynamicObject) object, value);
return value;
} catch (UnexpectedResultException e) {
writeNode.execute((DynamicObject) object, e.getResult());
throw e;
}
} else {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError(Layouts.MODULE.getFields(getContext().getCoreLibrary().getLogicalClass(object)).getName(), this));
}
}

@Override
public long executeLong(VirtualFrame frame) throws UnexpectedResultException {
final Object object = receiver.execute(frame);

if (object instanceof DynamicObject) {
try {
final long value = rhs.executeLong(frame);

writeNode.execute((DynamicObject) object, value);
return value;
} catch (UnexpectedResultException e) {
writeNode.execute((DynamicObject) object, e.getResult());
throw e;
}
} else {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError(Layouts.MODULE.getFields(getContext().getCoreLibrary().getLogicalClass(object)).getName(), this));
}
}

@Override
public double executeDouble(VirtualFrame frame) throws UnexpectedResultException {
final Object object = receiver.execute(frame);

if (object instanceof DynamicObject) {
try {
final double value = rhs.executeDouble(frame);

writeNode.execute((DynamicObject) object, value);
return value;
} catch (UnexpectedResultException e) {
writeNode.execute((DynamicObject) object, e.getResult());
throw e;
}
} else {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().frozenError(Layouts.MODULE.getFields(getContext().getCoreLibrary().getLogicalClass(object)).getName(), this));
}
}

@Override
public Object execute(VirtualFrame frame) {
final Object object = receiver.execute(frame);
Original file line number Diff line number Diff line change
@@ -1733,7 +1733,7 @@ public RubyNode visitInstVarNode(org.jruby.ast.InstVarNode node) {
}
}

ret = new ReadInstanceVariableNode(context, sourceSection, name, self, false);
ret = new ReadInstanceVariableNode(context, sourceSection, name, self);
return addNewlineIfNeeded(node, ret);
}