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
..
2023-03-06 21:59:23 -08:00
2023-03-06 22:29:35 -08:00
2023-04-16 11:06:31 -04:00
2023-03-06 21:59:23 -08:00
2023-04-16 11:06:31 -04:00
2023-03-06 21:59:23 -08:00
2023-03-06 21:59:23 -08:00
2023-03-06 21:59:23 -08:00
2023-03-06 21:59:23 -08:00
2023-01-18 08:49:32 -05:00
2023-01-18 08:49:32 -05:00
2023-03-06 21:59:23 -08:00
2023-03-06 21:59:23 -08:00
2023-01-18 08:49:32 -05:00
2023-03-06 21:59:23 -08:00
2023-03-14 14:01:53 -07:00