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

Commits on Sep 25, 2015

  1. Copy the full SHA
    dbccd22 View commit details
  2. [Truffle] Enable system assertions for specs.

    * Since Truffle is on the bootclasspath, assertions are ignored
      unless -esa or -ea:com.oracle.truffle... is specified.
      -esa is chosen so other bootclasspath assertions (like jruby's)
      are also enabled.
    eregon committed Sep 25, 2015
    Copy the full SHA
    bfce7bc View commit details
  3. Use methods instead of procs for converters.

    This is a temporary fix to improve perf of converters since JRuby
    does not currently JIT blocks.
    
    See #3348.
    headius committed Sep 25, 2015
    Copy the full SHA
    9de48c2 View commit details
  4. Copy the full SHA
    6a875ce View commit details
  5. Wire up invokedynamic caching for global variable reads.

    This improves global read perf for #3350 but global variable
    writes still seem to be slower than MRI. I'm not exactly sure why
    but it probably has to do with doing a full lookup for our too-
    abstract wrapper around these values.
    headius committed Sep 25, 2015
    Copy the full SHA
    f2612a2 View commit details

Commits on Sep 26, 2015

  1. Copy the full SHA
    3c164ca View commit details

Commits on Sep 27, 2015

  1. Copy the full SHA
    42791de View commit details
  2. Copy the full SHA
    6f69f20 View commit details
  3. Copy the full SHA
    b62b7f9 View commit details

Commits on Sep 28, 2015

  1. Copy the full SHA
    3bbe011 View commit details
  2. Copy the full SHA
    723dd77 View commit details
  3. Copy the full SHA
    95a3cf9 View commit details
  4. Copy the full SHA
    3b0b29c View commit details
  5. Copy the full SHA
    b271fc7 View commit details
  6. 2
    Copy the full SHA
    bfa7d6c View commit details
  7. Copy the full SHA
    a3c9c3a View commit details
  8. Copy the full SHA
    4e42e84 View commit details
  9. Copy the full SHA
    696babb View commit details
  10. Copy the full SHA
    a2c4477 View commit details
  11. Copy the full SHA
    64157c6 View commit details
  12. Copy the full SHA
    bb17f26 View commit details
  13. 3
    Copy the full SHA
    4c22a45 View commit details
  14. Copy the full SHA
    a13a50b View commit details
  15. 3
    Copy the full SHA
    c97f626 View commit details
  16. Copy the full SHA
    ec7e25e View commit details
  17. [Truffle] Unexclude timeout-related specs.

    * It's implemented now.
    eregon committed Sep 28, 2015
    Copy the full SHA
    d4c38d2 View commit details
  18. Copy the full SHA
    1f8a35a View commit details
  19. Copy the full SHA
    40844ff View commit details
  20. Copy the full SHA
    61c7a8e View commit details
  21. Copy the full SHA
    e79dbfd View commit details
  22. Copy the full SHA
    48a4e24 View commit details
  23. 2
    Copy the full SHA
    17ff676 View commit details
  24. Copy the full SHA
    0393ea2 View commit details
  25. 2
    Copy the full SHA
    07dec75 View commit details
  26. Copy the full SHA
    844590b View commit details
  27. Copy the full SHA
    0fe4e37 View commit details
  28. Copy the full SHA
    30b4387 View commit details
  29. Copy the full SHA
    db649ae View commit details
  30. Merge branch 'master' of github.com:jruby/jruby

    Conflicts:
    	truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
    chrisseaton committed Sep 28, 2015
    Copy the full SHA
    87f52a3 View commit details
  31. Copy the full SHA
    55be66e View commit details
  32. The form 'expr rescue {simple}' where simple is immediate values or

    values which do not cause any method execution (or side-effects) will
    omit generating backtraces since there is no way to get access to $!.
    This improves performance of these simple catch-all forms by ~48x.
    
    Note: a follow-on commit can fix 'begin; expr; rescue; {simple}; end' later.
    It is much less common and not as ripe a target.
    
    BEFORE:
    
    system ~/work/jruby master 814% jruby --dev ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil    89.000  i/100ms
    moo rescue nil (single)
                            91.000  i/100ms
    -------------------------------------------------
    begin moo rescue nil    956.234  (± 4.4%) i/s -      9.612k
    moo rescue nil (single)
                            955.879  (± 4.8%) i/s -      9.555k
    system ~/work/jruby master 815% jruby -X-C ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil   100.000  i/100ms
    moo rescue nil (single)
                           106.000  i/100ms
    -------------------------------------------------
    begin moo rescue nil      1.085k (± 5.2%) i/s -     10.900k
    moo rescue nil (single)
                              1.072k (± 5.5%) i/s -     10.706k
    system ~/work/jruby master 816% jruby ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil   104.000  i/100ms
    moo rescue nil (single)
                           105.000  i/100ms
    -------------------------------------------------
    begin moo rescue nil      1.074k (± 5.7%) i/s -     10.712k
    moo rescue nil (single)
                              1.089k (± 5.0%) i/s -     10.920k
    system ~/work/jruby master 817% jruby -Xcompile.invokedynamic=true ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil   112.000  i/100ms
    moo rescue nil (single)
                           122.000  i/100ms
    -------------------------------------------------
    begin moo rescue nil      1.275k (± 5.4%) i/s -     12.768k
    moo rescue nil (single)
                              1.253k (± 4.7%) i/s -     12.566k
    
    AFTER:
    
    system ~/work/jruby master * 820% jruby --dev ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil    89.000  i/100ms
    moo rescue nil (single)
                             1.199k i/100ms
    -------------------------------------------------
    begin moo rescue nil    921.217  (± 5.1%) i/s -      9.256k
    moo rescue nil (single)
                             12.833k (± 4.9%) i/s -    128.293k
    system ~/work/jruby master * 821% jruby -X-C ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil   100.000  i/100ms
    moo rescue nil (single)
                             3.037k i/100ms
    -------------------------------------------------
    begin moo rescue nil      1.031k (± 6.2%) i/s -     10.300k
    moo rescue nil (single)
                             35.393k (± 5.5%) i/s -    355.329k
    system ~/work/jruby master * 822% jruby ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil   100.000  i/100ms
    moo rescue nil (single)
                             4.725k i/100ms
    -------------------------------------------------
    begin moo rescue nil      1.119k (± 4.6%) i/s -     11.200k
    moo rescue nil (single)
                             52.318k (± 5.8%) i/s -    524.475k
    system ~/work/jruby master * 823% jruby -Xcompile.invokedynamic=true ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil   106.000  i/100ms
    moo rescue nil (single)
                             5.076k i/100ms
    -------------------------------------------------
    begin moo rescue nil      1.176k (± 5.5%) i/s -     11.766k
    moo rescue nil (single)
                             49.198k (± 5.5%) i/s -    492.372k
    
    MRI 2.2.2:
    
    system ~/work/jruby master * 824% mri22 ../snippets/bench2.rb
    Calculating -------------------------------------
    begin moo rescue nil     2.771k i/100ms
    moo rescue nil (single)
                             2.707k i/100ms
    -------------------------------------------------
    begin moo rescue nil     28.586k (± 5.2%) i/s -    285.413k
    moo rescue nil (single)
                             28.470k (± 4.2%) i/s -    284.235k
    enebo committed Sep 28, 2015
    Copy the full SHA
    fb4dcb4 View commit details
  33. [Truffle] Removed useless profiles.

    We explicitly transfer in each of these cases, so there's no need for a profile.
    nirvdrum committed Sep 28, 2015
    Copy the full SHA
    c7b5040 View commit details
  34. Copy the full SHA
    eb6909e View commit details
  35. Copy the full SHA
    f733a03 View commit details
  36. [Truffle] Better name.

    chrisseaton committed Sep 28, 2015
    Copy the full SHA
    94ae555 View commit details
  37. [Truffle] Add todos.

    chrisseaton committed Sep 28, 2015
    Copy the full SHA
    e4ef532 View commit details
  38. Merge branch 'master' into truffle-yaml

    Conflicts:
    	truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
    	truffle/src/main/java/org/jruby/truffle/runtime/layouts/Layouts.java
    chrisseaton committed Sep 28, 2015
    Copy the full SHA
    d273188 View commit details
Showing with 1,344 additions and 679 deletions.
  1. +54 −30 core/src/main/java/org/jruby/RubyRandom.java
  2. +20 −54 core/src/main/java/org/jruby/RubyString.java
  3. +1 −1 core/src/main/java/org/jruby/ast/BignumNode.java
  4. +1 −1 core/src/main/java/org/jruby/ast/ClassVarNode.java
  5. +1 −1 core/src/main/java/org/jruby/ast/ComplexNode.java
  6. +1 −1 core/src/main/java/org/jruby/ast/FalseNode.java
  7. +1 −1 core/src/main/java/org/jruby/ast/FileNode.java
  8. +1 −1 core/src/main/java/org/jruby/ast/FixnumNode.java
  9. +1 −1 core/src/main/java/org/jruby/ast/FloatNode.java
  10. +1 −1 core/src/main/java/org/jruby/ast/GlobalVarNode.java
  11. +1 −1 core/src/main/java/org/jruby/ast/InstVarNode.java
  12. +1 −1 core/src/main/java/org/jruby/ast/LocalVarNode.java
  13. +1 −1 core/src/main/java/org/jruby/ast/NilNode.java
  14. +1 −1 core/src/main/java/org/jruby/ast/RationalNode.java
  15. +12 −0 core/src/main/java/org/jruby/ast/RescueModNode.java
  16. +1 −1 core/src/main/java/org/jruby/ast/SelfNode.java
  17. +7 −0 core/src/main/java/org/jruby/ast/SideEffectFree.java
  18. +1 −1 core/src/main/java/org/jruby/ast/StrNode.java
  19. +1 −1 core/src/main/java/org/jruby/ast/SymbolNode.java
  20. +1 −1 core/src/main/java/org/jruby/ast/TrueNode.java
  21. +20 −15 core/src/main/java/org/jruby/exceptions/RaiseException.java
  22. +4 −4 core/src/main/java/org/jruby/internal/runtime/GlobalVariables.java
  23. +19 −0 core/src/main/java/org/jruby/ir/IRBuilder.java
  24. +7 −0 core/src/main/java/org/jruby/ir/IRManager.java
  25. +1 −0 core/src/main/java/org/jruby/ir/IRVisitor.java
  26. +2 −1 core/src/main/java/org/jruby/ir/Operation.java
  27. +5 −6 core/src/main/java/org/jruby/ir/instructions/GetGlobalVariableInstr.java
  28. +59 −0 core/src/main/java/org/jruby/ir/instructions/ToggleBacktraceInstr.java
  29. +4 −0 core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
  30. +1 −0 core/src/main/java/org/jruby/ir/persistence/IRReaderStream.java
  31. +64 −2 core/src/main/java/org/jruby/ir/targets/Bootstrap.java
  32. +14 −0 core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter.java
  33. +16 −0 core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter6.java
  34. +9 −12 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  35. +7 −0 core/src/main/java/org/jruby/parser/ParserSupport.java
  36. +7 −13 core/src/main/java/org/jruby/parser/RubyParser.java
  37. +4 −9 core/src/main/java/org/jruby/parser/RubyParser.y
  38. +9 −0 core/src/main/java/org/jruby/runtime/ThreadContext.java
  39. +38 −0 core/src/main/java/org/jruby/runtime/invokedynamic/GlobalSite.java
  40. +1 −11 core/src/main/java/org/jruby/runtime/opto/OptoFactory.java
  41. +13 −0 core/src/main/java/org/jruby/util/JRubyClassLoader.java
  42. +3 −0 core/src/main/java/org/jruby/util/Random.java
  43. +84 −0 core/src/main/java/org/jruby/util/StringSupport.java
  44. +38 −26 lib/ruby/stdlib/csv.rb
  45. +85 −0 spec/truffle/specs/truffle/rand.rb
  46. +0 −1 spec/truffle/tags/core/random/bytes_tags.txt
  47. +0 −10 spec/truffle/tags/core/random/rand_tags.txt
  48. +0 −1 spec/truffle/tags/core/random/srand_tags.txt
  49. +1 −16 spec/truffle/truffle.mspec
  50. +0 −3 test/mri/excludes/TestCSV/Encodings.rb
  51. 0 test/mri/excludes/TestCSV/{ → Encodings}/DifferentOFS.rb
  52. +2 −2 tool/jruby_eclipse
  53. +20 −7 tool/truffle/jruby_truffle_runner/lib/jruby+truffle_runner.rb
  54. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  55. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/cast/SplatCastNode.java
  56. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/constants/ReadConstantWithLexicalScopeNode.java
  57. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/constants/ReadLiteralConstantNode.java
  58. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/control/TraceNode.java
  59. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/BignumNodes.java
  60. +18 −14 truffle/src/main/java/org/jruby/truffle/nodes/core/EncodingNodes.java
  61. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/ExceptionNodes.java
  62. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
  63. +12 −11 truffle/src/main/java/org/jruby/truffle/nodes/core/InterpolatedStringNode.java
  64. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  65. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/LoadRequiredLibrariesNode.java
  66. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/MethodNodes.java
  67. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
  68. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
  69. +4 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  70. +149 −77 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  71. +5 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/ThreadBacktraceLocationNodes.java
  72. +6 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/TimeNodes.java
  73. +7 −8 truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
  74. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/UnboundMethodNodes.java
  75. +3 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayNodes.java
  76. +6 −6 truffle/src/main/java/org/jruby/truffle/nodes/core/fixnum/FixnumNodes.java
  77. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/defined/DefinedWrapperNode.java
  78. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/RubyCallNode.java
  79. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/ext/BigDecimalNodes.java
  80. +6 −0 truffle/src/main/java/org/jruby/truffle/nodes/ext/psych/PsychEmitterNodes.java
  81. +1 −0 truffle/src/main/java/org/jruby/truffle/nodes/ext/psych/PsychParserNodes.java
  82. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/globals/ReadLastBacktraceNode.java
  83. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/globals/ReadMatchReferenceNode.java
  84. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/interop/IndexLabelToRubyNode.java
  85. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/literal/BooleanLiteralNode.java
  86. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/literal/NilNode.java
  87. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/locals/ReadDeclarationVariableNode.java
  88. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/locals/ReadLocalVariableNode.java
  89. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/locals/WriteDeclarationVariableNode.java
  90. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/locals/WriteLocalVariableNode.java
  91. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/objects/AllocateObjectNode.java
  92. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/objects/ReadClassVariableNode.java
  93. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/objects/ReadInstanceVariableNode.java
  94. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/objects/SelfNode.java
  95. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/objects/WriteClassVariableNode.java
  96. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/objects/WriteInstanceVariableNode.java
  97. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/DirPrimitiveNodes.java
  98. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/FloatPrimitiveNodes.java
  99. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PointerPrimitiveNodes.java
  100. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PosixNodes.java
  101. +0 −112 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RandomPrimitiveNodes.java
  102. +134 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RandomizerPrimitiveNodes.java
  103. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusPrimitiveManager.java
  104. +31 −14 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/StringPrimitiveNodes.java
  105. +17 −9 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/TimePrimitiveNodes.java
  106. +5 −5 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
  107. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/supercall/GeneralSuperCallNode.java
  108. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/supercall/GeneralSuperReCallNode.java
  109. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/supercall/ZSuperOutsideMethodNode.java
  110. +13 −7 truffle/src/main/java/org/jruby/truffle/nodes/time/ReadTimeZoneNode.java
  111. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/yield/YieldNode.java
  112. +7 −7 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  113. +53 −42 truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  114. +65 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/EncodingOperations.java
  115. +5 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/StringOperations.java
  116. +3 −1 truffle/src/main/java/org/jruby/truffle/runtime/layouts/EncodingLayout.java
  117. +1 −0 truffle/src/main/java/org/jruby/truffle/runtime/layouts/Layouts.java
  118. +30 −0 truffle/src/main/java/org/jruby/truffle/runtime/layouts/rubinius/RandomizerLayout.java
  119. +3 −3 truffle/src/main/java/org/jruby/truffle/runtime/loader/FeatureLoader.java
  120. +6 −6 truffle/src/main/java/org/jruby/truffle/runtime/rubinius/DefaultRubiniusConfiguration.java
  121. +5 −0 truffle/src/main/ruby/core/rubinius/bootstrap/character.rb
  122. +3 −5 truffle/src/main/ruby/core/rubinius/common/random.rb
  123. +6 −0 truffle/src/main/ruby/core/string.rb
84 changes: 54 additions & 30 deletions core/src/main/java/org/jruby/RubyRandom.java
Original file line number Diff line number Diff line change
@@ -56,39 +56,55 @@ public static class RandomType {
RandomType(IRubyObject vseed) {
this.seed = vseed.convertToInteger();
if (seed instanceof RubyFixnum) {
long v = Math.abs(RubyNumeric.num2long(seed));
if (v == (v & 0xffffffffL)) {
this.mt = new Random((int) v);
} else {
int[] ints = new int[2];
ints[0] = (int) v;
ints[1] = (int) (v >> 32);
this.mt = new Random(ints);
}
this.mt = randomFromFixnum((RubyFixnum) seed);
} else if (seed instanceof RubyBignum) {
BigInteger big = ((RubyBignum) seed).getBigIntegerValue();
if (big.signum() < 0) {
big = big.abs();
}
byte[] buf = big.toByteArray();
int buflen = buf.length;
if (buf[0] == 0) {
buflen -= 1;
}
int len = Math.min((buflen + 3) / 4, Random.N);
int[] ints = bigEndianToInts(buf, len);
if (len <= 1) {
this.mt = new Random(ints[0]);
} else {
this.mt = new Random(ints);
}
this.mt = randomFromBignum((RubyBignum) seed);
} else {
throw vseed.getRuntime().newTypeError(
String.format("failed to convert %s into Integer", vseed.getMetaClass()
.getName()));
}
}

public static Random randomFromFixnum(RubyFixnum seed) {
return randomFromLong(RubyNumeric.num2long(seed));
}

public static Random randomFromLong(long seed) {
long v = Math.abs(seed);
if (v == (v & 0xffffffffL)) {
return new Random((int) v);
} else {
int[] ints = new int[2];
ints[0] = (int) v;
ints[1] = (int) (v >> 32);
return new Random(ints);
}
}

public static Random randomFromBignum(RubyBignum seed) {
BigInteger big = seed.getBigIntegerValue();
return randomFromBigInteger(big);
}

public static Random randomFromBigInteger(BigInteger big) {
if (big.signum() < 0) {
big = big.abs();
}
byte[] buf = big.toByteArray();
int buflen = buf.length;
if (buf[0] == 0) {
buflen -= 1;
}
int len = Math.min((buflen + 3) / 4, Random.N);
int[] ints = bigEndianToInts(buf, len);
if (len <= 1) {
return new Random(ints[0]);
} else {
return new Random(ints);
}
}

RandomType(IRubyObject vseed, RubyBignum state, int left) {
this.seed = vseed.convertToInteger();
byte[] bytes = state.getBigIntegerValue().toByteArray();
@@ -152,7 +168,7 @@ int getLeft() {
}

// big endian of bytes to reversed ints
private int[] bigEndianToInts(byte[] buf, int initKeyLen) {
private static int[] bigEndianToInts(byte[] buf, int initKeyLen) {
int[] initKey = new int[initKeyLen];
for (int idx = 0; idx < initKey.length; ++idx) {
initKey[idx] = getIntBigIntegerBuffer(buf, idx);
@@ -197,11 +213,15 @@ static void setIntBigIntegerBuffer(byte[] dest, int loc, int value) {

private static final int DEFAULT_SEED_CNT = 4;

public static BigInteger randomSeedBigInteger(java.util.Random random) {
byte[] seed = new byte[DEFAULT_SEED_CNT * 4];
random.nextBytes(seed);
return new BigInteger(seed).abs();
}

// c: random_seed
public static RubyBignum randomSeed(Ruby runtime) {
byte[] seed = new byte[DEFAULT_SEED_CNT * 4];
runtime.getRandom().nextBytes(seed);
return RubyBignum.newBignum(runtime, (new BigInteger(seed)).abs());
return RubyBignum.newBignum(runtime, randomSeedBigInteger(runtime.getRandom()));
}

public static RubyClass createRandomClass(Ruby runtime) {
@@ -358,6 +378,10 @@ public static RubyFloat randFloat(ThreadContext context, RandomType random) {
// limited_rand gets/returns ulong but we do this in signed long only.
private static IRubyObject randLimitedFixnum(ThreadContext context, RandomType random,
long limit) {
return RubyFixnum.newFixnum(context.getRuntime(), randLimitedFixnumInner(random.mt, limit));
}

public static long randLimitedFixnumInner(Random random, long limit) {
long val;
if (limit == 0) {
val = 0;
@@ -378,7 +402,7 @@ private static IRubyObject randLimitedFixnum(ThreadContext context, RandomType r
break;
}
}
return context.runtime.newFixnum(val);
return val;
}

// c: limited_big_rand
74 changes: 20 additions & 54 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -1674,10 +1674,12 @@ public IRubyObject str_eql_p19(ThreadContext context, IRubyObject other) {
/** rb_str_upcase / rb_str_upcase_bang
*
*/
@Deprecated
public RubyString upcase(ThreadContext context) {
return upcase19(context);
}

@Deprecated
public IRubyObject upcase_bang(ThreadContext context) {
return upcase_bang19(context);
}
@@ -1713,47 +1715,30 @@ public IRubyObject upcase_bang19(ThreadContext context) {
}

private IRubyObject singleByteUpcase(Ruby runtime, byte[]bytes, int s, int end) {
boolean modify = false;
while (s < end) {
int c = bytes[s] & 0xff;
if (ASCII.isLower(c)) {
bytes[s] = AsciiTables.ToUpperCaseTable[c];
modify = true;
}
s++;
}
boolean modify = StringSupport.singleByteUpcase(bytes, s, end);

return modify ? this : runtime.getNil();
}

private IRubyObject multiByteUpcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) {
boolean modify = false;
int c;
while (s < end) {
if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) {
if (ASCII.isLower(c)) {
bytes[s] = AsciiTables.ToUpperCaseTable[c];
modify = true;
}
s++;
} else {
c = codePoint(runtime, enc, bytes, s, end);
if (enc.isLower(c)) {
enc.codeToMbc(toUpper(enc, c), bytes, s);
modify = true;
}
s += codeLength(enc, c);
}
try {
boolean modify = StringSupport.multiByteUpcase(enc, bytes, s, end);

return modify ? this : runtime.getNil();
} catch (IllegalArgumentException e) {
throw runtime.newArgumentError(e.getMessage());
}
return modify ? this : runtime.getNil();
}

/** rb_str_downcase / rb_str_downcase_bang
*
*/
@Deprecated
public RubyString downcase(ThreadContext context) {
return downcase19(context);
}

@Deprecated
public IRubyObject downcase_bang(ThreadContext context) {
return downcase_bang19(context);
}
@@ -1789,38 +1774,19 @@ public IRubyObject downcase_bang19(ThreadContext context) {
}

private IRubyObject singleByteDowncase(Ruby runtime, byte[]bytes, int s, int end) {
boolean modify = false;
while (s < end) {
int c = bytes[s] & 0xff;
if (ASCII.isUpper(c)) {
bytes[s] = AsciiTables.ToLowerCaseTable[c];
modify = true;
}
s++;
}
boolean modify = StringSupport.singleByteDowncase(bytes, s, end);

return modify ? this : runtime.getNil();
}

private IRubyObject multiByteDowncase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) {
boolean modify = false;
int c;
while (s < end) {
if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) {
if (ASCII.isUpper(c)) {
bytes[s] = AsciiTables.ToLowerCaseTable[c];
modify = true;
}
s++;
} else {
c = codePoint(runtime, enc, bytes, s, end);
if (enc.isUpper(c)) {
enc.codeToMbc(toLower(enc, c), bytes, s);
modify = true;
}
s += codeLength(enc, c);
}
try {
boolean modify = StringSupport.multiByteDowncase(enc, bytes, s, end);

return modify ? this : runtime.getNil();
} catch (IllegalArgumentException e) {
throw runtime.newArgumentError(e.getMessage());
}
return modify ? this : runtime.getNil();
}


2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/BignumNode.java
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
/**
* Represents a big integer literal.
*/
public class BignumNode extends NumericNode {
public class BignumNode extends NumericNode implements SideEffectFree {
private BigInteger value;

public BignumNode(ISourcePosition position, BigInteger value) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/ClassVarNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* Access to a class variable.
*/
public class ClassVarNode extends Node implements INameNode {
public class ClassVarNode extends Node implements INameNode, SideEffectFree {
private String name;

public ClassVarNode(ISourcePosition position, String name) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/ComplexNode.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
*
* @author enebo
*/
public class ComplexNode extends NumericNode {
public class ComplexNode extends NumericNode implements SideEffectFree {
private NumericNode y;

public ComplexNode(ISourcePosition position, NumericNode y) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/FalseNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* Represents a false literal.
*/
public class FalseNode extends Node implements INameNode {
public class FalseNode extends Node implements INameNode, SideEffectFree {
public FalseNode(ISourcePosition position) {
super(position, false);
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/FileNode.java
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
/**
* Represents __FILE__ nodes
*/
public class FileNode extends StrNode {
public class FileNode extends StrNode implements SideEffectFree {
public FileNode(ISourcePosition position, ByteList value) {
super(position, value);
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/FixnumNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* Represents an integer literal.
*/
public class FixnumNode extends NumericNode implements ILiteralNode {
public class FixnumNode extends NumericNode implements ILiteralNode, SideEffectFree {
private long value;

public FixnumNode(ISourcePosition position, long value) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/FloatNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* Represents a float literal.
*/
public class FloatNode extends NumericNode implements ILiteralNode {
public class FloatNode extends NumericNode implements ILiteralNode, SideEffectFree {
private double value;

public FloatNode(ISourcePosition position, double value) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/GlobalVarNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* access to a global variable.
*/
public class GlobalVarNode extends Node implements INameNode {
public class GlobalVarNode extends Node implements INameNode, SideEffectFree {
private String name;

public GlobalVarNode(ISourcePosition position, String name) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/InstVarNode.java
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
/**
* Represents an instance variable accessor.
*/
public class InstVarNode extends Node implements INameNode {
public class InstVarNode extends Node implements INameNode, SideEffectFree {
private String name;

public InstVarNode(ISourcePosition position, String name) {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/LocalVarNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* Access a local variable
*/
public class LocalVarNode extends Node implements INameNode, IScopedNode {
public class LocalVarNode extends Node implements INameNode, IScopedNode, SideEffectFree {
// The name of the variable
private String name;

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/NilNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* represents 'nil'
*/
public class NilNode extends Node implements INameNode {
public class NilNode extends Node implements INameNode, SideEffectFree {
public NilNode(ISourcePosition position) {
super(position, false);
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/RationalNode.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
*
* @author enebo
*/
public class RationalNode extends NumericNode {
public class RationalNode extends NumericNode implements SideEffectFree {
private final long numerator;
private final long denominator;

12 changes: 12 additions & 0 deletions core/src/main/java/org/jruby/ast/RescueModNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.jruby.ast;

import org.jruby.lexer.yacc.ISourcePosition;

/**
* f rescue nil
*/
public class RescueModNode extends RescueNode {
public RescueModNode(ISourcePosition position, Node bodyNode, RescueBodyNode rescueNode) {
super(position, bodyNode, rescueNode, null /* else */);
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/SelfNode.java
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
/**
* Represents 'self' keyword
*/
public class SelfNode extends Node implements INameNode {
public class SelfNode extends Node implements INameNode, SideEffectFree {
public SelfNode(ISourcePosition position) {
super(position, false);
}
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ast/SideEffectFree.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jruby.ast;

/**
* Created by enebo on 9/26/15.
*/
public interface SideEffectFree {
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/StrNode.java
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
/**
* Representing a simple String literal.
*/
public class StrNode extends Node implements ILiteralNode {
public class StrNode extends Node implements ILiteralNode, SideEffectFree {
private final ByteList value;
private final int codeRange;

Loading