summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorÉtienne Barrié <[email protected]>2024-08-05 12:31:24 +0200
committerJean Boussier <[email protected]>2024-09-05 12:46:02 +0200
commitbf9879791af11a20e50921551220c08d1c7f7f02 ()
tree68732e79fac871a629fc815b525f0cc20ed1c8bc /compile.c
parenta99707cd9c6a1d53cf8ebc883dc210219bd67a28 (diff)
Optimized instruction for Hash#freeze
If a Hash which is empty or only using literals is frozen, we detect this as a peephole optimization and change the instructions to be `opt_hash_freeze`. [Feature #20684] Co-authored-by: Jean Boussier <[email protected]>
Notes: Merged: https://.com/ruby/ruby/pull/11406
-rw-r--r--compile.c49
1 files changed, 49 insertions, 0 deletions
@@ -3430,6 +3430,32 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
/*
* newarray 0
* send <calldata!mid:freeze, argc:0, ARGS_SIMPLE>, nil
* =>
@@ -3452,6 +3478,29 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
if (IS_INSN_ID(iobj, branchif) ||
IS_INSN_ID(iobj, branchnil) ||
IS_INSN_ID(iobj, branchunless)) {