Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add one more test example for swap instruction #5057

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

nvasilevski
Copy link
Contributor

I may be confusing the purpose of this test file but personally I am using it to find examples of the ruby code that generate certain instructions. This is really helpful but the code example for the swap instruction is really complicated compared to other examples.

The added example generates much smaller number of instructions:

ruby --dump=insns -e "defined? [[]]"

== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: TRUE)
== catch table
| catch type: rescue st: 0001 ed: 0003 sp: 0000 cont: 0005
| == disasm: #<ISeq:defined guard in <main>@-e:0 (0,0)-(-1,-1)> (catch: FALSE)
| local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
| [ 1] "\#$!"@0
| 0000 putnil
| 0001 leave
|------------------------------------------------------------------------
0000 putnil                                                           (   1)[Li]
0001 putobject                    "expression"
0003 swap
0004 pop
0005 leave

I'm keeping the existing example because for my purposes the more examples we have - the better 馃檭

@ko1
Copy link
Contributor

ko1 commented Nov 9, 2021

We can merge this PR but I think it seems fragile (some optimizations can remove these instructions).

@ko1 ko1 merged commit c1c13c5 into ruby:master Nov 9, 2021
@nvasilevski nvasilevski deleted the add-new-swap-insns-example branch November 9, 2021 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants