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 support can be added to GraalVM using the gu utility.
More information is available on the GraalVM website: https://www.graalvm.org/ruby/
Changelog
21.1.0
New features:
- Access to local variables of the interactive Binding via language bindings is now supported:
context.getBindings("ruby").putMember("my_var", 42);
(#2030). VALUE
s in C extensions now expose the Ruby object when viewed in the debugger, as long as they have not been converted to native values.- Signal handlers can now be run without triggering multi-threading.
- Fibers no longer trigger Truffle multi-threading.
Bug fixes:
Range#to_a
wasn't working forlong
ranges (#2198, @tomstuart and @LillianZ).- Show the interleaved host and guest stacktrace for host exceptions (#2226).
- Fix the label of the first location reported by
Thread#backtrace_locations
(#2229). - Fix
Thread.handle_interrupt
to defer non-pure interrupts until the end of thehandle_interrupt
block (#2219). - Clear and restore errinfo on entry and normal return from methods in C extensions (#2227).
- Fix extra whitespace in squiggly heredoc with escaped newline (#2238, @wildmaples and @norswap).
- Fix handling of signals with
--single-threaded
(#2265). - Fix
Enumerator::Lazy#{chunk_while, slice_before, slice_after, slice_when}
to return instances ofEnumerator::Lazy
(#2273). - Fix
Truffle::Interop.source_location
to return unavailable source sections for modules instead of null (#2257). - Fix usage of
Thread.handle_interrupt
inMonitorMixin#mon_synchronize
. - Fixed
TruffleRuby.synchronized
to handle guest safepoints (#2277). - Fix control flow bug when assigning constants using ||= (#1489).
- Fix
Kernel#raise
argument handling for hashes (#2298). - Set errinfo when
rb_protect
captures a Ruby exception (#2245). - Fixed handling of multiple optional arguments and keywords when passed a positional
Hash
(#2302).
Compatibility:
- Prepend the GraalVM LLVM Toolchain to
PATH
when installing gems (#1974, #1088, #1343, #1400, #1947, #1931, #1588). - Installing the
nokogiri
gem now defaults to use the vendoredlibxml2
andlibxslt
, similar to CRuby, which means the corresponding system packages are no longer needed (#62). - Implemented
$LOAD_PATH.resolve_feature_path
. - Add
Pathname#/
alias toPathname#+
(#2178). - Fixed issue with large
Integer
s inMath.log
(#2184). - Updated
Regexp.last_match
to supportSymbol
andString
parameter (#2179). - Added support for numbered block parameters (
_1
etc). - Fixed
String#upto
issue with non-ascii strings (#2183). - Implemented partial support for pattern matching (#2186).
- Make
File.extname
return'.'
if the path ends with one (#2192, @tomstuart). - Include fractional seconds in
Time#inspect
output (#2194, @tomstuart). - Add support for
Integer#[Range]
andInteger#[start, length]
(#2182, @gogainda). - Allow private calls with
self
as an explicit receiver (#2196, @wildmaples). - Fixed
:perm
parameter forFile.write
. - Implemented
Time#floor
and#ceil
(#2201, @wildmaples). - Allow
Range#include?
and#member?
withTime
(#2202, @wildmaples). - Implemented
Comparable#clamp(Range)
(#2200, @wildmaples). - Added a
Array#minmax
to overrideEnumerable#minmax
(#2199, @wildmaples). - Implemented
chomp
parameter forIO.{readlines, foreach}
(#2205). - Implemented the Debug Inspector C API.
- Added beginless range support for
Range#{new, bsearch, count, each, equal_value, first, inspect, max, min, size, cover?, include?, ===}
. - Added beginless range support for
Array#{[], []=, slice, slice!, to_a, fill, values_at}
(#2155, @LillianZ). - Added beginless range support for
String#{byteslice, slice, slice!}
andSymbol#slice
(#2211, @LillianZ). - Added beginless range support for
Kernel#{caller, caller_locations}
andThread#backtrace_locations
(#2211, @LillianZ). - Make rand work with exclusive range with Float (#1506, @gogainda)
- Fixed
String#dump
's formatting of escaped unicode characters (#2217, @meganniu). - Switched to the io-console C extension from C ruby for better performance and compatibility in
irb
. - Coerce the message to a
String
forBasicSocket#send
(#2209, @HoneyryderChuck). - Support buffer argument for
UDPSocket#recvfrom_nonblock
(#2209, @HoneyryderChuck). - Fixed
Integer#digits
implementation to handle more bases (#2224, #2225). - Support the
inherit
parameter forModule#{private, protected, public}_method_defined?
. - Implement
Thread.pending_interrupt?
andThread#pending_interrupt?
(#2219). - Implement
rb_lastline_set
(#2170). - Implemented
Module#const_source_location
(#2212, @tomstuart and @wildmaples). - Do not call
File.exist?
inDir.glob
asFile.exist?
is often mocked (#2236, @gogainda). - Coerce the inherit argument to a boolean in
Module#const_defined?
andModule#const_get
(#2240). - Refinements take place at
Object#method
andModule#instance_method
(#2004, @ssnickolay). - Add support for
rb_scan_args_kw
in C API (#2244, @LillianZ). - Update random implementation layout to be more compatible (#2234).
- Set
RbConfig::CONFIG['LIBPATHFLAG'/'RPATHFLAG']
like MRI to let$LIBPATH
changes inextconf.rb
work. - Access to path and mode via
rb_io_t
from C has been changed to improve compatibility for io-console. - Implemented the
Time.at
in:
parameter. - Implemented
Kernel#raise
cause
parameter. - Improved compatibility of
Signal.trap
andKernel#trap
(#2287, @chrisseaton). - Implemented
GC.stat(:total_allocated_objects)
as0
(#2292, @chrisseaton). ObjectSpace::WeakMap
now supports immediate and frozen values as both keys and values (#2267).- Call
divmod
when coercion toFloat
fails for#sleep
(#2289, @LillianZ).
Performance:
- Multi-Tier compilation is now enabled by default, which improves warmup significantly.
- Improve the performance of checks for recursion (#2189, @LillianZ).
- Improve random number generation performance by avoiding synchronization (#2190, @ivoanjo).
- We now create a single call target per block by default instead of two.
- Some uses of class variables are now much better optimized (#2259, @chrisseaton).
- Several methods that need the caller frame are now always inlined in their caller, which speeds up the interpreter and reduces footprint.
- Pasting code in IRB should be reasonably fast, by updating to
irb
1.3.3 andreline
0.2.3 (#2233).
Changes:
- Standalone builds of TruffleRuby are now based on JDK11 (they used JDK8 previously). There should be no user-visible changes. Similarly, JDK11 is now used by default in development instead of JDK8.
- The deprecated
Truffle::System.synchronized
has been removed. Java.synchronized
has been removed, it did not work on host objects.