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

Commits on Aug 18, 2016

  1. Copy the full SHA
    a6a726b View commit details
  2. Copy the full SHA
    2834a6d View commit details
Original file line number Diff line number Diff line change
@@ -189,15 +189,15 @@ private static CallTarget makeGenericMethod(RubyContext context, MethodDetails m
final boolean needsSelf = method.constructor() || (!method.isModuleFunction() && !method.onSingleton() && method.needsSelf());

if (needsSelf) {
RubyNode readSelfNode = new SelfNode(context, sourceSection);
argumentsNodes.add(transformArgument(method, readSelfNode, 0));
RubyNode readSelfNode = new SelfNode();
argumentsNodes.add(transformArgument(context, sourceSection, method, readSelfNode, 0));
}

final int nArgs = required + optional;

for (int n = 0; n < nArgs; n++) {
RubyNode readArgumentNode = new ReadPreArgumentNode(n, MissingArgumentBehavior.UNDEFINED);
argumentsNodes.add(transformArgument(method, readArgumentNode, n + 1));
argumentsNodes.add(transformArgument(context, sourceSection, method, readArgumentNode, n + 1));
}
if (method.rest()) {
argumentsNodes.add(new ReadRemainingArgumentsNode(nArgs));
@@ -255,13 +255,13 @@ private static CallTarget makeGenericMethod(RubyContext context, MethodDetails m
return Truffle.getRuntime().createCallTarget(rootNode);
}

private static RubyNode transformArgument(CoreMethod method, RubyNode argument, int n) {
private static RubyNode transformArgument(RubyContext context, SourceSection sourceSection, CoreMethod method, RubyNode argument, int n) {
if (ArrayUtils.contains(method.lowerFixnum(), n)) {
argument = FixnumLowerNodeGen.create(null, null, argument);
}

if (n == 0 && method.raiseIfFrozenSelf()) {
argument = new RaiseIfFrozenNode(argument);
argument = new RaiseIfFrozenNode(context, sourceSection, argument);
}

return argument;
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public RubyNode createCallPrimitiveNode(RubyContext context, SourceSection sourc
List<Class<?>> signature = signatures.get(0);

if (annotation.needsSelf()) {
arguments.add(transformArgument(new SelfNode(context, sourceSection), 0));
arguments.add(transformArgument(new SelfNode(), 0));
argumentsCount--;
}

Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@

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.objects.IsFrozenNode;
@@ -24,10 +26,10 @@ public class RaiseIfFrozenNode extends RubyNode {
@Child private RubyNode child;
@Child private IsFrozenNode isFrozenNode;

public RaiseIfFrozenNode(RubyNode child) {
super(child.getContext(), child.getEncapsulatingSourceSection());
public RaiseIfFrozenNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
super(context, sourceSection);
this.child = child;
isFrozenNode = IsFrozenNodeGen.create(child.getContext(), child.getEncapsulatingSourceSection(), null);
isFrozenNode = IsFrozenNodeGen.create(context, sourceSection, null);
}

@Override
Original file line number Diff line number Diff line change
@@ -383,7 +383,7 @@ private void createAccesor(DynamicObject module, String name) {
final RubyNode checkArity = Translator.createCheckArityNode(getContext(), sourceSection, arity);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, indicativeName, false, null, false, false, false);

final SelfNode self = new SelfNode(getContext(), sourceSection);
final SelfNode self = new SelfNode();
final RubyNode accessInstanceVariable;
if (isGetter) {
accessInstanceVariable = new ReadInstanceVariableNode(getContext(), sourceSection, ivar, self);
@@ -1772,7 +1772,7 @@ public abstract static class UndefMethodNode extends CoreMethodArrayArgumentsNod
public UndefMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
this.nameToJavaStringNode = NameToJavaStringNode.create();
this.raiseIfFrozenNode = new RaiseIfFrozenNode(new SelfNode(context, sourceSection));
this.raiseIfFrozenNode = new RaiseIfFrozenNode(context, sourceSection, new SelfNode());
this.methodUndefinedNode = DispatchHeadNodeFactory.createMethodCallOnSelf(context);
}

Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
@@ -20,10 +19,6 @@ public class SelfNode extends RubyNode {

private final ValueProfile valueProfile = ValueProfile.createEqualityProfile();

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

@Override
public Object execute(VirtualFrame frame) {
return valueProfile.profile(RubyArguments.getSelf(frame));
Original file line number Diff line number Diff line change
@@ -29,7 +29,6 @@
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.builtins.PrimitiveNodeConstructor;
import org.jruby.truffle.core.CoreLibrary;
@@ -51,7 +50,6 @@
import org.jruby.truffle.core.cast.ToProcNodeGen;
import org.jruby.truffle.core.cast.ToSNode;
import org.jruby.truffle.core.cast.ToSNodeGen;
import org.jruby.truffle.core.exception.SystemCallErrorNodesFactory;
import org.jruby.truffle.core.hash.ConcatHashLiteralNode;
import org.jruby.truffle.core.hash.HashLiteralNode;
import org.jruby.truffle.core.hash.HashNodesFactory;
@@ -135,7 +133,6 @@
import org.jruby.truffle.language.locals.LocalFlipFlopStateNode;
import org.jruby.truffle.language.locals.LocalVariableType;
import org.jruby.truffle.language.locals.ReadLocalVariableNode;
import org.jruby.truffle.language.locals.WriteLocalVariableNode;
import org.jruby.truffle.language.methods.AddMethodNodeGen;
import org.jruby.truffle.language.methods.Arity;
import org.jruby.truffle.language.methods.BlockDefinitionNode;
@@ -243,7 +240,7 @@ public RubyNode visitAliasNode(org.jruby.ast.AliasNode node) {
final DynamicObject newName = translateNameNodeToSymbol(node.getNewName());

final RubyNode ret = ModuleNodesFactory.AliasMethodNodeFactory.create(
new RaiseIfFrozenNode(new GetDefaultDefineeNode(context, sourceSection)),
new RaiseIfFrozenNode(context, sourceSection, new GetDefaultDefineeNode(context, sourceSection)),
new ObjectLiteralNode(context, sourceSection, newName),
new ObjectLiteralNode(context, sourceSection, oldName));

@@ -607,7 +604,7 @@ public RubyNode translateSingleBlockArg(SourceSection sourceSection, org.jruby.a
}

private RubyNode translateCheckFrozen(SourceSection sourceSection) {
return new RaiseIfFrozenNode(new SelfNode(context, sourceSection));
return new RaiseIfFrozenNode(context, sourceSection, new SelfNode());
}

private RubyNode translateCallNode(org.jruby.ast.CallNode node, boolean ignoreVisibility, boolean isVCall, boolean isAttrAssign) {
@@ -1068,6 +1065,10 @@ public RubyNode visitConstDeclNode(org.jruby.ast.ConstDeclNode node) {
}

private String getSourcePath(SourceSection sourceSection) {
if (sourceSection == null) {
return "(unknown)";
}

final Source source = sourceSection.getSource();

if (source == null) {
@@ -1237,7 +1238,7 @@ public RubyNode visitDefinedNode(org.jruby.ast.DefinedNode node) {
@Override
public RubyNode visitDefnNode(org.jruby.ast.DefnNode node) {
final SourceSection sourceSection = translate(node.getPosition(), node.getName());
final RubyNode classNode = new RaiseIfFrozenNode(new GetDefaultDefineeNode(context, sourceSection));
final RubyNode classNode = new RaiseIfFrozenNode(context, sourceSection, new GetDefaultDefineeNode(context, sourceSection));

String methodName = node.getName();

@@ -1742,7 +1743,7 @@ public RubyNode visitInstAsgnNode(org.jruby.ast.InstAsgnNode node) {

// Every case will use a SelfNode, just don't it use more than once.
// Also note the check for frozen.
final RubyNode self = new RaiseIfFrozenNode(new SelfNode(context, sourceSection));
final RubyNode self = new RaiseIfFrozenNode(context, sourceSection, new SelfNode());

final String path = getSourcePath(sourceSection);
final String corePath = buildCorePath("");
@@ -1790,7 +1791,7 @@ public RubyNode visitInstVarNode(org.jruby.ast.InstVarNode node) {
final String name = node.getName();

// About every case will use a SelfNode, just don't it use more than once.
final SelfNode self = new SelfNode(context, sourceSection);
final SelfNode self = new SelfNode();

final String path = getSourcePath(sourceSection);
final String corePath = buildCorePath("");
@@ -2804,7 +2805,7 @@ public RubyNode visitSValueNode(org.jruby.ast.SValueNode node) {

@Override
public RubyNode visitSelfNode(org.jruby.ast.SelfNode node) {
final RubyNode ret = new SelfNode(context, translate(node.getPosition()));
final RubyNode ret = new SelfNode();
return addNewlineIfNeeded(node, ret);
}

@@ -2860,7 +2861,7 @@ public RubyNode visitUndefNode(org.jruby.ast.UndefNode node) {
final DynamicObject nameSymbol = translateNameNodeToSymbol(node.getName());

final RubyNode ret = ModuleNodesFactory.UndefMethodNodeFactory.create(context, sourceSection, new RubyNode[]{
new RaiseIfFrozenNode(new GetDefaultDefineeNode(context, sourceSection)),
new RaiseIfFrozenNode(context, sourceSection, new GetDefaultDefineeNode(context, sourceSection)),
new ObjectLiteralNode(context, sourceSection, new Object[]{ nameSymbol })
});
return addNewlineIfNeeded(node, ret);