ruby/internal
Aaron Patterson c5fc1ce975 Emit special instruction for array literal + .(hash|min|max)
This commit introduces a new instruction `opt_newarray_send` which is
used when there is an array literal followed by either the `hash`,
`min`, or `max` method.

```
[a, b, c].hash
```

Will emit an `opt_newarray_send` instruction.  This instruction falls
back to a method call if the "interested" method has been monkey
patched.

Here are some examples of the instructions generated:

```
$ ./miniruby --dump=insns -e '[@a, @b].max'
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 getinstancevariable                    :@a, <is:0>               (   1)[Li]
0003 getinstancevariable                    :@b, <is:1>
0006 opt_newarray_send                      2, :max
0009 leave
$ ./miniruby --dump=insns -e '[@a, @b].min'
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 getinstancevariable                    :@a, <is:0>               (   1)[Li]
0003 getinstancevariable                    :@b, <is:1>
0006 opt_newarray_send                      2, :min
0009 leave
$ ./miniruby --dump=insns -e '[@a, @b].hash'
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: FALSE)
0000 getinstancevariable                    :@a, <is:0>               (   1)[Li]
0003 getinstancevariable                    :@b, <is:1>
0006 opt_newarray_send                      2, :hash
0009 leave
```

[Feature #18897] [ruby-core:109147]

Co-authored-by: John Hawthorn <jhawthorn@github.com>
2023-04-18 17:16:22 -07:00
..
array.h Emit special instruction for array literal + .(hash|min|max) 2023-04-18 17:16:22 -07:00
basic_operators.h Emit special instruction for array literal + .(hash|min|max) 2023-04-18 17:16:22 -07:00
bignum.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
bits.h Remove obsoleted MJIT_HEADER macro 2023-03-06 22:29:35 -08:00
class.h Make classes embedded on 32 bit 2023-04-16 11:06:31 -04:00
cmdlineopt.h RJIT: Prefix rjit_options with rb_ 2023-03-18 21:28:55 -07:00
compar.h Introduce BOP_CMP for optimized comparison 2022-12-06 12:37:23 -08:00
compile.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
compilers.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
complex.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
cont.h Introduce `Fiber#storage` for inheritable fiber-scoped variables. (#6612) 2022-12-01 23:00:33 +13:00
dir.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
enc.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
encoding.h parenthesize to macro 2022-12-02 01:31:27 +09:00
enum.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
enumerator.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
error.h suppress GCC's -Wsuggest-attribute=format 2021-09-10 20:00:06 +09:00
eval.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
file.h Revert "reuse open(2) from rb_file_load_ok on POSIX-like system" 2023-02-27 09:24:45 -08:00
fixnum.h Fix rb_fix_mul_fix on OpenBSD/mips64 2022-07-03 09:42:44 -07:00
gc.h Make classes embedded on 32 bit 2023-04-16 11:06:31 -04:00
hash.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
imemo.h use correct svar even if env is escaped 2023-02-10 17:55:25 +09:00
inits.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
io.h Move some function declaration to internal/io.h 2021-09-28 18:08:08 +13:00
load.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
loadpath.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
math.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
missing.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
numeric.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
object.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
parse.h Revert "reuse open(2) from rb_file_load_ok on POSIX-like system" 2023-02-27 09:24:45 -08:00
proc.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
process.h Don't redefine RB_OBJ_WRITE 2023-01-18 08:49:32 -05:00
ractor.h internal/ractor.h: Added 2022-03-30 16:50:46 +09:00
random.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
range.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
rational.h Don't redefine RB_OBJ_WRITE 2023-01-18 08:49:32 -05:00
re.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
sanitizers.h Remove obsoleted MJIT_HEADER macro 2023-03-06 22:29:35 -08:00
serial.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
signal.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
static_assert.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
string.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
struct.h Don't redefine RB_OBJ_WRITE 2023-01-18 08:49:32 -05:00
symbol.h Ensure _id2ref finds symbols with the correct type 2022-07-20 10:38:44 -07:00
thread.h Move RB_VM_SAVE_MACHINE_CONTEXT to internal/thread.h 2023-03-15 21:26:26 +00:00
time.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
transcode.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
util.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
variable.h Stop exporting symbols for MJIT 2023-03-06 21:59:23 -08:00
vm.h Remove unused jit_enable_p flag 2023-03-14 14:01:53 -07:00
warnings.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00