CRuby3.0 compatible keyword arguments are introduced. Keyword arguments are basically separated from ordinal arguments.
- Implement endless-def Ruby:Feature#16746
- Replace
R-assignmentbysingle-line pattern matchingRuby:Feature#15921 - Support squiggly heredocs. #5246
- Hash value omission Ruby:Feature#14579
Some configuration macros are available:
MRB_WORDBOX_NO_INLINE_FLOAT(formerlyMRB_WORDBOX_NO_FLOAT_TRUNCATE): by default, float values are packed in the word if possible, but define this macro to allocate float values in the heap.MRB_USE_RO_DATA_P_ETEXT: define this macro if_etextis available on your platform.MRB_NO_DEFAULT_RO_DATA_P: define this macro to avoid using predefinedmrb_ro_data_p()function
We have added several new build configurations in the build_config directory.
cross-mingw-winetest.rbcross-mingw.rbnintendo_switch.rbserenity.rbminimal: minimal configurationhost-f32: compiles withmrb_floatas 32-bitfloathost-nofloat: compiles with no float configurationandroid_arm64_v8a.rb: renamed fromandroid_arm64-v8a.rb
Array#productArray#repeated_combinationArray#repeated_permutationKernel#__ENCODING__Random.bytesRandom#bytesString#center
mrbgems/mruby-packnow supportsMdirective (Q encoding)mrbgems/mruby-packnow supportsXdirective (back-up by bytes)mrbgems/mruby-packnow supports@directive (absolute position)mrbgems/mruby-packnow supportswdirective (BER compression)
mruby-confignow supports--ccand--ldoptions.- Remove
OP_prefix frommruby -vcode dump output. - Prohibit use of
OP_EXT{1,2,3}bymrbcwith--no-ext-opsoption.
- Add new specifier
ctomrb_get_args()for receive Class/Module.
Kernel#printf(mruby-sprintf) Format specifiers%aand%Aare removed.Kernel#puts(mruby-print) Now expand Array arguments.
Due to improvements in the binary format, mruby binaries are no longer backward compatible.
To run the mruby binaries on mruby 3.1, recompile with the mruby 3.1 mrbc.
- Upgrade mruby VM version
RITE_VM_VERto0300(means mruby 3.0 or after). - Upgrade mruby binary version
RITE_BINARY_FORMAT_VERto0300.
mruby3.0 removed OP_EXT1, OP_EXT2, OP_EXT3 for operand extension. But the operand size limitations was too tight for real-world application.
mruby3.1 reintroduces those extension instructions.
mruby3.1 removed following instructions.
OP_LOADL16OP_LOADSYM16OP_STRING16OP_LAMBDA16OP_BLOCK16OP_METHOD16OP_EXEC16
Those instructions are no longer needed by reintroduction of extension instructions.
OP_SENDVOP_SENDVB
Those instructions for method calls with variable number of arguments are no longer needed. They are covered by OP_SEND instruction with n=15.
mruby3.1 introduces following new instructions.
OP_GETIDX: takes 1 operandsR[a][a+1]OP_SETIDX: takes 1 operandsR[a][a+1]=R[a+2]OP_SSEND: takes 3 operandsa=self.b(c...); seeOP_SENDOP_SSENDB: takes 3 operandsa=self.b(c...){...}; seeOP_SENDOP_SYMBOL: takes 2 operandsR[a] = intern(Pool[b])
Execute obj[int] and obj[int] = value respectively, where obj is string|array|hash.
They are similar to OP_SEND and OP_SENDB respectively. They initialize the R[a] by self first so that we can skip one OP_LOADSELF instruction for each call.
Extracts the character string placed in the pool as a symbol.
Method calling instructions are unified. Now OP_SEND and OP_SENDB (method call with a block) can support both splat arguments and keyword arguments as well.
The brief description of the instructions:
|OP_SEND | BBB | R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1],R[a+n+2]..nk) c=n|nk<<4 |
|OP_SENDB | BBB | R[a] = R[a].call(Syms[b],R[a+1..n],R[a+n+1..nk],R[a+n+2..nk],&R[a+n+2*nk+2]) c=n|nk<<4 |
Operand C specifies the number of arguments. Lower 4 bits (n) represents the number of ordinal arguments, and higher 4 bits (nk) represents the number of keyword arguments.
When n == 15, the method takes arguments packed in an array. When nk == 15, the method takes keyword arguments are packed in a hash.
Now takes 2 operands and pushes multiple entries to an array.
MRB_WORD_BOXING now packs floating-point numbers in the word, if the size of mrb_float is equal or smaller than the size of mrb_int by default.
If the size of mrb_float and mrb_int are same, the last 2 bits in the mrb_float are trimmed and used as flags. If you need full precision, you need to define MRB_WORDBOX_NO_INLINE_FLOAT (formerly MRB_WORDBOX_NO_FLOAT_TRUNCATE) as described above.
Previous NaN boxing packs values in NaN representation, but pointer retrievals are far more frequent than floating-point number references. So we add constant offset to NaN representation to clear higher bits of pointer representation. This representation is called "Favor Pointer" NaN Boxing.
Also, previous NaN boxing limit the size of mrb_int to 4 bytes (32 bits) to fit in NaN values. Now we allocate integer values in the heap, if the value does not fit in the 32 bit range, just like we did in Word Boxing.
The code generator was updated to reduce the number of instructions, e.g.
a = 2 * 5will be interpreted as
a = 10In addition, we have improved peephole optimizations, for example:
GETIV R4 :@foo
MOVE R1 R4to
GETIV R1 :@fooFor better and faster hash values.
- Fix infinite recursive call bugs in integer division 98799aa6
- Fix to raise TypeError with super inside instance_eval / class_eval #5476
- Fix to call
method_addedhooks on method definitions; #2339 - Fix a potential buffer overflow in
time_zonename26340a88 - Fix
Module.instance_evalbug #5528 - Fix fix
Mpacking bug bfe2bd49 - Fix a bug regarding attribute assignment with kargs de2b4bd0
- Fix SIGSEGV with mrbgems/mruby-method #5580
- Fix print error before cleanup in
codegen_error()#5603 - Fix a bug in unpacking BER #5611
- Fix a bug with numbered parameters as arguments #5605
- Fix
mrb_ary_shift_minitialization bug 27d1e013 - Fix keyword argument with
super#5628 - Fix a bug with numbered parameters on toplevel 7e7f1b2f
- Fix keyword argument bug #5632
- Fix multiple assignments in parameters #5647
- Fix keyword parameters not passing through super #5660
- Fix infinite loop from unclosed here-doc #5676
- Fix negative integer division bug #5678
Following CVEs are fixed in this release.
- CVE-2021-4110
- CVE-2021-4188
- CVE-2022-0080
- CVE-2022-0240
- CVE-2022-0326
- CVE-2022-0481
- CVE-2022-0631
- CVE-2022-0632
- CVE-2022-0890
- CVE-2022-1071
- CVE-2022-1106
- CVE-2022-1201
- CVE-2022-1427
Following CVEs do not cause problems in this release. They are fixed in the later release.