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

Commits on May 12, 2016

  1. fix quoted paths

    ahorek committed May 12, 2016
    Copy the full SHA
    0269680 View commit details
  2. Copy the full SHA
    4e84246 View commit details
  3. Refactor transcodeLoop into ruby and non-ruby parts.

    In prep for a String-based transcode to address the test in #3877.
    headius committed May 12, 2016
    Copy the full SHA
    8befbfe View commit details
  4. Merge pull request #3882 from jruby/refactor_transcode_loop

    Refactor transcodeLoop into ruby and non-ruby parts.
    headius committed May 12, 2016

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3b03bdf View commit details
  5. Improve transcoding of Java String to bytes using joni.

    Previously, if the target encoding was not supported by the JDK,
    we would be unable to encode the string and would just make it
    UTF-8. Now if there's no JDK support we will fall back on joni
    transcoding.
    
    Part of #3877 work.
    headius committed May 12, 2016
    7
    Copy the full SHA
    d025e43 View commit details
  6. Copy the full SHA
    4fde8c6 View commit details
  7. Copy the full SHA
    9cc6f52 View commit details
  8. [Truffle] Fixed loading core files on Windows.

    My previous fix for relative path names broke things on Windows. The problem is canonicalizing a path makes it fully qualified. On Linux & Mac, that's not a problem because the classpath root and the filesystem root use the same charact ('/'), but on Windows the filesystem root is 'C:\'. We need to normalize the path instead and then replace any backslashes with forward slashes to make it a valid path for the resource loader.
    nirvdrum committed May 12, 2016
    Copy the full SHA
    fdb2b6d View commit details
  9. Copy the full SHA
    dd81c00 View commit details
  10. Copy the full SHA
    344ffb4 View commit details
  11. Copy the full SHA
    bc9df5f View commit details
  12. Also check content of encoded File.basename result.

    Triggers bug discovered by @ahorek here:
    
    d025e43#commitcomment-17451035
    headius committed May 12, 2016
    Copy the full SHA
    e3b8e8c View commit details
  13. Copy the full SHA
    c28f62a View commit details
  14. Re-port Array#hash and some related logic to fix #3884.

    It appears MRI defers recursion detection to the elements of an
    array and has other logic for combining hashes of those elements.
    I also added better initial hash value similar to MRI's use of a
    pointer in memory, which appears to be the main thing helping this
    issue, since now the hash of an empty array is a useful number.
    headius committed May 12, 2016
    Copy the full SHA
    1b92064 View commit details
  15. Add a spec for hashing a double-nested array with inner zarray.

    Relates to #3884, where JRuby
    was always returning the same hash for certain combinations of
    nested array with an innermost empty array.
    headius committed May 12, 2016
    2
    Copy the full SHA
    ac53c54 View commit details
  16. Clean up imports.

    headius committed May 12, 2016
    Copy the full SHA
    9334a2b View commit details
  17. Fixes #3680. JRuby and devise Null pointer exception

    This was largely just some code which was added before prepend existed.
    It would re-wrap begin and end of a range and make an array and call min
    on that.  This would obviously not have anything prepended on it and it
    would not even be the same type.
    
    I ended up re-porting min and max in range from MRI since I found another
    mistake with min(a) and max(a) not passing a to super if invoked in the
    block form.  This also makes us a tiny bit faster since we end up only
    doing on cmp in cases of fixnums (why is this even optimized by MRI :) ).
    enebo committed May 12, 2016
    Copy the full SHA
    d0fe3c0 View commit details

Commits on May 13, 2016

  1. Copy the full SHA
    f5da86f View commit details
  2. Copy the full SHA
    4658edd View commit details
  3. Copy the full SHA
    4971aae View commit details
  4. Copy the full SHA
    8310821 View commit details
  5. Merge pull request #3879 from ahorek/fix_quoted_paths

    fix quoted paths
    enebo committed May 13, 2016
    Copy the full SHA
    5508a08 View commit details
  6. Copy the full SHA
    41e728b View commit details
  7. Copy the full SHA
    02d6818 View commit details
  8. Copy the full SHA
    72e21d3 View commit details
  9. Copy the full SHA
    a142e0b View commit details
  10. [Truffle] Add a CheckLayoutNode to cache the Shape when doing isRuby<…

    …Type> checks.
    
    * Just an identity or a Shape check instead of (3 reads + instanceof).
      The instanceof folds away if the Shape is compilation constant
      as then the ObjecctType is compilation constant as well.
    eregon committed May 13, 2016
    3
    Copy the full SHA
    72a1908 View commit details
  11. [Truffle] New spec tag.

    eregon committed May 13, 2016
    Copy the full SHA
    48d98fd View commit details
  12. Copy the full SHA
    3581134 View commit details
  13. Copy the full SHA
    61cbc8c View commit details
  14. Copy the full SHA
    4f9eeb5 View commit details

Commits on May 14, 2016

  1. Revert "Re-port Array#hash and some related logic to fix #3884."

    This reverts commit 1b92064.
    headius committed May 14, 2016
    Copy the full SHA
    89d8af7 View commit details
  2. Smaller fix for #3884.

    The fix here is as follows:
    
    * Always provide a non-zero hash for any array, including empty.
    * Better hash combination function with less collision.
    
    An improved recursion guard will go into the next release.
    headius committed May 14, 2016
    Copy the full SHA
    f1e056b View commit details
  3. Copy the full SHA
    c07af6c View commit details
  4. Copy the full SHA
    be480ba View commit details
  5. Merge branch 'master' into truffle-head

    # Conflicts:
    #	tool/jt.rb
    chrisseaton committed May 14, 2016
    Copy the full SHA
    16ed170 View commit details
  6. Copy the full SHA
    b3fc1ec View commit details
Showing with 442 additions and 202 deletions.
  1. +3 −3 core/src/main/java/org/jruby/RubyArray.java
  2. +3 −19 core/src/main/java/org/jruby/RubyFile.java
  3. +23 −35 core/src/main/java/org/jruby/RubyRange.java
  4. +4 −2 core/src/main/java/org/jruby/RubyString.java
  5. +1 −1 core/src/main/java/org/jruby/ext/ffi/StructLayout.java
  6. +1 −1 core/src/main/java/org/jruby/ext/stringio/StringIO.java
  7. +3 −0 core/src/main/java/org/jruby/util/ShellLauncher.java
  8. +148 −37 core/src/main/java/org/jruby/util/io/EncodingUtils.java
  9. +4 −0 spec/ruby/core/array/hash_spec.rb
  10. +6 −0 spec/ruby/core/file/basename_spec.rb
  11. +0 −1 spec/tags/ruby/core/range/max_tags.txt
  12. +0 −3 spec/truffle/tags/core/array/flatten_tags.txt
  13. +1 −0 spec/truffle/tags/core/array/hash_tags.txt
  14. +0 −1 spec/truffle/tags/core/array/multiply_tags.txt
  15. +0 −14 spec/truffle/tags/core/io/write_nonblock_tags.txt
  16. +0 −7 spec/truffle/tags/core/string/modulo_tags.txt
  17. +0 −1 spec/truffle/tags/core/string/split_tags.txt
  18. 0 test/truffle/compiler/pe/{core → interop}/interop_pe.rb
  19. 0 test/truffle/compiler/pe/{ → interop}/js.rb
  20. +1 −2 test/truffle/compiler/pe/{ → interop}/r.rb
  21. +3 −3 test/truffle/compiler/pe/pe.rb
  22. +8 −0 truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
  23. +9 −1 truffle/src/main/java/org/jruby/truffle/core/exception/CoreExceptions.java
  24. +2 −0 truffle/src/main/java/org/jruby/truffle/core/module/ModuleLayout.java
  25. +127 −62 truffle/src/main/java/org/jruby/truffle/core/rubinius/IOPrimitiveNodes.java
  26. +3 −1 truffle/src/main/java/org/jruby/truffle/core/rubinius/UndefinedPrimitiveNodes.java
  27. +75 −0 truffle/src/main/java/org/jruby/truffle/language/CheckLayoutNode.java
  28. +7 −0 truffle/src/main/java/org/jruby/truffle/language/constants/LookupConstantNode.java
  29. +7 −5 truffle/src/main/java/org/jruby/truffle/language/loader/SourceLoader.java
  30. +1 −1 truffle/src/main/java/org/jruby/truffle/platform/NativePlatformFactory.java
  31. +2 −2 truffle/src/test/java/org/jruby/truffle/tck/RubyDebugTest.java
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@
***** END LICENSE BLOCK *****/
package org.jruby;

import org.jcodings.Encoding;
import org.jcodings.specific.USASCIIEncoding;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
@@ -683,13 +682,14 @@ public IRubyObject call(IRubyObject obj, boolean recur) {
final Ruby runtime = context.runtime;
int begin = RubyArray.this.begin;
long h = realLength;
h ^= System.identityHashCode(RubyArray.class);
if (recur) {
h ^= RubyNumeric.num2long(invokedynamic(context, runtime.getArray(), HASH));
h ^= h * 31 + RubyNumeric.num2long(invokedynamic(context, runtime.getArray(), HASH));
} else {
for (int i = begin; i < begin + realLength; i++) {
h = (h << 1) | (h < 0 ? 1 : 0);
final IRubyObject value = safeArrayRef(runtime, values, i);
h ^= RubyNumeric.num2long(invokedynamic(context, value, HASH));
h ^= h * 31 + RubyNumeric.num2long(invokedynamic(context, value, HASH));
}
}
return runtime.newFixnum(h);
22 changes: 3 additions & 19 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -518,15 +518,7 @@ public static IRubyObject basename(ThreadContext context, IRubyObject recv, IRub
case 2:
return RubyString.newEmptyString(runtime, origString.getEncoding()).infectBy(args[0]);
case 3:
if (origEncoding.getCharset() != null) {
try {
return RubyString.newString(runtime, new ByteList(name.substring(2).getBytes(origEncoding.getCharsetName()), origString.getEncoding())).infectBy(args[0]);
} catch (UnsupportedEncodingException uee) {
// fall through to UTF-8 logic
}
}

return RubyString.newString(runtime, name.substring(2)).infectBy(args[0]);
return RubyString.newString(runtime, RubyString.encodeBytelist(name.substring(2), origEncoding));
default:
switch (name.charAt(2)) {
case '/':
@@ -581,15 +573,8 @@ public static IRubyObject basename(ThreadContext context, IRubyObject recv, IRub
name = name.substring(0, name.length() - ext.length());
}
}
if (origEncoding.getCharset() != null) {
try {
return RubyString.newString(runtime, new ByteList(name.getBytes(origEncoding.getCharsetName()), origString.getEncoding())).infectBy(args[0]);
} catch (UnsupportedEncodingException uee) {
// fall through to UTF-8 logic
}
}

return RubyString.newString(runtime, name).infectBy(args[0]);
return RubyString.newString(runtime, RubyString.encodeBytelist(name, origEncoding));
}

@JRubyMethod(required = 2, rest = true, meta = true)
@@ -1370,8 +1355,7 @@ private static RubyString filePathConvert(ThreadContext context, RubyString path
pathEncoding != encodingService.getAscii8bitEncoding() &&
pathEncoding != encodingService.getFileSystemEncoding(runtime) &&
!path.isAsciiOnly()) {
ByteList bytes = EncodingUtils.strConvEnc(context, path.getByteList(), pathEncoding, encodingService.getFileSystemEncoding(runtime));
path = RubyString.newString(runtime, bytes);
path = EncodingUtils.strConvEnc(context, path, pathEncoding, encodingService.getFileSystemEncoding(runtime));
}
}

58 changes: 23 additions & 35 deletions core/src/main/java/org/jruby/RubyRange.java
Original file line number Diff line number Diff line change
@@ -645,64 +645,52 @@ public IRubyObject cover_p(ThreadContext context, IRubyObject obj) {

@JRubyMethod(frame = true)
public IRubyObject min(ThreadContext context, Block block) {
IRubyObject receiver = getReceiverForMinMax(context, end, block);
if(receiver.isNil()) return receiver;
return Helpers.invokeSuper(context, receiver, block);
if (block.isGiven()) return Helpers.invokeSuper(context, this, block);

int cmp = RubyComparable.cmpint(context, invokedynamic(context, begin, MethodNames.OP_CMP, end), begin, end);
if (cmp > 0 || (cmp == 0 && isExclusive)) return context.nil;

return begin;
}

@JRubyMethod(frame = true)
public IRubyObject max(ThreadContext context, Block block) {
IRubyObject rangeEnd;
boolean isNumeric = end instanceof RubyNumeric;

if (block.isGiven() || (isExclusive && !isNumeric)) {
return Helpers.invokeSuper(context, this, block);
}

int cmp = RubyComparable.cmpint(context, invokedynamic(context, begin, MethodNames.OP_CMP, end), begin, end);
if (cmp > 0) return context.nil;
if (isExclusive) {
if (!(end instanceof RubyInteger)) {
throw context.runtime.newTypeError("cannot exclude non Integer end value");
}

if (cmp == 0) return context.nil;

if (!(begin instanceof RubyInteger)) {
throw context.runtime.newTypeError("cannot exclude end value with non Integer begin value");
}
if (end instanceof RubyFixnum) {
rangeEnd = RubyFixnum.newFixnum(context.runtime, ((RubyFixnum)end).getLongValue() - 1);
} else {
rangeEnd = end.callMethod(context, "-", RubyFixnum.one(context.runtime));
return RubyFixnum.newFixnum(context.runtime, ((RubyFixnum)end).getLongValue() - 1);
}
} else {
rangeEnd = end;

return end.callMethod(context, "-", RubyFixnum.one(context.runtime));
}

IRubyObject receiver = getReceiverForMinMax(context, rangeEnd, block);
if(receiver.isNil()) return receiver;
return Helpers.invokeSuper(context, receiver, block);
return end;
}

@JRubyMethod(frame = true)
public IRubyObject min(ThreadContext context, IRubyObject arg, Block block) {
if (block.isGiven()) return Helpers.invokeSuper(context, this, block);

return first(context, arg);
return Helpers.invokeSuper(context, this, arg, block);
}

@JRubyMethod(frame = true)
public IRubyObject max(ThreadContext context, IRubyObject arg, Block block) {
if (block.isGiven()) return Helpers.invokeSuper(context, this, block);

return ((RubyArray) last(context, arg)).reverse();
}

private boolean rangeEmpty_p(ThreadContext context) {
int cmp = RubyComparable.cmpint(context, invokedynamic(context, begin, MethodNames.OP_CMP, end), begin, end);
return cmp > 0 || (cmp == 0 && isExclusive);
}

private IRubyObject getReceiverForMinMax(ThreadContext context, IRubyObject rangeEnd, Block block) {
RubyObject receiver;

if (block.isGiven()) {
receiver = this;
} else {
if(rangeEmpty_p(context)) return context.runtime.getNil();
receiver = RubyArray.newArray(context.runtime, new IRubyObject[]{begin, rangeEnd});
}
return receiver;
return Helpers.invokeSuper(context, this, arg, block);
}

@JRubyMethod
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -5463,8 +5463,10 @@ public static ByteList encodeBytelist(CharSequence value, Encoding encoding) {

Charset charset = encoding.getCharset();

// if null charset, fall back on Java default charset
if (charset == null) charset = Charset.defaultCharset();
// if null charset, let our transcoder handle it
if (charset == null) {
return EncodingUtils.transcodeString(value.toString(), encoding, 0);
}

byte[] bytes;
if (charset == RubyEncoding.UTF8) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/ffi/StructLayout.java
Original file line number Diff line number Diff line change
@@ -480,7 +480,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return 53 * 5 + (int) (this.offset ^ (this.offset >>> 32)) + 37 * type.hashCode();
return 53 * 5 + this.offset + 37 * type.hashCode();
}

/**
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ext/stringio/StringIO.java
Original file line number Diff line number Diff line change
@@ -1007,7 +1007,7 @@ public IRubyObject write(ThreadContext context, IRubyObject arg) {
if (enc != encStr && enc != EncodingUtils.ascii8bitEncoding(runtime)
// this is a hack because we don't seem to handle incoming ASCII-8BIT properly in transcoder
&& encStr != ASCIIEncoding.INSTANCE) {
str = runtime.newString(EncodingUtils.strConvEnc(context, strByteList, encStr, enc));
str = EncodingUtils.strConvEnc(context, str, encStr, enc);
}
len = str.size();
if (len == 0) return RubyFixnum.zero(runtime);
3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/util/ShellLauncher.java
Original file line number Diff line number Diff line change
@@ -389,6 +389,9 @@ private static File isValidFile(Ruby runtime, String fname, boolean isExec) {

private static File findPathFile(Ruby runtime, String fname, String[] path, boolean isExec) {
File pathFile = null;
if (Platform.IS_WINDOWS && fname.startsWith("\"") && fname.endsWith("\"")) {
fname = fname.substring(1, fname.length() - 1); // remove double quotes if present
}
boolean doPathSearch = filenameIsPathSearchable(fname, isExec);
if (doPathSearch) {
for (String fdir: path) {
Loading