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

Commits on Feb 27, 2016

  1. Copy the full SHA
    0ed725d View commit details
  2. Copy the full SHA
    462b925 View commit details
  3. Copy the full SHA
    835f526 View commit details
  4. Copy the full SHA
    22b62ae View commit details
  5. Copy the full SHA
    9cb63f4 View commit details
  6. Copy the full SHA
    25ae0a4 View commit details
  7. Copy the full SHA
    9aa7e80 View commit details
  8. Copy the full SHA
    531deb8 View commit details
  9. Copy the full SHA
    c88f593 View commit details
  10. Copy the full SHA
    7c1d5ec View commit details
  11. Copy the full SHA
    6e34681 View commit details
  12. Copy the full SHA
    1c6a045 View commit details
  13. Copy the full SHA
    9515f94 View commit details
  14. Copy the full SHA
    a769636 View commit details
  15. [Truffle] Store in ReadThreadLocalGlobalVariableNode whether or not t…

    …he variable is always defined.
    chrisseaton committed Feb 27, 2016
    Copy the full SHA
    f539fca View commit details
  16. Copy the full SHA
    6890480 View commit details
  17. Copy the full SHA
    cb74154 View commit details
  18. Copy the full SHA
    37ea8ee View commit details
  19. Copy the full SHA
    b2ab64e View commit details
  20. Copy the full SHA
    9423502 View commit details
Showing with 286 additions and 193 deletions.
  1. +10 −5 truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
  2. +1 −1 truffle/src/main/java/org/jruby/truffle/core/binding/BindingNodes.java
  3. +1 −1 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  4. +1 −1 truffle/src/main/java/org/jruby/truffle/core/regexp/RegexpNodes.java
  5. +1 −0 truffle/src/main/java/org/jruby/truffle/core/rubinius/DirPrimitiveNodes.java
  6. +1 −2 truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusLastStringReadNode.java
  7. +1 −2 truffle/src/main/java/org/jruby/truffle/core/rubinius/RubiniusLastStringWriteNode.java
  8. +1 −1 truffle/src/main/java/org/jruby/truffle/language/RubyGuards.java
  9. +13 −7 truffle/src/main/java/org/jruby/truffle/language/arguments/ReadKeywordRestArgumentNode.java
  10. +16 −15 truffle/src/main/java/org/jruby/truffle/language/arguments/ReadRestArgumentNode.java
  11. +7 −3 truffle/src/main/java/org/jruby/truffle/language/arguments/ReadUserKeywordsHashNode.java
  12. +10 −13 truffle/src/main/java/org/jruby/truffle/language/arguments/ShouldDestructureNode.java
  13. +2 −2 truffle/src/main/java/org/jruby/truffle/language/exceptions/SetExceptionVariableNode.java
  14. +5 −3 truffle/src/main/java/org/jruby/truffle/language/globals/CheckMatchVariableTypeNode.java
  15. +5 −3 truffle/src/main/java/org/jruby/truffle/language/globals/CheckOutputSeparatorVariableTypeNode.java
  16. +5 −3 truffle/src/main/java/org/jruby/truffle/language/globals/CheckProgramNameVariableTypeNode.java
  17. +5 −3 truffle/src/main/java/org/jruby/truffle/language/globals/CheckRecordSeparatorVariableTypeNode.java
  18. +18 −6 truffle/src/main/java/org/jruby/truffle/language/globals/CheckStdoutVariableTypeNode.java
  19. +14 −10 truffle/src/main/java/org/jruby/truffle/language/globals/ReadGlobalVariableNode.java
  20. +30 −10 truffle/src/main/java/org/jruby/truffle/language/globals/ReadLastBacktraceNode.java
  21. +46 −34 truffle/src/main/java/org/jruby/truffle/language/globals/ReadMatchReferenceNode.java
  22. +31 −13 truffle/src/main/java/org/jruby/truffle/language/globals/ReadThreadLocalGlobalVariableNode.java
  23. +26 −5 truffle/src/main/java/org/jruby/truffle/language/globals/UpdateLastBacktraceNode.java
  24. +14 −7 truffle/src/main/java/org/jruby/truffle/language/globals/WriteGlobalVariableNode.java
  25. +2 −2 truffle/src/main/java/org/jruby/truffle/language/globals/WriteReadOnlyGlobalNode.java
  26. +1 −11 truffle/src/main/java/org/jruby/truffle/language/{globals → threadlocal}/GetFromThreadLocalNode.java
  27. +1 −1 truffle/src/main/java/org/jruby/truffle/language/{objects → threadlocal}/ThreadLocalObject.java
  28. +5 −4 truffle/src/main/java/org/jruby/truffle/language/{objects → threadlocal}/ThreadLocalObjectNode.java
  29. +1 −11 truffle/src/main/java/org/jruby/truffle/language/{globals → threadlocal}/WrapInThreadLocalNode.java
  30. +6 −6 truffle/src/main/java/org/jruby/truffle/language/translator/BodyTranslator.java
  31. +3 −3 truffle/src/main/java/org/jruby/truffle/language/translator/LoadArgumentsTranslator.java
  32. +2 −3 truffle/src/main/java/org/jruby/truffle/language/translator/MethodTranslator.java
  33. +1 −2 truffle/src/main/java/org/jruby/truffle/language/translator/Translator.java
15 changes: 10 additions & 5 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -940,8 +940,8 @@ public DynamicObject argumentErrorUnknownKeyword(Object name, Node currentNode)
return argumentError("unknown keyword: " + name, currentNode, null);
}

@TruffleBoundary
public DynamicObject argumentError(String message, Node currentNode, Throwable javaThrowable) {
CompilerAsserts.neverPartOfCompilation();
return ExceptionNodes.createRubyException(argumentErrorClass, StringOperations.createString(context, StringOperations.encodeRope(message, UTF8Encoding.INSTANCE)), context.getCallStack().getBacktrace(currentNode, javaThrowable));
}

@@ -1075,6 +1075,11 @@ public DynamicObject typeErrorShouldReturn(String object, String method, String
return typeError(String.format("%s#%s should return %s", object, method, expectedType), currentNode);
}

@TruffleBoundary
public DynamicObject typeErrorMustHaveWriteMethod(Object object, Node currentNode) {
return typeError(String.format("$stdout must have write method, %s given", Layouts.MODULE.getFields(getLogicalClass(object)).getName()), currentNode);
}

public DynamicObject typeErrorCantConvertTo(Object from, String toClass, String methodUsed, Object result, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
String fromClass = Layouts.MODULE.getFields(getLogicalClass(from)).getName();
@@ -1097,13 +1102,13 @@ public DynamicObject typeErrorIsNotA(String value, String expectedType, Node cur
return typeError(String.format("%s is not a %s", value, expectedType), currentNode);
}

@TruffleBoundary
public DynamicObject typeErrorNoImplicitConversion(Object from, String to, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return typeError(String.format("no implicit conversion of %s into %s", Layouts.MODULE.getFields(getLogicalClass(from)).getName(), to), currentNode);
}

@TruffleBoundary
public DynamicObject typeErrorMustBe(String variable, String type, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return typeError(String.format("value of %s must be %s", variable, type), currentNode);
}

@@ -1124,8 +1129,8 @@ public DynamicObject typeErrorCantDump(Object object, Node currentNode) {
return typeError(String.format("can't dump %s", logicalClass), currentNode);
}

@TruffleBoundary
public DynamicObject typeErrorWrongArgumentType(Object object, String expectedType, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
String badClassName = Layouts.MODULE.getFields(getLogicalClass(object)).getName();
return typeError(String.format("wrong argument type %s (expected %s)", badClassName, expectedType), currentNode);
}
@@ -1177,8 +1182,8 @@ public DynamicObject nameErrorInstanceVariableNotDefined(String name, Node curre
return nameError(String.format("instance variable %s not defined", name), name, currentNode);
}

@TruffleBoundary
public DynamicObject nameErrorReadOnly(String name, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return nameError(String.format("%s is a read-only variable", name), name, currentNode);
}

Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@
import org.jruby.truffle.language.locals.WriteFrameSlotNodeGen;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
import org.jruby.truffle.language.objects.ThreadLocalObject;
import org.jruby.truffle.language.threadlocal.ThreadLocalObject;

import java.util.ArrayList;
import java.util.List;
Original file line number Diff line number Diff line change
@@ -122,9 +122,9 @@
import org.jruby.truffle.language.objects.SingletonClassNodeGen;
import org.jruby.truffle.language.objects.TaintNode;
import org.jruby.truffle.language.objects.TaintNodeGen;
import org.jruby.truffle.language.objects.ThreadLocalObject;
import org.jruby.truffle.language.objects.WriteObjectFieldNode;
import org.jruby.truffle.language.objects.WriteObjectFieldNodeGen;
import org.jruby.truffle.language.threadlocal.ThreadLocalObject;
import org.jruby.truffle.language.translator.TranslatorDriver;
import org.jruby.truffle.language.translator.TranslatorDriver.ParserContext;
import org.jruby.util.ByteList;
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.Node.Child;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.Encoding;
@@ -68,6 +67,7 @@
import org.jruby.util.ByteList;
import org.jruby.util.RegexpOptions;
import org.jruby.util.RegexpSupport;

import java.nio.charset.StandardCharsets;
import java.util.Iterator;

Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;

import java.io.File;

public abstract class DirPrimitiveNodes {
Original file line number Diff line number Diff line change
@@ -15,12 +15,11 @@
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.FrameSlotTypeException;
import com.oracle.truffle.api.frame.MaterializedFrame;
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.objects.ThreadLocalObject;
import org.jruby.truffle.language.threadlocal.ThreadLocalObject;

public class RubiniusLastStringReadNode extends RubyNode {

Original file line number Diff line number Diff line change
@@ -17,12 +17,11 @@
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.FrameSlotTypeException;
import com.oracle.truffle.api.frame.MaterializedFrame;
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;
import org.jruby.truffle.language.objects.ThreadLocalObject;
import org.jruby.truffle.language.threadlocal.ThreadLocalObject;

@NodeChild(value = "value", type = RubyNode.class)
public abstract class RubiniusLastStringWriteNode extends RubyNode {
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.language.objects.ThreadLocalObject;
import org.jruby.truffle.language.threadlocal.ThreadLocalObject;

public abstract class RubyGuards {

Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.CompilerDirectives;
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.core.Layouts;
@@ -30,7 +31,10 @@ public class ReadKeywordRestArgumentNode extends RubyNode {

@Child private ReadUserKeywordsHashNode readUserKeywordsHashNode;

public ReadKeywordRestArgumentNode(RubyContext context, SourceSection sourceSection, int minimum, String[] excludedKeywords) {
private final ConditionProfile noHash = ConditionProfile.createBinaryProfile();

public ReadKeywordRestArgumentNode(RubyContext context, SourceSection sourceSection,
int minimum, String[] excludedKeywords) {
super(context, sourceSection);
this.excludedKeywords = excludedKeywords;
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(context, sourceSection, minimum);
@@ -42,17 +46,19 @@ public Object execute(VirtualFrame frame) {
}

private Object lookupRestKeywordArgumentHash(VirtualFrame frame) {
CompilerDirectives.transferToInterpreter();

final DynamicObject hash = (DynamicObject) readUserKeywordsHashNode.execute(frame);
final Object hash = readUserKeywordsHashNode.execute(frame);

if (hash == null) {
if (noHash.profile(hash == null)) {
return Layouts.HASH.createHash(coreLibrary().getHashFactory(), null, 0, null, null, null, null, false);
}

CompilerDirectives.bailout("Ruby keyword arguments aren't optimized");

final DynamicObject hashObject = (DynamicObject) hash;

final List<Map.Entry<Object, Object>> entries = new ArrayList<>();

outer: for (Map.Entry<Object, Object> keyValue : HashOperations.iterableKeyValues(hash)) {
outer: for (Map.Entry<Object, Object> keyValue : HashOperations.iterableKeyValues(hashObject)) {
if (!RubyGuards.isRubySymbol(keyValue.getKey())) {
continue;
}
@@ -66,7 +72,7 @@ private Object lookupRestKeywordArgumentHash(VirtualFrame frame) {
entries.add(keyValue);
}

return BucketsStrategy.create(getContext(), entries, Layouts.HASH.getCompareByIdentity(hash));
return BucketsStrategy.create(getContext(), entries, Layouts.HASH.getCompareByIdentity(hashObject));
}

}
Original file line number Diff line number Diff line change
@@ -20,35 +20,32 @@
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;

/**
* Read the rest of arguments after a certain point into an array.
*/
public class ReadRestArgumentNode extends RubyNode {

private final int startIndex;
private final int negativeEndIndex;
private final int indexFromCount;
private final boolean keywordArguments;
private final int minimumForKWargs;

private final BranchProfile noArgumentsLeftProfile = BranchProfile.create();
private final BranchProfile subsetOfArgumentsProfile = BranchProfile.create();

@Child private ReadUserKeywordsHashNode readUserKeywordsHashNode;

public ReadRestArgumentNode(RubyContext context, SourceSection sourceSection, int startIndex, int negativeEndIndex, boolean keywordArguments, int minimumForKWargs) {
public ReadRestArgumentNode(RubyContext context, SourceSection sourceSection, int startIndex, int indexFromCount,
boolean keywordArguments, int minimumForKWargs) {
super(context, sourceSection);
this.startIndex = startIndex;
this.negativeEndIndex = negativeEndIndex;
this.indexFromCount = indexFromCount;
this.keywordArguments = keywordArguments;
this.minimumForKWargs = minimumForKWargs;
readUserKeywordsHashNode = new ReadUserKeywordsHashNode(context, sourceSection, minimumForKWargs);

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

@Override
public Object execute(VirtualFrame frame) {
int count = RubyArguments.getArgumentsCount(frame);

int endIndex = count + negativeEndIndex;
int endIndex = RubyArguments.getArgumentsCount(frame) - indexFromCount;

if (keywordArguments) {
final Object lastArgument = RubyArguments.getArgument(frame, RubyArguments.getArgumentsCount(frame) - 1);
@@ -80,18 +77,22 @@ public Object execute(VirtualFrame frame) {
}
}

final DynamicObject rest = Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(), resultStore, resultLength);
final DynamicObject rest = Layouts.ARRAY.createArray(coreLibrary().getArrayFactory(),
resultStore, resultLength);

if (keywordArguments) {
CompilerDirectives.transferToInterpreter();
CompilerDirectives.bailout("Ruby keyword arguments not optimized yet");

Object kwargsHash = readUserKeywordsHashNode.execute(frame);

if (kwargsHash == null) {
kwargsHash = nil();
}

getContext().getCodeLoader().inlineRubyHelper(this, "Truffle::Primitive.add_rejected_kwargs_to_rest(rest, kwargs)", "rest", rest, "kwargs", kwargsHash);
getContext().getCodeLoader().inlineRubyHelper(this,
"Truffle::Primitive.add_rejected_kwargs_to_rest(rest, kwargs)",
"rest", rest,
"kwargs", kwargsHash);
}

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

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;
@@ -20,6 +21,9 @@ public class ReadUserKeywordsHashNode extends RubyNode {

private final int minArgumentCount;

private final ConditionProfile notEnoughArgumentsProfile = ConditionProfile.createBinaryProfile();
private final ConditionProfile lastArgumentIsHashProfile = ConditionProfile.createBinaryProfile();

public ReadUserKeywordsHashNode(RubyContext context, SourceSection sourceSection, int minArgumentCount) {
super(context, sourceSection);
this.minArgumentCount = minArgumentCount;
@@ -29,17 +33,17 @@ public ReadUserKeywordsHashNode(RubyContext context, SourceSection sourceSection
public Object execute(VirtualFrame frame) {
final int argumentCount = RubyArguments.getArgumentsCount(frame);

if (argumentCount <= minArgumentCount) {
if (notEnoughArgumentsProfile.profile(argumentCount <= minArgumentCount)) {
return null;
}

final Object lastArgument = RubyArguments.getArgument(frame, argumentCount - 1);

if (RubyGuards.isRubyHash(lastArgument)) {
if (lastArgumentIsHashProfile.profile(RubyGuards.isRubyHash(lastArgument))) {
return lastArgument;
}

CompilerDirectives.transferToInterpreter();
CompilerDirectives.bailout("Ruby keyword arguments aren't optimized yet");

if ((boolean) ruby("last_arg.respond_to?(:to_hash)", "last_arg", lastArgument)) {
final Object converted = ruby("last_arg.to_hash", "last_arg", lastArgument);
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.language.arguments;

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;
@@ -17,38 +18,34 @@
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.dispatch.RespondToNode;

/**
* Switches between loading arguments as normal and doing a destructure.
*/
public class ShouldDestructureNode extends RubyNode {

@Child private RubyNode readArrayNode;
@Child private RespondToNode respondToCheck;

private final BranchProfile checkRespondProfile = BranchProfile.create();
private final BranchProfile checkIsArrayProfile = BranchProfile.create();

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

@Override
public boolean executeBoolean(VirtualFrame frame) {
// If the caller supplied no arguments, or more than one argument, there's no need to destructure this time

if (RubyArguments.getArgumentsCount(frame) != 1) {
return false;
}

// If the single argument is a RubyArray, destructure
// TODO(CS): can we not just rely on the respondToCheck? Should experiment.
checkIsArrayProfile.enter();

if (RubyGuards.isRubyArray(RubyArguments.getArgument(frame, 0))) {
return true;
}

// If the single argument responds to #to_ary, then destructure

checkRespondProfile.enter();
if (respondToCheck == null) {
CompilerDirectives.transferToInterpreter();
respondToCheck = insert(new RespondToNode(getContext(), getSourceSection(), readArrayNode, "to_ary"));
}

return respondToCheck.executeBoolean(frame);
}
Original file line number Diff line number Diff line change
@@ -18,10 +18,10 @@
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.objects.ReadObjectFieldNode;
import org.jruby.truffle.language.objects.ReadObjectFieldNodeGen;
import org.jruby.truffle.language.objects.ThreadLocalObjectNode;
import org.jruby.truffle.language.objects.ThreadLocalObjectNodeGen;
import org.jruby.truffle.language.objects.WriteObjectFieldNode;
import org.jruby.truffle.language.objects.WriteObjectFieldNodeGen;
import org.jruby.truffle.language.threadlocal.ThreadLocalObjectNode;
import org.jruby.truffle.language.threadlocal.ThreadLocalObjectNodeGen;

public class SetExceptionVariableNode extends Node {

Loading