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:
- Updated to Ruby 3.1.3 (#2733, @andrykonchin, @eregon).
foreign_object.is_a?(foreign_meta_object)
is now supported (@eregon).- Foreign big integers are now supported and work with all
Numeric
operators (@eregon).
Bug fixes:
- Ensure every parse node has a source section and fix the source section for
ensure
(#2758, @eregon). - Fix
spawn(..., fd => fd)
on macOS, it did not work due to a macOS bug (@eregon). - Fix
rb_gc_register_address()
/rb_global_variable()
to read the latest value (#2721, #2734, #2720, @eregon). - Synchronize concurrent writes to the same StringIO (@eregon).
- Fix
StringIO#write(str)
whenstr
is of an incompatible encoding and position < buffer size (#2770, @eregon). - Fix
rb_thread_fd_select()
to correctly initialize fdset copies and handle the timeout (@eregon). - Fix
TracePoint#inspect
when it's called outside of a callback (@andrykonchin). - Fix
Signal.trap
when signal argument is not supported (#2774, @andrykonchin). - Fix
Dir.mkdir
and convert permissions argument toInteger
(#2781, @andrykonchin). - Fix
String#dump
and use\u{xxxx}
notation (with curly brackets) for characters that don't fit in\uxxxx
(#2794, @andrykonchin). - Fix
Marshal.dump
when big Integer (that cannot be expressed with 4 bytes) is serialized (#2790, @andrykonchin). - Fix
Array#pack
and acceptNumeric
values whenFloat
is expected (#2815, @andrykonchin). - Fix
\P{}
matching in regular expressions (#2798, @andrykonchin). - Fix constants lookup when
BasicObject#instance_eval
method is called with a String (#2810, @andrykonchin). - Don't trigger the
method_added
event when changing a method's visibility or callingmodule_function
(@paracycle, @nirvdrum). - Fix
rb_time_timespec_new
function to not callTime.at
method directly (@andrykonchin). - Fix
StringIO#write
to transcode strings with encodings that don't match theStringIO
'sexternal_encoding
. (#2839, @flavorjones) - Fix processing of proc rest arguments located at the beginning if there are no actual arguments (#2921, @andrykonchin).
- Fix
Monitor#exit
to raiseThreadError
when monitor not owned by the current thread (#2922, @andrykonchin). - Fix
MatchData#[]
to support negativelength
argument (#2929, @andrykonchin). - Fix
IO
line reading calls when using a multi-byte delimiter (IO#{each,gets,readline,readlines,etc.}
) (#2961, @vinistock, @nirvdrum). - Fix the exception type raised when type coercion raises a
NoMethodError
(#2903, @paracycle, @nirvdrum). - Fix
Method
andProc
#parameters
method to return_
parameter name without synthetic suffix when there are multiple_
parameters (@paracycle). - Fixed errors in IRB when attempting to navigate beyond bounds in singleline mode (@rwstauner).
- Fix
Dir.glob
returning blank string entry with leading**/
in glob andbase:
argument (@rwstauner).
Compatibility:
- Fix
MatchData#[]
when passed unbounded Range (#2755, @andrykonchin). - Updated
rb_define_class
,rb_define_class_under
, andrb_define_class_id_under
to allow class names that aren't valid in Ruby (#2739, @nirvdrum). - Fixed
rb_gv_get
so that it no longer implicitly creates global variables (#2748, @nirvdrum). - Added implementations of
rb_gvar_val_getter
andrb_define_virtual_variable
(#2750, @nirvdrum). - Implement
rb_warning_category_enabled_p
to support thesyntax_tree
gem (#2764, @andrykonchin). - Fix desctructuring of a single block argument that implements
#to_ary
dynamically (#2719, @andrykonchin). - Fix
Kernel#Complex
and raise exception when an argument is formatted incorrectly (#2765, @andrykonchin). - Add
#public?
,#private?
and#protected?
methods forMethod
andUnboundMethod
classes (@andrykonchin). - Add optional argument to
Thread::Queue.new
(@andrykonchin). - Support a module as the second argument of
Kernel#load
(@andrykonchin). - Improve argument validation in
Struct#valies_at
- raiseIndexError
orRangeError
when arguments are out of range (#2773, @andrykonchin). - Fix
MatchData#values_at
and handling indices that are out of range (#2783, @andrykonchin). - Add support for
%-z
(UTC for unknown local time offset, RFC 3339) toTime#strftime
(@andrykonchin). - Add support for
UTC
andA
-Z
utc offset values, as well as+/-HH
,+/-HHMM
,+/-HHMMSS
(without:
) (@andrykonchin). - Treat time with
UTC
,Z
and-00:00
utc offset as UTC time (@andrykonchin). - Raise
FrozenError
whenTime#localtime
,Time#utc
andTime#gmtime
is called on a frozen time object (@andrykonchin). - Validate a microseconds argument used to create a time object (@andrykonchin).
- Support accessing
dmark
anddfree
fields forRData
(#2771, @eregon). - Implement
rb_enc_nth()
(#2771, @eregon). - Support
offset
keyword argument forString#unpack
andString#unpack1
(@andrykonchin). - Fix
Process.detach
and castpid
argument toInteger
(#2782, @andrykonchin). rb_to_id()
should create a staticID
, used by RMagick (@eregon).- Resolve the current user home even when
$HOME
is not set (#2784, @eregon) - Fix
IO#lineno=
and convert argument toInteger
more strictly (#2786, @andrykonchin). - Fix argument implicit convertion in
IO#pos=
andIO#seek
methods (#2787, @andrykonchin). - Warn about unknown directive passed to
Array#pack
in verbose mode (#2791, @andrykonchin). - Added constants
IO::SEEK_DATE
andIO::SEEK_HOLE
(#2792, @andrykonchin). - Fix
StringIO.new
to accept keyword arguments (#2793, @andrykonchin). Process#spawn
should call#to_io
on non-IO file descriptor objects (#2809, @jcouball).- Add constants
IO::SEEK_DATE
andIO::SEEK_HOLE
(#2792, @andrykonchin). - Add
Class#subclasses
method (#2733, @andrykonchin). - Implement
Coverage.running?
method (@andrykonchin). - Fix arguments implicit type conversion for
Enumerable#zip
andArray#zip
(#2788, @andrykonchin). - Fix
Array#unshift
to not depend onArray#[]=
and allow overriding#[]=
in a subclass (#2772, @andrykonchin). - Fix syntactic check for
void value expression
(#2821, @eregon). - Fix
Range#step
with no block and non-Numeric
values (#2824, @eregon). - Fix execution order of
END
blocks andat_exit
callbacks (#2818, @andrykonchin). - Fix
String#casecmp?
for empty strings of different encodings (#2826, @eregon). - Implement
Enumerable#compact
andEnumerator::Lazy#compact
(#2733, @andrykonchin). - Implement
Array#intersect?
(#2831, @nirvdrum). - Record the source location in the constant for the
module
/class
keywords (#2833, @eregon). - Fix
File.open
and supportflags
option (#2820, @andrykonchin). - Support writing to
RData.dfree
for native extensions (#2830, #2732, #2165, @eregon). - Fix
IO#write
and support multiple arguments with different encodings (#2829, @andrykonchin). - Fix
Array
methodsreject
,reject!
,inject
,map
,select
,each_index
and handle a case when array is modified by a passed block like CRuby does (#2822, andrykonchin, @eregon). - Fix
EncodingError
exception message when Symbol has invalid encoding (#2850, @andrykonchin). - Raise
EncodingError
at parse time when Hash literal contains a Symbol key with invalid encoding (#2848, @andrykonchin). - Fix
Array
methodsreject
,reject!
,inject
,map
,select
,each_index
and handle a case when array is modified by a passed block like CRuby does (#2822, @andrykonchin, @eregon). - Fix
Array
methodsselect!
andkeep_if
and handle a case when exception is raised in a passed block properly (@andrykonchin). - Fix
Enumerable
methodseach_cons
andeach_slice
to return receiver (#2733, @horakivo) Module
methods#private
,#public
,#protected
,#module_function
now returns their arguments like in CRuby 3.1 (#2733, @horakivo)Kernel#exit!
, killing Fibers and internal errors do not run code inensure
clauses anymore, the same as CRuby (@eregon).- Implement
UnboundMethod#original_name
(@paracycle, @nirvdrum). - Implement
Thread#native_thread_id
method (#2733, @horakivo). - Modify
Struct#{inspect,to_s}
to match MRI when the struct is nested inside of an anonymous class or module (@st0012, @nirvdrum). Fiber.current
andFiber#transfer
are available withoutrequire 'fiber'
like in CRuby 3.1 (#2733, @eregon).- Add
freeze
keyword argument toMarshal.load
(#2733, @andrykonchin). - Add
Integer.try_convert
(#2733, @moste00, @eregon). - Support optional
:in
keyword argument forTime.now
andTime.new
(#2733, @andrykonchin). - Add optional
Hash
argument toEnumerable#tally
(#2733, @andrykonchin). - Update
$LOAD_PATH.resolve_feature_path
to returnnil
instead of raisingLoadError
when feature isn't found (#2733, @andrykonchin). - Add
objspace/trace
file (#2733, @andrykonchin). - Add
Process._fork
(#2733, @horakivo). - Update to JCodings 1.0.58 and Joni 2.1.44 (@eregon).
- Add
MatchData#match
andMatchData#match_length
(#2733, @horakivo). - Add
StructClass#keyword_init?
method (#2377, @moste00). - Support optional
level
argument forFile.dirname
method (#2733, @moste00). - Add
Thread::Backtrace.limit
method (#2733, @andrykonchin). - Deprecate
rb_gc_force_recycle
and make it a no-op function (#2733, @moste00). - Add
Refinement#import_methods
method and add deprecation warning forRefinement#include
andRefinement#prepend
(#2733, @horakivo). - Upgrading
UNICODE
version to 13.0.0 andEMOJI
version to 13.1 (#2733, @horakivo). - Add
rb_io_maybe_wait_readable
,rb_io_maybe_wait_writable
andrb_io_maybe_wait
functions (#2733, @andrykonchin). StringIO#set_encoding
should coerce the argument to an Encoding (#2954, @eregon).- Implement changes of Ruby 3.0 to
IO#wait
(#2953, @larskanis). - Fix
Pathname#relative_path_from
to convert string arguments to Pathname objects (@rwstauner). - Implement
rb_io_descriptor()
(@eregon).
Performance:
- Marking of native structures wrapped in objects is now done on C call exit to reduce memory overhead (@aardvark179).
- Splitting (copying) of call targets has been optimized by implementing
cloneUninitialized()
(@andrykonchin, @eregon). Process.pid
is now cached per process like$$
(#2882, @horakivo)- Use the system
libyaml
forpsych
to improve warmup when parsing YAML (#2089, @eregon). - Fixed repeated deoptimizations for methods building an
Array
which is growing over multiple calls at a given call site (@eregon).
Changes: