Skip to content

Commit

Permalink
Showing 29 changed files with 46 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
final List<RubyNode> argumentsNodes = new ArrayList<>();

if (needsCallerFrame) {
argumentsNodes.add(new ReadCallerFrameNode(context, sourceSection));
argumentsNodes.add(new ReadCallerFrameNode());
}

// Do not use needsSelf=true in module functions, it is either the module/class or the instance.
@@ -190,7 +190,7 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
}

for (int n = 0; n < arity.getPreRequired() + arity.getOptional(); n++) {
RubyNode readArgumentNode = new ReadPreArgumentNode(context, sourceSection, n, MissingArgumentBehavior.UNDEFINED);
RubyNode readArgumentNode = new ReadPreArgumentNode(n, MissingArgumentBehavior.UNDEFINED);

if (ArrayUtils.contains(method.lowerFixnumParameters(), n)) {
readArgumentNode = FixnumLowerNodeGen.create(context, sourceSection, readArgumentNode);
@@ -203,11 +203,11 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails
argumentsNodes.add(readArgumentNode);
}
if (method.rest()) {
argumentsNodes.add(new ReadRemainingArgumentsNode(context, sourceSection, arity.getPreRequired() + arity.getOptional()));
argumentsNodes.add(new ReadRemainingArgumentsNode(arity.getPreRequired() + arity.getOptional()));
}

if (method.needsBlock()) {
argumentsNodes.add(new ReadBlockNode(context, sourceSection, NotProvided.INSTANCE));
argumentsNodes.add(new ReadBlockNode(NotProvided.INSTANCE));
}

final RubyNode methodNode;
Original file line number Diff line number Diff line change
@@ -2104,7 +2104,7 @@ public MaxBlock(RubyContext context) {

callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, MaxBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
new ReadDeclarationVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehavior.RUNTIME_ERROR)
new ReadPreArgumentNode(0, MissingArgumentBehavior.RUNTIME_ERROR)
}), false));
}

@@ -2222,7 +2222,7 @@ public MinBlock(RubyContext context) {

callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(context, sourceSection, null, sharedMethodInfo, MinBlockNodeFactory.create(context, sourceSection, new RubyNode[]{
new ReadDeclarationVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, 1, frameSlot),
new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehavior.RUNTIME_ERROR)
new ReadPreArgumentNode(0, MissingArgumentBehavior.RUNTIME_ERROR)
}), false));
}

Original file line number Diff line number Diff line change
@@ -432,7 +432,7 @@ public DynamicObject generateAccessor(VirtualFrame frame, DynamicObject module,
if (isGetter) {
accessInstanceVariable = new ReadInstanceVariableNode(getContext(), sourceSection, ivar, self);
} else {
ReadPreArgumentNode readArgument = new ReadPreArgumentNode(getContext(), sourceSection, 0, MissingArgumentBehavior.RUNTIME_ERROR);
ReadPreArgumentNode readArgument = new ReadPreArgumentNode(0, MissingArgumentBehavior.RUNTIME_ERROR);
accessInstanceVariable = new WriteInstanceVariableNode(getContext(), sourceSection, ivar, self, readArgument);
}
final RubyNode sequence = Translator.sequence(getContext(), sourceSection, Arrays.asList(checkArity, accessInstanceVariable));
Original file line number Diff line number Diff line change
@@ -42,17 +42,17 @@ public RubyNode createCallPrimitiveNode(RubyContext context, SourceSection sourc
return new CallRubiniusPrimitiveNode(context, sourceSection,
MethodNodesFactory.CallNodeFactory.create(context, sourceSection, new RubyNode[] {
new ObjectLiteralNode(context, sourceSection, method),
new ReadAllArgumentsNode(context, sourceSection),
new ReadBlockNode(context, sourceSection, NotProvided.INSTANCE)
new ReadAllArgumentsNode(),
new ReadBlockNode(NotProvided.INSTANCE)
}), returnID);
}

@Override
public RubyNode createInvokePrimitiveNode(RubyContext context, SourceSection sourceSection, RubyNode[] arguments) {
return MethodNodesFactory.CallNodeFactory.create(context, sourceSection, new RubyNode[] {
new ObjectLiteralNode(context, sourceSection, method),
new ObjectArrayNode(context, sourceSection, arguments),
new ReadBlockNode(context, sourceSection, NotProvided.INSTANCE)
new ObjectArrayNode(arguments),
new ReadBlockNode(NotProvided.INSTANCE)
});
}

Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ public RubyNode createCallPrimitiveNode(RubyContext context, SourceSection sourc
}

for (int n = 0; n < argumentsCount; n++) {
RubyNode readArgumentNode = new ReadPreArgumentNode(context, sourceSection, n, MissingArgumentBehavior.UNDEFINED);
RubyNode readArgumentNode = new ReadPreArgumentNode(n, MissingArgumentBehavior.UNDEFINED);
arguments.add(transformArgument(readArgumentNode, n));
}

@@ -91,7 +91,7 @@ public RubyNode createInvokePrimitiveNode(RubyContext context, SourceSection sou

private RubyNode transformArgument(RubyNode argument, int n) {
if (ArrayUtils.contains(annotation.lowerFixnumParameters(), n)) {
return FixnumLowerNodeGen.create(argument.getContext(), argument.getSourceSection(), argument);
return FixnumLowerNodeGen.create(null, null, argument);
} else {
return argument;
}
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@

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.RubyContext;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.language.RubyNode;

@@ -22,9 +20,7 @@ public class ArrayIsAtLeastAsLargeAsNode extends RubyNode {

@Child private RubyNode child;

public ArrayIsAtLeastAsLargeAsNode(RubyContext context, SourceSection sourceSection,
int requiredSize, RubyNode child) {
super(context, sourceSection);
public ArrayIsAtLeastAsLargeAsNode(int requiredSize, RubyNode child) {
this.requiredSize = requiredSize;
this.child = child;
}
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.methods.Arity;
@@ -23,8 +21,7 @@ public class CheckArityNode extends RubyNode {

private final BranchProfile checkFailedProfile = BranchProfile.create();

public CheckArityNode(RubyContext context, SourceSection sourceSection, Arity arity) {
super(context, sourceSection);
public CheckArityNode(Arity arity) {
this.arity = arity;
}

Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ public class CheckKeywordArityNode extends RubyNode {
public CheckKeywordArityNode(RubyContext context, SourceSection sourceSection, Arity arity) {
super(context, sourceSection);
this.arity = arity;
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(context, sourceSection, arity.getRequired());
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(arity.getRequired());
}

@Override
Original file line number Diff line number Diff line change
@@ -10,17 +10,14 @@
package org.jruby.truffle.language.arguments;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.RaiseException;

public class MissingKeywordArgumentNode extends RubyNode {

private final String name;

public MissingKeywordArgumentNode(RubyContext context, SourceSection sourceSection, String name) {
super(context, sourceSection);
public MissingKeywordArgumentNode(String name) {
this.name = name;
}

Original file line number Diff line number Diff line change
@@ -11,16 +11,13 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;

public class ObjectArrayNode extends RubyNode {

@Children private final RubyNode[] nodes;

public ObjectArrayNode(RubyContext context, SourceSection sourceSection, RubyNode[] nodes) {
super(context, sourceSection);
public ObjectArrayNode(RubyNode[] nodes) {
this.nodes = nodes;
}

Original file line number Diff line number Diff line change
@@ -16,10 +16,6 @@

public class ReadAllArgumentsNode extends RubyNode {

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

@Override
public Object[] executeObjectArray(VirtualFrame frame) {
return RubyArguments.getArguments(frame);
Original file line number Diff line number Diff line change
@@ -12,8 +12,6 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;

public class ReadBlockNode extends RubyNode {
@@ -22,8 +20,7 @@ public class ReadBlockNode extends RubyNode {

private final ConditionProfile blockProfile = ConditionProfile.createBinaryProfile();

public ReadBlockNode(RubyContext context, SourceSection sourceSection, Object valueIfAbsent) {
super(context, sourceSection);
public ReadBlockNode(Object valueIfAbsent) {
this.valueIfAbsent = valueIfAbsent;
}

Original file line number Diff line number Diff line change
@@ -11,19 +11,13 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyNode;

public class ReadCallerFrameNode extends RubyNode {

private final ConditionProfile callerFrameProfile = ConditionProfile.createBinaryProfile();

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

@Override
public Object execute(VirtualFrame frame) {
final Object callerFrame = RubyArguments.getCallerFrame(frame);
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public ReadKeywordArgumentNode(RubyContext context, SourceSection sourceSection,
super(context, sourceSection);
this.name = name;
this.defaultValue = defaultValue;
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(context, sourceSection, minimum);
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(minimum);
}

@Override
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ public ReadKeywordRestArgumentNode(RubyContext context, SourceSection sourceSect
int minimum, String[] excludedKeywords) {
super(context, sourceSection);
this.excludedKeywords = excludedKeywords;
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(context, sourceSection, minimum);
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(minimum);
}

@Override
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ public ReadOptionalArgumentNode(RubyContext context, SourceSection sourceSection
this.reduceMinimumWhenNoKWargs = reduceMinimumWhenNoKWargs;

if (reduceMinimumWhenNoKWargs) {
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(context, sourceSection, requiredForKWArgs);
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(requiredForKWArgs);
}
}

Original file line number Diff line number Diff line change
@@ -10,16 +10,13 @@
package org.jruby.truffle.language.arguments;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;

public class ReadPostArgumentNode extends RubyNode {

private final int indexFromCount;

public ReadPostArgumentNode(RubyContext context, SourceSection sourceSection, int indexFromCount) {
super(context, sourceSection);
public ReadPostArgumentNode(int indexFromCount) {
this.indexFromCount = indexFromCount;
}

Original file line number Diff line number Diff line change
@@ -12,8 +12,6 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyNode;

@@ -26,9 +24,8 @@ public class ReadPreArgumentNode extends RubyNode {

private final ValueProfile argumentValueProfile = ValueProfile.createEqualityProfile();

public ReadPreArgumentNode(RubyContext context, SourceSection sourceSection, int index,
public ReadPreArgumentNode(int index,
MissingArgumentBehavior missingArgumentBehavior) {
super(context, sourceSection);
this.index = index;
this.missingArgumentBehavior = missingArgumentBehavior;
}
Original file line number Diff line number Diff line change
@@ -11,17 +11,14 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;

public class ReadRemainingArgumentsNode extends RubyNode {

private final int start;
private final ConditionProfile remainingArguments = ConditionProfile.createBinaryProfile();

public ReadRemainingArgumentsNode(RubyContext context, SourceSection sourceSection, int start) {
super(context, sourceSection);
public ReadRemainingArgumentsNode(int start) {
this.start = start;
}

Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ public ReadRestArgumentNode(RubyContext context, SourceSection sourceSection, in
this.keywordArguments = keywordArguments;

if (keywordArguments) {
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(context, sourceSection, minimumForKWargs);
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(minimumForKWargs);
}
}

Original file line number Diff line number Diff line change
@@ -12,8 +12,6 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;

@@ -24,8 +22,7 @@ public class ReadUserKeywordsHashNode extends RubyNode {
private final ConditionProfile notEnoughArgumentsProfile = ConditionProfile.createBinaryProfile();
private final ConditionProfile lastArgumentIsHashProfile = ConditionProfile.createBinaryProfile();

public ReadUserKeywordsHashNode(RubyContext context, SourceSection sourceSection, int minArgumentCount) {
super(context, sourceSection);
public ReadUserKeywordsHashNode(int minArgumentCount) {
this.minArgumentCount = minArgumentCount;
}

Original file line number Diff line number Diff line change
@@ -12,8 +12,6 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.locals.ReadFrameSlotNode;
@@ -28,8 +26,7 @@ public class RunBlockKWArgsHelperNode extends RubyNode {

private final Object kwrestName;

public RunBlockKWArgsHelperNode(RubyContext context, SourceSection sourceSection, FrameSlot arrayFrameSlot, Object kwrestName) {
super(context, sourceSection);
public RunBlockKWArgsHelperNode(FrameSlot arrayFrameSlot, Object kwrestName) {
readArrayNode = ReadFrameSlotNodeGen.create(arrayFrameSlot);
writeArrayNode = WriteFrameSlotNodeGen.create(arrayFrameSlot);
this.kwrestName = kwrestName;
Original file line number Diff line number Diff line change
@@ -12,8 +12,6 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.dispatch.RespondToNode;
@@ -25,8 +23,7 @@ public class ShouldDestructureNode extends RubyNode {

private final BranchProfile checkIsArrayProfile = BranchProfile.create();

public ShouldDestructureNode(RubyContext context, SourceSection sourceSection, RubyNode readArrayNode) {
super(context, sourceSection);
public ShouldDestructureNode(RubyNode readArrayNode) {
this.readArrayNode = readArrayNode;
}

Original file line number Diff line number Diff line change
@@ -2282,7 +2282,7 @@ public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {

final RubyNode assignPost =
new IfElseNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, sourceSection)),
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, sourceSection)),
atLeastAsLarge,
smaller);

@@ -2422,7 +2422,7 @@ public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {

final RubyNode assignPost =
new IfElseNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, sourceSection)),
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), environment.findLocalVarNode(tempName, sourceSection)),
atLeastAsLarge,
smaller);

Original file line number Diff line number Diff line change
@@ -123,8 +123,8 @@ public RubyNode visitArgsNode(org.jruby.ast.ArgsNode node) {
}

sequence.add(new IfNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, node.getPreCount() + node.getPostCount(), loadArray(sourceSection)),
new RunBlockKWArgsHelperNode(context, sourceSection, arraySlotStack.peek().getArraySlot(), keyRestNameOrNil)));
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), loadArray(sourceSection)),
new RunBlockKWArgsHelperNode(arraySlotStack.peek().getArraySlot(), keyRestNameOrNil)));
}

final int preCount = node.getPreCount();
@@ -218,7 +218,7 @@ public RubyNode visitArgsNode(org.jruby.ast.ArgsNode node) {
if (useArray()) {
if (node.getPreCount() == 0 || node.hasRestArg()) {
sequence.add(new IfElseNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, node.getPreCount() + node.getPostCount(), loadArray(sourceSection)),
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), loadArray(sourceSection)),
notNilAtLeastAsLarge,
notNilSmaller));
} else {
@@ -285,7 +285,7 @@ public RubyNode visitKeywordArgNode(org.jruby.ast.KeywordArgNode node) {
if (asgnNode.getValueNode() instanceof RequiredKeywordArgumentValueNode) {
/* This isn't a true default value - it's a marker to say there isn't one. This actually makes sense;
* the semantic action of executing this node is to report an error, and we do the same thing. */
defaultValue = new MissingKeywordArgumentNode(context, sourceSection, name);
defaultValue = new MissingKeywordArgumentNode(name);
} else {
defaultValue = translateNodeOrNil(sourceSection, asgnNode.getValueNode());
}
@@ -311,9 +311,9 @@ private RubyNode readArgument(SourceSection sourceSection) {
return PrimitiveArrayNodeFactory.read(context, sourceSection, loadArray(sourceSection), index);
} else {
if (state == State.PRE) {
return new ReadPreArgumentNode(context, sourceSection, index, isProc ? MissingArgumentBehavior.NIL : MissingArgumentBehavior.RUNTIME_ERROR);
return new ReadPreArgumentNode(index, isProc ? MissingArgumentBehavior.NIL : MissingArgumentBehavior.RUNTIME_ERROR);
} else if (state == State.POST) {
return new ReadPostArgumentNode(context, sourceSection, -index);
return new ReadPostArgumentNode(-index);
} else {
throw new IllegalStateException();
}
@@ -346,7 +346,7 @@ public RubyNode visitRestArgNode(org.jruby.ast.RestArgNode node) {
public RubyNode visitBlockArgNode(org.jruby.ast.BlockArgNode node) {
final SourceSection sourceSection = translate(node.getPosition());

final RubyNode readNode = new ReadBlockNode(context, sourceSection, context.getCoreLibrary().getNilObject());
final RubyNode readNode = new ReadBlockNode(context.getCoreLibrary().getNilObject());
final FrameSlot slot = methodBodyTranslator.getEnvironment().getFrameDescriptor().findFrameSlot(node.getName());
return new WriteLocalVariableNode(context, sourceSection, slot, readNode);
}
@@ -412,7 +412,7 @@ private RubyNode translateLocalAssignment(ISourcePosition sourcePosition, String
if (useArray()) {
// TODO CS 10-Jan-16 we should really hoist this check, or see if Graal does it for us
readNode = new IfElseNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, minimum, loadArray(sourceSection)),
new ArrayIsAtLeastAsLargeAsNode(minimum, loadArray(sourceSection)),
PrimitiveArrayNodeFactory.read(context, sourceSection, loadArray(sourceSection), index),
defaultValue);
} else {
@@ -588,7 +588,7 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnNode node) {
new IsNilNode(context, sourceSection, new ReadLocalVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, arraySlot)),
nil,
new IfElseNode(context, sourceSection,
new ArrayIsAtLeastAsLargeAsNode(context, sourceSection, node.getPreCount() + node.getPostCount(), new ReadLocalVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, arraySlot)),
new ArrayIsAtLeastAsLargeAsNode(node.getPreCount() + node.getPostCount(), new ReadLocalVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, arraySlot)),
notNilAtLeastAsLarge,
notNilSmaller))));
}
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ public BlockDefinitionNode compileBlockNode(SourceSection sourceSection, String

final RubyNode preludeProc;
if (shouldConsiderDestructuringArrayArg(arity)) {
final RubyNode readArrayNode = new ReadPreArgumentNode(context, sourceSection, 0, MissingArgumentBehavior.RUNTIME_ERROR);
final RubyNode readArrayNode = new ReadPreArgumentNode(0, MissingArgumentBehavior.RUNTIME_ERROR);
final RubyNode castArrayNode = ArrayCastNodeGen.create(context, sourceSection, readArrayNode);

final FrameSlot arraySlot = environment.declareVar(environment.allocateLocalTemp("destructure"));
@@ -105,7 +105,7 @@ public BlockDefinitionNode compileBlockNode(SourceSection sourceSection, String
destructureArgumentsTranslator.pushArraySlot(arraySlot);
final RubyNode newDestructureArguments = argsNode.accept(destructureArgumentsTranslator);

final RubyNode shouldDestructure = new ShouldDestructureNode(context, sourceSection, readArrayNode);
final RubyNode shouldDestructure = new ShouldDestructureNode(readArrayNode);

final RubyNode arrayWasNotNil = sequence(context, sourceSection, Arrays.asList(writeArrayNode, new NotNode(context, sourceSection, new IsNilNode(context, sourceSection, new ReadLocalVariableNode(context, sourceSection, LocalVariableType.FRAME_LOCAL, arraySlot)))));

@@ -361,7 +361,7 @@ private RubyNode executeOrInheritBlock(SourceSection sourceSection, RubyNode blo
if (blockNode != null) {
return blockNode;
} else {
return new ReadBlockNode(context, sourceSection, context.getCoreLibrary().getNilObject());
return new ReadBlockNode(context.getCoreLibrary().getNilObject());
}
}

Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ public RubyNode visitOptArgNode(org.jruby.ast.OptArgNode node) {
@Override
public RubyNode visitMultipleAsgnNode(org.jruby.ast.MultipleAsgnNode node) {
final SourceSection sourceSection = translate(node.getPosition());
return new ReadPreArgumentNode(context, sourceSection, index, MissingArgumentBehavior.NIL);
return new ReadPreArgumentNode(index, MissingArgumentBehavior.NIL);
}

@Override
Original file line number Diff line number Diff line change
@@ -173,7 +173,7 @@ protected RubyNode translateNodeOrNil(SourceSection sourceSection, org.jruby.ast

public static RubyNode createCheckArityNode(RubyContext context, SourceSection sourceSection, Arity arity) {
if (!arity.acceptsKeywords()) {
return new CheckArityNode(context, sourceSection, arity);
return new CheckArityNode(arity);
} else {
return new CheckKeywordArityNode(context, sourceSection, arity);
}
Original file line number Diff line number Diff line change
@@ -173,7 +173,7 @@ public RubyRootNode parse(RubyContext context, Source source, Encoding defaultEn

for (int n = 0; n < argumentNames.length; n++) {
final String name = argumentNames[n];
final RubyNode readNode = new ReadPreArgumentNode(context, sourceSection, n, MissingArgumentBehavior.NIL);
final RubyNode readNode = new ReadPreArgumentNode(n, MissingArgumentBehavior.NIL);
final FrameSlot slot = environment.getFrameDescriptor().findFrameSlot(name);
sequence.add(new WriteLocalVariableNode(context, sourceSection, slot, readNode));
}

1 comment on commit 8bbb289

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jruby/truffle

If your nodes aren't syntax nodes (as in they don't appear literally in the source code), then they don't need a source section, as they can get that from their parent. It's now also possible to get their context from their parent.

This means we can simplify many node constructors to remove both the context and source section parameters. This is particular beneficial when those were the only parameters, and the whole constructor can go.

A further benefit (not shown here yet) is that this means it may be much easier to create Ruby nodes with an @Cached("new()") now.

Sorry, something went wrong.

Please sign in to comment.