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

Commits on Jun 30, 2015

  1. Copy the full SHA
    12ed8d4 View commit details
  2. Copy the full SHA
    dff8eed View commit details
  3. adjust osgi after merge

    mkristian committed Jun 30, 2015
    Copy the full SHA
    01a3f68 View commit details
  4. Revert "Fixes #3056. java.lang.IncompatibleClassChangeError in 9.0.0.…

    …0 rc1"
    
    This fixed the issue but @subbuss rightly points out this scope should have
    been marked as BINDING_HAS_ESCAPED and thus this pass should not have even
    ran.
    
    This reverts commit 467e2f7.
    enebo committed Jun 30, 2015
    Copy the full SHA
    11bbc8a View commit details
  5. Fixes #3056. java.lang.IncompatibleClassChangeError in 9.0.0.0 rc1.

    This replaces the previous fix.  The previous fix was wrong because the
    code in question contained a closure and we were not marking the parent
    method as scope as BINDING_HAS_ESCAPED.  As a result, OptimizeDelegationPass
    was executing and mucking things up.  The previous fix corrected the pass
    to work with nested closures but it would create new problems if that closure
    did something which needed to conume the parents binding.
    
    The new fix is just a simple oversight in a few of our instructions.  ZSuper,
    UnresolvesSuper, and Match are calls but they were not calling their
    superclasses computeScopeFlags.  This is turn made the issue at hand not notice
    that the method contained a closure so it never marked BINDING_HAS_ESCAPED.
    
    This fix should potentially fix other weird errors where we did not set common
    call IRScope flags.
    enebo committed Jun 30, 2015
    Copy the full SHA
    debee1d View commit details
  6. Copy the full SHA
    2cd436d View commit details
  7. Copy the full SHA
    71f95f7 View commit details
  8. Fix hanging in modified FIFO read/write spec, tagged in 04db9d8.

    In MRI, rb_read_internal always just does a blind read on the
    descriptor, since kernel-level interruption of that blocking call
    is safe. On JDK, interruption of an NIO channel read generally
    closes that channel, because there's too much state between Java
    and the native side to ensure has been cleaned up correctly. Our
    normal behavior when dealing with NIO channels is then to always
    use select before blocking reads, so we can safely interrupt when
    there's no data available. However, this is not appropriate for
    native descriptors, like the FIFO in this case, because all ENXIO
    channels appear to be selectable (so we attempt it) and the
    additional select does not match MRI semantics here.
    
    My change is to modify our version of rb_read_internal to never
    select when using a native descriptor. ENXIO should not damage the
    descriptor when interrupted, and we should still be able to
    interrupt it properly.
    
    Note also that we generally use ENXIO native channels for the
    following cases, so only these cases should see any changed
    behavior:
    
    * stdio
    * some pipes
    * most files
    headius committed Jun 30, 2015
    Copy the full SHA
    9093145 View commit details
  9. Copy the full SHA
    363175b View commit details
  10. Always use variableNames for sizing growable scopes. Fixes #3089.

    variableNames is updated when IRScope gets set into StaticScope,
    and is used for other sizing and definition logic, so make it the
    sole place we get variable counts from when sizing scopes.
    headius committed Jun 30, 2015
    Copy the full SHA
    1e6e3ff View commit details
  11. Copy the full SHA
    b731175 View commit details
  12. Copy the full SHA
    1365a46 View commit details
  13. Copy the full SHA
    515d4a6 View commit details
  14. Remove some dead getIRScope usages. Use IRScope from IC rather than a…

    …sk staticScope for it (closer proximity to ic than ss from interpreterengine's perspective)
    enebo committed Jun 30, 2015
    Copy the full SHA
    9d2d570 View commit details
  15. Kill unused method invoker logic and related classes.

    We have largely committed to JRuby 9k being Java 7+, and to
    simplify the process of binding jitted method bodies we are using
    MethodHandle exclusively. Because of this, and because MHs work
    anywhere reflection works, we are removing the bytecode-generate
    CompiledMethod and the Reflected*Method.
    
    There's also a bit of peripheral cleanup for code that is defunct
    with these classes removed.
    headius committed Jun 30, 2015
    Copy the full SHA
    3f44a10 View commit details
  16. Copy the full SHA
    de65120 View commit details
  17. Copy the full SHA
    3e75be4 View commit details
  18. Copy the full SHA
    04e0ee3 View commit details
  19. Copy the full SHA
    5602cfc View commit details
  20. Copy the full SHA
    c3f6141 View commit details
  21. Copy the full SHA
    487303b View commit details
  22. Copy the full SHA
    232b219 View commit details
  23. Copy the full SHA
    0b0e32d View commit details
  24. Copy the full SHA
    52f0251 View commit details
  25. Copy the full SHA
    38e8bcd View commit details
  26. Copy the full SHA
    33ff860 View commit details
  27. Copy the full SHA
    7250ae5 View commit details

Commits on Jul 1, 2015

  1. Copy the full SHA
    db2bf39 View commit details
  2. Copy the full SHA
    d6a6654 View commit details
  3. Copy the full SHA
    af7aeff View commit details
  4. Copy the full SHA
    0a74bdd View commit details
  5. Copy the full SHA
    81c8c1d View commit details
  6. Revert "use jossl-0.9.8.dev to run test before releasing gem"

    needs more testing and fixes
    This reverts commit 71f95f7.
    mkristian committed Jul 1, 2015
    Copy the full SHA
    89b3c00 View commit details
  7. fix wrong java classname inside rubygems/defaults/jruby.rb

    fixes #3095
    
    Sponsored by Lookout Inc.
    mkristian committed Jul 1, 2015
    Copy the full SHA
    0473991 View commit details
  8. Merge branch 'jruby-1_7'

    Conflicts:
    	lib/ruby/shared/rubygems/defaults/jruby.rb
    mkristian committed Jul 1, 2015
    Copy the full SHA
    6c228c7 View commit details
  9. [Truffle] Use primitive types classes for primitives in static proper…

    …ties.
    
    * Integer.class would be for the case when we need to allow null.
    eregon committed Jul 1, 2015
    Copy the full SHA
    5e82154 View commit details
  10. Copy the full SHA
    c893eac View commit details
  11. Copy the full SHA
    1461bfe View commit details
  12. [Truffle] Call to_f on arbitrary objects in %f format string.

    Take two.  The first one broke array packing.
    nirvdrum committed Jul 1, 2015
    Copy the full SHA
    094e01f View commit details
  13. Copy the full SHA
    c61f2bb View commit details
  14. Copy the full SHA
    c9c2390 View commit details

Commits on Jul 2, 2015

  1. [Truffle] Fixed the starting byte location being used in the wrong ar…

    …gument in the :string_character_byte_index primitive.
    nirvdrum committed Jul 2, 2015
    Copy the full SHA
    5ef6c72 View commit details
  2. [Truffle] The :string_character_byte_index primitive should always ta…

    …ke as input and return as output, zero-offset indices.
    
    ByteLists with 'begin' values > 0 are an implementation detail and should be handled internally only.
    nirvdrum committed Jul 2, 2015
    Copy the full SHA
    f49d172 View commit details
  3. [Truffle] Use unsafe bytes in the :regexp_search_region primitive to …

    …be consistent with the MatchData calculations.
    nirvdrum committed Jul 2, 2015
    Copy the full SHA
    b840fcb View commit details
  4. [Truffle] Fix logic to find module to set the class variable.

    * Fixes remaining specs.
    eregon committed Jul 2, 2015
    Copy the full SHA
    05cbb63 View commit details
  5. Copy the full SHA
    b72b87e View commit details
  6. Copy the full SHA
    2b05ad7 View commit details
  7. Copy the full SHA
    a21af9c View commit details
  8. Copy the full SHA
    ebe28b9 View commit details
  9. Copy the full SHA
    52250e5 View commit details
Showing with 2,356 additions and 6,598 deletions.
  1. +51 −88 core/src/main/java/org/jruby/Ruby.java
  2. +0 −6 core/src/main/java/org/jruby/RubyBasicObject.java
  3. +1 −1 core/src/main/java/org/jruby/RubyFile.java
  4. +4 −5 core/src/main/java/org/jruby/RubySymbol.java
  5. +1 −1 core/src/main/java/org/jruby/ast/DXStrNode.java
  6. +1 −12 core/src/main/java/org/jruby/embed/bsf/JRubyEngine.java
  7. +1 −5 core/src/main/java/org/jruby/exceptions/JumpException.java
  8. +11 −7 core/src/main/java/org/jruby/ext/socket/Addrinfo.java
  9. +21 −28 core/src/main/java/org/jruby/ext/socket/RubySocket.java
  10. +18 −3 core/src/main/java/org/jruby/ext/socket/SocketUtils.java
  11. +0 −2 core/src/main/java/org/jruby/internal/runtime/RubyRunnable.java
  12. +0 −327 core/src/main/java/org/jruby/internal/runtime/methods/CompiledMethod.java
  13. +0 −22 core/src/main/java/org/jruby/internal/runtime/methods/DynamicMethod.java
  14. +0 −524 core/src/main/java/org/jruby/internal/runtime/methods/InvocationMethodFactory.java
  15. +0 −121 core/src/main/java/org/jruby/internal/runtime/methods/InvokeDynamicMethodFactory.java
  16. +0 −97 core/src/main/java/org/jruby/internal/runtime/methods/ReflectedCompiledMethod.java
  17. +0 −198 core/src/main/java/org/jruby/internal/runtime/methods/ReflectedJavaMethod.java
  18. +0 −111 core/src/main/java/org/jruby/internal/runtime/methods/ReflectedJavaMultiMethod.java
  19. +0 −177 core/src/main/java/org/jruby/internal/runtime/methods/ReflectionMethodFactory.java
  20. +1 −1 core/src/main/java/org/jruby/ir/instructions/BacktickInstr.java
  21. +1 −0 core/src/main/java/org/jruby/ir/instructions/MatchInstr.java
  22. +1 −0 core/src/main/java/org/jruby/ir/instructions/UnresolvedSuperInstr.java
  23. +1 −0 core/src/main/java/org/jruby/ir/instructions/ZSuperInstr.java
  24. +1 −2 core/src/main/java/org/jruby/ir/interpreter/BodyInterpreterEngine.java
  25. +3 −6 core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
  26. +5 −10 core/src/main/java/org/jruby/ir/interpreter/SimpleMethodInterpreterEngine.java
  27. +3 −4 core/src/main/java/org/jruby/ir/interpreter/StartupInterpreterEngine.java
  28. +11 −28 core/src/main/java/org/jruby/ir/passes/OptimizeDelegationPass.java
  29. +69 −3 core/src/main/java/org/jruby/ir/targets/Bootstrap.java
  30. +3 −4 core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter7.java
  31. +1 −1 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  32. +1 −10 core/src/main/java/org/jruby/javasupport/bsf/JRubyEngine.java
  33. +1 −1 core/src/main/java/org/jruby/parser/ParserSupport.java
  34. +4 −2 core/src/main/java/org/jruby/parser/StaticScope.java
  35. +0 −3 core/src/main/java/org/jruby/runtime/DynamicScope.arities.erb
  36. +0 −372 core/src/main/java/org/jruby/runtime/DynamicScope.erb
  37. +0 −103 core/src/main/java/org/jruby/runtime/Helpers.java
  38. +2 −147 core/src/main/java/org/jruby/runtime/MethodFactory.java
  39. +0 −50 core/src/main/java/org/jruby/runtime/invokedynamic/GlobalSite.java
  40. +8 −1,883 core/src/main/java/org/jruby/runtime/invokedynamic/InvocationLinker.java
  41. +3 −872 core/src/main/java/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
  42. +0 −49 core/src/main/java/org/jruby/runtime/invokedynamic/RubyConstantCallSite.java
  43. +4 −4 core/src/main/java/org/jruby/runtime/load/LibrarySearcher.java
  44. +15 −1 core/src/main/java/org/jruby/util/io/OpenFile.java
  45. +6 −0 core/src/main/ruby/jruby/jruby.rb
  46. +1 −1 core/src/main/ruby/jruby/kernel/kernel.rb
  47. +2 −2 lib/pom.rb
  48. +1 −1 lib/pom.xml
  49. +2 −2 lib/ruby/stdlib/rubygems/defaults/jruby.rb
  50. +110 −9 lib/ruby/truffle/truffle/bigdecimal.rb
  51. +62 −0 maven/jruby-complete/src/it/GH-3095-gem-install-with-forked-jruby/pom.xml
  52. +1 −1 ...y_bundles_with_embedded_gems/test/src/test/java/org/jruby/embed/osgi/test/JRubyOsgiEmbedTest.java
  53. +15 −0 spec/regression/GH-2558_socket_hostname_and_address_encoding_spec.rb
  54. +9 −0 spec/regression/GH-3035_spec.rb
  55. +4 −0 spec/ruby/core/binding/fixtures/classes.rb
  56. +12 −0 spec/ruby/core/binding/local_variable_set_spec.rb
  57. +15 −8 spec/ruby/core/file/socket_spec.rb
  58. +3 −0 spec/ruby/core/module/fixtures/classes.rb
  59. +16 −0 spec/ruby/core/module/prepended_spec.rb
  60. +2 −0 spec/ruby/library/bigdecimal/div_spec.rb
  61. +0 −4 spec/tags/ruby/core/file/realdirpath_tags.txt
  62. +0 −1 spec/tags/ruby/core/io/write_tags.txt
  63. +0 −1 spec/tags/ruby/core/kernel/require_relative_tags.txt
  64. +1 −0 spec/truffle/tags/core/binding/local_variable_set_tags.txt
  65. +0 −7 spec/truffle/tags/core/module/class_variable_defined_tags.txt
  66. +0 −6 spec/truffle/tags/core/module/class_variable_get_tags.txt
  67. +0 −7 spec/truffle/tags/core/module/class_variable_set_tags.txt
  68. +0 −2 spec/truffle/tags/core/module/class_variables_tags.txt
  69. +1 −0 spec/truffle/tags/core/module/prepended_tags.txt
  70. +0 −8 spec/truffle/tags/library/bigdecimal/div_tags.txt
  71. +0 −14 spec/truffle/tags/library/bigdecimal/divmod_tags.txt
  72. +0 −1 spec/truffle/tags/library/bigdecimal/double_fig_tags.txt
  73. +0 −6 spec/truffle/tags/library/bigdecimal/inspect_tags.txt
  74. +0 −12 spec/truffle/tags/library/bigdecimal/modulo_tags.txt
  75. +0 −7 spec/truffle/tags/library/bigdecimal/remainder_tags.txt
  76. +3 −0 spec/truffle/tags/library/bigdecimal/sqrt_tags.txt
  77. +0 −7 spec/truffle/tags/library/bigdecimal/to_s_tags.txt
  78. +0 −1 spec/truffle/tags/library/bigdecimal/ver_tags.txt
  79. +4 −1 spec/truffle/truffle.mspec
  80. +18 −7 tool/jt.rb
  81. +51 −0 tool/truffle-bisect.rb
  82. +5 −5 truffle/src/main/java/org/jruby/truffle/Main.java
  83. +9 −0 truffle/src/main/java/org/jruby/truffle/nodes/RubyGuards.java
  84. +0 −14 truffle/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  85. +2 −3 truffle/src/main/java/org/jruby/truffle/nodes/arguments/NodeArrayToObjectArrayNode.java
  86. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/arguments/ShouldDestructureNode.java
  87. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/cast/ArrayCastNode.java
  88. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/cast/BooleanCastWithDefaultNode.java
  89. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/cast/ProcOrNullNode.java
  90. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/cast/SplatCastNode.java
  91. +99 −0 truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToFNode.java
  92. +10 −4 truffle/src/main/java/org/jruby/truffle/nodes/control/WhenSplatNode.java
  93. +2 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/BignumNodes.java
  94. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java
  95. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/IntegerNodes.java
  96. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  97. +9 −15 truffle/src/main/java/org/jruby/truffle/nodes/core/MethodNodes.java
  98. +47 −12 truffle/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
  99. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/ObjectSpaceNodes.java
  100. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
  101. +0 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcessNodes.java
  102. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/RangeNodes.java
  103. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  104. +12 −19 truffle/src/main/java/org/jruby/truffle/nodes/core/SymbolNodes.java
  105. +38 −5 truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
  106. +1 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/UnboundMethodNodes.java
  107. +42 −43 truffle/src/main/java/org/jruby/truffle/nodes/core/array/AppendManyNode.java
  108. +27 −28 truffle/src/main/java/org/jruby/truffle/nodes/core/array/AppendOneNode.java
  109. +15 −15 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayBuilderNode.java
  110. +11 −11 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayConcatNode.java
  111. +10 −11 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayDropTailNode.java
  112. +10 −11 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayGetTailNode.java
  113. +18 −24 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayLiteralNode.java
  114. +345 −361 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayNodes.java
  115. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayPushNode.java
  116. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayReadDenormalizedNode.java
  117. +14 −15 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayReadNormalizedNode.java
  118. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayReadSliceDenormalizedNode.java
  119. +25 −26 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayReadSliceNormalizedNode.java
  120. +10 −11 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArraySliceNode.java
  121. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayWriteDenormalizedNode.java
  122. +53 −58 truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayWriteNormalizedNode.java
  123. +10 −10 truffle/src/main/java/org/jruby/truffle/nodes/core/array/EnsureCapacityArrayNode.java
  124. +9 −10 truffle/src/main/java/org/jruby/truffle/nodes/core/array/GeneralizeArrayNode.java
  125. +12 −13 truffle/src/main/java/org/jruby/truffle/nodes/core/array/PopOneNode.java
  126. +11 −8 truffle/src/main/java/org/jruby/truffle/nodes/core/hash/HashNodes.java
  127. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/RespondToNode.java
  128. +3 −3 truffle/src/main/java/org/jruby/truffle/nodes/dispatch/RubyCallNode.java
  129. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/exceptions/RescueSplatNode.java
  130. +447 −192 truffle/src/main/java/org/jruby/truffle/nodes/ext/BigDecimalNodes.java
  131. +1 −19 truffle/src/main/java/org/jruby/truffle/nodes/instrument/RubyWrapperNode.java
  132. +16 −0 truffle/src/main/java/org/jruby/truffle/nodes/internal/UnreachableCodeBranch.java
  133. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/methods/CallMethodNode.java
  134. +5 −6 truffle/src/main/java/org/jruby/truffle/nodes/methods/CanBindMethodToModuleNode.java
  135. +2 −3 truffle/src/main/java/org/jruby/truffle/nodes/methods/ExceptionTranslatingNode.java
  136. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/methods/LookupMethodNode.java
  137. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/objects/DefineOrGetClassNode.java
  138. +17 −7 truffle/src/main/java/org/jruby/truffle/nodes/objects/ReadClassVariableNode.java
  139. +5 −3 truffle/src/main/java/org/jruby/truffle/nodes/objects/WriteClassVariableNode.java
  140. +48 −15 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/ByteArrayNodes.java
  141. +7 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/ExceptionPrimitiveNodes.java
  142. +10 −11 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/IOBufferPrimitiveNodes.java
  143. +100 −7 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/IOPrimitiveNodes.java
  144. +23 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PosixNodes.java
  145. +4 −3 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RegexpPrimitiveNodes.java
  146. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusLastStringReadNode.java
  147. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusPrimitiveCallConstructor.java
  148. +1 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusPrimitiveConstructor.java
  149. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusPrimitiveManager.java
  150. +3 −4 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusPrimitiveNodeConstructor.java
  151. +5 −6 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/StringPrimitiveNodes.java
  152. +2 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/UndefinedPrimitiveNodes.java
  153. +0 −3 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
  154. +2 −3 truffle/src/main/java/org/jruby/truffle/nodes/supercall/GeneralSuperCallNode.java
  155. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/supercall/GeneralSuperReCallNode.java
  156. +0 −1 truffle/src/main/java/org/jruby/truffle/nodes/time/ReadTimeZoneNode.java
  157. +4 −3 truffle/src/main/java/org/jruby/truffle/nodes/yield/YieldNode.java
  158. +2 −4 truffle/src/main/java/org/jruby/truffle/pack/nodes/PackGuards.java
  159. +10 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/PackNode.java
  160. +47 −0 truffle/src/main/java/org/jruby/truffle/pack/nodes/type/ToDoubleWithCoercionNode.java
  161. +3 −3 truffle/src/main/java/org/jruby/truffle/pack/nodes/type/ToStringNode.java
  162. +1 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/Write8Node.java
  163. +3 −3 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/WriteBinaryStringNode.java
  164. +4 −4 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/WriteBitStringNode.java
  165. +1 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/WriteByteNode.java
  166. +2 −2 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/WriteHexStringNode.java
  167. +1 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/WritePaddedBytesNode.java
  168. +1 −1 truffle/src/main/java/org/jruby/truffle/pack/nodes/write/WriteUTF8CharacterNode.java
  169. +9 −3 truffle/src/main/java/org/jruby/truffle/pack/parser/FormatParser.java
  170. +47 −46 truffle/src/main/java/org/jruby/truffle/runtime/ModuleOperations.java
  171. +6 −5 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  172. +1 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/ArrayForeignAccessFactory.java
  173. +1 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyArray.java
  174. +1 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyBasicObject.java
  175. +2 −3 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyException.java
  176. +0 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyRegexp.java
  177. +1 −0 truffle/src/main/java/org/jruby/truffle/runtime/hash/BucketsStrategy.java
  178. +0 −29 truffle/src/main/java/org/jruby/truffle/runtime/rubinius/RubiniusByteArray.java
  179. +7 −0 truffle/src/main/java/org/jruby/truffle/runtime/sockets/NativeSockets.java
  180. +0 −1 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/ObjectSpaceManager.java
  181. +0 −1 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/SourceManager.java
  182. +16 −0 truffle/src/main/java/org/jruby/truffle/runtime/util/Function.java
  183. +3 −2 truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  184. +0 −1 truffle/src/main/java/org/jruby/truffle/translator/TranslatorDriver.java
  185. +5 −0 truffle/src/main/ruby/core/rubinius/api/shims/io.rb
139 changes: 51 additions & 88 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -818,39 +818,23 @@ public IRubyObject runScript(Script script, boolean wrap) {
throw new UnsupportedOperationException();
}

ThreadContext context = getCurrentContext();

try {
return script.load(context, getTopSelf(), wrap);
} catch (JumpException.ReturnJump rj) {
return (IRubyObject) rj.getValue();
}
return script.load(getCurrentContext(), getTopSelf(), wrap);
}

/**
* This is used for the "gets" loop, and we bypass 'load' to use an
* already-prepared, already-pushed scope for the script body.
*/
public IRubyObject runScriptBody(Script script) {
ThreadContext context = getCurrentContext();

try {
return script.__file__(context, getTopSelf(), Block.NULL_BLOCK);
} catch (JumpException.ReturnJump rj) {
return (IRubyObject) rj.getValue();
}
return script.__file__(getCurrentContext(), getTopSelf(), Block.NULL_BLOCK);
}

public IRubyObject runInterpreter(ThreadContext context, ParseResult parseResult, IRubyObject self) {
if (getInstanceConfig().getCompileMode() == CompileMode.TRUFFLE) {
throw new UnsupportedOperationException();
}

try {
return Interpreter.getInstance().execute(this, parseResult, self);
} catch (JumpException.ReturnJump rj) {
return (IRubyObject) rj.getValue();
}
return Interpreter.getInstance().execute(this, parseResult, self);
}

public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObject self) {
@@ -862,13 +846,7 @@ public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObj
getTruffleContext().execute((RootNode) rootNode);
return getNil();
} else {
try {

// FIXME: retrieve from IRManager unless lifus does it later
return Interpreter.getInstance().execute(this, rootNode, self);
} catch (JumpException.ReturnJump rj) {
return (IRubyObject) rj.getValue();
}
return Interpreter.getInstance().execute(this, rootNode, self);
}
}

@@ -2921,8 +2899,6 @@ public void loadFile(String scriptName, InputStream in, boolean wrap) {
}

runInterpreter(context, parseResult, self);
} catch (JumpException.ReturnJump rj) {
return;
} finally {
context.postNodeEval();
ThreadContext.popBacktrace(context);
@@ -2932,65 +2908,61 @@ public void loadFile(String scriptName, InputStream in, boolean wrap) {
public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
InputStream readStream = in;

Script script = null;
ScriptAndCode scriptAndCode = null;
String className = null;

try {
Script script = null;
ScriptAndCode scriptAndCode = null;
String className = null;
// read full contents of file, hash it, and try to load that class first
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int num;
while ((num = in.read(buffer)) > -1) {
baos.write(buffer, 0, num);
}
buffer = baos.toByteArray();
String hash = JITCompiler.getHashForBytes(buffer);
className = JITCompiler.RUBY_JIT_PREFIX + ".FILE_" + hash;

// FIXME: duplicated from ClassCache
Class contents;
try {
// read full contents of file, hash it, and try to load that class first
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int num;
while ((num = in.read(buffer)) > -1) {
baos.write(buffer, 0, num);
contents = jrubyClassLoader.loadClass(className);
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("found jitted code for " + filename + " at class: " + className);
}
buffer = baos.toByteArray();
String hash = JITCompiler.getHashForBytes(buffer);
className = JITCompiler.RUBY_JIT_PREFIX + ".FILE_" + hash;

// FIXME: duplicated from ClassCache
Class contents;
try {
contents = jrubyClassLoader.loadClass(className);
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("found jitted code for " + filename + " at class: " + className);
}
script = (Script)contents.newInstance();
readStream = new ByteArrayInputStream(buffer);
} catch (ClassNotFoundException cnfe) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("no jitted code in classloader for file " + filename + " at class: " + className);
}
} catch (InstantiationException ie) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("jitted code could not be instantiated for file " + filename + " at class: " + className);
}
} catch (IllegalAccessException iae) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("jitted code could not be instantiated for file " + filename + " at class: " + className);
}
script = (Script) contents.newInstance();
readStream = new ByteArrayInputStream(buffer);
} catch (ClassNotFoundException cnfe) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("no jitted code in classloader for file " + filename + " at class: " + className);
}
} catch (InstantiationException ie) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("jitted code could not be instantiated for file " + filename + " at class: " + className);
}
} catch (IllegalAccessException iae) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("jitted code could not be instantiated for file " + filename + " at class: " + className);
}
} catch (IOException ioe) {
// TODO: log something?
}
} catch (IOException ioe) {
// TODO: log something?
}

// script was not found in cache above, so proceed to compile
RootNode scriptNode = (RootNode) parseFile(readStream, filename, null);
if (script == null) {
scriptAndCode = tryCompile(scriptNode, new ClassDefiningJRubyClassLoader(jrubyClassLoader));
if (scriptAndCode != null) script = scriptAndCode.script();
}
// script was not found in cache above, so proceed to compile
RootNode scriptNode = (RootNode) parseFile(readStream, filename, null);
if (script == null) {
scriptAndCode = tryCompile(scriptNode, new ClassDefiningJRubyClassLoader(jrubyClassLoader));
if (scriptAndCode != null) script = scriptAndCode.script();
}

if (script == null) {
failForcedCompile(scriptNode);
if (script == null) {
failForcedCompile(scriptNode);

runInterpreter(scriptNode);
} else {
runScript(script, wrap);
}
} catch (JumpException.ReturnJump rj) {
return;
runInterpreter(scriptNode);
} else {
runScript(script, wrap);
}
}

@@ -2999,14 +2971,7 @@ public void loadScript(Script script) {
}

public void loadScript(Script script, boolean wrap) {
IRubyObject self = getTopSelf();
ThreadContext context = getCurrentContext();

try {
script.load(context, self, wrap);
} catch (JumpException.ReturnJump rj) {
return;
}
script.load(getCurrentContext(), getTopSelf(), wrap);
}

/**
@@ -3027,8 +2992,6 @@ public void loadExtension(String extName, BasicLibraryService extension, boolean
extension.basicLoad(this);
} catch (IOException ioe) {
throw newIOErrorFromException(ioe);
} catch (JumpException.ReturnJump rj) {
return;
} finally {
context.postNodeEval();
}
6 changes: 0 additions & 6 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -1700,9 +1700,6 @@ protected IRubyObject yieldUnder(final ThreadContext context, RubyModule under,
IRubyObject valueInYield = RubyArray.newArrayNoCopy(context.runtime, args);
return setupBlock(block, evalType).yieldArray(context, valueInYield, this); // context.getRubyClass());
}
//TODO: Should next and return also catch here?
} catch (JumpException.BreakJump bj) {
return (IRubyObject) bj.getValue();
} finally {
block.getBinding().setVisibility(savedVisibility);
block.getBinding().setSelf(savedBindingSelf);
@@ -1736,9 +1733,6 @@ protected IRubyObject yieldUnder(final ThreadContext context, RubyModule under,

try {
return setupBlock(block, evalType).yieldNonArray(context, this, this); //, context.getRubyClass());
//TODO: Should next and return also catch here?
} catch (JumpException.BreakJump bj) {
return (IRubyObject) bj.getValue();
} finally {
block.getBinding().setVisibility(savedVisibility);
block.getBinding().setSelf(savedBindingSelf);
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -789,7 +789,7 @@ public static IRubyObject absolute_path(ThreadContext context, IRubyObject recv,

@JRubyMethod(required = 1, optional = 1, meta = true)
public static IRubyObject realdirpath(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
return expandPathInternal(context, recv, args, false, false);
return expandPathInternal(context, recv, args, false, true);
}

@JRubyMethod(required = 1, optional = 1, meta = true)
9 changes: 4 additions & 5 deletions core/src/main/java/org/jruby/RubySymbol.java
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@
import org.jruby.anno.JRubyMethod;
import org.jruby.ast.util.ArgsUtil;
import org.jruby.compiler.Constantizable;
import org.jruby.RubyEncoding;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Binding;
@@ -65,6 +66,7 @@

import java.lang.ref.WeakReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.Arrays;

import static org.jruby.util.StringSupport.codeLength;
import static org.jruby.util.StringSupport.codePoint;
@@ -962,13 +964,10 @@ private static int javaStringHashCode(String str) {
private static int javaStringHashCode(ByteList iso8859) {
int h = 0;
int length = iso8859.length();
if (h == 0 && length > 0) {
if (length > 0) {
byte val[] = iso8859.getUnsafeBytes();
int begin = iso8859.begin();

for (int i = 0; i < length; i++) {
h = 31 * h + val[begin + i];
}
h = new String(val, begin, length, RubyEncoding.ISO).hashCode();
}
return h;
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/DXStrNode.java
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
*/
public class DXStrNode extends DNode implements ILiteralNode {
public DXStrNode(ISourcePosition position, DStrNode node) {
super(position);
super(position, node.getEncoding());
addAll(node);
}

13 changes: 1 addition & 12 deletions core/src/main/java/org/jruby/embed/bsf/JRubyEngine.java
Original file line number Diff line number Diff line change
@@ -46,7 +46,6 @@
import org.apache.bsf.BSFManager;
import org.apache.bsf.util.BSFEngineImpl;
import org.apache.bsf.util.BSFFunctions;
import org.jruby.CompatVersion;
import org.jruby.Ruby;
import org.jruby.RubyObject;
import org.jruby.embed.EmbedRubyObjectAdapter;
@@ -57,7 +56,6 @@
import org.jruby.embed.util.SystemPropertyCatcher;
import org.jruby.embed.variable.BiVariable;
import org.jruby.embed.variable.VariableInterceptor;
import org.jruby.exceptions.JumpException;
import org.jruby.exceptions.RaiseException;
import org.jruby.internal.runtime.GlobalVariable;
import org.jruby.javasupport.Java;
@@ -214,16 +212,7 @@ public void handleException(BSFException bsfExcptn) {
*/
private static void printException(Ruby runtime, Exception exception) {
assert exception != null;
if (exception instanceof RaiseException) {
JumpException je = (JumpException)exception;
if (je instanceof RaiseException) {
runtime.printError(((RaiseException)je).getException());
} else if (je instanceof JumpException.BreakJump) {
runtime.getErrorStream().println("break without block.");
} else if (je instanceof JumpException.ReturnJump) {
runtime.getErrorStream().println("return without block.");
}
}
if (exception instanceof RaiseException) runtime.printError(((RaiseException)exception).getException());
}

private static class FunctionsGlobalVariable implements IAccessor {
6 changes: 1 addition & 5 deletions core/src/main/java/org/jruby/exceptions/JumpException.java
Original file line number Diff line number Diff line change
@@ -82,13 +82,9 @@ public RaiseException buildException(Ruby runtime) {
}
}

public static class BreakJump extends FlowControlException { public BreakJump(int t, Object v) { super(Reason.BREAK, t, v); } }
public static class NextJump extends FlowControlException { public NextJump(Object v) { super(Reason.NEXT, 0, v); } }
public static class RedoJump extends FlowControlException { public RedoJump() {super(Reason.REDO); } }
public static class SpecialJump extends FlowControlException { public SpecialJump() {super(Reason.NOREASON); } }
public static final SpecialJump SPECIAL_JUMP = new SpecialJump();
public static class ReturnJump extends FlowControlException { public ReturnJump(int t, Object v) { super(Reason.RETURN, t, v); }}


/**
* Constructor for flow-control-only JumpExceptions.
*/
18 changes: 11 additions & 7 deletions core/src/main/java/org/jruby/ext/socket/Addrinfo.java
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import jnr.constants.platform.AddressFamily;
import jnr.constants.platform.ProtocolFamily;
import jnr.constants.platform.Sock;
import jnr.netdb.Protocol;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
@@ -187,6 +188,8 @@ private void initializeCommon(Ruby runtime, IRubyObject sockaddr, IRubyObject fa
} else {
this.port = (int) port.convertToInteger().getLongValue();
}

protocol = Protocol.getProtocolByName("tcp");
} catch (IOException ioe) {
throw runtime.newIOErrorFromException(ioe);
}
@@ -244,25 +247,25 @@ public static IRubyObject unix(ThreadContext context, IRubyObject recv, IRubyObj

@JRubyMethod
public IRubyObject afamily(ThreadContext context) {
return context.runtime.newFixnum(pfamily.intValue());
return context.runtime.newFixnum(afamily.intValue());
}

@JRubyMethod(notImplemented = true)
@JRubyMethod
public IRubyObject pfamily(ThreadContext context) {
return context.runtime.newFixnum(afamily.intValue());
return context.runtime.newFixnum(pfamily.intValue());
}

@JRubyMethod(notImplemented = true)
@JRubyMethod
public IRubyObject socktype(ThreadContext context) {
if (sock == null) {
return context.runtime.newFixnum(0);
}
return context.runtime.newFixnum(sock.intValue());
}

@JRubyMethod(notImplemented = true)
@JRubyMethod
public IRubyObject protocol(ThreadContext context) {
return context.runtime.newFixnum(port);
return context.runtime.newFixnum(protocol.getProto());
}

@JRubyMethod
@@ -543,5 +546,6 @@ public String toString(){
private String interfaceName;
private boolean interfaceLink;
private NetworkInterface networkInterface;
private boolean isBroadcast;
private boolean isBroadcast;
private Protocol protocol = Protocol.getProtocolByNumber(0);
}
49 changes: 21 additions & 28 deletions core/src/main/java/org/jruby/ext/socket/RubySocket.java
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@
import jnr.constants.platform.SocketLevel;
import jnr.constants.platform.SocketOption;
import jnr.constants.platform.TCP;
import jnr.netdb.Protocol;
import jnr.unixsocket.UnixSocketAddress;
import jnr.unixsocket.UnixSocketChannel;
import org.jruby.Ruby;
@@ -165,12 +166,8 @@ public static IRubyObject for_fd(ThreadContext context, IRubyObject socketClass,
}
}

public IRubyObject initialize(ThreadContext context, IRubyObject domain, IRubyObject type, IRubyObject protocol) {
return initialize(context, domain, type, protocol);
}

@JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE)
public IRubyObject initialize19(ThreadContext context, IRubyObject domain, IRubyObject type) {
public IRubyObject initialize(ThreadContext context, IRubyObject domain, IRubyObject type) {
Ruby runtime = context.runtime;

initFieldsFromArgs(runtime, domain, type);
@@ -183,7 +180,7 @@ public IRubyObject initialize19(ThreadContext context, IRubyObject domain, IRuby
}

@JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE)
public IRubyObject initialize19(ThreadContext context, IRubyObject domain, IRubyObject type, IRubyObject protocol) {
public IRubyObject initialize(ThreadContext context, IRubyObject domain, IRubyObject type, IRubyObject protocol) {
Ruby runtime = context.runtime;

initFieldsFromArgs(runtime, domain, type, protocol);
@@ -216,7 +213,7 @@ public IRubyObject connect(ThreadContext context, IRubyObject arg) {
@JRubyMethod()
public IRubyObject bind(ThreadContext context, IRubyObject arg) {
InetSocketAddress iaddr = null;

if (arg instanceof Addrinfo){
Addrinfo addr = (Addrinfo) arg;
iaddr = new InetSocketAddress(addr.getInetAddress().getHostAddress(), addr.getPort());
@@ -263,7 +260,7 @@ public IRubyObject accept(ThreadContext context) {
public static IRubyObject gethostname(ThreadContext context, IRubyObject recv) {
return SocketUtils.gethostname(context);
}

@JRubyMethod(meta = true)
public static IRubyObject getifaddrs(ThreadContext context, IRubyObject recv) {
RubyArray list = RubyArray.newArray(context.runtime);
@@ -370,19 +367,20 @@ private void initFieldsFromDescriptor(Ruby runtime, ChannelFD fd) {
// just using AF_INET since we can't tell from SocketChannel...
soDomain = AddressFamily.AF_INET;
soType = Sock.SOCK_STREAM;
soProtocol = ProtocolFamily.PF_INET;
soProtocolFamily = ProtocolFamily.PF_INET;
soProtocol = Protocol.getProtocolByName("tcp");

} else if (mainChannel instanceof UnixSocketChannel) {
soDomain = AddressFamily.AF_UNIX;
soType = Sock.SOCK_STREAM;
soProtocol = ProtocolFamily.PF_UNIX;
soProtocolFamily = ProtocolFamily.PF_UNIX;

} else if (mainChannel instanceof DatagramChannel) {
// datagram, set accordingly
// again, AF_INET
soDomain = AddressFamily.AF_INET;
soType = Sock.SOCK_DGRAM;
soProtocol = ProtocolFamily.PF_INET;
soProtocolFamily = ProtocolFamily.PF_INET;

} else {
throw runtime.newErrnoENOTSOCKError("can't Socket.new/for_fd against a non-socket");
@@ -417,15 +415,15 @@ protected ChannelFD initChannelFD(Ruby runtime) {
try {
if(soType == Sock.SOCK_STREAM) {

if (soProtocol == ProtocolFamily.PF_UNIX ||
soProtocol == ProtocolFamily.PF_LOCAL) {
if (soProtocolFamily == ProtocolFamily.PF_UNIX ||
soProtocolFamily == ProtocolFamily.PF_LOCAL) {
channel = UnixSocketChannel.open();
} else if (soProtocol == ProtocolFamily.PF_INET ||
soProtocol == ProtocolFamily.PF_INET6 ||
soProtocol == ProtocolFamily.PF_UNSPEC) {
} else if (soProtocolFamily == ProtocolFamily.PF_INET ||
soProtocolFamily == ProtocolFamily.PF_INET6 ||
soProtocolFamily == ProtocolFamily.PF_UNSPEC) {
channel = SocketChannel.open();
} else {
throw runtime.newArgumentError("unsupported protocol family `" + soProtocol + "'");
throw runtime.newArgumentError("unsupported protocol family `" + soProtocolFamily + "'");
}

} else if(soType == Sock.SOCK_DGRAM) {
@@ -445,13 +443,7 @@ protected ChannelFD initChannelFD(Ruby runtime) {
}

private void initProtocol(Ruby runtime, IRubyObject protocol) {
ProtocolFamily protocolFamily = SocketUtils.protocolFamilyFromArg(protocol);

if (protocolFamily == null) {
return; // no protocol specified, ignore it
}

soProtocol = protocolFamily;
soProtocol = SocketUtils.protocolFromArg(protocol);
}

private void initType(Ruby runtime, IRubyObject type) {
@@ -472,7 +464,7 @@ private void initDomain(Ruby runtime, IRubyObject domain) {
}

soDomain = family;
soProtocol = ProtocolFamily.valueOf("PF" + soDomain.name().substring(2));
soProtocolFamily = ProtocolFamily.valueOf("PF" + soDomain.name().substring(2));
}

private void doConnectNonblock(ThreadContext context, Channel channel, SocketAddress addr) {
@@ -617,7 +609,7 @@ private static String formatMessage(Throwable e, String defaultMsg) {
private SocketAddress addressForChannel(ThreadContext context, IRubyObject arg) {
if (arg instanceof Addrinfo) return Sockaddr.addressFromArg(context, arg);

switch (soProtocol) {
switch (soProtocolFamily) {
case PF_UNIX:
case PF_LOCAL:
return Sockaddr.addressFromSockaddr_un(context, arg);
@@ -628,7 +620,7 @@ private SocketAddress addressForChannel(ThreadContext context, IRubyObject arg)
return Sockaddr.addressFromSockaddr_in(context, arg);

default:
throw context.runtime.newArgumentError("unsupported protocol family `" + soProtocol + "'");
throw context.runtime.newArgumentError("unsupported protocol family `" + soProtocolFamily + "'");
}
}

@@ -647,8 +639,9 @@ public static RuntimeException sockerr(Ruby runtime, String msg) {
public static final int MSG_WAITALL = 0x100;

protected AddressFamily soDomain;
protected ProtocolFamily soProtocolFamily;
protected Sock soType;
protected ProtocolFamily soProtocol;
protected Protocol soProtocol = Protocol.getProtocolByNumber(0);

private static final String JRUBY_SERVER_SOCKET_ERROR =
"use ServerSocket for servers (http://wiki.jruby.org/ServerSocket)";
21 changes: 18 additions & 3 deletions core/src/main/java/org/jruby/ext/socket/SocketUtils.java
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import jnr.constants.platform.AddressFamily;
import jnr.constants.platform.ProtocolFamily;
import jnr.constants.platform.Sock;
import jnr.netdb.Protocol;
import jnr.netdb.Service;
import org.jruby.Ruby;
import org.jruby.RubyArray;
@@ -75,12 +76,12 @@ public static IRubyObject gethostname(ThreadContext context) {
Ruby runtime = context.runtime;

try {
return runtime.newString(InetAddress.getLocalHost().getHostName());
return RubyString.newInternalFromJavaExternal(context.runtime, InetAddress.getLocalHost().getHostName());

} catch(UnknownHostException e) {

try {
return runtime.newString(InetAddress.getByAddress(new byte[]{0,0,0,0}).getHostName());
return RubyString.newInternalFromJavaExternal(context.runtime, InetAddress.getByAddress(new byte[]{0, 0, 0, 0}).getHostName());

} catch(UnknownHostException e2) {
throw sockerr(runtime, "gethostname: name or service not known");
@@ -509,7 +510,7 @@ public static InetAddress getRubyInetAddress(ByteList address) throws UnknownHos

public static IRubyObject getaddress(ThreadContext context, IRubyObject hostname) {
try {
return context.runtime.newString(InetAddress.getByName(hostname.convertToString().toString()).getHostAddress());
return RubyString.newInternalFromJavaExternal(context.runtime, InetAddress.getByName(hostname.convertToString().toString()).getHostAddress());
} catch(UnknownHostException e) {
throw sockerr(context.runtime, "getaddress: name or service not known");
}
@@ -618,6 +619,20 @@ static ProtocolFamily protocolFamilyFromArg(IRubyObject protocol) {

return protocolFamily;
}

static Protocol protocolFromArg(IRubyObject protocol) {
Protocol proto;

if(protocol instanceof RubyString || protocol instanceof RubySymbol) {
String protocolString = protocol.toString();
proto = Protocol.getProtocolByName(protocolString);
} else {
int protocolInt = RubyNumeric.fix2int(protocol);
proto = Protocol.getProtocolByNumber(protocolInt);
}

return proto;
}

public static int portToInt(IRubyObject port) {
return port.isNil() ? 0 : RubyNumeric.fix2int(port);
Original file line number Diff line number Diff line change
@@ -99,8 +99,6 @@ public void run() {
IRubyObject result = proc.call(context, arguments);
if (runtime.hasEventHooks() && runtime.is2_0()) context.trace(RubyEvent.THREAD_END, null, frameClass);
rubyThread.cleanTerminate(result);
} catch (JumpException.ReturnJump rj) {
rubyThread.exceptionRaised(rj.buildException(runtime));
} catch (MainExitException mee) {
// Someone called exit!, so we need to kill the main thread
runtime.getThreadService().getMainThread().kill();

This file was deleted.

Original file line number Diff line number Diff line change
@@ -33,11 +33,7 @@
import java.lang.reflect.Method;
import java.util.Arrays;
import org.jruby.MetaClass;
import org.jruby.Ruby;
import org.jruby.RubyLocalJumpError;
import org.jruby.RubyModule;
import org.jruby.exceptions.JumpException;
import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
@@ -590,22 +586,4 @@ public MethodData getMethodData() {
public void setNotImplemented(boolean setNotImplemented) {
this.notImplemented = setNotImplemented;
}

protected IRubyObject handleRedo(Ruby runtime) throws RaiseException {
throw runtime.newLocalJumpError(RubyLocalJumpError.Reason.REDO, runtime.getNil(), "unexpected redo");
}

protected IRubyObject handleReturn(ThreadContext context, JumpException.ReturnJump rj, int callNumber) {
if (rj.getTarget() == callNumber) {
return (IRubyObject) rj.getValue();
}
throw rj;
}

protected IRubyObject handleBreak(ThreadContext context, Ruby runtime, JumpException.BreakJump bj, int callNumber) {
if (bj.getTarget() == callNumber) {
throw runtime.newLocalJumpError(RubyLocalJumpError.Reason.BREAK, runtime.getNil(), "unexpected break");
}
throw bj;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -76,123 +76,6 @@ public InvokeDynamicMethodFactory(ClassLoader classLoader) {
super(classLoader);
}

/**
* Use code generation to provide a method handle for a compiled Ruby method.
*
* @see org.jruby.runtime.MethodFactory#getCompiledMethod
*/
@Override
public DynamicMethod getCompiledMethodLazily(
RubyModule implementationClass,
String rubyName,
String javaName,
Visibility visibility,
StaticScope scope,
Object scriptObject,
CallConfiguration callConfig,
ISourcePosition position,
String parameterDesc,
MethodNodes methodNodes) {

return getCompiledMethod(implementationClass, rubyName, javaName, visibility, scope, scriptObject, callConfig, position, parameterDesc, methodNodes);
}

/**
* Use JSR292 to provide a method handle for a compiled Ruby method.
*
* @see org.jruby.runtime.MethodFactory#getCompiledMethod
*/
@Override
public DynamicMethod getCompiledMethod(
RubyModule implementationClass,
String rubyName,
String javaName,
Visibility visibility,
StaticScope scope,
Object scriptObject,
CallConfiguration callConfig,
ISourcePosition position,
String parameterDesc,
MethodNodes methodNodes) {
Class scriptClass = scriptObject.getClass();

try {
MethodHandle[] targets = new MethodHandle[5];
SmartHandle directCall;
int specificArity = -1;

// acquire handle to the actual method body
// FIXME: This passes in Arity but then gets info from static scope?
if (!safeFixedSignature(scope.getSignature())) {
// variable arity method (has optional, rest, or more args than we can splat)
directCall = SmartBinder
.from(VARIABLE_ARITY_SIGNATURE.prependArg("script", scriptClass))
.invokeStaticQuiet(LOOKUP, scriptClass, javaName)
.bindTo(scriptObject);
} else {
// specific arity method (less than 4 required args only)
specificArity = scope.getSignature().required();

directCall = SmartBinder
.from(SPECIFIC_ARITY_SIGNATURES[specificArity].prependArg("script", scriptClass))
.invokeStaticQuiet(LOOKUP, scriptClass, javaName)
.bindTo(scriptObject);
}

// wrap with framing logic if needed
if (!callConfig.isNoop()) {
directCall = SmartHandle
.from(directCall.signature(), InvocationLinker.wrapWithFraming(directCall.signature(), callConfig, implementationClass, rubyName, directCall.handle(), scope));
}

// provide a variable-arity path for specific-arity target
SmartHandle variableCall;
if (specificArity >= 0) {
SmartHandle arityCheck = SmartBinder
.from(ARITY_CHECK_FOLD)
.append(new String[]{"min", "max"}, new Class[]{int.class, int.class}, specificArity, specificArity)
.cast(ARITY_CHECK_SIGNATURE)
.invokeStaticQuiet(LOOKUP, Arity.class, "checkArgumentCount");

variableCall = SmartBinder
.from(VARIABLE_ARITY_SIGNATURE)
.foldVoid(arityCheck)
.permute("script", "context", "self", "block", "args")
.spread("arg", specificArity)
.permute("script", "context", "self", "arg*", "block")
.invoke(directCall);
} else {
variableCall = directCall;
}

// TODO: tracing

// pre-call trace
if (RubyInstanceConfig.FULL_TRACE_ENABLED) {
}

if (specificArity >= 0) {
targets[specificArity] = directCall.handle();
targets[4] = variableCall.handle();
} else {
targets[4] = directCall.handle();
}

return new HandleMethod(implementationClass, visibility, callConfig, targets, parameterDesc);

} catch(Exception e) {
throw new RuntimeException(e);
}
}

@Override
public byte[] getCompiledMethodOffline(
String rubyName, String javaName, String className, String invokerPath,
StaticScope scope, CallConfiguration callConfig, String filename, int line,
MethodNodes methodNodes) {
throw new RuntimeException("no offline support for invokedynamic handles");
}

@Override
public DynamicMethod getAnnotatedMethod(RubyModule implementationClass, List<JavaMethodDescriptor> descs) {
JavaMethodDescriptor desc1 = descs.get(0);
@@ -441,8 +324,4 @@ public DynamicMethod getAnnotatedMethod(RubyModule implementationClass, JavaMeth
.permute("context", "self", "arg*", "block");
}
}

private static final SmartHandle HANDLE_GETTER = SmartBinder
.from(Signature.returning(MethodHandle.class).appendArg("targets", MethodHandle[].class).appendArg("arity", int.class))
.arrayGet();
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco

for (Operand p: operands) {
RubyBasicObject piece = (RubyBasicObject) p.retrieve(context, self, currScope, currDynScope, temp);
newString.append((piece instanceof RubyString) ? (RubyString) piece : piece.to_s());
newString.append19((piece instanceof RubyString) ? (RubyString) piece : piece.to_s());
}

newString.setFrozen(true);
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ public MatchInstr(Variable result, Operand receiver, Operand arg) {

@Override
public boolean computeScopeFlags(IRScope scope) {
super.computeScopeFlags(scope);
// $~ is implicitly used since Backref and NthRef operands
// access it and $~ is not made explicit in those operands.
scope.getFlags().add(USES_BACKREF_OR_LASTLINE);
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ public UnresolvedSuperInstr(Variable result, Operand receiver, Operand[] args, O

@Override
public boolean computeScopeFlags(IRScope scope) {
super.computeScopeFlags(scope);
scope.getFlags().add(IRFlags.REQUIRES_FRAME); // for current class and method name
scope.getFlags().add(IRFlags.REQUIRES_DYNSCOPE); // for current class and method name
return true;
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ public ZSuperInstr(Variable result, Operand receiver, Operand[] args, Operand cl

@Override
public boolean computeScopeFlags(IRScope scope) {
super.computeScopeFlags(scope);
scope.getFlags().add(IRFlags.USES_ZSUPER);
scope.getFlags().add(IRFlags.CAN_CAPTURE_CALLERS_BINDING);
return true;
Original file line number Diff line number Diff line change
@@ -47,7 +47,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
@@ -205,7 +204,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
} catch (Throwable t) {
ipc = instr.getRPC();
if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

Original file line number Diff line number Diff line change
@@ -3,11 +3,9 @@
import org.jruby.RubyBoolean;
import org.jruby.RubyFixnum;
import org.jruby.RubyFloat;
import org.jruby.RubyHash;
import org.jruby.RubyModule;
import org.jruby.common.IRubyWarnings;
import org.jruby.exceptions.Unrescuable;
import org.jruby.ir.IRScope;
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.BreakInstr;
import org.jruby.ir.instructions.CheckArityInstr;
@@ -118,13 +116,12 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();
boolean acceptsKeywordArgument = interpreterContext.receivesKeywordArguments();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
boolean profile = IRRuntimeHelpers.inProfileMode();
Integer scopeVersion = profile ? Profiler.initProfiling(scope) : 0;
Integer scopeVersion = profile ? Profiler.initProfiling(interpreterContext.getScope()) : 0;

// Enter the looooop!
while (ipc < n) {
@@ -153,7 +150,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,
receiveArg(context, instr, operation, args, acceptsKeywordArgument, currDynScope, temp, exception, block);
break;
case CALL_OP:
if (profile) Profiler.updateCallSite(instr, scope, scopeVersion);
if (profile) Profiler.updateCallSite(instr, interpreterContext.getScope(), scopeVersion);
processCall(context, instr, operation, currDynScope, currScope, temp, self);
break;
case RET_OP:
@@ -185,7 +182,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,
ipc = instr.getRPC();

if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

Original file line number Diff line number Diff line change
@@ -84,7 +84,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
@@ -255,7 +254,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
} catch (Throwable t) {
ipc = instr.getRPC();
if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

@@ -279,7 +278,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
@@ -457,7 +455,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
} catch (Throwable t) {
ipc = instr.getRPC();
if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

@@ -481,7 +479,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
@@ -660,7 +657,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
} catch (Throwable t) {
ipc = instr.getRPC();
if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

@@ -684,7 +681,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
@@ -864,7 +860,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
} catch (Throwable t) {
ipc = instr.getRPC();
if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

@@ -888,7 +884,6 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
@@ -1060,7 +1055,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
} catch (Throwable t) {
ipc = instr.getRPC();
if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

Original file line number Diff line number Diff line change
@@ -43,15 +43,14 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
IRScope scope = currScope.getIRScope();
boolean acceptsKeywordArgument = interpreterContext.receivesKeywordArguments();

Stack<Integer> rescuePCs = new Stack<>();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
boolean profile = IRRuntimeHelpers.inProfileMode();
Integer scopeVersion = profile ? Profiler.initProfiling(scope) : 0;
Integer scopeVersion = profile ? Profiler.initProfiling(interpreterContext.getScope()) : 0;

// Enter the looooop!
while (ipc < n) {
@@ -74,7 +73,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,
receiveArg(context, instr, operation, args, acceptsKeywordArgument, currDynScope, temp, exception, block);
break;
case CALL_OP:
if (profile) Profiler.updateCallSite(instr, scope, scopeVersion);
if (profile) Profiler.updateCallSite(instr, interpreterContext.getScope(), scopeVersion);
processCall(context, instr, operation, currDynScope, currScope, temp, self);
break;
case RET_OP:
@@ -119,7 +118,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,
}

if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getStaticScope().getIRScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}

39 changes: 11 additions & 28 deletions core/src/main/java/org/jruby/ir/passes/OptimizeDelegationPass.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.jruby.ir.passes;

import org.jruby.ir.IRClosure;
import org.jruby.ir.IRScope;
import org.jruby.ir.IRFlags;
import org.jruby.ir.instructions.*;
import org.jruby.ir.instructions.ClosureAcceptingInstr;
import org.jruby.ir.instructions.CopyInstr;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.instructions.ReifyClosureInstr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.representations.BasicBlock;
@@ -32,7 +34,9 @@ public boolean invalidate(IRScope s) {
return false;
}

private static void calculateBlockUsage(IRScope s, Map<Operand, Operand> unusedExplicitBlocks) {
private static void optimizeDelegatedVars(IRScope s) {
Map<Operand, Operand> unusedExplicitBlocks = new HashMap<>();

for (BasicBlock bb: s.getCFG().getBasicBlocks()) {
for (Instr i: bb.getInstrs()) {
if (i instanceof ReifyClosureInstr) {
@@ -50,12 +54,6 @@ private static void calculateBlockUsage(IRScope s, Map<Operand, Operand> unusedE
}
}

for (IRScope child: s.getClosures()) {
calculateBlockUsage(child, unusedExplicitBlocks);
}
}

private static void replaceBlockUsage(IRScope s, Map<Operand, Operand> unusedExplicitBlocks) {
for (BasicBlock bb: s.getCFG().getBasicBlocks()) {
ListIterator<Instr> instrs = bb.getInstrs().listIterator();
while (instrs.hasNext()) {
@@ -72,28 +70,13 @@ private static void replaceBlockUsage(IRScope s, Map<Operand, Operand> unusedExp
}
}
}

for (IRScope child: s.getClosures()) {
replaceBlockUsage(child, unusedExplicitBlocks);
}
}
private static void optimizeDelegatedVars(IRScope s) {
Map<Operand, Operand> unusedExplicitBlocks = new HashMap<>();

calculateBlockUsage(s, unusedExplicitBlocks);
replaceBlockUsage(s, unusedExplicitBlocks);
}

private static boolean usesVariableAsNonClosureArg(Instr i, Variable v) {
List<Variable> usedVariables = i.getUsedVariables();
if (usedVariables.contains(v)) {
if (i instanceof ClosureAcceptingInstr) {
return usedVariables.indexOf(v) != usedVariables.lastIndexOf(v) ||
v != ((ClosureAcceptingInstr) i).getClosureArg();
} else {
return true;
}
}
return false;
return usedVariables.contains(v) &&
(!(i instanceof ClosureAcceptingInstr) ||
usedVariables.indexOf(v) != usedVariables.lastIndexOf(v) ||
v != ((ClosureAcceptingInstr) i).getClosureArg());
}
}
72 changes: 69 additions & 3 deletions core/src/main/java/org/jruby/ir/targets/Bootstrap.java
Original file line number Diff line number Diff line change
@@ -18,9 +18,12 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.invokedynamic.InvocationLinker;
import org.jruby.runtime.invokedynamic.InvokeDynamicSupport;
import org.jruby.runtime.invokedynamic.MathLinker;
import org.jruby.runtime.invokedynamic.VariableSite;
import org.jruby.runtime.ivars.FieldVariableAccessor;
import org.jruby.runtime.ivars.VariableAccessor;
import org.jruby.runtime.opto.Invalidator;
import org.jruby.runtime.opto.OptoFactory;
import org.jruby.util.ByteList;
import org.jruby.util.cli.Options;
@@ -34,11 +37,25 @@
import static java.lang.invoke.MethodHandles.*;
import static java.lang.invoke.MethodType.methodType;
import static org.jruby.runtime.Helpers.arrayOf;
import static org.jruby.runtime.invokedynamic.InvokeDynamicSupport.*;
import static org.jruby.util.CodegenUtils.p;
import static org.jruby.util.CodegenUtils.sig;

public class Bootstrap {
public final static String BOOTSTRAP_BARE_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class);
public final static String BOOTSTRAP_LONG_STRING_INT_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class, long.class, String.class, int.class);
public final static String BOOTSTRAP_DOUBLE_STRING_INT_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class, double.class, String.class, int.class);
public static final Class[] REIFIED_OBJECT_CLASSES = {
RubyObjectVar0.class,
RubyObjectVar1.class,
RubyObjectVar2.class,
RubyObjectVar3.class,
RubyObjectVar4.class,
RubyObjectVar5.class,
RubyObjectVar6.class,
RubyObjectVar7.class,
RubyObjectVar8.class,
RubyObjectVar9.class,
};
private static final Logger LOG = LoggerFactory.getLogger("Bootstrap");
static final Lookup LOOKUP = MethodHandles.lookup();

@@ -521,7 +538,7 @@ public static IRubyObject ivarGet(VariableSite site, IRubyObject self) throws Th
}

// prepare test
MethodHandle test = findStatic(InvocationLinker.class, "testRealClass", methodType(boolean.class, int.class, IRubyObject.class));
MethodHandle test = findStatic(Bootstrap.class, "testRealClass", methodType(boolean.class, int.class, IRubyObject.class));
test = insertArguments(test, 0, accessor.getClassId());

getValue = guardWithTest(test, getValue, fallback);
@@ -577,7 +594,7 @@ public static void ivarSet(VariableSite site, IRubyObject self, IRubyObject valu
}

// prepare test
MethodHandle test = findStatic(InvocationLinker.class, "testRealClass", methodType(boolean.class, int.class, IRubyObject.class));
MethodHandle test = findStatic(Bootstrap.class, "testRealClass", methodType(boolean.class, int.class, IRubyObject.class));
test = insertArguments(test, 0, accessor.getClassId());
test = dropArguments(test, 1, IRubyObject.class);

@@ -605,6 +622,10 @@ private static MethodHandle findStatic(Lookup lookup, Class target, String name,
}
}

public static boolean testRealClass(int id, IRubyObject self) {
return id == ((RubyBasicObject)self).getMetaClass().getRealClass().id;
}

public static boolean testType(RubyClass original, IRubyObject self) {
// naive test
return ((RubyBasicObject)self).getMetaClass() == original;
@@ -744,4 +765,49 @@ public static boolean testArg0ModuleMatch(IRubyObject arg0, int id) {
private static String extractSourceInfo(VariableSite site) {
return " (" + site.file() + ":" + site.line() + ")";
}

public static Handle getFixnumOperatorHandle() {
return getBootstrapHandle("fixnumOperatorBootstrap", MathLinker.class, BOOTSTRAP_LONG_STRING_INT_SIG);
}

public static Handle getFloatOperatorHandle() {
return getBootstrapHandle("floatOperatorBootstrap", MathLinker.class, BOOTSTRAP_DOUBLE_STRING_INT_SIG);
}

public static Handle checkpointHandle() {
return getBootstrapHandle("checkpointBootstrap", BOOTSTRAP_BARE_SIG);
}

public static Handle getBootstrapHandle(String name, String sig) {
return getBootstrapHandle(name, Bootstrap.class, sig);
}

public static Handle getBootstrapHandle(String name, Class type, String sig) {
return new Handle(Opcodes.H_INVOKESTATIC, p(type), name, sig);
}

public static CallSite checkpointBootstrap(Lookup lookup, String name, MethodType type) throws Throwable {
MutableCallSite site = new MutableCallSite(type);
MethodHandle handle = lookup.findStatic(Bootstrap.class, "checkpointFallback", methodType(void.class, MutableCallSite.class, ThreadContext.class));

handle = handle.bindTo(site);
site.setTarget(handle);

return site;
}

public static void checkpointFallback(MutableCallSite site, ThreadContext context) throws Throwable {
Ruby runtime = context.runtime;
Invalidator invalidator = runtime.getCheckpointInvalidator();

MethodHandle target = Binder
.from(void.class, ThreadContext.class)
.nop();
MethodHandle fallback = lookup().findStatic(Bootstrap.class, "checkpointFallback", methodType(void.class, MutableCallSite.class, ThreadContext.class));
fallback = fallback.bindTo(site);

target = ((SwitchPoint)invalidator.getData()).guardWithTest(target, fallback);

site.setTarget(target);
}
}
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
import org.jruby.runtime.CallType;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.invokedynamic.InvokeDynamicSupport;
import org.jruby.util.ByteList;
import org.jruby.util.JavaNameMangler;
import org.jruby.util.RegexpOptions;
@@ -149,7 +148,7 @@ public void invokeOtherOneFixnum(String name, long fixnum) {
adapter.invokedynamic(
"fixnumOperator:" + JavaNameMangler.mangleMethodName(name),
signature,
InvokeDynamicSupport.getFixnumOperatorHandle(),
Bootstrap.getFixnumOperatorHandle(),
fixnum,
"",
0);
@@ -161,7 +160,7 @@ public void invokeOtherOneFloat(String name, double flote) {
adapter.invokedynamic(
"floatOperator:" + JavaNameMangler.mangleMethodName(name),
signature,
InvokeDynamicSupport.getFloatOperatorHandle(),
Bootstrap.getFloatOperatorHandle(),
flote,
"",
0);
@@ -295,6 +294,6 @@ public void checkpoint() {
adapter.invokedynamic(
"checkpoint",
sig(void.class, ThreadContext.class),
InvokeDynamicSupport.checkpointHandle());
Bootstrap.checkpointHandle());
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -643,7 +643,7 @@ public void BacktickInstr(BacktickInstr instr) {
jvmAdapter().invokevirtual(p(IRubyObject.class), "anyToString", sig(IRubyObject.class));

jvmAdapter().label(after);
jvmAdapter().invokevirtual(p(RubyString.class), "append", sig(RubyString.class, IRubyObject.class));
jvmAdapter().invokevirtual(p(RubyString.class), "append19", sig(RubyString.class, IRubyObject.class));
}

// freeze the string
11 changes: 1 addition & 10 deletions core/src/main/java/org/jruby/javasupport/bsf/JRubyEngine.java
Original file line number Diff line number Diff line change
@@ -155,16 +155,7 @@ public void handleException(BSFException bsfExcptn) {
* @param exception An Exception thrown by JRuby
*/
private static void printException(Ruby runtime, Exception exception) {
if (exception instanceof RaiseException) {
JumpException je = (JumpException)exception;
if (je instanceof RaiseException) {
runtime.printError(((RaiseException)je).getException());
} else if (je instanceof JumpException.BreakJump) {
runtime.getErrorStream().println("break without block.");
} else if (je instanceof JumpException.ReturnJump) {
runtime.getErrorStream().println("return without block.");
}
}
if (exception instanceof RaiseException) runtime.printError(((RaiseException) exception).getException());
}

private static class BeanGlobalVariable implements IAccessor {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/parser/ParserSupport.java
Original file line number Diff line number Diff line change
@@ -1229,7 +1229,7 @@ private List<Integer> allocateNamedLocals(RegexpNode regexpNode) {
for (int i = 0; i < length; i++) {
// TODO: Pass by non-local-varnamed things but make sure consistent with list we get from regexp

if (RubyLexer.getKeyword(names[i]) == null) {
if (RubyLexer.getKeyword(names[i]) == null && !Character.isUpperCase(names[i].charAt(0))) {
int slot = scope.isDefined(names[i]);
if (slot >= 0) {
locals.add(slot);
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/parser/StaticScope.java
Original file line number Diff line number Diff line change
@@ -93,7 +93,9 @@ public class StaticScope implements Serializable {

private long commandArgumentStack;

private IRScope irScope; // Method/Closure that this static scope corresponds to
// Method/Closure that this static scope corresponds to. This is used to tell whether this
// scope refers to a method scope or to determined IRScope of the parent of a compiling eval.
private IRScope irScope;

public enum Type {
LOCAL, BLOCK, EVAL;
@@ -225,7 +227,7 @@ public String[] getVariables() {
}

public int getNumberOfVariables() {
return irScope == null ? variableNames.length : irScope.getUsedVariablesCount();
return variableNames.length;
}

public void setVariables(String[] names) {
3 changes: 0 additions & 3 deletions core/src/main/java/org/jruby/runtime/DynamicScope.arities.erb

This file was deleted.

372 changes: 0 additions & 372 deletions core/src/main/java/org/jruby/runtime/DynamicScope.erb

This file was deleted.

103 changes: 0 additions & 103 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -239,20 +239,6 @@ public static final Map<String, String> map(String... keyValues) {
return map;
}

/**
* Should be called on jumps out of blocks. Inspects the jump, returning or rethrowing as appropriate
*/
public static IRubyObject handleBlockJump(ThreadContext context, JumpException.FlowControlException jump, Block.Type type) {
// 'next' and Lambda 'return' are local returns from the block, ending the call or yield
if (jump instanceof JumpException.NextJump
|| (jump instanceof JumpException.ReturnJump && type == Block.Type.LAMBDA)) {
return jump.getValue() == null ? context.runtime.getNil() : (IRubyObject)jump.getValue();
}

// other jumps propagate up
throw jump;
}

public static boolean additionOverflowed(long original, long other, long result) {
return (~(original ^ other) & (original ^ result) & RubyFixnum.SIGN_BIT) != 0;
}
@@ -1835,95 +1821,6 @@ private static void callSingletonMethodHook(IRubyObject receiver, ThreadContext
receiver.callMethod(context, "singleton_method_added", name);
}

private static DynamicMethod constructNormalMethod(
MethodFactory factory,
String javaName,
String name,
RubyModule containingClass,
ISourcePosition position,
int arity,
StaticScope scope,
Visibility visibility,
Object scriptObject,
CallConfiguration callConfig,
String parameterDesc,
MethodNodes methodNodes) {

DynamicMethod method;
final Ruby runtime = containingClass.getRuntime();

if (name.equals("initialize") || name.equals("initialize_copy") || name.equals("initialize_clone") || name.equals("initialize_dup") || name.equals("respond_to_missing?") || visibility == Visibility.MODULE_FUNCTION) {
visibility = Visibility.PRIVATE;
}

if (RubyInstanceConfig.LAZYHANDLES_COMPILE) {
method = factory.getCompiledMethodLazily(
containingClass,
name,
javaName,
visibility,
scope,
scriptObject,
callConfig,
position,
parameterDesc,
methodNodes);
} else {
method = factory.getCompiledMethod(
containingClass,
name,
javaName,
visibility,
scope,
scriptObject,
callConfig,
position,
parameterDesc,
methodNodes);
}

return method;
}

private static DynamicMethod constructSingletonMethod(
MethodFactory factory,
String rubyName,
String javaName,
RubyClass rubyClass,
ISourcePosition position,
StaticScope scope,
Object scriptObject,
CallConfiguration callConfig,
String parameterDesc,
MethodNodes methodNodes) {

if (RubyInstanceConfig.LAZYHANDLES_COMPILE) {
return factory.getCompiledMethodLazily(
rubyClass,
rubyName,
javaName,
Visibility.PUBLIC,
scope,
scriptObject,
callConfig,
position,
parameterDesc,
methodNodes);
} else {
return factory.getCompiledMethod(
rubyClass,
rubyName,
javaName,
Visibility.PUBLIC,
scope,
scriptObject,
callConfig,
position,
parameterDesc,
methodNodes);
}
}

public static String encodeScope(StaticScope scope) {
StringBuilder namesBuilder = new StringBuilder(scope.getType().name()); // 0

Loading