summaryrefslogtreecommitdiff
path: root/insns.def
diff options
context:
space:
mode:
authorRandy Stauner <[email protected]>2024-07-20 10:03:02 -0700
committerAlan Wu <[email protected]>2024-07-29 16:26:58 -0400
commitacbb8d4fb56ac3b5894991760a075dbef78d10e3 ()
treec09e88424f1a72646cfec44f5d1a8279340b7171 /insns.def
parent86a762ce56cd44db69ccff2e02587ed748a3ad04 (diff)
Expand opt_newarray_send to support Array#pack with buffer keyword arg
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: #<ISeq:<main>@-e:1 (1,0)-(1,34)> 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 <calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0007 newarray 1 0009 putchilledstring "E*" 0011 getlocal_WC_0 b@0 0013 opt_send_without_block <calldata!mid:pack, argc:2, kw:[#<Symbol:0x000000000023110c>], KWARG> 0015 leave ``` after: ``` == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,34)> 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 <calldata!mid:v, argc:0, FCALL|VCALL|ARGS_SIMPLE> 0007 putchilledstring "E*" 0009 getlocal b@0, 0 0012 opt_newarray_send 3, 5 0015 leave ```
Notes: Merged: https://.com/ruby/ruby/pull/11249
-rw-r--r--insns.def15
1 files changed, 9 insertions, 6 deletions
@@ -983,7 +983,7 @@ opt_str_uminus
DEFINE_INSN
opt_newarray_send
-(rb_num_t num, ID method)
(...)
(VALUE val)
/* This instruction typically has no funcalls. But it compares array
@@ -995,17 +995,20 @@ opt_newarray_send
// attr rb_snum_t comptime_sp_inc = 1 - (rb_snum_t)num;
{
switch(method) {
- case idHash:
val = vm_opt_newarray_hash(ec, num, STACK_ADDR_FROM_TOP(num));
break;
- case idMin:
val = vm_opt_newarray_min(ec, num, STACK_ADDR_FROM_TOP(num));
break;
- case idMax:
val = vm_opt_newarray_max(ec, num, STACK_ADDR_FROM_TOP(num));
break;
- case idPack:
- val = rb_vm_opt_newarray_pack(ec, (long)num-1, STACK_ADDR_FROM_TOP(num), TOPN(0));
break;
default:
rb_bug("unreachable");