TruffleRuby is a high-performance implementation of the Ruby programming language.
TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the website: http://www.graalvm.org/ruby/
Changelog
New features:
- Foreign exceptions are now fully integrated and have most methods of
Exception
(@eregon). - Foreign exceptions can now be rescued with
rescue Polyglot::ForeignException
orrescue foreign_meta_object
(#2544, @eregon).
Bug fixes:
- Guard against unterminated ranges in file matching patterns (#2556, @aardvark179).
- Fixed
rb_proc_new
to return a proc that will pass all required arguments to C (#2556, @aardvark179). - Fixed
String#split
to return empty array when splitting all whitespace on whitespace (#2565, @bjfish). - Raise
RangeError
forTime.at(bignum)
(#2580, @eregon). - Fix
Integer#{<<,>>}
with RHS bignum and long (@eregon). - Fix a resource leak from allocators defined in C extensions (@aardvark179).
SIGINT
/Interrupt
/Ctrl+C
now shows the backtrace and exits as signaled, like CRuby (@eregon).- Update patch feature finding to prefer the longest matching load path (#2605, @bjfish).
- Fix
Hash#{to_s,inspect}
for keys whose#inspect
return a frozen String (#2613, @eregon). - Fix
Array#pack
withx*
to not output null characters (#2614, @bjfish). - Fix
Random#rand
not returning random floats when given float ranges (#2612, @bjfish). - Fix
Array#sample
for[]
when called withoutn
and aRandom
is given (#2612, @bjfish). - Fix
Module#const_get
to raise aNameError
when nested modules do not exist (#2610, @bjfish). - Ensure native
VALUE
s returned from C are unwrapped before the objects can be collected (@aardvark179). - Fix
Enumerator::Lazy#with_index
to start with new index for multiple enumerations (@bjfish). - Fix
rb_id2name
to ensure the native string will have the same lifetime as the id (#2630, @aardvark179). - Fix
MatchData#[]
exception when passing a length argument larger than the number of match values (#2636, @nirvdrum). - Fix
MatchData#[]
exception when supplying a large negative index along with a length argument (@nirvdrum). - Fix
Integer#fdiv
andRational#to_f
for largeInteger
values (#2631, @bjfish).
Compatibility:
- Implement full Ruby 3 keyword arguments semantics (#2453, @eregon, @chrisseaton).
- Implement
ruby_native_thread_p
for compatibility (#2556, @aardvark179). - Add
rb_argv0
for thetk
gem. (#2556, @aardvark179). - Implement more correct conversion of array elements by
Array#pack
(#2503, #2504, @aardvark179). - Implement
Pathname#{empty?, glob}
(#2559, @bjfish) - Fixed
Rational('')
to raise error like MRI (#2566, @aardvark179). - Freeze instances of
Range
but not subclasses, like CRuby (#2570, @MattAlp). - When writing to STDOUT redirected to a closed pipe, no broken pipe error message will be shown now. (#2532, @gogainda).
- Use
#to_a
for convertinglist
inrescue *list
(#2572, @eregon). - Implement 'rb_str_buf_append' (@bjfish).
- Add patch for
digest
so that TruffleRuby implementation is not overridden (@bjfish). - Handle encoding conversion errors when reading directory entries (@aardvark179).
- Follow symlinks when processing
*/
directory glob patterns. (#2589, @aardvark179). - Set
@gem_prelude_index
variable on the default load paths (#2586 , @bjfish) - Do not call
IO#flush
dynamically fromIO#close
(#2594, @gogainda). - Implement
rb_str_new_static
for C extensions that use it (@aardvark179). - Rewrote
ArrayEachIteratorNode
and re-introducedeach
specs for MRI parity when mutating arrays whilst iterating, rather than crashing (#2587, @MattAlp) - Update
String#rindex
to only acceptRegexp
or objects convertable toString
as the first parameter (#2608, @bjfish). - Update
String#<<
to require one argument (#2609, @bjfish). - Update
String#split
to raiseTypeError
when false is given (#2606, @bjfish). - Update
String#lstrip!
to remove leading null characters (#2607, @bjfish). - Update
File.utime
to return the number of file names in the arguments (#2616, @bjfish). - Update
Dir.foreach
to accept anencoding
parameter (#2627, @bjfish). - Update
IO.readlines
to ignore negative limit parameters (#2625 , @bjfish). - Update
Math.sqrt
to raise aMath::DomainError
for negative numbers (#2621, @bjfish). - Update
Enumerable#inject
to raise anArgumentError
if no block or symbol are given (#2626, @bjfish). - Fix
Marshal.dump
to raise an error when an object has singleton methods (@bjfish).
Performance:
- Increase dispatch limit for string library to handle mutable, immutable and non-strings (@aardvark179)
- Switch to
Arrays.mismatch()
in string comparison for better performance (@aardvark179). - Removed extra array allocations for method calls in the interpreter to improve warmup performance (@aardvark179).
- Optimize
Dir[]
by sorting entries as they are found and grouping syscalls (#2092, @aardvark179). - Reduce memory footprint by tracking
VALUE
s created during C extension init separately (@aardvark179). - Rewrote
ArrayEachIteratorNode
to optimize performance for a constant-sized array and reduce specializations to 1 general case (#2587, @MattAlp) - Reduce conversion of
VALUE
s to native handle during common operations in C extensions (@aardvark179). - Improved performance of regex boolean matches (e.g.,
Regexp#match?
) by avoiding match data allocation in TRegex (#2588, @nirvdrum). - Remove overhead when getting using
RDATA_PTR
(@aardvark179). - Additional copy operations have been reduced when performing IO (#2536, @aardvark179).
Changes:
- Foreign exceptions are no longer translated to
RuntimeError
but instead remain as foreign exceptions, see the documentation for how to rescue them (@eregon).