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

Commits on Jun 30, 2016

  1. Work in progress.

    headius committed Jun 30, 2016
    Copy the full SHA
    7488347 View commit details
  2. Copy the full SHA
    f541c3b View commit details
  3. Wire up 1-obj arrays and unify some construction paths.

    This is not yet running properly.
    headius committed Jun 30, 2016
    Copy the full SHA
    c2f3ce3 View commit details
  4. Copy the full SHA
    b47a8af View commit details
  5. Copy the full SHA
    51eb164 View commit details
  6. Copy the full SHA
    3d10abf View commit details
  7. Copy the full SHA
    b81e3ca View commit details
  8. Copy the full SHA
    0ae5f8f View commit details
  9. Implement two-object specialized arrays, plus misc improvements.

    * Reduce #unpack logic.
    * Pull a couple more methods up to RubyArray with accessors.
    * Document specialized array classes.
    * Eliminate flag; null values field is good enough (maybe better).
    headius committed Jun 30, 2016
    Copy the full SHA
    793815e View commit details
  10. Copy the full SHA
    76fe2c2 View commit details
  11. Copy the full SHA
    93f0c02 View commit details
  12. Copy the full SHA
    5cf6e65 View commit details
  13. Copy the full SHA
    e5776b5 View commit details
  14. Copy the full SHA
    2336f2c View commit details
  15. Copy the full SHA
    3a15447 View commit details
  16. Add new mechanism for visiting all Hash elements without alloc.

    This new mechanism passes in state that makes most Visitor
    construction unnecessary: thread context, currently-visiting Hash,
    and a generic state object.
    headius committed Jun 30, 2016
    Copy the full SHA
    b6739cf View commit details
  17. Use new visitor logic everywhere.

    Nearly all of these are now allocated once, like a lambda. A few
    require more state to be passed in than is reasonable for a
    generic visitor, or require state to be calculated during visit
    and retrieved at the end. These cases were at least reduced to
    only allocate a visitor, rather than a visitor and a state-holding
    object.
    headius committed Jun 30, 2016
    Copy the full SHA
    cfab498 View commit details
  18. Deprecate old visitAll to prevent mix-ups.

    See MapJavaProxy's RubyHashMap subclass; it previously override
    the old visitAll, which broke Map instances returned from Java
    because that visitAll was not being used. This will help ensure
    no subclasses are overriding the wrong method. I don't expect
    there's many (or maybe any) other cases in the wild.
    headius committed Jun 30, 2016
    Copy the full SHA
    540a491 View commit details
  19. Utilize packed 1-2 elt arrays more places in the codebase.

    This commit includes a pass over our code to improve places where
    we are creating one or two-element arrays via the IRubyObject[]
    paths, so they will use packed arrays when possible. I did this
    survey by applying the patch (below) and running ruby/spec,
    various gem commands, and starting up and hitting a blank rails
    application.
    
    The pattern used for most of these changes is as follows:
    
    * Allocate a new "blank" array with RubyArray.newBlankArray(size).
    * Popululate at least the first 'size' elements. This is
      necessary since the packed arrays can only represent exactly
      one or two elements, and must be unpacked to represent other
      sizes.
    
    Most cases found in the survey were updated to this new pattern
    and now will create packed forms. Notable exceptions that I
    skipped (usually due to algorithms that had unpredictable sizing)
    were:
    
    * RubyString.enumerate[chars,codepoints] - Because of the variable
      width of characters in multibyte, this logic was difficult to
      connect up to an "exactly this size" array. It should be
      possible to use packed arrays for 7-bit cases, or to be smarter
      about small strings with one or two codepoints, but I have not
      attempted that here.
    * RubyArray.values_at - Because the incoming arguments may not
      represent exactly how many items will be pulled from the array
      (e.g if you pass in a Range).
    * RubyStruct.values_at - Same reasons as for RubyArray.values_at.
    * SelectExecutor's construction of result arrays - Because some
      or all of the expected channels may not be ready, it would
      require more logic to right-size the arrays. This is a heavily-
      hit piece of logic and such an improvement may be warranted,
      but there's significantly more overhead in SelectExecutor that
      needs a rewrite before packed arrays would show any significant
      improvement.
    
    The patch mentioned above follows.
    
    ```diff
    diff --git a/core/src/main/java/org/jruby/RubyArray.java b/core/src/main/java/org/jruby/RubyArray.java
    index d2bc419..180af8f 100644
    --- a/core/src/main/java/org/jruby/RubyArray.java
    +++ b/core/src/main/java/org/jruby/RubyArray.java
    @@ -160,26 +160,30 @@ public class RubyArray extends RubyObject implements List, RandomAccess {
    
         /** rb_ary_new2
          *
          */
         public static final RubyArray newArray(final Ruby runtime, final long len) {
    +        if (len == 1 || len == 2) Thread.dumpStack();
             checkLength(runtime, len);
             return newArray(runtime, (int)len);
         }
    
         public static final RubyArray newArrayLight(final Ruby runtime, final long len) {
    +        if (len == 1 || len == 2) Thread.dumpStack();
             checkLength(runtime, len);
             return newArrayLight(runtime, (int)len);
         }
    
         public static final RubyArray newArray(final Ruby runtime, final int len) {
    +        if (len == 1 || len == 2) Thread.dumpStack();
             RubyArray array = new RubyArray(runtime, len);
             Helpers.fillNil(array.values, 0, len, runtime);
             return array;
         }
    
         public static final RubyArray newArrayLight(final Ruby runtime, final int len) {
    +        if (len == 1 || len == 2) Thread.dumpStack();
             RubyArray array = new RubyArray(runtime, len, false);
             Helpers.fillNil(array.values, 0, len, runtime);
             return array;
         }
    
    ```
    headius committed Jun 30, 2016
    Copy the full SHA
    54218a3 View commit details

Commits on Jul 5, 2016

  1. Propagate packed arrays to IRubyObject[] factory methods.

    This commit introduces a few new RubyArray.newArray factory
    methods that are aware of packed forms and can produce the most
    memory-efficient RubyArray possible.
    
    RubyArray.newArrayMayCopy takes an array and will either construct
    a packed copy of the first one or two elements or a COW-shared
    array viewing the original. The expectation is that the given
    array is "effectively read-only", so it can be owned or discarded
    by the factory method at will.
    
    There are new RubyArray.newArray forms for three and four elts.
    Only the one and two-elt versions use packed forms.
    
    Several calls through Ruby.newArray utility methods were moved
    to new or existing RubyArray factory methods.
    
    All specs pass with these changes, and many cases that created
    "heavy" arrays before will now create packed arrays. This is
    particularly useful for splatting one or two arguments into an
    array. A quick benchmark of "def foo(*a); a; end" five times in
    a 1M iteration loop shows 15-20% improved performance for both
    one and two-argument calls.
    headius committed Jul 5, 2016
    Copy the full SHA
    5f37238 View commit details

Commits on Jul 6, 2016

  1. Copy the full SHA
    6bdcd7a View commit details
  2. Copy the full SHA
    7998429 View commit details
  3. Copy the full SHA
    0180583 View commit details
Showing with 1,800 additions and 678 deletions.
  1. +1 −1 core/src/main/java/org/jruby/NativeException.java
  2. +443 −211 core/src/main/java/org/jruby/RubyArray.java
  3. +10 −6 core/src/main/java/org/jruby/RubyBasicObject.java
  4. +1 −1 core/src/main/java/org/jruby/RubyContinuation.java
  5. +1 −1 core/src/main/java/org/jruby/RubyConverter.java
  6. +3 −3 core/src/main/java/org/jruby/RubyDir.java
  7. +1 −1 core/src/main/java/org/jruby/RubyEncoding.java
  8. +24 −26 core/src/main/java/org/jruby/RubyEnumerable.java
  9. +1 −1 core/src/main/java/org/jruby/RubyEnumerator.java
  10. +1 −1 core/src/main/java/org/jruby/RubyFile.java
  11. +290 −228 core/src/main/java/org/jruby/RubyHash.java
  12. +2 −2 core/src/main/java/org/jruby/RubyKernel.java
  13. +7 −5 core/src/main/java/org/jruby/RubyMatchData.java
  14. +2 −1 core/src/main/java/org/jruby/RubyNameError.java
  15. +1 −1 core/src/main/java/org/jruby/RubyRandom.java
  16. +2 −1 core/src/main/java/org/jruby/RubyRange.java
  17. +6 −4 core/src/main/java/org/jruby/RubyRegexp.java
  18. +12 −11 core/src/main/java/org/jruby/RubyString.java
  19. +9 −19 core/src/main/java/org/jruby/RubyStruct.java
  20. +2 −2 core/src/main/java/org/jruby/RubySymbol.java
  21. +21 −19 core/src/main/java/org/jruby/RubyThread.java
  22. +1 −1 core/src/main/java/org/jruby/RubyTime.java
  23. +1 −1 core/src/main/java/org/jruby/RubyUncaughtThrowError.java
  24. +8 −7 core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
  25. +2 −1 core/src/main/java/org/jruby/ext/etc/RubyEtc.java
  26. +1 −1 core/src/main/java/org/jruby/ext/ffi/Struct.java
  27. +1 −1 core/src/main/java/org/jruby/ext/ffi/StructLayout.java
  28. +5 −4 core/src/main/java/org/jruby/ext/fiber/ThreadFiber.java
  29. +1 −1 core/src/main/java/org/jruby/ext/jruby/JRubyUtilLibrary.java
  30. +9 −8 core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
  31. +8 −8 core/src/main/java/org/jruby/ext/socket/RubyIPSocket.java
  32. +9 −8 core/src/main/java/org/jruby/ext/socket/RubyTCPSocket.java
  33. +14 −14 core/src/main/java/org/jruby/ext/socket/SocketUtils.java
  34. +0 −4 core/src/main/java/org/jruby/internal/runtime/methods/CompiledIRMethod.java
  35. +1 −1 core/src/main/java/org/jruby/ir/instructions/CheckArityInstr.java
  36. +12 −1 core/src/main/java/org/jruby/ir/operands/Array.java
  37. +35 −24 core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
  38. +1 −1 core/src/main/java/org/jruby/ir/targets/Bootstrap.java
  39. +7 −0 core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter6.java
  40. +7 −0 core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter7.java
  41. +3 −2 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  42. +10 −9 core/src/main/java/org/jruby/java/proxies/JavaProxy.java
  43. +3 −2 core/src/main/java/org/jruby/java/proxies/MapJavaProxy.java
  44. +1 −1 core/src/main/java/org/jruby/javasupport/JavaClass.java
  45. +1 −1 core/src/main/java/org/jruby/javasupport/ext/JavaLang.java
  46. +3 −3 core/src/main/java/org/jruby/javasupport/ext/JavaUtil.java
  47. +3 −3 core/src/main/java/org/jruby/javasupport/ext/JavaUtilRegex.java
  48. +1 −1 core/src/main/java/org/jruby/javasupport/proxy/JavaProxyReflectionObject.java
  49. +6 −5 core/src/main/java/org/jruby/runtime/Helpers.java
  50. +1 −1 core/src/main/java/org/jruby/runtime/IRBlockBody.java
  51. +6 −5 core/src/main/java/org/jruby/runtime/NullBlockBody.java
  52. +1 −1 core/src/main/java/org/jruby/runtime/ThreadContext.java
  53. +1 −1 core/src/main/java/org/jruby/runtime/backtrace/TraceType.java
  54. +328 −0 core/src/main/java/org/jruby/specialized/RubyArrayOneObject.java
  55. +79 −0 core/src/main/java/org/jruby/specialized/RubyArraySpecialized.java
  56. +371 −0 core/src/main/java/org/jruby/specialized/RubyArrayTwoObject.java
  57. +3 −2 core/src/main/java/org/jruby/util/SunSignalFacade.java
  58. +10 −6 core/src/main/java/org/jruby/util/io/PopenExecutor.java
  59. +1 −1 core/src/main/java/org/jruby/util/io/Sockaddr.java
  60. +1 −0 core/src/main/resources/org/jruby/runtime/Constants.java
  61. +1 −1 core/src/test/java/org/jruby/test/TestRaiseException.java
  62. +1 −1 core/src/test/java/org/jruby/test/TestRubyArray.java
  63. +2 −1 test/jruby/test_java_extension.rb
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/NativeException.java
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ private static RubyArray joinedBacktrace(final Ruby runtime, final RubyArray rTr
trace[i] = RubyString.newString(runtime, line.toString());
}
System.arraycopy(rTrace.toJavaArrayMaybeUnsafe(), 0, trace, jTrace.length, rTrace.size());
return RubyArray.newArrayNoCopy(runtime, trace);
return RubyArray.newArrayMayCopy(runtime, trace);
}

@Deprecated // not used
Loading