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

Commits on May 9, 2015

  1. Copy the full SHA
    e808d66 View commit details
  2. Copy the full SHA
    5409335 View commit details
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
@@ -13,13 +13,16 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.runtime.RubyContext;

public class AssignmentWrapperNode extends RubyNode {
public class DefinedWrapperNode extends RubyNode {

@Child private RubyNode child;

public AssignmentWrapperNode(RubyContext context, SourceSection sourceSection, RubyNode child) {
private final String definition;

public DefinedWrapperNode(RubyContext context, SourceSection sourceSection, RubyNode child, String definition) {
super(context, sourceSection);
this.child = child;
this.definition = definition;
}

@Override
@@ -29,7 +32,7 @@ public Object execute(VirtualFrame frame) {

@Override
public Object isDefined(VirtualFrame frame) {
return getContext().makeString("assignment");
return getContext().makeString(definition);
}

}
35 changes: 0 additions & 35 deletions truffle/src/main/java/org/jruby/truffle/nodes/control/ForNode.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.DefinedWrapperNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.literal.NilLiteralNode;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyNilClass;
@@ -40,7 +40,9 @@ public static RubyNode sequence(RubyContext context, SourceSection sourceSection
final List<RubyNode> flattened = flatten(sequence, true);

if (flattened.isEmpty()) {
return new NilLiteralNode(context, sourceSection);
return new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil");
} else if (flattened.size() == 1) {
return flattened.get(0);
} else {
Original file line number Diff line number Diff line change
@@ -14,9 +14,8 @@
import com.oracle.truffle.api.nodes.ControlFlowException;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.DefinedWrapperNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.exceptions.RescueNode;
import org.jruby.truffle.nodes.literal.NilLiteralNode;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.nodes.methods.ExceptionTranslatingNode;
import org.jruby.truffle.nodes.objects.WriteInstanceVariableNode;
@@ -47,7 +46,9 @@ public TryNode(RubyContext context, SourceSection sourceSection, ExceptionTransl
this.elsePart = elsePart;
clearExceptionVariableNode = new WriteInstanceVariableNode(context, sourceSection, "$!",
new ObjectLiteralNode(context, sourceSection, context.getThreadManager().getCurrentThread().getThreadLocals()),
new NilLiteralNode(context, sourceSection),
new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil"),
true);
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -43,12 +43,12 @@
import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Sysconf;
import jnr.posix.Times;
import org.jruby.truffle.nodes.DefinedWrapperNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.BasicObjectNodes;
import org.jruby.truffle.nodes.core.BasicObjectNodesFactory;
import org.jruby.truffle.nodes.core.KernelNodes;
import org.jruby.truffle.nodes.core.KernelNodesFactory;
import org.jruby.truffle.nodes.literal.NilLiteralNode;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.nodes.objects.ClassNode;
import org.jruby.truffle.nodes.objects.ClassNodeGen;
@@ -108,10 +108,14 @@ public Object doCatch(VirtualFrame frame, Object tag, RubyProc block) {
if (areSame(frame, e.getTag(), tag)) {
if (clearExceptionVariableNode == null) {
CompilerDirectives.transferToInterpreter();
RubyContext context = getContext();
SourceSection sourceSection = getSourceSection();
clearExceptionVariableNode = insert(
new WriteInstanceVariableNode(getContext(), getSourceSection(), "$!",
new ObjectLiteralNode(getContext(), getSourceSection(), getContext().getThreadManager().getCurrentThread().getThreadLocals()),
new NilLiteralNode(getContext(), getSourceSection()),
new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil"),
true)
);
}
115 changes: 83 additions & 32 deletions truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -18,15 +18,16 @@
import org.jruby.ast.StarNode;
import org.jruby.ast.types.INameNode;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.truffle.nodes.DefinedWrapperNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.core.array.ArraySliceNodeGen;
import org.jruby.truffle.nodes.core.array.PrimitiveArrayNodeFactory;
import org.jruby.truffle.nodes.cast.ArrayCastNodeGen;
import org.jruby.truffle.nodes.control.IfNode;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.core.array.ArrayLiteralNode;
import org.jruby.truffle.nodes.literal.NilLiteralNode;
import org.jruby.truffle.nodes.arguments.*;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.nodes.locals.ReadLocalVariableNodeGen;
import org.jruby.truffle.nodes.locals.WriteLocalVariableNodeGen;
import org.jruby.truffle.runtime.RubyContext;
@@ -176,7 +177,9 @@ public RubyNode visitKeywordArgNode(org.jruby.ast.KeywordArgNode node) {
name = localAsgnNode.getName();

if (localAsgnNode.getValueNode() == null) {
defaultValue = new NilLiteralNode(context, sourceSection);
defaultValue = new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil");
} else if (localAsgnNode.getValueNode() instanceof RequiredKeywordArgumentValueNode) {
/*
* This isn't a true default value - it's a marker to say there isn't one. This actually makes sense;
@@ -191,7 +194,9 @@ public RubyNode visitKeywordArgNode(org.jruby.ast.KeywordArgNode node) {
name = dAsgnNode.getName();

if (dAsgnNode.getValueNode() == null) {
defaultValue = new NilLiteralNode(context, sourceSection);
defaultValue = new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil");
} else if (dAsgnNode.getValueNode() instanceof RequiredKeywordArgumentValueNode) {
/*
* This isn't a true default value - it's a marker to say there isn't one. This actually makes sense;
@@ -411,7 +416,9 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnNode node) {
}

for (String parameterToClear : parametersToClearCollector.getParameters()) {
nilSequence.add(((ReadNode) methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(parameterToClear, sourceSection)).makeWriteNode(new NilLiteralNode(context, sourceSection)));
nilSequence.add(((ReadNode) methodBodyTranslator.getEnvironment().findOrAddLocalVarNodeDangerous(parameterToClear, sourceSection)).makeWriteNode(new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil")));
}

if (!childNodes.isEmpty()) {
@@ -429,7 +436,9 @@ public RubyNode visitMultipleAsgnNode(MultipleAsgnNode node) {
new IfNode(context, sourceSection,
new IsNilNode(context, sourceSection, ReadLocalVariableNodeGen.create(context, sourceSection, arraySlot)),
nil,
notNil == null ? new NilLiteralNode(context, sourceSection) : notNil));
notNil == null ? new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil") : notNil));
}

@Override
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.ast.ArgsNode;
import org.jruby.truffle.nodes.DefinedWrapperNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.cast.ArrayCastNodeGen;
import org.jruby.truffle.nodes.control.IfNode;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.literal.NilLiteralNode;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.nodes.methods.*;
import org.jruby.truffle.nodes.arguments.CheckArityNode;
@@ -88,7 +88,9 @@ public RubyNode compileFunctionNode(SourceSection sourceSection, String methodNa
parentSourceSection.pop();
}
} else {
body = new NilLiteralNode(context, sourceSection);
body = new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil");
}

final LoadArgumentsTranslator loadArgumentsTranslator = new LoadArgumentsTranslator(currentNode, context, source, isBlock, this);
@@ -137,7 +139,9 @@ public RubyNode compileFunctionNode(SourceSection sourceSection, String methodNa

prelude = SequenceNode.sequence(context, sourceSection,
new BehaveAsBlockNode(context, sourceSection,
new NilLiteralNode(context, sourceSection),
new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil"),
new CheckArityNode(context, sourceSection, arityForCheck, parameterCollector.getKeywords(), argsNode.getKeyRest() != null)), preludeBuilder);
} else {
if (usesRubiniusPrimitive) {
Original file line number Diff line number Diff line change
@@ -14,10 +14,10 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.DefinedWrapperNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.literal.NilLiteralNode;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.nodes.methods.AliasNodeGen;
import org.jruby.truffle.nodes.methods.CatchReturnPlaceholderNode;
@@ -54,7 +54,9 @@ public MethodDefinitionNode compileClassNode(SourceSection sourceSection, String
parentSourceSection.pop();
}
} else {
body = new NilLiteralNode(context, sourceSection);
body = new DefinedWrapperNode(context, sourceSection,
new ObjectLiteralNode(context, sourceSection, context.getCoreLibrary().getNilObject()),
"nil");
}

if (environment.getFlipFlopStates().size() > 0) {
Original file line number Diff line number Diff line change
@@ -19,10 +19,10 @@
import org.jcodings.Encoding;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.scope.ManyVarsDynamicScope;
import org.jruby.truffle.nodes.DefinedWrapperNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.literal.NilLiteralNode;
import org.jruby.truffle.nodes.literal.ObjectLiteralNode;
import org.jruby.truffle.nodes.methods.CatchNextNode;
import org.jruby.truffle.nodes.methods.CatchRetryAsErrorNode;
@@ -154,7 +154,9 @@ public RubyRootNode parse(Node currentNode, RubyContext context, Source source,
translator.parentSourceSection.push(sharedMethodInfo.getSourceSection());

try {
truffleNode = new NilLiteralNode(context, null);
truffleNode = new DefinedWrapperNode(context, null,
new ObjectLiteralNode(context, null, context.getCoreLibrary().getNilObject()),
"nil");
} finally {
translator.parentSourceSection.pop();
}