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

Commits on Mar 29, 2016

  1. Copy the full SHA
    65f917f View commit details
  2. Copy the full SHA
    b448451 View commit details
  3. Copy the full SHA
    f379892 View commit details
  4. Copy the full SHA
    00cc27f View commit details
  5. Copy the full SHA
    9cdc930 View commit details
  6. Copy the full SHA
    2ad1010 View commit details
  7. Copy the full SHA
    77318cc View commit details
  8. Copy the full SHA
    a730ef2 View commit details
  9. Copy the full SHA
    fe35e26 View commit details
  10. Copy the full SHA
    fe57857 View commit details
  11. Copy the full SHA
    a2edf42 View commit details
  12. Copy the full SHA
    961a3f7 View commit details
  13. [Truffle] Formatting.

    chrisseaton committed Mar 29, 2016
    Copy the full SHA
    ca3b1de View commit details
  14. Copy the full SHA
    ad9f07b View commit details
  15. Copy the full SHA
    37404dc View commit details
  16. Copy the full SHA
    ebf39fa View commit details
  17. Copy the full SHA
    446460c View commit details
  18. Copy the full SHA
    333802f View commit details
  19. Copy the full SHA
    6007d9a View commit details
  20. Copy the full SHA
    550f8fe View commit details
  21. Copy the full SHA
    ba6d219 View commit details
  22. Copy the full SHA
    2a3c166 View commit details
  23. Copy the full SHA
    adaedc2 View commit details
  24. Copy the full SHA
    cffa4ba View commit details
  25. Copy the full SHA
    bc5f9f1 View commit details
  26. Copy the full SHA
    1e2bfb7 View commit details
  27. Copy the full SHA
    1fb104c View commit details
  28. Copy the full SHA
    ab96518 View commit details
  29. Copy the full SHA
    b743734 View commit details
  30. Copy the full SHA
    edbb256 View commit details
  31. Copy the full SHA
    5b150ba View commit details
  32. [Truffle] Tidy up WriteValueNode and use an OutputNode as SourceNode...

    so we're ready for specialised arrays in the future.
    chrisseaton committed Mar 29, 2016
    Copy the full SHA
    a94328a View commit details
Showing with 465 additions and 447 deletions.
  1. +4 −4 truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
  2. +12 −3 truffle/src/main/java/org/jruby/truffle/core/format/SharedTreeBuilder.java
  3. +7 −4 ...a/org/jruby/truffle/core/format/control/{ForwardUnpackNode.java → AdvanceSourcePositionNode.java}
  4. +0 −68 truffle/src/main/java/org/jruby/truffle/core/format/control/NNode.java
  5. +39 −0 truffle/src/main/java/org/jruby/truffle/core/format/control/RepeatExplodedNode.java
  6. +42 −0 truffle/src/main/java/org/jruby/truffle/core/format/control/RepeatLoopNode.java
  7. +6 −12 .../main/java/org/jruby/truffle/core/format/control/{BackNode.java → ReverseOutputPositionNode.java}
  8. +7 −7 ...java/org/jruby/truffle/core/format/control/{BackUnpackNode.java → ReverseSourcePositionNode.java}
  9. +1 −6 truffle/src/main/java/org/jruby/truffle/core/format/control/SequenceNode.java
  10. +2 −9 ...le/src/main/java/org/jruby/truffle/core/format/control/{AtNode.java → SetOutputPositionNode.java}
  11. +6 −4 .../main/java/org/jruby/truffle/core/format/control/{AtUnpackNode.java → SetSourcePositionNode.java}
  12. +25 −18 truffle/src/main/java/org/jruby/truffle/core/format/control/StarNode.java
  13. +9 −8 ...rg/jruby/truffle/core/format/convert/{DecodeInteger32BigNode.java → BytesToInteger16BigNode.java}
  14. +9 −8 ...jruby/truffle/core/format/convert/{DecodeInteger64BigNode.java → BytesToInteger16LittleNode.java}
  15. +11 −8 ...jruby/truffle/core/format/convert/{DecodeInteger16LittleNode.java → BytesToInteger32BigNode.java}
  16. +11 −8 ...jruby/truffle/core/format/convert/{DecodeInteger16BigNode.java → BytesToInteger32LittleNode.java}
  17. +15 −8 ...jruby/truffle/core/format/convert/{DecodeInteger32LittleNode.java → BytesToInteger64BigNode.java}
  18. +57 −0 truffle/src/main/java/org/jruby/truffle/core/format/convert/BytesToInteger64LittleNode.java
  19. +0 −50 truffle/src/main/java/org/jruby/truffle/core/format/convert/DecodeInteger64LittleNode.java
  20. +4 −4 ...a/org/jruby/truffle/core/format/convert/{DecodeByteNode.java → ReinterpretByteAsIntegerNode.java}
  21. +5 −5 ...g/jruby/truffle/core/format/convert/{DecodeFloat32Node.java → ReinterpretIntegerAsFloatNode.java}
  22. +5 −5 ...org/jruby/truffle/core/format/convert/{DecodeFloat64Node.java → ReinterpretLongAsDoubleNode.java}
  23. +0 −15 truffle/src/main/java/org/jruby/truffle/core/format/convert/ToDoubleNode.java
  24. +0 −4 truffle/src/main/java/org/jruby/truffle/core/format/convert/ToDoubleWithCoercionNode.java
  25. +8 −5 truffle/src/main/java/org/jruby/truffle/core/format/convert/ToIntegerNode.java
  26. +25 −53 truffle/src/main/java/org/jruby/truffle/core/format/convert/ToLongNode.java
  27. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/CantCompressNegativeException.java
  28. +2 −1 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/CantConvertException.java
  29. +16 −2 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/FormatException.java
  30. +3 −5 .../java/org/jruby/truffle/core/format/exceptions/{PackException.java → InvalidFormatException.java}
  31. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/NoImplicitConversionException.java
  32. +2 −1 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/OutsideOfStringException.java
  33. +2 −1 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/RangeException.java
  34. +2 −1 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/TooFewArgumentsException.java
  35. +0 −30 truffle/src/main/java/org/jruby/truffle/core/format/exceptions/WrongArgumentTypeException.java
  36. +9 −0 truffle/src/main/java/org/jruby/truffle/core/format/pack/PackCompiler.java
  37. +9 −6 truffle/src/main/java/org/jruby/truffle/core/format/pack/PackTreeBuilder.java
  38. +0 −4 truffle/src/main/java/org/jruby/truffle/core/format/read/SourceNode.java
  39. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadLongOrBigIntegerNode.java
  40. +10 −10 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadBase64StringNode.java
  41. +2 −2 truffle/src/main/java/org/jruby/truffle/core/format/read/bytes/ReadUTF8CharacterNode.java
  42. +42 −41 truffle/src/main/java/org/jruby/truffle/core/format/unpack/UnpackTreeBuilder.java
  43. +27 −0 truffle/src/main/java/org/jruby/truffle/core/format/write/OutputNode.java
  44. +14 −11 truffle/src/main/java/org/jruby/truffle/core/format/write/array/WriteValueNode.java
  45. +6 −6 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
  46. +6 −7 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@
import org.jruby.truffle.core.format.exceptions.CantConvertException;
import org.jruby.truffle.core.format.exceptions.NoImplicitConversionException;
import org.jruby.truffle.core.format.exceptions.OutsideOfStringException;
import org.jruby.truffle.core.format.exceptions.PackException;
import org.jruby.truffle.core.format.exceptions.FormatException;
import org.jruby.truffle.core.format.exceptions.RangeException;
import org.jruby.truffle.core.format.exceptions.TooFewArgumentsException;
import org.jruby.truffle.core.kernel.KernelNodes;
@@ -2406,7 +2406,7 @@ public DynamicObject packCached(

try {
result = (BytesResult) callPackNode.call(frame, new Object[] { getStore(array), getSize(array) });
} catch (PackException e) {
} catch (FormatException e) {
CompilerDirectives.transferToInterpreter();
throw handleException(e);
}
@@ -2424,15 +2424,15 @@ public DynamicObject packUncached(

try {
result = (BytesResult) callPackNode.call(frame, compileFormat(format), new Object[] { getStore(array), getSize(array) });
} catch (PackException e) {
} catch (FormatException e) {
CompilerDirectives.transferToInterpreter();
throw handleException(e);
}

return finishPack(Layouts.STRING.getRope(format).byteLength(), result);
}

private RuntimeException handleException(PackException exception) {
private RuntimeException handleException(FormatException exception) {
try {
throw exception;
} catch (TooFewArgumentsException e) {
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@
package org.jruby.truffle.core.format;

import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.control.NNode;
import org.jruby.truffle.core.format.control.RepeatExplodedNode;
import org.jruby.truffle.core.format.control.RepeatLoopNode;
import org.jruby.truffle.core.format.control.SequenceNode;
import org.jruby.truffle.core.format.control.StarNode;
import org.jruby.truffle.core.format.pack.PackParser;
@@ -33,20 +34,28 @@ public FormatNode finishSubSequence(Deque<List<FormatNode>> sequenceStack, PackP
if (ctx.INT() == null) {
return sequenceNode;
} else {
return new NNode(context, Integer.parseInt(ctx.INT().getText()), sequenceNode);
return createRepeatNode(Integer.parseInt(ctx.INT().getText()), sequenceNode);
}
}

public FormatNode applyCount(PackParser.CountContext count, FormatNode node) {
if (count == null) {
return node;
} else if (count.INT() != null) {
return new NNode(context, Integer.parseInt(count.INT().getText()), node);
return createRepeatNode(Integer.parseInt(count.INT().getText()), node);
} else {
return new StarNode(context, node);
}
}

private FormatNode createRepeatNode(int count, FormatNode node) {
if (count > context.getOptions().PACK_UNROLL_LIMIT) {
return new RepeatLoopNode(context, count, node);
} else {
return new RepeatExplodedNode(context, count, node);
}
}

public StarLength parseCountContext(PackParser.CountContext ctx) {
final boolean star;
final int length;
Original file line number Diff line number Diff line change
@@ -10,15 +10,18 @@
package org.jruby.truffle.core.format.control;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.exceptions.OutsideOfStringException;

public class ForwardUnpackNode extends FormatNode {
public class AdvanceSourcePositionNode extends FormatNode {

private boolean toEnd;
private final boolean toEnd;

public ForwardUnpackNode(RubyContext context, boolean toEnd) {
private final ConditionProfile rangeProfile = ConditionProfile.createBinaryProfile();

public AdvanceSourcePositionNode(RubyContext context, boolean toEnd) {
super(context);
this.toEnd = toEnd;
}
@@ -30,7 +33,7 @@ public Object execute(VirtualFrame frame) {
} else {
final int position = getSourcePosition(frame);

if (position + 1 > getSourceLength(frame)) {
if (rangeProfile.profile(position + 1 > getSourceLength(frame))) {
throw new OutsideOfStringException();
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2015, 2016 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:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.control;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;

public class RepeatExplodedNode extends FormatNode {

private final int count;

@Child private FormatNode child;

public RepeatExplodedNode(RubyContext context, int count, FormatNode child) {
super(context);
this.count = count;
this.child = child;
}

@Override
@ExplodeLoop
public Object execute(VirtualFrame frame) {
for (int i = 0; i < count; i++) {
child.execute(frame);
}

return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2015, 2016 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:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.control;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;

public class RepeatLoopNode extends FormatNode {

private final int count;

@Child private FormatNode child;

public RepeatLoopNode(RubyContext context, int count, FormatNode child) {
super(context);
this.count = count;
this.child = child;
}

@Override
public Object execute(VirtualFrame frame) {
for (int i = 0; i < count; i++) {
child.execute(frame);
}

if (CompilerDirectives.inInterpreter()) {
getRootNode().reportLoopCount(count);
}

return null;
}

}
Original file line number Diff line number Diff line change
@@ -11,34 +11,28 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.exceptions.OutsideOfStringException;

/**
* Moves the output position to the previous byte - similar to seek
* absolute -1 in a file stream.
* <pre>
* [0xabcd, 0x1234].pack('NN') # => "\x00\x00\xAB\xCD\x00\x00\x124"
* [0xabcd, 0x1234].pack('NXN') # => "\x00\x00\xAB\x00\x00\x124"
*/
public class BackNode extends FormatNode {
public class ReverseOutputPositionNode extends FormatNode {

private final ConditionProfile rangeProfile = ConditionProfile.createBinaryProfile();

public BackNode(RubyContext context) {
public ReverseOutputPositionNode(RubyContext context) {
super(context);
}

@Override
public Object execute(VirtualFrame frame) {
final int position = getOutputPosition(frame);

if (position == 0) {
CompilerDirectives.transferToInterpreter();
if (rangeProfile.profile(position == 0)) {
throw new OutsideOfStringException();
}

setOutputPosition(frame, position - 1);

return null;
}

Original file line number Diff line number Diff line change
@@ -11,15 +11,18 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
import org.jruby.truffle.core.format.exceptions.OutsideOfStringException;

public class BackUnpackNode extends FormatNode {
public class ReverseSourcePositionNode extends FormatNode {

private boolean star;

public BackUnpackNode(RubyContext context, boolean star) {
private final ConditionProfile rangeProfile = ConditionProfile.createBinaryProfile();

public ReverseSourcePositionNode(RubyContext context, boolean star) {
super(context);
this.star = star;
}
@@ -33,22 +36,19 @@ public Object execute(VirtualFrame frame) {

final int target = position - remaining;

if (target < 0) {
CompilerDirectives.transferToInterpreter();
if (rangeProfile.profile(target < 0)) {
throw new OutsideOfStringException();
}

setSourcePosition(frame, target);
} else {
if (position == 0) {
CompilerDirectives.transferToInterpreter();
if (rangeProfile.profile(position == 0)) {
throw new OutsideOfStringException();
}

setSourcePosition(frame, position - 1);
}


return null;
}

Original file line number Diff line number Diff line change
@@ -15,16 +15,11 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;

/**
* Run a sequence of child nodes.
* <pre>
* [1, 2, 3].pack('CCC') # => "\x01\x02\x03"
*/
public class SequenceNode extends FormatNode {

@Children private final FormatNode[] children;

public SequenceNode(RubyContext context, FormatNode... children) {
public SequenceNode(RubyContext context, FormatNode[] children) {
super(context);
this.children = children;
}
Original file line number Diff line number Diff line change
@@ -13,18 +13,11 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;

/**
* Moves the output position to a particular location - similar to seek
* absolute in a file stream.
* <pre>
* [0xabcd].pack('N') # => "\x00\x00\xAB\xCD"
* [0xabcd].pack('@2N') # => "\x00\x00\x00\x00\xAB\xCD"
*/
public class AtNode extends FormatNode {
public class SetOutputPositionNode extends FormatNode {

private final int position;

public AtNode(RubyContext context, int position) {
public SetOutputPositionNode(RubyContext context, int position) {
super(context);
this.position = position;
}
Loading