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: da4d8bc53fec
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f3c8d37b5cd2
Choose a head ref

Commits on Mar 30, 2016

  1. Copy the full SHA
    cef3be1 View commit details
  2. Copy the full SHA
    50b2f99 View commit details
  3. Copy the full SHA
    ca1cae3 View commit details
  4. Copy the full SHA
    435082b View commit details
  5. Copy the full SHA
    3aa410d View commit details
  6. Copy the full SHA
    652d60c View commit details
  7. Copy the full SHA
    be73c47 View commit details
  8. Copy the full SHA
    cb775bd View commit details
  9. Copy the full SHA
    3330024 View commit details
  10. Copy the full SHA
    720afd4 View commit details
  11. Copy the full SHA
    896acbe View commit details
  12. Copy the full SHA
    c9d9eb2 View commit details
  13. Copy the full SHA
    b74ad80 View commit details
  14. Copy the full SHA
    e3d4066 View commit details
  15. Copy the full SHA
    a26019a View commit details
  16. Copy the full SHA
    2b72c3d View commit details
  17. Copy the full SHA
    9d5ae08 View commit details
  18. Copy the full SHA
    ece4dec View commit details
  19. Copy the full SHA
    ae1ca29 View commit details
  20. Copy the full SHA
    9cd8029 View commit details
  21. Copy the full SHA
    e3fa3aa View commit details
  22. Copy the full SHA
    1b41659 View commit details
  23. Copy the full SHA
    ee839f8 View commit details
  24. Copy the full SHA
    59cda2b View commit details
  25. Copy the full SHA
    3a4b910 View commit details
  26. Copy the full SHA
    bd81e23 View commit details
  27. Copy the full SHA
    54754a8 View commit details
  28. Copy the full SHA
    41eaede View commit details
  29. Copy the full SHA
    7ce7a29 View commit details
  30. Copy the full SHA
    14df746 View commit details
  31. Copy the full SHA
    f26f9ed View commit details
  32. Copy the full SHA
    4412f5f View commit details
  33. Copy the full SHA
    8ee18ff View commit details
  34. Copy the full SHA
    2444e90 View commit details
  35. Copy the full SHA
    f3c8d37 View commit details
Showing with 712 additions and 519 deletions.
  1. +5 −0 truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
  2. +5 −17 truffle/src/main/java/org/jruby/truffle/core/format/FormatEncoding.java
  3. +2 −1 truffle/src/main/java/org/jruby/truffle/core/format/FormatErrorListener.java
  4. +0 −31 truffle/src/main/java/org/jruby/truffle/core/format/LiteralBytesNode.java
  5. +4 −3 ...le/src/main/java/org/jruby/truffle/core/format/{LiteralIntegerNode.java → LiteralFormatNode.java}
  6. +8 −24 truffle/src/main/java/org/jruby/truffle/core/format/convert/ToStringNode.java
  7. +13 −3 truffle/src/main/java/org/jruby/truffle/core/format/pack/PackTreeBuilder.java
  8. +5 −6 truffle/src/main/java/org/jruby/truffle/core/format/printf/PrintfTreeBuilder.java
  9. +0 −43 truffle/src/main/java/org/jruby/truffle/core/format/read/array/PNode.java
  10. +0 −7 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadDoubleNode.java
  11. +19 −6 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadHashValueNode.java
  12. +5 −8 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadIntegerNode.java
  13. +0 −9 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadLongOrBigIntegerNode.java
  14. +6 −9 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadStringNode.java
  15. +0 −4 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadValueNode.java
  16. +88 −74 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBERNode.java
  17. +55 −10 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBase64StringNode.java
  18. +66 −27 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBitStringNode.java
  19. +4 −6 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadByteNode.java
  20. +4 −5 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBytesNode.java
  21. +62 −26 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadHexStringNode.java
  22. +70 −14 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadMIMEStringNode.java
  23. +9 −10 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUTF8CharacterNode.java
  24. +83 −82 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUUStringNode.java
  25. +47 −21 truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBERNode.java
  26. +0 −4 truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBase64StringNode.java
  27. +0 −6 truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBinaryStringNode.java
  28. +36 −8 truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteBitStringNode.java
  29. +36 −7 truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteHexStringNode.java
  30. +1 −4 truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteMIMEStringNode.java
  31. +79 −44 truffle/src/main/java/org/jruby/truffle/core/format/write/bytes/WriteUTF8CharacterNode.java
5 changes: 5 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -947,6 +947,11 @@ public DynamicObject frozenError(String className, Node currentNode) {
return runtimeError(String.format("can't modify frozen %s", className), currentNode);
}

@TruffleBoundary
public DynamicObject argumentErrorOneHashRequired(Node currentNode) {
return argumentError("one hash required", currentNode, null);
}

public DynamicObject argumentError(String message, Node currentNode) {
return argumentError(message, currentNode, null);
}
Original file line number Diff line number Diff line change
@@ -9,13 +9,8 @@
*/
package org.jruby.truffle.core.format;

/**
* The encoding to be used for the string resulting from pack.
* <p>
* We use this enum as the range of encodings possible are very limited and
* we want to abstracted between JRuby's pack and Truffle's pack.
*/
public enum FormatEncoding {

DEFAULT,
ASCII_8BIT,
US_ASCII,
@@ -35,20 +30,12 @@ public FormatEncoding unifyWith(FormatEncoding other) {
return this;
}

switch (this) {
switch (other) {
case ASCII_8BIT:
case US_ASCII:
switch (other) {
case ASCII_8BIT:
case US_ASCII:
return ASCII_8BIT;
case UTF_8:
return ASCII_8BIT;
default:
throw new UnsupportedOperationException();
}
return ASCII_8BIT;
case UTF_8:
switch (other) {
switch (this) {
case ASCII_8BIT:
case US_ASCII:
return ASCII_8BIT;
@@ -61,4 +48,5 @@ public FormatEncoding unifyWith(FormatEncoding other) {
throw new UnsupportedOperationException();
}
}

}
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@ public FormatErrorListener(RubyContext context, RubyNode currentNode) {
}

@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) {
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
String msg, RecognitionException e) {
throw new RaiseException(context.getCoreLibrary().argumentError(msg, currentNode));
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -12,12 +12,13 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.util.ByteList;

public class LiteralIntegerNode extends FormatNode {
public class LiteralFormatNode extends FormatNode {

private final int value;
private final Object value;

public LiteralIntegerNode(RubyContext context, int value) {
public LiteralFormatNode(RubyContext context, Object value) {
super(context);
this.value = value;
}
Original file line number Diff line number Diff line change
@@ -27,17 +27,13 @@
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.language.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.language.dispatch.DispatchNode;
import org.jruby.truffle.language.dispatch.MissingBehavior;
import org.jruby.truffle.language.objects.IsTaintedNode;
import org.jruby.truffle.language.objects.IsTaintedNodeGen;
import org.jruby.util.ByteList;

import java.nio.charset.StandardCharsets;

/**
* Convert a value to a string.
*/
@NodeChildren({
@NodeChild(value = "value", type = FormatNode.class),
})
@@ -63,18 +59,16 @@ public ToStringNode(RubyContext context, boolean convertNumbersToStrings,
this.conversionMethod = conversionMethod;
this.inspectOnConversionFailure = inspectOnConversionFailure;
this.valueOnNil = valueOnNil;
isTaintedNode = IsTaintedNodeGen.create(context, getEncapsulatingSourceSection(), null);
isTaintedNode = IsTaintedNodeGen.create(context, null, null);
}

public abstract Object executeToString(VirtualFrame frame, Object object);

@Specialization(guards = "isNil(nil)")
public Object toStringNil(VirtualFrame frame, Object nil) {
public Object toStringNil(Object nil) {
return valueOnNil;
}

// TODO CS 31-Mar-15 these boundaries and slow versions are not ideal

@TruffleBoundary
@Specialization(guards = "convertNumbersToStrings")
public ByteList toString(int value) {
@@ -106,7 +100,8 @@ public ByteList toStringString(VirtualFrame frame, DynamicObject string) {
public ByteList toString(VirtualFrame frame, DynamicObject array) {
if (toSNode == null) {
CompilerDirectives.transferToInterpreter();
toSNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true, MissingBehavior.RETURN_MISSING));
toSNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true,
MissingBehavior.RETURN_MISSING));
}

final Object value = toSNode.call(frame, array, "to_s", null);
@@ -117,22 +112,17 @@ public ByteList toString(VirtualFrame frame, DynamicObject array) {
}

return StringOperations.getByteListReadOnly((DynamicObject) value);
}

CompilerDirectives.transferToInterpreter();

if (value == DispatchNode.MISSING) {
} else {
throw new NoImplicitConversionException(array, "String");
}

throw new NoImplicitConversionException(array, "String");
}

@Specialization(guards = {"!isRubyString(object)", "!isRubyArray(object)"})
public ByteList toString(VirtualFrame frame, Object object) {
if (toStrNode == null) {
CompilerDirectives.transferToInterpreter();
toStrNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true, MissingBehavior.RETURN_MISSING));
toStrNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true,
MissingBehavior.RETURN_MISSING));
}

final Object value = toStrNode.call(frame, object, conversionMethod, null);
@@ -153,15 +143,9 @@ public ByteList toString(VirtualFrame frame, Object object) {
}

return StringOperations.getByteListReadOnly(inspectNode.toS(frame, object));
}

CompilerDirectives.transferToInterpreter();

if (value == DispatchNode.MISSING) {
} else {
throw new NoImplicitConversionException(object, "String");
}

throw new NoImplicitConversionException(object, "String");
}

}
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@
import com.oracle.truffle.api.nodes.Node;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.LiteralFormatNode;
import org.jruby.truffle.core.format.SharedTreeBuilder;
import org.jruby.truffle.core.format.control.AdvanceSourcePositionNode;
import org.jruby.truffle.core.format.convert.ReinterpretAsLongNodeGen;
import org.jruby.truffle.core.format.convert.ToFloatNodeGen;
import org.jruby.truffle.core.format.read.SourceNode;
@@ -24,7 +26,6 @@
import org.jruby.truffle.core.format.read.array.ReadStringNodeGen;
import org.jruby.truffle.core.format.read.array.ReadValueNodeGen;
import org.jruby.truffle.core.format.convert.ToLongNodeGen;
import org.jruby.truffle.core.format.read.array.PNode;
import org.jruby.truffle.core.format.write.bytes.Write16BigNodeGen;
import org.jruby.truffle.core.format.write.bytes.Write16LittleNodeGen;
import org.jruby.truffle.core.format.write.bytes.Write32BigNodeGen;
@@ -313,8 +314,17 @@ public void exitBase64String(PackParser.Base64StringContext ctx) {

@Override
public void exitPointer(PackParser.PointerContext ctx) {
appendNode(writeInteger(64, ByteOrder.nativeOrder(),
new PNode(context)));
/*
* P and p print the address of a string. Obviously that doesn't work
* well in Java. We'll print 0x0000000000000000 with the hope that at
* least it should page fault if anyone tries to read it.
*/

appendNode(new SequenceNode(context, new FormatNode[]{
new AdvanceSourcePositionNode(context, false),
writeInteger(64, ByteOrder.nativeOrder(),
new LiteralFormatNode(context, (long) 0))
}));

}

Original file line number Diff line number Diff line change
@@ -17,8 +17,7 @@
import org.jruby.truffle.core.format.control.SequenceNode;
import org.jruby.truffle.core.format.format.FormatFloatNodeGen;
import org.jruby.truffle.core.format.format.FormatIntegerNodeGen;
import org.jruby.truffle.core.format.LiteralBytesNode;
import org.jruby.truffle.core.format.LiteralIntegerNode;
import org.jruby.truffle.core.format.LiteralFormatNode;
import org.jruby.truffle.core.format.read.array.ReadHashValueNodeGen;
import org.jruby.truffle.core.format.read.array.ReadIntegerNodeGen;
import org.jruby.truffle.core.format.read.array.ReadStringNodeGen;
@@ -167,7 +166,7 @@ public void exitFormat(PrintfParser.FormatContext ctx) {
if (spacePadding == PADDING_FROM_ARGUMENT) {
spacePaddingNode = ReadIntegerNodeGen.create(context, new SourceNode());
} else {
spacePaddingNode = new LiteralIntegerNode(context, spacePadding);
spacePaddingNode = new LiteralFormatNode(context, spacePadding);
}

final FormatNode zeroPaddingNode;
@@ -181,9 +180,9 @@ public void exitFormat(PrintfParser.FormatContext ctx) {
if (zeroPadding == PADDING_FROM_ARGUMENT) {
zeroPaddingNode = ReadIntegerNodeGen.create(context, new SourceNode());
} else if (ctx.precision != null) {
zeroPaddingNode = new LiteralIntegerNode(context, Integer.parseInt(ctx.precision.getText()));
zeroPaddingNode = new LiteralFormatNode(context, Integer.parseInt(ctx.precision.getText()));
} else {
zeroPaddingNode = new LiteralIntegerNode(context, zeroPadding);
zeroPaddingNode = new LiteralFormatNode(context, zeroPadding);
}

final char format;
@@ -239,7 +238,7 @@ public void exitLiteral(PrintfParser.LiteralContext ctx) {
if (text.length() == 1) {
node = new WriteByteNode(context, (byte) text.get(0));
} else {
node = WriteBytesNodeGen.create(context, new LiteralBytesNode(context, text));
node = WriteBytesNodeGen.create(context, new LiteralFormatNode(context, text));
}

sequence.add(node);

This file was deleted.

Original file line number Diff line number Diff line change
@@ -20,9 +20,6 @@
import org.jruby.truffle.core.format.convert.ToDoubleNode;
import org.jruby.truffle.core.format.convert.ToDoubleNodeGen;

/**
* Read a {@code double} value from the source.
*/
@NodeChildren({
@NodeChild(value = "source", type = SourceNode.class),
})
@@ -36,11 +33,7 @@ public ReadDoubleNode(RubyContext context) {

@Specialization(guards = "isNull(source)")
public double read(VirtualFrame frame, Object source) {
CompilerDirectives.transferToInterpreter();

// Advance will handle the error
advanceSourcePosition(frame);

throw new IllegalStateException();
}

Loading