Skip to content
  • Nobuyoshi Nakada's avatar
    49fcd33e
    Introduce a specialize instruction for Array#pack · 49fcd33e
    Nobuyoshi Nakada authored
    
    
    Instructions for this code:
    
    ```ruby
      # frozen_string_literal: true
    
    [a].pack("C")
    ```
    
    Before this commit:
    
    ```
    == disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
    0000 putself                                                          (   3)[Li]
    0001 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
    0003 newarray                               1
    0005 putobject                              "C"
    0007 opt_send_without_block                 <calldata!mid:pack, argc:1, ARGS_SIMPLE>
    0009 leave
    ```
    
    After this commit:
    
    ```
    == disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
    0000 putself                                                          (   3)[Li]
    0001 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
    0003 putobject                              "C"
    0005 opt_newarray_send                      2, :pack
    0008 leave
    ```
    
    Co-authored-by: default avatarMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
    Co-authored-by: default avatarAaron Patterson <tenderlove@ruby-lang.org>
    49fcd33e
    Introduce a specialize instruction for Array#pack
    Nobuyoshi Nakada authored
    
    
    Instructions for this code:
    
    ```ruby
      # frozen_string_literal: true
    
    [a].pack("C")
    ```
    
    Before this commit:
    
    ```
    == disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
    0000 putself                                                          (   3)[Li]
    0001 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
    0003 newarray                               1
    0005 putobject                              "C"
    0007 opt_send_without_block                 <calldata!mid:pack, argc:1, ARGS_SIMPLE>
    0009 leave
    ```
    
    After this commit:
    
    ```
    == disasm: #<ISeq:<main>@test.rb:1 (1,0)-(3,13)>
    0000 putself                                                          (   3)[Li]
    0001 opt_send_without_block                 <calldata!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>
    0003 putobject                              "C"
    0005 opt_newarray_send                      2, :pack
    0008 leave
    ```
    
    Co-authored-by: default avatarMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
    Co-authored-by: default avatarAaron Patterson <tenderlove@ruby-lang.org>
Loading