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: 9a0facf34599
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: eee1188156fc
Choose a head ref
  • 8 commits
  • 55 files changed
  • 1 contributor

Commits on Apr 10, 2015

  1. Copy the full SHA
    a935919 View commit details
  2. Copy the full SHA
    04d88a6 View commit details
  3. Copy the full SHA
    83311cc View commit details
  4. Copy the full SHA
    3c4ff87 View commit details
  5. Copy the full SHA
    2a0660e View commit details
  6. Copy the full SHA
    9fdebaf View commit details
  7. Copy the full SHA
    d26067a View commit details
  8. Copy the full SHA
    eee1188 View commit details
Showing with 735 additions and 248 deletions.
  1. +4 −5 core/src/main/java/org/jruby/RubyArray.java
  2. +20 −0 core/src/main/java/org/jruby/TrufflePackBridge.java
  3. +20 −0 core/src/main/java/org/jruby/truffle/pack/runtime/PackEncoding.java
  4. +9 −0 core/src/main/java/org/jruby/truffle/pack/runtime/PackResult.java
  5. +1 −1 core/src/main/java/org/jruby/truffle/pack/runtime/{ → exceptions}/CantCompressNegativeException.java
  6. +1 −1 core/src/main/java/org/jruby/truffle/pack/runtime/{ → exceptions}/CantConvertException.java
  7. +1 −1 core/src/main/java/org/jruby/truffle/pack/runtime/{ → exceptions}/FormatException.java
  8. +1 −1 core/src/main/java/org/jruby/truffle/pack/runtime/{ → exceptions}/NoImplicitConversionException.java
  9. +1 −1 core/src/main/java/org/jruby/truffle/pack/runtime/{ → exceptions}/OutsideOfStringException.java
  10. +1 −1 core/src/main/java/org/jruby/truffle/pack/runtime/{ → exceptions}/RangeException.java
  11. +1 −1 core/src/main/java/org/jruby/truffle/pack/runtime/{ → exceptions}/TooFewArgumentsException.java
  12. +0 −8 spec/truffle/tags/core/array/pack/b_tags.txt
  13. +0 −6 spec/truffle/tags/core/array/pack/m_tags.txt
  14. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  15. +15 −0 truffle/src/main/java/org/jruby/truffle/pack/TrufflePackBridgeImpl.java
  16. +61 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/PackGuards.java
  17. +73 −41 truffle/src/main/java/org/jruby/truffle/pack/nodes/PackNode.java
  18. +3 −2 truffle/src/main/java/org/jruby/truffle/pack/nodes/PackRootNode.java
  19. +3 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/PackTypes.java
  20. +4 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/SourceNode.java
  21. +7 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/control/AtNode.java
  22. +8 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/control/BackNode.java
  23. +12 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/control/NNode.java
  24. +5 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/control/SequenceNode.java
  25. +5 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/control/StarNode.java
  26. +24 −5 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → read}/ReadDoubleNode.java
  27. +26 −7 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → read}/ReadLongNode.java
  28. +20 −6 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → read}/ReadLongOrBigIntegerNode.java
  29. +24 −9 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → read}/ReadStringNode.java
  30. +12 −16 truffle/src/main/java/org/jruby/truffle/pack/nodes/type/AsLongNode.java
  31. +12 −6 truffle/src/main/java/org/jruby/truffle/pack/nodes/type/AsSinglePrecisionNode.java
  32. +0 −22 truffle/src/main/java/org/jruby/truffle/pack/nodes/type/PNode.java
  33. +14 −11 truffle/src/main/java/org/jruby/truffle/pack/nodes/type/ToLongNode.java
  34. +35 −11 truffle/src/main/java/org/jruby/truffle/pack/nodes/type/ToStringNode.java
  35. +6 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/NullNode.java
  36. +38 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/PNode.java
  37. +10 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/Write16BigNode.java
  38. +10 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/Write16LittleNode.java
  39. +10 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/Write32BigNode.java
  40. +10 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/Write32LittleNode.java
  41. +10 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/Write64BigNode.java
  42. +10 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/Write64LittleNode.java
  43. +10 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/Write8Node.java
  44. +19 −4 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteBERNode.java
  45. +7 −5 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteBase64StringNode.java
  46. +7 −2 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteBinaryStringNode.java
  47. +47 −28 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteBitStringNode.java
  48. +8 −3 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteHexStringNode.java
  49. +7 −4 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteMIMEStringNode.java
  50. +14 −4 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteUTF8CharacterNode.java
  51. +8 −10 truffle/src/main/java/org/jruby/truffle/pack/nodes/{type → write}/WriteUUStringNode.java
  52. +45 −11 truffle/src/main/java/org/jruby/truffle/pack/parser/PackParser.java
  53. +17 −4 truffle/src/main/java/org/jruby/truffle/pack/parser/PackTokenizer.java
  54. +9 −0 truffle/src/main/java/org/jruby/truffle/pack/runtime/Nil.java
  55. +9 −0 truffle/src/main/java/org/jruby/truffle/pack/runtime/PackFrame.java
9 changes: 4 additions & 5 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@

import org.jcodings.Encoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF16BEEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
@@ -59,12 +58,11 @@
import org.jruby.runtime.marshal.MarshalStream;
import org.jruby.runtime.marshal.UnmarshalStream;
import org.jruby.truffle.pack.runtime.*;
import org.jruby.truffle.pack.runtime.exceptions.*;
import org.jruby.util.ByteList;
import org.jruby.util.Pack;
import org.jruby.util.PerlHash;
import org.jruby.util.Qsort;
import org.jruby.util.RecursiveComparator;
import org.jruby.util.SipHashInline;
import org.jruby.util.TypeConverter;
import org.jruby.util.cli.Options;

@@ -77,7 +75,6 @@
import static org.jruby.RubyEnumerator.enumeratorize;
import static org.jruby.RubyEnumerator.enumeratorizeWithSize;
import static org.jruby.runtime.Helpers.invokedynamic;
import static org.jruby.runtime.Helpers.memchr;
import static org.jruby.runtime.Visibility.PRIVATE;
import static org.jruby.runtime.invokedynamic.MethodNames.HASH;
import static org.jruby.runtime.invokedynamic.MethodNames.OP_CMP;
@@ -4108,6 +4105,8 @@ public RubyString pack(ThreadContext context, IRubyObject obj) {
throw context.getRuntime().newArgumentError(e.getMessage());
}

// TODO CS 10-Apr-15 how do we limit the size of the cache

// We can race on this, but it doesn't matter as long as something goes in the cache
trufflePackerCache.put(iFmt.getByteList().dup(), packer);
}
@@ -4151,7 +4150,7 @@ public RubyString pack(ThreadContext context, IRubyObject obj) {
}
}

if (result.isTainted()) {
if (result.isTainted() || iFmt.isTaint()) {
string.taint(context.getRuntime());
}

20 changes: 20 additions & 0 deletions core/src/main/java/org/jruby/TrufflePackBridge.java
Original file line number Diff line number Diff line change
@@ -12,10 +12,30 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.pack.runtime.PackResult;

/**
* Interface to the Truffle implementation of pack. The implementation is in
* the {@code truffle} package, so is only available if the {@code truffle.jar}
* is available on the classpath.
* <p>
* To instantiate the implementation, use reflection to look for
* {@code org.jruby.truffle.pack.TrufflePackBridgeImpl}.
* <p>
* Using the Truffle implementation only makes sense on a JVM that has the
* Graal compiler.
*/
public interface TrufflePackBridge {

/**
* Compile a format expression into code that can apply that expression
* to an array.
*/
Packer compileFormat(String format);

/**
* Represents a Truffle implementation of a particular pack format
* expression. Both interpretation and dynamic compilation implementations
* of the format are contained behind this interface.
*/
interface Packer {

PackResult pack(IRubyObject[] objects, int size);
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
/*
* 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:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.pack.runtime;

/**
* 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 PackEncoding {
DEFAULT,
ASCII_8BIT,
US_ASCII,
UTF_8;

/**
* Given the current encoding for a pack string, and something that requires
* another encoding, give us the encoding that we should use for the result
* of pack.
*/
public PackEncoding unifyWith(PackEncoding other) {
if (this == DEFAULT) {
return other;
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.pack.runtime;

public class PackResult {
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.pack.runtime;
package org.jruby.truffle.pack.runtime.exceptions;

public class CantCompressNegativeException extends RuntimeException {

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.pack.runtime;
package org.jruby.truffle.pack.runtime.exceptions;

public class CantConvertException extends RuntimeException {

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.pack.runtime;
package org.jruby.truffle.pack.runtime.exceptions;

public class FormatException extends RuntimeException {

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.pack.runtime;
package org.jruby.truffle.pack.runtime.exceptions;

public class NoImplicitConversionException extends RuntimeException {

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.pack.runtime;
package org.jruby.truffle.pack.runtime.exceptions;

public class OutsideOfStringException extends RuntimeException {
}
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.pack.runtime;
package org.jruby.truffle.pack.runtime.exceptions;

public class RangeException extends RuntimeException {

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.pack.runtime;
package org.jruby.truffle.pack.runtime.exceptions;

public class TooFewArgumentsException extends RuntimeException {
}
8 changes: 0 additions & 8 deletions spec/truffle/tags/core/array/pack/b_tags.txt

This file was deleted.

6 changes: 0 additions & 6 deletions spec/truffle/tags/core/array/pack/m_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@

import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.RubyObject;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.nodes.CoreSourceSection;
@@ -47,6 +46,7 @@
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.pack.parser.PackParser;
import org.jruby.truffle.pack.runtime.*;
import org.jruby.truffle.pack.runtime.exceptions.*;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.BreakException;
import org.jruby.truffle.runtime.control.NextException;
@@ -61,7 +61,6 @@
import org.jruby.util.Memo;

import java.util.Arrays;
import java.util.Comparator;

@CoreClass(name = "Array")
public abstract class ArrayNodes {
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* 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:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.pack;

import com.oracle.truffle.api.CallTarget;
@@ -6,6 +15,12 @@
import org.jruby.truffle.pack.parser.PackParser;
import org.jruby.truffle.pack.runtime.PackResult;

/**
* The implementation of the interface from the {@code core} package.
* <p>
* Instantiated by {@code core} using reflection, as there is normally no
* dependency on {@code truffle} from {@code core}.
*/
public class TrufflePackBridgeImpl implements TrufflePackBridge {

@Override
61 changes: 61 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/pack/nodes/PackGuards.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.pack.nodes;

import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyBignum;
import org.jruby.truffle.runtime.core.RubyString;

import java.math.BigInteger;

public class PackGuards {

public static boolean isNull(Object object) {
return object == null;
}

public static boolean isRubyNilClass(Object object) {
return object instanceof RubyString;
}

public static boolean isBoolean(Object object) {
return object instanceof Boolean;
}

public static boolean isInteger(Object object) {
return object instanceof Integer;
}

public static boolean isLong(Object object) {
return object instanceof Long;
}

public static boolean isBigInteger(Object object) {
return object instanceof BigInteger;
}

public static boolean isRubyBignum(Object object) {
return object instanceof RubyBignum;
}

public static boolean isRubyString(Object object) {
return object instanceof RubyString;
}

public static boolean isRubyArray(Object object) {
return object instanceof RubyArray;
}

public static boolean isIRubyArray(Object[] array) {
return array instanceof IRubyObject[];
}

}
Loading