<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/bootstraptest/test_insns.rb, branch v4.0.2</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Follow up cleanup for `opt_(aref|aset)_with` removal</title>
<updated>2025-08-26T22:03:47+00:00</updated>
<author>
<name>Stan Lo</name>
<email>stan.lo@shopify.com</email>
</author>
<published>2025-08-26T20:57:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c7ef8df8516aa27a78a1f3b6dff78c523eca259d'/>
<id>c7ef8df8516aa27a78a1f3b6dff78c523eca259d</id>
<content type='text'>
Just removing some unneeded tests, outdated comments...etc.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Just removing some unneeded tests, outdated comments...etc.
</pre>
</div>
</content>
</entry>
<entry>
<title>Optimize instructions when creating an array just to call `include?` (#12123)</title>
<updated>2024-11-26T19:31:08+00:00</updated>
<author>
<name>Randy Stauner</name>
<email>randy.stauner@shopify.com</email>
</author>
<published>2024-11-26T19:31:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1dd40ec18a55ff46f52d0ba44ff5d7923f57c08f'/>
<id>1dd40ec18a55ff46f52d0ba44ff5d7923f57c08f</id>
<content type='text'>
* Add opt_duparray_send insn to skip the allocation on `#include?`

If the method isn't going to modify the array we don't need to copy it.
This avoids the allocation / array copy for things like `[:a, :b].include?(x)`.

This adds a BOP for include? and tracks redefinition for it on Array.

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* YJIT: Implement opt_duparray_send include_p

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* Update opt_newarray_send to support simple forms of include?(arg)

Similar to opt_duparray_send but for non-static arrays.

* YJIT: Implement opt_newarray_send include_p

---------

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Add opt_duparray_send insn to skip the allocation on `#include?`

If the method isn't going to modify the array we don't need to copy it.
This avoids the allocation / array copy for things like `[:a, :b].include?(x)`.

This adds a BOP for include? and tracks redefinition for it on Array.

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* YJIT: Implement opt_duparray_send include_p

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* Update opt_newarray_send to support simple forms of include?(arg)

Similar to opt_duparray_send but for non-static arrays.

* YJIT: Implement opt_newarray_send include_p

---------

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Expand opt_newarray_send to support Array#pack with buffer keyword arg</title>
<updated>2024-07-29T20:26:58+00:00</updated>
<author>
<name>Randy Stauner</name>
<email>randy.stauner@shopify.com</email>
</author>
<published>2024-07-20T17:03:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=acbb8d4fb56ac3b5894991760a075dbef78d10e3'/>
<id>acbb8d4fb56ac3b5894991760a075dbef78d10e3</id>
<content type='text'>
Use an enum for the method arg instead of needing to add an id
that doesn't map to an actual method name.

$ ruby --dump=insns -e 'b = "x"; [v].pack("E*", buffer: b)'

before:

```
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,34)&gt;
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] b@0
0000 putchilledstring                       "x"                       (   1)[Li]
0002 setlocal_WC_0                          b@0
0004 putself
0005 opt_send_without_block                 &lt;calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE&gt;
0007 newarray                               1
0009 putchilledstring                       "E*"
0011 getlocal_WC_0                          b@0
0013 opt_send_without_block                 &lt;calldata!mid:pack, argc:2, kw:[#&lt;Symbol:0x000000000023110c&gt;], KWARG&gt;
0015 leave
```

after:

```
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,34)&gt;
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] b@0
0000 putchilledstring                       "x"                       (   1)[Li]
0002 setlocal_WC_0                          b@0
0004 putself
0005 opt_send_without_block                 &lt;calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE&gt;
0007 putchilledstring                       "E*"
0009 getlocal                               b@0, 0
0012 opt_newarray_send                      3, 5
0015 leave
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use an enum for the method arg instead of needing to add an id
that doesn't map to an actual method name.

$ ruby --dump=insns -e 'b = "x"; [v].pack("E*", buffer: b)'

before:

```
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,34)&gt;
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] b@0
0000 putchilledstring                       "x"                       (   1)[Li]
0002 setlocal_WC_0                          b@0
0004 putself
0005 opt_send_without_block                 &lt;calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE&gt;
0007 newarray                               1
0009 putchilledstring                       "E*"
0011 getlocal_WC_0                          b@0
0013 opt_send_without_block                 &lt;calldata!mid:pack, argc:2, kw:[#&lt;Symbol:0x000000000023110c&gt;], KWARG&gt;
0015 leave
```

after:

```
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,34)&gt;
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] b@0
0000 putchilledstring                       "x"                       (   1)[Li]
0002 setlocal_WC_0                          b@0
0004 putself
0005 opt_send_without_block                 &lt;calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE&gt;
0007 putchilledstring                       "E*"
0009 getlocal                               b@0, 0
0012 opt_newarray_send                      3, 5
0015 leave
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Ensure test suite is compatible with --frozen-string-literal</title>
<updated>2024-03-14T16:56:15+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>byroot@ruby-lang.org</email>
</author>
<published>2024-03-13T11:50:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=09d8c99cdcb04fb6c6c8e61c9dea28927a3a0b46'/>
<id>09d8c99cdcb04fb6c6c8e61c9dea28927a3a0b46</id>
<content type='text'>
As preparation for https://bugs.ruby-lang.org/issues/20205
making sure the test suite is compatible with frozen string
literals is making things easier.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As preparation for https://bugs.ruby-lang.org/issues/20205
making sure the test suite is compatible with frozen string
literals is making things easier.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add pushtoarraykwsplat instruction to avoid unnecessary array allocation</title>
<updated>2024-02-20T18:47:44+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2024-01-30T18:31:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=77c1233f79a0f96a081b70da533fbbde4f3037fa'/>
<id>77c1233f79a0f96a081b70da533fbbde4f3037fa</id>
<content type='text'>
This is designed to replace the newarraykwsplat instruction, which is
no longer used in the parse.y compiler after this commit.  This avoids
an unnecessary array allocation in the case where ARGSCAT is followed
by LIST with keyword:

```ruby
a = []
kw = {}
[*a, 1, **kw]
```

Previous Instructions:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 newhash                                0                         (   2)[Li]
0006 setlocal_WC_0                          kw@1
0008 getlocal_WC_0                          a@0                       (   3)[Li]
0010 splatarray                             true
0012 putobject_INT2FIX_1_
0013 putspecialobject                       1
0015 newhash                                0
0017 getlocal_WC_0                          kw@1
0019 opt_send_without_block                 &lt;calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE&gt;
0021 newarraykwsplat                        2
0023 concattoarray
0024 leave
```

New Instructions:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 newhash                                0                         (   2)[Li]
0006 setlocal_WC_0                          kw@1
0008 getlocal_WC_0                          a@0                       (   3)[Li]
0010 splatarray                             true
0012 putobject_INT2FIX_1_
0013 pushtoarray                            1
0015 putspecialobject                       1
0017 newhash                                0
0019 getlocal_WC_0                          kw@1
0021 opt_send_without_block                 &lt;calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE&gt;
0023 pushtoarraykwsplat
0024 leave
```

pushtoarraykwsplat is designed to be simpler than newarraykwsplat.
It does not take a variable number of arguments from the stack, it
pops the top of the stack, and appends it to the second from the top,
unless the top of the stack is an empty hash.

During this work, I found the ARGSPUSH followed by HASH with keyword
did not compile correctly, as it pushed the generated hash to the
array even if the hash was empty.  This fixes the behavior, to use
pushtoarraykwsplat instead of pushtoarray in that case:

```ruby
a = []
kw = {}
[*a, **kw]

[{}] # Before

[] # After
```

This does not remove the newarraykwsplat instruction, as it is still
referenced in the prism compiler (which should be updated similar
to this), YJIT (only in the bindings, it does not appear to be
implemented), and RJIT (in a couple comments).  After those are
updated, the newarraykwsplat instruction should be removed.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is designed to replace the newarraykwsplat instruction, which is
no longer used in the parse.y compiler after this commit.  This avoids
an unnecessary array allocation in the case where ARGSCAT is followed
by LIST with keyword:

```ruby
a = []
kw = {}
[*a, 1, **kw]
```

Previous Instructions:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 newhash                                0                         (   2)[Li]
0006 setlocal_WC_0                          kw@1
0008 getlocal_WC_0                          a@0                       (   3)[Li]
0010 splatarray                             true
0012 putobject_INT2FIX_1_
0013 putspecialobject                       1
0015 newhash                                0
0017 getlocal_WC_0                          kw@1
0019 opt_send_without_block                 &lt;calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE&gt;
0021 newarraykwsplat                        2
0023 concattoarray
0024 leave
```

New Instructions:

```
0000 newarray                               0                         (   1)[Li]
0002 setlocal_WC_0                          a@0
0004 newhash                                0                         (   2)[Li]
0006 setlocal_WC_0                          kw@1
0008 getlocal_WC_0                          a@0                       (   3)[Li]
0010 splatarray                             true
0012 putobject_INT2FIX_1_
0013 pushtoarray                            1
0015 putspecialobject                       1
0017 newhash                                0
0019 getlocal_WC_0                          kw@1
0021 opt_send_without_block                 &lt;calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE&gt;
0023 pushtoarraykwsplat
0024 leave
```

pushtoarraykwsplat is designed to be simpler than newarraykwsplat.
It does not take a variable number of arguments from the stack, it
pops the top of the stack, and appends it to the second from the top,
unless the top of the stack is an empty hash.

During this work, I found the ARGSPUSH followed by HASH with keyword
did not compile correctly, as it pushed the generated hash to the
array even if the hash was empty.  This fixes the behavior, to use
pushtoarraykwsplat instead of pushtoarray in that case:

```ruby
a = []
kw = {}
[*a, **kw]

[{}] # Before

[] # After
```

This does not remove the newarraykwsplat instruction, as it is still
referenced in the prism compiler (which should be updated similar
to this), YJIT (only in the bindings, it does not appear to be
implemented), and RJIT (in a couple comments).  After those are
updated, the newarraykwsplat instruction should be removed.
</pre>
</div>
</content>
</entry>
<entry>
<title>Emit special instruction for array literal + .(hash|min|max)</title>
<updated>2023-04-19T00:16:22+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2022-06-07T00:27:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c5fc1ce975ecdf1c6818714e47579c5d3531c4ca'/>
<id>c5fc1ce975ecdf1c6818714e47579c5d3531c4ca</id>
<content type='text'>
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: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,12)&gt; (catch: FALSE)
0000 getinstancevariable                    :@a, &lt;is:0&gt;               (   1)[Li]
0003 getinstancevariable                    :@b, &lt;is:1&gt;
0006 opt_newarray_send                      2, :max
0009 leave
$ ./miniruby --dump=insns -e '[@a, @b].min'
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,12)&gt; (catch: FALSE)
0000 getinstancevariable                    :@a, &lt;is:0&gt;               (   1)[Li]
0003 getinstancevariable                    :@b, &lt;is:1&gt;
0006 opt_newarray_send                      2, :min
0009 leave
$ ./miniruby --dump=insns -e '[@a, @b].hash'
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,13)&gt; (catch: FALSE)
0000 getinstancevariable                    :@a, &lt;is:0&gt;               (   1)[Li]
0003 getinstancevariable                    :@b, &lt;is:1&gt;
0006 opt_newarray_send                      2, :hash
0009 leave
```

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

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,12)&gt; (catch: FALSE)
0000 getinstancevariable                    :@a, &lt;is:0&gt;               (   1)[Li]
0003 getinstancevariable                    :@b, &lt;is:1&gt;
0006 opt_newarray_send                      2, :max
0009 leave
$ ./miniruby --dump=insns -e '[@a, @b].min'
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,12)&gt; (catch: FALSE)
0000 getinstancevariable                    :@a, &lt;is:0&gt;               (   1)[Li]
0003 getinstancevariable                    :@b, &lt;is:1&gt;
0006 opt_newarray_send                      2, :min
0009 leave
$ ./miniruby --dump=insns -e '[@a, @b].hash'
== disasm: #&lt;ISeq:&lt;main&gt;@-e:1 (1,0)-(1,13)&gt; (catch: FALSE)
0000 getinstancevariable                    :@a, &lt;is:0&gt;               (   1)[Li]
0003 getinstancevariable                    :@b, &lt;is:1&gt;
0006 opt_newarray_send                      2, :hash
0009 leave
```

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

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add one more test example for swap instruction</title>
<updated>2021-11-09T07:56:44+00:00</updated>
<author>
<name>Nikita Vasilevsky</name>
<email>nikita.vasilevsky@shopify.com</email>
</author>
<published>2021-10-29T16:31:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c1c13c58eebb7441d27536a32d73380d165d6eda'/>
<id>c1c13c58eebb7441d27536a32d73380d165d6eda</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Prefer qualified names under Thread</title>
<updated>2021-06-29T02:41:10+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2021-06-28T14:01:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9eae8cdefba61e9e51feb30a4b98525593169666'/>
<id>9eae8cdefba61e9e51feb30a4b98525593169666</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Removed deprecated Time#succ</title>
<updated>2020-12-07T09:38:59+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2020-12-02T06:50:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7817a438eb1803e7b3358f43bd1f38479badfbdc'/>
<id>7817a438eb1803e7b3358f43bd1f38479badfbdc</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove test for putiseq insn</title>
<updated>2020-09-24T00:56:12+00:00</updated>
<author>
<name>Michael Lindley</name>
<email>lindleymichael@gmail.com</email>
</author>
<published>2020-08-31T21:09:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e06f4a3b1fbf703bc6ccb113bfe6bdc75ec9be38'/>
<id>e06f4a3b1fbf703bc6ccb113bfe6bdc75ec9be38</id>
<content type='text'>
putiseq was removed from instruction set in 2b5bb8a0</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
putiseq was removed from instruction set in 2b5bb8a0</pre>
</div>
</content>
</entry>
</feed>
