A high performance implementation of the Ruby programming language, built on GraalVM.
TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI, version 2.6.5.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the GraalVM website: http://www.graalvm.org/docs/reference-manual/languages/ruby/
TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI, version 2.6.6.
More information is available on the GraalVM website: http://www.graalvm.org/docs/reference-manual/ruby/
New features:
InteropLibrary#toDisplayString()
to better display objects from other languages.foreign_object.to_s
now uses InteropLibrary#toDisplayString()
(and still asString()
if isString()
).foreign_object.inspect
has been improved to be more useful (include the language and meta object).foreign_object.class
now calls getMetaObject()
(except for Java classes, same as before).foreign_object.name = value
will now call Interoplibrary#writeMember("name", value)
instead of invokeMember("name=", value)
(@aardvark179).foreign.name
will now use invokeMember
if invocable and if not use readMember
, see doc/contrib/interop_implicit_api.md
for details.foreign.to_f
and foreign.to_i
will now attempt to convert to Ruby Float
and Integer
(#2038).foreign.equal?(other)
now uses InteropLibrary#isIdentical(other)
and foreign.object_id/__id__
now uses InteropLibrary#identityHashCode()
.Bug fixes:
#class_exec
, #module_exec
, #instance_eval
, and instance_exec
to use activated refinements (#1988, @ssnickolay).blocking: true
when interrupted.NameError
when requiring an autoload path that does not define the autoload constant (#1905).TracePoint
thread-safety by storing the state on the Ruby Thread
(like MRI) instead of inside the TracePoint
instance.require 'rubygems/package'
succeed and define Gem::Deprecate
correctly (#2014).MBCLEN_CHARFOUND_P
error (@bjfish).rb_enc_str_new
when NULL
encoding is given with a constant string.rb_enc_precise_mbclen
to handle more inputs.--engine.TraceCompilation
is now significantly easier to read, by having shorter method names and source names (oracle/graal#2052).#inspect
(#2027).Kernel#srand
in a Thread (#2028).IO
for IO#reopen(IO)
which is important for the 3 standard IOs (#2034).require 'rubygems/specification'
work before require 'rubygems'
.Compatibility:
UnboundMethod#bind_call
(@norswap).ObjectSpace::WeakMap
(#1385, #1958).strtod
and ruby_strtod
(#2007, @chrisseaton).#find_type
in FFI to ignore MakeMakefile#find_type
from mkmf
(#1896, #2010).rb_uv_to_utf8
(#1998, @skateman).rb_str_cat_cstr
.rb_fstring
.#refine
for Module (#2021, @ssnickolay).rb_ident_hash_new
.Symbol.all_symbols
(#2022, @chrisseaton).rb_enc_str_buf_cat
.rb_int_positive_pow
.rb_usascii_str_new_lit
.#getch
and #getpass
on StringIO
when io/console
is required.rb_uv_to_utf8
(#1998).rb_funcall(a, '+', b)
will now do the same thing as in MRI.String
.rb_array_sort
and rb_array_sort_bang
.Thread
if there are other public languages, which is helpful for polyglot cases (#2035).rb_enc_isalnum
and rb_enc_isspace
.RUBY_REVISION
is now the full commit hash used to build TruffleRuby, similar to MRI 2.7+.rb_enc_mbc_to_codepoint
.Digest::Instance#new
(#2040).ONIGENC_MBC_CASE_FOLD
.Thread#raise
to call the exception class' constructor with no arguments when given no message (#2045).refine + super
compatibility (#2039, #2048, @ssnickolay)rb_enc_codelen
.Ripper
by using the C extension (#1585).Changes:
--no-document
option by default.Performance:
instance variable ... not initialized
and similar warnings are now optimized to have no peak performance impact if they are not printed (depends on $VERBOSE
).BigInteger#mod_pow
(#1999, @skateman)String
with non-US-ASCII characters.TruffleRuby is a high-performance implementation of the Ruby programming language. TruffleRuby aims to be fully compatible with the standard implementation of Ruby, MRI, version 2.6.5.
The Ruby language component can be added to GraalVM using the gu
utility.
More information is available on the GraalVM website: http://www.graalvm.org/docs/reference-manual/languages/ruby/
TruffleRuby is a high-performance implementation of the Ruby programming language 2.6.5.
More information is available on the GraalVM website: http://www.graalvm.org/docs/reference-manual/languages/ruby/
New features:
||=
will not compile the right-hand-side if it's only executed once, to match the idiomatic lazy-initialisation use-case (blog post, #1887, @kipply).--metrics-profile-require
option to profile searching, parsing, translating and loading files.Bug fixes:
Exception#dup
to copy the Exception#backtrace
string array.rb_warn
and rb_warning
when used as statements (#1886, @chrisseaton).NameError.new
and NoMethodError.new
:receiver
argument.rb_funcall
(#1882, @aardvark179).Module#{include, prepend}
.OpenSSL::Digest.{digest,hexdigest,base64digest}
to handle algorithm, data
arguments (#1889, @bdewater).SystemCallError.new
parameter conversion.File#{chmod, umask}
argument conversion check.Hash.[]
for non-array elements.File.lchmod
to raise NotImplementedError
when not available.RSTRING_PTR()
now always returns a native pointer, resolving two bugs memcpy
ing to (#1822) and from (#1772) Ruby Strings.Dir#children
implementation.SignalException.new
error when bad parameter given.Kernel#=~
.puts
for a foreign objects, e.g. puts Polyglot.eval('js', '[]')
(#1881, @pitr-ch).Exception#full_message
implementation.Kernel.Complex()
to handle the exception: false
parameter.Kernel#dup
to return self for Complex
and Rational
objects.Kernel.Float()
to handle the exception: false
parameter.String#unpack
M
format (#1901).SystemCallError
message contained non-ASCII characters.rb_rescue
to allow null rescue methods. (#1909, @kipply).Kernel#caller_locations
to be overridden by user code (#1934, @norswap).Regexp#quote
(#1927).Kernel.Float()
to return given string in error message (#1945).method_missing
should now match MRI (#1921).RB_FLOAT_TYPE_P
macro (#1928).Symbol#match
to call the block with the MatchData
(#1933).Digest::SHA2.hexdigest
error with long messages (#1922).Date.parse
to dup the coerced string to not modify original (#1946).Comparable
error messages for special constant values (#1941).File.ftype
parameter conversion (#1961).Digest::Instance#file
to not modify string literals (#1964).String
, and not a subclass (#1950).alias_method
and instance_methods
should now work correctly inside a refinement (#1942).Regexp.union
parameter conversion (#1963).IO#read(n)
no longer buffers more than needed, which could cause hanging if detecting readability via a native call such as select(2)
(#1951).Random::DEFAULT.seed
to be different on boot (#1965, @kipply)rb_encoding->name
can now be read even if the rb_encoding
is stored in native memory.$LOAD_PATH
path entry for .rb
, then every entry for native extension when require
is called with no extension._DARWIN_C_SOURCE
macro in extension makefiles (#1592).rb_rescue2
to handle usage in C extensions (#1823).Encoding::CompatibilityError
raised for some interpolated Regexps (#1967).nil
value for Process.spawn
instead of setting them to an empty String.RbConfig::CONFIG['LIBRUBY_SO']
file extension.char
, short
, unsigned char
, unsigned int
, and unsigned short
types in Fiddle
(#1971).IO#select
to reallocate its buffer if it is interrupted by a signal.#
within string as being a variable (#1495).File.join
to raise error on strings with null bytes.Compatibility:
VALUE
is now defined as unsigned long
as on MRI. This enables switch (VALUE)
and other expressions which rely on VALUE
being an integer type (#1409, #1541, #1675, #1917, #1954).Float#{floor, ceil}
with ndigits
argument.Thread#fetch
.Float#truncate
with ndigits
argument.String#{byteslice, slice, slice!}
and Symbol#slice
compatible with endless ranges.Kernel#{caller, caller_locations}
and Thread#backtrace_locations
compatible with endless ranges.Dir#each_child
.Kernel.{chomp, chop}
and Kernel#{chomp, chop}
.-p
and -a
, and -l
CLI options.File.realpath
with #to_path
(#1894).StringIO#binmode
now sets the external encoding to BINARY like MRI (#1898).StringIO#inspect
should not include the contents of the StringIO
(#1898).rb_fd_*
functions (#1623).Thread#backtrace
support omit, length and range arguments.Range#%
.flags
field of rb_data_type_t
(#1911).rb_obj_is_proc
(#1908, @kipply, @XrXr).RARRAY_ASET()
.num2short
(#1910, @kipply).RSTRING_END()
now always returns a native pointer.register
specifier for rb_mem_clear()
(#1924).Thread::Backtrace::Locations#base_label
(#1920).rb_mProcess
(#1936).rb_gc_latest_gc_info
(#1937).RBASIC_CLASS
(#1935).Hash#map
if the arity of the block is > 1 (#1944).Errno
constants to match MRI, needed by recent RubyGems.ruby_dep
warnings since that gem is unmaintained.Process.daemon
(#1962).NoMethodError#message
to match MRI (#1957).StringIO
work with --enable-frozen-string-literal
(#1969).NULL
for the status of rb_protect()
.BigDecimal#inspect
does not call BigDecimal#to_s
to avoid behaviour change on to_s
override (#1960).rb_{c,m,e}*
constants as C global variables (#1541).ArgumentError
for Socket.unpack_sockaddr_un
if the socket family is incorrect.RTYPEDDATA_*()
macros and rb_str_tmp_new()
(#1975).rb_set_end_proc
(#1959).rb_to_symbol
.rb_class_instance_methods
, rb_class_public_instance_methods
, rb_class_protected_instance_methods
, and rb_class_private_instance_methods
.rb_tracepoint_new
, rb_tracepoint_disable
, rb_tracepoint_enable
, and rb_tracepoint_enabled_p
(#1450).RbConfig::CONFIG['AR']
and RbConfig::CONFIG['STRIP']
(#1973).mkmf
's have_func
(#1980).RUBY_INTERNAL_EVENT_{NEWOBJ,FREEOBJ}
events but warn they are not triggered (#1978, #1983).IO.copy_stream(in, STDOUT)
now writes to STDOUT
without buffering like MRI.RbConfig['vendordir']
.Enumerator::ArithmeticSequence
.(struct RBasic *)->flags
and ->klass
from ruby.h
(#1891, #1884, #1978).Changes:
TRUFFLERUBY_RESILIENT_GEM_HOME
has been removed. Unset GEM_HOME
and GEM_PATH
instead if you need to.Truffle::System.full_memory_barrier
, Truffle::Primitive.logical_processors
, and Truffle::AtomicReference
have been removed.#size
, #[]
methods has been removed and replaced with an explicit interface where each method starts with polyglot_*
.#[]
method was replaced with polyglot_*
methods.polyglot_
prefix, drop get
and is
prefix, append ?
on all predicates.Truffle::Interop.write
into .write_array_element
and .write_member
methods.Truffle::Interop.size
to .array_size
.Truffle::Interop.is_boolean?
to .boolean?
.Truffle::Interop.read
into .read_member
and .read_array_element
.is_
prefix in Truffle::Interop.is_array_element_*
predicates.Truffle::Interop.hash_keys_as_members
has been added to treat a Ruby Hash as a polyglot object with the Hash keys as members.Performance:
RSTRING_PTR()
accesses by going to native directly, optimized various core methods, use Mode=latency and tune GC heap size for Bundler. This speeds up bundle install
from 84s to 19s for a small Gemfile with 6 gems (#1398).bundle install
(#1893).ArrayBuilderNode
now uses a new Truffle library for manipulating array stores.return
expressions are now rewritten as implicit return expressions where control flow allows this to be safely done as a tail optimisation. This can improve interpreter performance by up to 50% in some benchmarks, and can be applied to approximately 80% of return nodes seen in Rails and its dependencies (#1977).ArrayStoreLibrary
.nil
to be a global immutable singleton (#1835).TruffleRuby is a high-performance implementation of the Ruby programming language 2.6.5.
More information is available on the GraalVM website: http://www.graalvm.org/docs/reference-manual/languages/ruby/
TruffleRuby is a high-performance implementation of the Ruby programming language 2.6.5. More information is available on the GraalVM website. Changes in 20.0.0 (from the project changelog):
New features:
--coverage
option (#1840, @chrisseaton).PKG_CONFIG_PATH
as needed for compiling OpenSSL on macOS (#1830).Bug fixes:
Tempfile#{size,length}
when the IO is not flushed (#1765, @rafaelfranca).Exception
(#1766, @rafaelfranca).Date._iso8601
and Date._rfc3339
when the string is an invalid date (#1773, @rafaelfranca).ArgumentError
message with MRI (#1774, @rafaelfranca)Encoding::CompatibilityError
with incompatible encodings on Regexp
(#1775, @rafaelfranca).Struct
(#1776, @chrisseaton).TCPServer.new
(#1780, @XrXr)Float#<=>
not calling coerce
when other
argument responds to it (#1783, @XrXr).BigDecimal
with a String
(#1796, @XrXr).close_others
in Process.exec
to false
like Ruby 2.6 (#1798, @XrXr).BigDecimal()
deal with large rationals precisely (#1797, @XrXr).instance_exec
with rb_block_call
(#1802, @XrXr).Struct.new
(#1803, @XrXr).Process::Status#to_i
return raw waitpid(2)
status (#1800, @XrXr).Process#exec
: set close-on-exec to false for fd redirection (#1805, @XrXr, @rafaelfranca).to_native
to polyglot_to_native
to match polyglot_pointer?
and polyglot_address
methods.Array#{sort,sort!}
(#1727).self
and the wrapping Module
for Kernel#load(path, wrap=true)
(#1739).RSTRING_PTR
to help with native/managed interop.Module#to_s
and Module#inspect
to not return an extra #<Class:
for singleton classes.ConditionVariable#wait
that could lose a ConditionVariable#signal
.Array#swap
(#1816, @pitr-ch)#inspect
on broken UTF-8 sequences (#1842, @chrisseaton).Truffle::Interop.keys
should report methods of String
and Symbol
(#1817)Kernel#sprintf
encoding validity has been fixed (#1852, @XrXr).ArrayIndexOutOfBoundsException
in File.fnmatch
(#1845, @bjfish).String#concat
work with no or multiple arguments (#1519, @norswap).Array#concat
work with no or multiple arguments (#1519, @norswap).BigDecimal(arg)
using to_str
(#1826).NameError#dup
, NoMethodError#dup
, and SystemCallError#dup
to copy internal fields.Enumerable#chunk
work without a block (#1518).SystemCallError.new
setting a backtrace too early.BigDecimal#to_s
formatting issue (#1711).END
keyword block only once at exit.Numeric#clone
to return self
.Symbol#to_proc
to create a Proc
with nil
source_location
(#1663).GC.start
work with keyword arguments.Kernel#clone
for nil
, true
, false
, Integer
, and Symbol
.Context#getBindings()
(#1838).Kernel#caller_locations
accept a range argument, and return nil
when appropriate.rb_respond_to
work with primitives (#1869, @chrisseaton).rescue $ERROR_INFO
(#1660).Struct#hash
for keyword_init: true
Struct
.String#{upcase!,downcase!,swapcase!}(:ascii)
for non-ASCII-compatible encodings like UTF-16.String#capitalize!
for strings that weren't full ASCII.ENV.{select, filter}
.Complex
and Rational
should be frozen after initializing.printf
should raise error when not enough arguments for positional argument.String
in ENV methods.ENV.index
is called.ENV.each_key
.ENV.replace
implementation.ENV.udpate
implementation.Kernel.printf
.Numeric#step
step
parameter.Kernel#Integer
conversion.IO.try_convert
parameter conversion.-std=gnu90
(#1837, #1879).gem install
by using a single download thread.RSTRING_PTR()
now always returns a native pointer, resolving two bugs memcpy
ing to (#1822) and from (#1772) Ruby Strings.Compatibility:
String#start_with?(Regexp)
(#1771, @dimameshcharakou).SignalException
and signal handling (#1790, @XrXr).rb_utf8_str_new
, rb_utf8_str_new_cstr
, rb_utf8_str_new_static
(#1788, @chrisseaton).unit
argument of Time.at
(#1791, @XrXr).keyword_init: true
for Struct.new
(#1789, @XrXr).MatchData#dup
(#1792, @XrXr).Array
to allow better C extension compatibility.rb_check_symbol_cstr
(#1814).rb_hash_start
(#1841, @XrXr).Method#<<
and Method#>>
(#1821)..bundle
file extension is now used for C extensions on macOS (#1819, #1837).Comparable#clamp
(#1517).rb_gc_register_mark_object
and rb_enc_str_asciionly_p
(#1856, @chrisseaton).rb_io_set_nonblock
(#1741).RUBY_PLATFORM
on macOS like MRI (#1860, @eightbitraptor).Enumerator::Chain
, Enumerator#+
, and Enumerable#chain
(#1859, #1858).Thread#backtrace_locations
and Exception#backtrace_locations
(#1556).rb_module_new
, rb_define_class_id
, rb_define_module_id
, (#1876, @XrXr, @chrisseaton).-n
CLI option (#1532).Symbol
of method names in call nodes only when needed (#1872).rb_get_alloc_func
and related functions (#1874, @XrXr).rb_module_new
, rb_define_class_id
, rb_define_module_id
, (#1876, @chrisseaton).ENV.slice
.Kernel#system
exception: true
option.Random.bytes
.Random.random_number
.Range#to_a
compatible with endless ranges.Array#[]
and Array#[]=
compatible with endless ranges.Performance:
long[]
array storage now correctly declare that they accept int
values, reducing deoptimisations and promotions to Object[]
storage.Symbol
conversion for rb_iv_get
and rb_iv_set
.rb_type
information is now cached on classes as a hidden variable to improve performance.IO.select
to reduce copying and optimisation boundaries.String
and Rope
nodes to avoid Truffle performance warnings.TruffleRuby is a high-performance implementation of the Ruby programming language 2.6.5. More information is available on the GraalVM website. Changes in 19.3.1:
New features:
Compatibility:
rb_gc_register_mark_object
and rb_enc_str_asciionly_p
(#1856, @chrisseaton).Ruby is an experimental language in the GraalVM 19.3.0.2 release. More information is available on the GraalVM website.
Ruby is an experimental language in the GraalVM 19.3.0 release. More information is available on the GraalVM website. Changes in 19.3.0 (from the project changelog):
New features:
Bug fixes:
rb_undef_method
now works for private methods (#1731, @cky).self.method ||= value
with a private method now works correctly (#1673, @pitr-ch).RegexpError: invalid multibyte escape
for binary regexps with a non-binary String (#1433, @aardvark179).sassc
now works due to using the LLVM toolchain (#1753).Truffle::Interop.respond_to?
to avoid conflict with Ruby's respond_to?
(#1491).$VERBOSE
is true
when a magic comment is ignored (#1757, @nirvdrum).Compatibility:
GC.stat
can now take an optional argument (#1716, @kirs).Kernel#load
with wrap
has been implemented (#1739, @chrisseaton).Kernel#spawn
with :chdir
(#1492).rb_str_drop_bytes
, notably used by OpenSSL (#1740, @cky).rails new
in Rails 6.gem update --system
as it is not fully supported yet and is often not needed.-undefined dynamic_lookup
to the linker on macOS like MRI.Performance:
rb_intern()
with a constant name in C extensions.NIL_P
and INT2FIX
in C extensions.String#gsub(String)
by not creating a Regexp
and using String#index
instead.TryNode
.The general GraalVM 19.2.0 release notes are available on the graalvm.org website.
Ruby is an experimental language in the GraalVM 19.2.1 release. More information is available on the GraalVM website. Changes in 19.2.1:
The general GraalVM 19.2.1 release notes are available on the the graalvm.org website.