Skip to content

Commit

Permalink
Showing 17 changed files with 29 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@ public CallPrimitiveNode(RubyContext context, SourceSection sourceSection, RubyN
public Object execute(VirtualFrame frame) {
final Object value = primitive.execute(frame);

// Primitives fail by returning null, allowing the method to continue (the fallback)
if (failedProfile.profile(value == null)) {
// Primitives fail by returning null, allowing the method to continue (the fallback)
return nil();
} else {
// If the primitive didn't fail its value is returned in the calling method
4 changes: 2 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/core/MainNodes.java
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ public abstract static class PublicNode extends CoreMethodArrayArgumentsNode {

public PublicNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
publicNode = ModuleNodesFactory.PublicNodeFactory.create(context, sourceSection, new RubyNode[]{null, null});
publicNode = ModuleNodesFactory.PublicNodeFactory.create(context, sourceSection, null);
}

@Specialization
@@ -49,7 +49,7 @@ public abstract static class PrivateNode extends CoreMethodArrayArgumentsNode {

public PrivateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
privateNode = ModuleNodesFactory.PrivateNodeFactory.create(context, sourceSection, new RubyNode[]{null, null});
privateNode = ModuleNodesFactory.PrivateNodeFactory.create(context, sourceSection, null);
}

@Specialization
Original file line number Diff line number Diff line change
@@ -696,7 +696,7 @@ public abstract static class DeleteNode extends ArrayCoreMethodNode {

public DeleteNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(new RubyNode[]{null,null});
equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(null);
}

@Specialization(guards = "isNullArray(array)")
@@ -891,7 +891,7 @@ public abstract static class IncludeNode extends ArrayCoreMethodNode {

public IncludeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(new RubyNode[]{null,null});
equalNode = KernelNodesFactory.SameOrEqualNodeFactory.create(null);
}

@Specialization(guards = "isNullArray(array)")
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ public DynamicObject coerceRubyBignum(DynamicObject value) {
public Object coerceDouble(VirtualFrame frame, double value) {
if (floatToIntNode == null) {
CompilerDirectives.transferToInterpreter();
floatToIntNode = insert(FloatNodesFactory.ToINodeFactory.create(getContext(), getSourceSection(), new RubyNode[] { null }));
floatToIntNode = insert(FloatNodesFactory.ToINodeFactory.create(getContext(), getSourceSection(), null));
}
return floatToIntNode.executeToI(frame, value);
}
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
protected DynamicObject kernelToS(VirtualFrame frame, Object object) {
if (kernelToSNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
kernelToSNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(), getSourceSection(), new RubyNode[] {null}));
kernelToSNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(), getSourceSection(), null));
}
return kernelToSNode.executeToS(frame, object);
}
Original file line number Diff line number Diff line change
@@ -260,7 +260,7 @@ public abstract static class ResumeNode extends CoreMethodArrayArgumentsNode {

public ResumeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(new RubyNode[] { null, null, null });
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(null);
}

@Specialization
@@ -277,7 +277,7 @@ public abstract static class YieldNode extends CoreMethodArrayArgumentsNode {

public YieldNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(new RubyNode[] { null, null, null });
fiberTransferNode = FiberNodesFactory.FiberTransferNodeFactory.create(null);
}

@Specialization
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ public byte[] toString(VirtualFrame frame, Object object) {
if (inspectNode == null) {
CompilerDirectives.transferToInterpreter();
inspectNode = insert(KernelNodesFactory.ToSNodeFactory.create(getContext(),
getEncapsulatingSourceSection(), new RubyNode[]{null}));
getEncapsulatingSourceSection(), null));
}

return Layouts.STRING.getRope(inspectNode.toS(frame, object)).getBytes();
Original file line number Diff line number Diff line change
@@ -185,7 +185,7 @@ public GetIndexNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(new RubyNode[]{null, null});
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null);
callDefaultNode = DispatchHeadNodeFactory.createMethodCall(context);
lookupEntryNode = new LookupEntryNode(context, sourceSection);
}
@@ -375,7 +375,7 @@ public abstract static class GetOrUndefinedNode extends CoreMethodArrayArguments

public GetOrUndefinedNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
getIndexNode = HashNodesFactory.GetIndexNodeFactory.create(context, sourceSection, new RubyNode[]{null, null});
getIndexNode = HashNodesFactory.GetIndexNodeFactory.create(context, sourceSection, null);
getIndexNode.setUndefinedValue(context.getCoreLibrary().getRubiniusUndefined());
}

Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public LookupEntryNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(new RubyNode[]{null, null});
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null);
}

public HashLookupResult lookup(VirtualFrame frame, DynamicObject hash, Object key) {
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ public SetNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
hashNode = new HashNode(context, sourceSection);
eqlNode = DispatchHeadNodeFactory.createMethodCall(context);
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(new RubyNode[]{null, null});
equalNode = BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null);
}

public abstract Object executeSet(VirtualFrame frame, DynamicObject hash, Object key, Object value, boolean byIdentity);
Original file line number Diff line number Diff line change
@@ -231,7 +231,7 @@ public boolean sameOrEqual(VirtualFrame frame, Object a, Object b) {
private boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(new RubyNode[]{null, null}));
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null));
}

return referenceEqualNode.executeReferenceEqual(frame, left, right);
@@ -282,7 +282,7 @@ public abstract static class CompareNode extends CoreMethodArrayArgumentsNode {

public CompareNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
equalNode = SameOrEqualNodeFactory.create(new RubyNode[]{ null, null });
equalNode = SameOrEqualNodeFactory.create(null);
}

@Specialization
@@ -1931,8 +1931,8 @@ public abstract static class ToSNode extends CoreMethodArrayArgumentsNode {
public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
classNode = LogicalClassNodeGen.create(context, sourceSection, null);
objectIDNode = ObjectNodesFactory.ObjectIDPrimitiveNodeFactory.create(new RubyNode[]{ null });
toHexStringNode = KernelNodesFactory.ToHexStringNodeFactory.create(new RubyNode[]{ null });
objectIDNode = ObjectNodesFactory.ObjectIDPrimitiveNodeFactory.create(null);
toHexStringNode = KernelNodesFactory.ToHexStringNodeFactory.create(null);
}

public abstract DynamicObject executeToS(VirtualFrame frame, Object self);
Original file line number Diff line number Diff line change
@@ -277,7 +277,7 @@ void triggerInheritedHook(VirtualFrame frame, DynamicObject subClass, DynamicObj
void moduleInitialize(VirtualFrame frame, DynamicObject rubyClass, DynamicObject block) {
if (moduleInitializeNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
moduleInitializeNode = insert(ModuleNodesFactory.InitializeNodeFactory.create(new RubyNode[]{ null, null }));
moduleInitializeNode = insert(ModuleNodesFactory.InitializeNodeFactory.create(null));
}
moduleInitializeNode.executeInitialize(frame, rubyClass, block);
}
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ public abstract static class EqualNode extends CoreMethodArrayArgumentsNode {
protected boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(new RubyNode[]{null, null}));
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null));
}
return referenceEqualNode.executeReferenceEqual(frame, left, right);
}
Original file line number Diff line number Diff line change
@@ -256,7 +256,7 @@ public abstract static class CompareNode extends CoreMethodArrayArgumentsNode {
private Object isSubclass(DynamicObject self, DynamicObject other) {
if (subclassNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
subclassNode = insert(ModuleNodesFactory.IsSubclassOfOrEqualToNodeFactory.create(new RubyNode[]{null, null}));
subclassNode = insert(ModuleNodesFactory.IsSubclassOfOrEqualToNodeFactory.create(null));
}
return subclassNode.executeIsSubclassOfOrEqualTo(self, other);
}
@@ -1132,7 +1132,7 @@ public abstract static class InitializeNode extends CoreMethodArrayArgumentsNode
void classEval(VirtualFrame frame, DynamicObject module, DynamicObject block) {
if (classExecNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
classExecNode = insert(ModuleNodesFactory.ClassExecNodeFactory.create(getContext(), getSourceSection(), new RubyNode[]{null,null,null}));
classExecNode = insert(ModuleNodesFactory.ClassExecNodeFactory.create(getContext(), getSourceSection(), null));
}
classExecNode.executeClassExec(frame, module, new Object[]{}, block);
}
Original file line number Diff line number Diff line change
@@ -880,7 +880,7 @@ public Object leftShiftWithOverflow(long a, int b) {
public Object leftShiftNeg(VirtualFrame frame, long a, int b) {
if (rightShiftNode == null) {
CompilerDirectives.transferToInterpreter();
rightShiftNode = insert(FixnumNodesFactory.RightShiftNodeFactory.create(new RubyNode[]{ null, null }));
rightShiftNode = insert(FixnumNodesFactory.RightShiftNodeFactory.create(null));
}
return rightShiftNode.executeRightShift(frame, a, -b);
}
@@ -940,7 +940,7 @@ public Object rightShift(VirtualFrame frame, long a, int b,
public Object rightShiftNeg(VirtualFrame frame, long a, int b) {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(new RubyNode[]{ null, null }));
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(null));
}
return leftShiftNode.executeLeftShift(frame, a, -b);
}
@@ -960,7 +960,7 @@ public int rightShift(long a, DynamicObject b) {
public Object rightShiftNeg(VirtualFrame frame, long a, DynamicObject b) {
if (leftShiftNode == null) {
CompilerDirectives.transferToInterpreter();
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(new RubyNode[]{ null, null }));
leftShiftNode = insert(FixnumNodesFactory.LeftShiftNodeFactory.create(null));
}
return leftShiftNode.executeLeftShift(frame, a, Layouts.BIGNUM.getValue(b).negate());
}
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ public CatchNode(RubyContext context, SourceSection sourceSection) {
private boolean areSame(VirtualFrame frame, Object left, Object right) {
if (referenceEqualNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(new RubyNode[]{null, null}));
referenceEqualNode = insert(BasicObjectNodesFactory.ReferenceEqualNodeFactory.create(null));
}
return referenceEqualNode.executeReferenceEqual(frame, left, right);
}
@@ -237,7 +237,7 @@ public static abstract class VMObjectEqualPrimitiveNode extends PrimitiveArrayAr

public VMObjectEqualPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
referenceEqualNode = ReferenceEqualNodeFactory.create(new RubyNode[]{null, null});
referenceEqualNode = ReferenceEqualNodeFactory.create(null);
}

@Specialization
@@ -288,7 +288,7 @@ public static abstract class VMObjectSingletonClassPrimitiveNode extends Primiti

public VMObjectSingletonClassPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
singletonClassNode = KernelNodesFactory.SingletonClassMethodNodeFactory.create(context, sourceSection, new RubyNode[]{ null });
singletonClassNode = KernelNodesFactory.SingletonClassMethodNodeFactory.create(context, sourceSection, null);
}

@Specialization
Original file line number Diff line number Diff line change
@@ -615,9 +615,7 @@ private ToIntNode getToIntNode() {
private StringSubstringPrimitiveNode getSubstringNode() {
if (substringNode == null) {
CompilerDirectives.transferToInterpreter();

substringNode = insert(StringNodesFactory.StringSubstringPrimitiveNodeFactory.create(
new RubyNode[] { null, null, null }));
substringNode = insert(StringNodesFactory.StringSubstringPrimitiveNodeFactory.create(null));
}

return substringNode;

3 comments on commit 3eff054

@eregon
Copy link
Member Author

@eregon eregon commented on 3eff054 May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jruby/truffle building a RubyNode[] to fill with null is no longer necessary, the generated code handles it already.

@chrisseaton
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's amazing! Now we just need an override of create that takes no parameters and passes null for you.

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. I've been meaning to look into fixing that, but haven't been able to find the time. Now I don't need to!

Sorry, something went wrong.

Please sign in to comment.