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: 27e80e3d254f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 81fe82d43566
Choose a head ref
  • 18 commits
  • 30 files changed
  • 1 contributor

Commits on Mar 28, 2016

  1. Verified

    This commit was signed with the committer’s verified signature.
    makenowjust Hiroya Fujinami
    Copy the full SHA
    aba54a9 View commit details
  2. Copy the full SHA
    b4481f2 View commit details
  3. Copy the full SHA
    1a32eae View commit details
  4. Copy the full SHA
    a220bd8 View commit details
  5. [Truffle] Unused imports.

    chrisseaton committed Mar 28, 2016
    Copy the full SHA
    bad01c6 View commit details
  6. Copy the full SHA
    50031ea View commit details
  7. Copy the full SHA
    f87ae1c View commit details
  8. Copy the full SHA
    bfd9e10 View commit details
  9. Copy the full SHA
    67e632a View commit details
  10. Copy the full SHA
    7c11121 View commit details
  11. Copy the full SHA
    a0974c2 View commit details
  12. Copy the full SHA
    1e1d0dc View commit details
  13. Copy the full SHA
    4e69e48 View commit details
  14. Copy the full SHA
    eb2478a View commit details
  15. Copy the full SHA
    f9fbebf View commit details
  16. Copy the full SHA
    e1ec3ae View commit details
  17. Copy the full SHA
    1918abc View commit details
  18. Copy the full SHA
    81fe82d View commit details
Showing with 219 additions and 196 deletions.
  1. +28 −0 truffle/src/main/java/org/jruby/truffle/core/format/DescriptionTruncater.java
  2. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{pack → }/LoopRecovery.java
  3. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeByteNode.java
  4. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeFloat32Node.java
  5. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeFloat64Node.java
  6. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeInteger16BigNode.java
  7. +1 −1 ...fle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeInteger16LittleNode.java
  8. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeInteger32BigNode.java
  9. +1 −1 ...fle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeInteger32LittleNode.java
  10. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeInteger64BigNode.java
  11. +1 −1 ...fle/src/main/java/org/jruby/truffle/core/format/{decode → convert}/DecodeInteger64LittleNode.java
  12. +4 −8 ...rg/jruby/truffle/core/format/{type/ReinterpretLongNode.java → convert/ReinterpretAsLongNode.java}
  13. +12 −12 ...org/jruby/truffle/core/format/{type/AsUnsignedNode.java → convert/ReinterpretAsUnsignedNode.java}
  14. +19 −7 truffle/src/main/java/org/jruby/truffle/core/format/{type → convert}/ToDoubleNode.java
  15. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{type → convert}/ToDoubleWithCoercionNode.java
  16. +4 −7 ...n/java/org/jruby/truffle/core/format/{type/AsSinglePrecisionNode.java → convert/ToFloatNode.java}
  17. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{type → convert}/ToIntegerNode.java
  18. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{type → convert}/ToLongNode.java
  19. +1 −1 truffle/src/main/java/org/jruby/truffle/core/format/{type → convert}/ToStringNode.java
  20. +3 −16 truffle/src/main/java/org/jruby/truffle/core/format/pack/PackCompiler.java
  21. +82 −88 truffle/src/main/java/org/jruby/truffle/core/format/pack/PackTreeBuilder.java
  22. +6 −6 truffle/src/main/java/org/jruby/truffle/core/format/printf/PrintfCompiler.java
  23. +20 −14 truffle/src/main/java/org/jruby/truffle/core/format/printf/PrintfTreeBuilder.java
  24. +2 −2 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadDoubleNode.java
  25. +2 −2 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadIntegerNode.java
  26. +2 −2 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadLongOrBigIntegerNode.java
  27. +2 −2 truffle/src/main/java/org/jruby/truffle/core/format/read/array/ReadStringNode.java
  28. +6 −3 truffle/src/main/java/org/jruby/truffle/core/format/unpack/UnpackCompiler.java
  29. +12 −12 truffle/src/main/java/org/jruby/truffle/core/format/unpack/UnpackTreeBuilder.java
  30. +1 −1 truffle/src/main/java/org/jruby/truffle/core/kernel/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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;

public abstract class DescriptionTruncater {

/**
* Provide a simple string describing the format expression that is short
* enough to be used in Truffle and Graal diagnostics.
*/
public static String trunate(String format) {
format = format.replace("\\s+", "");

if (format.length() > 10) {
format = format.substring(0, 10) + "…";
}

return format;
}

}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.pack;
package org.jruby.truffle.core.format;

public abstract class LoopRecovery {

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.decode;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
Original file line number Diff line number Diff line change
@@ -7,30 +7,26 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;

/**
* Re-interpret a value as a {@code long}. In other words, get the raw bytes
* as a long.
*/
@NodeChildren({
@NodeChild(value = "value", type = FormatNode.class),
})
public abstract class ReinterpretLongNode extends FormatNode {
public abstract class ReinterpretAsLongNode extends FormatNode {

public ReinterpretLongNode(RubyContext context) {
public ReinterpretAsLongNode(RubyContext context) {
super(context);
}

@Specialization
public long asLong(float object) {
return (long) Float.floatToIntBits(object);
return Float.floatToIntBits(object);
}

@Specialization
Original file line number Diff line number Diff line change
@@ -7,13 +7,12 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;
@@ -25,48 +24,50 @@
@NodeChildren({
@NodeChild(value = "value", type = FormatNode.class),
})
public abstract class AsUnsignedNode extends FormatNode {
public abstract class ReinterpretAsUnsignedNode extends FormatNode {

@Child private FixnumOrBignumNode fixnumOrBignumNode;

public AsUnsignedNode(RubyContext context) {
public ReinterpretAsUnsignedNode(RubyContext context) {
super(context);
}

@Specialization
public MissingValue asUnsigned(VirtualFrame frame, MissingValue missingValue) {
public MissingValue asUnsigned(MissingValue missingValue) {
return missingValue;
}

@Specialization(guards = "isNil(nil)")
public DynamicObject asUnsigned(VirtualFrame frame, DynamicObject nil) {
public DynamicObject asUnsigned(DynamicObject nil) {
return nil;
}

@Specialization
public int asUnsigned(VirtualFrame frame, short value) {
public int asUnsigned(short value) {
return value & 0xffff;
}

@Specialization
public long asUnsigned(VirtualFrame frame, int value) {
public long asUnsigned(int value) {
return value & 0xffffffffL;
}

@Specialization
public Object asUnsigned(VirtualFrame frame, long value) {
public Object asUnsigned(long value) {
if (fixnumOrBignumNode == null) {
CompilerDirectives.transferToInterpreter();
fixnumOrBignumNode = insert(FixnumOrBignumNode.create(getContext(), getSourceSection()));
}

return fixnumOrBignumNode.fixnumOrBignum(asUnsigned(value));
return fixnumOrBignumNode.fixnumOrBignum(asUnsignedBigInteger(value));
}

private static final long UNSIGNED_LONG_MASK = 0x7fffffffffffffffL;

@CompilerDirectives.TruffleBoundary
private BigInteger asUnsigned(long value) {
private BigInteger asUnsignedBigInteger(long value) {
// TODO CS 28-Mar-16 can't we work out if it would fit into a long, and not create a BigInteger?

BigInteger bigIntegerValue = BigInteger.valueOf(value & UNSIGNED_LONG_MASK);

if (value < 0) {
@@ -76,5 +77,4 @@ private BigInteger asUnsigned(long value) {
return bigIntegerValue;
}


}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
@@ -16,9 +16,6 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;

/**
* Convert a value to a {@code double}.
*/
@NodeChildren({
@NodeChild(value = "value", type = FormatNode.class),
})
@@ -31,17 +28,32 @@ public ToDoubleNode(RubyContext context) {
public abstract double executeToDouble(VirtualFrame frame, Object object);

@Specialization
public double toDouble(VirtualFrame frame, int value) {
public double toDouble(byte value) {
return value;
}

@Specialization
public double toDouble(int value) {
return value;
}

@Specialization
public double toDouble(short value) {
return value;
}

@Specialization
public double toDouble(long value) {
return value;
}

@Specialization
public double toDouble(VirtualFrame frame, long value) {
public double toDouble(float value) {
return value;
}

@Specialization
public double toDouble(VirtualFrame frame, double value) {
public double toDouble(double value) {
return value;
}

Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
* GNU Lesser General Public License version 2.1
*/

package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
Original file line number Diff line number Diff line change
@@ -7,28 +7,25 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.FormatNode;

/**
* Convert a {@code double} value to a {@code float}.
*/
@NodeChildren({
@NodeChild(value = "value", type = FormatNode.class),
})
public abstract class AsSinglePrecisionNode extends FormatNode {
public abstract class ToFloatNode extends FormatNode {

public AsSinglePrecisionNode(RubyContext context) {
public ToFloatNode(RubyContext context) {
super(context);
}

@Specialization
public float asFloat(double object) {
public float toFloat(double object) {
return (float) object;
}

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.core.format.type;
package org.jruby.truffle.core.format.convert;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
Original file line number Diff line number Diff line change
@@ -5,8 +5,10 @@
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.format.DescriptionTruncater;
import org.jruby.truffle.core.format.FormatRootNode;
import org.jruby.truffle.core.format.FormatErrorListener;
import org.jruby.truffle.core.format.LoopRecovery;
import org.jruby.truffle.language.RubyNode;

import org.jruby.truffle.core.format.pack.PackLexer;
@@ -48,22 +50,7 @@ public CallTarget compile(String format) {
parser.sequence();

return Truffle.getRuntime().createCallTarget(
new FormatRootNode(describe(format), builder.getEncoding(), builder.getNode()));
new FormatRootNode(DescriptionTruncater.trunate(format), builder.getEncoding(), builder.getNode()));
}

/**
* Provide a simple string describing the format expression that is short
* enough to be used in Truffle and Graal diagnostics.
*/
public static String describe(String format) {
format = format.replace("\\s+", "");

if (format.length() > 10) {
format = format.substring(0, 10) + "…";
}

return format;
}


}
Loading