@@ -3195,7 +3195,7 @@ iseq_pop_newarray(rb_iseq_t *iseq, INSN *iobj)
31953195static int
31963196is_frozen_putstring(INSN *insn, VALUE *op)
31973197{
3198- if (IS_INSN_ID(insn, putstring ) || IS_INSN_ID(insn, putchilledstring )) {
3198+ if (IS_INSN_ID(insn, dupstring ) || IS_INSN_ID(insn, dupchilledstring )) {
31993199 *op = OPERAND_AT(insn, 0);
32003200 return 1;
32013201 }
@@ -3255,8 +3255,8 @@ optimize_checktype(rb_iseq_t *iseq, INSN *iobj)
32553255 VALUE type;
32563256
32573257 switch (INSN_OF(iobj)) {
3258- case BIN(putstring ):
3259- case BIN(putchilledstring ):
3258+ case BIN(dupstring ):
3259+ case BIN(dupchilledstring ):
32603260 type = INT2FIX(T_STRING);
32613261 break;
32623262 case BIN(putnil):
@@ -3454,8 +3454,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
34543454 }
34553455
34563456 /*
3457- * putstring "beg"
3458- * putstring "end"
3457+ * dupstring "beg"
3458+ * dupstring "end"
34593459 * newrange excl
34603460 *
34613461 * ==>
@@ -3670,16 +3670,16 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
36703670 * =>
36713671 * jump L1
36723672 *
3673- * putstring ".."
3673+ * dupstring ".."
36743674 * if L1
36753675 * =>
36763676 * jump L1
36773677 *
3678- * putstring ".."
3678+ * dupstring ".."
36793679 * dup
36803680 * if L1
36813681 * =>
3682- * putstring ".."
3682+ * dupstring ".."
36833683 * jump L1
36843684 *
36853685 */
@@ -3694,7 +3694,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
36943694 OPERAND_AT(pobj, 0) == Qfalse :
36953695 FALSE);
36963696 }
3697- else if (IS_INSN_ID(pobj, putstring ) ||
3697+ else if (IS_INSN_ID(pobj, dupstring ) ||
36983698 IS_INSN_ID(pobj, duparray) ||
36993699 IS_INSN_ID(pobj, newarray)) {
37003700 cond = IS_INSN_ID(iobj, branchif);
@@ -3732,7 +3732,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
37323732
37333733 if (IS_INSN_ID(iobj, pop)) {
37343734 /*
3735- * putself / putnil / putobject obj / putstring "..."
3735+ * putself / putnil / putobject obj / dupstring "..."
37363736 * pop
37373737 * =>
37383738 * # do nothing
@@ -3741,8 +3741,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
37413741 if (IS_INSN(prev)) {
37423742 enum ruby_vminsn_type previ = ((INSN *)prev)->insn_id;
37433743 if (previ == BIN(putobject) || previ == BIN(putnil) ||
3744- previ == BIN(putself) || previ == BIN(putstring ) ||
3745- previ == BIN(putchilledstring ) ||
3744+ previ == BIN(putself) || previ == BIN(dupstring ) ||
3745+ previ == BIN(dupchilledstring ) ||
37463746 previ == BIN(dup) ||
37473747 previ == BIN(getlocal) ||
37483748 previ == BIN(getblockparam) ||
@@ -3884,10 +3884,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
38843884 }
38853885 }
38863886
3887- if (IS_INSN_ID(iobj, putstring ) || IS_INSN_ID(iobj, putchilledstring ) ||
3887+ if (IS_INSN_ID(iobj, dupstring ) || IS_INSN_ID(iobj, dupchilledstring ) ||
38883888 (IS_INSN_ID(iobj, putobject) && RB_TYPE_P(OPERAND_AT(iobj, 0), T_STRING))) {
38893889 /*
3890- * putstring ""
3890+ * dupstring ""
38913891 * concatstrings N
38923892 * =>
38933893 * concatstrings N-1
@@ -4222,7 +4222,7 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
42224222 }
42234223 }
42244224 }
4225- else if ((IS_INSN_ID(niobj, putstring ) || IS_INSN_ID(niobj, putchilledstring ) ||
4225+ else if ((IS_INSN_ID(niobj, dupstring ) || IS_INSN_ID(niobj, dupchilledstring ) ||
42264226 (IS_INSN_ID(niobj, putobject) && RB_TYPE_P(OPERAND_AT(niobj, 0), T_STRING))) &&
42274227 IS_NEXT_INSN_ID(&niobj->link, send)) {
42284228 const struct rb_callinfo *ci = (struct rb_callinfo *)OPERAND_AT((INSN *)niobj->link.next, 0);
@@ -4235,9 +4235,9 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
42354235 return COMPILE_OK;
42364236 }
42374237 }
4238- // newarray n, putchilledstring "E", getlocal b, send :pack with {buffer: b}
4239- // -> putchilledstring "E", getlocal b, opt_newarray_send n+2, :pack, :buffer
4240- else if ((IS_INSN_ID(niobj, putstring ) || IS_INSN_ID(niobj, putchilledstring ) ||
4238+ // newarray n, dupchilledstring "E", getlocal b, send :pack with {buffer: b}
4239+ // -> dupchilledstring "E", getlocal b, opt_newarray_send n+2, :pack, :buffer
4240+ else if ((IS_INSN_ID(niobj, dupstring ) || IS_INSN_ID(niobj, dupchilledstring ) ||
42414241 (IS_INSN_ID(niobj, putobject) && RB_TYPE_P(OPERAND_AT(niobj, 0), T_STRING))) &&
42424242 IS_NEXT_INSN_ID(&niobj->link, getlocal) &&
42434243 (niobj->link.next && IS_NEXT_INSN_ID(niobj->link.next, send))) {
@@ -4260,7 +4260,7 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
42604260 // Break the "else if" chain since some prior checks abort after sub-ifs.
42614261 // We already found "newarray". To match `[...].include?(arg)` we look for
42624262 // the instruction(s) representing the argument followed by a "send".
4263- if ((IS_INSN_ID(niobj, putstring ) || IS_INSN_ID(niobj, putchilledstring ) ||
4263+ if ((IS_INSN_ID(niobj, dupstring ) || IS_INSN_ID(niobj, dupchilledstring ) ||
42644264 IS_INSN_ID(niobj, putobject) ||
42654265 IS_INSN_ID(niobj, putself) ||
42664266 IS_INSN_ID(niobj, getlocal) ||
@@ -4729,7 +4729,7 @@ compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
47294729 int cnt;
47304730 if (!RNODE_DSTR(node)->nd_next) {
47314731 VALUE lit = rb_node_dstr_string_val(node);
4732- ADD_INSN1(ret, node, putstring , lit);
4732+ ADD_INSN1(ret, node, dupstring , lit);
47334733 RB_OBJ_SET_SHAREABLE(lit);
47344734 RB_OBJ_WRITTEN(iseq, Qundef, lit);
47354735 }
@@ -11250,10 +11250,10 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
1125011250 }
1125111251 switch (option->frozen_string_literal) {
1125211252 case ISEQ_FROZEN_STRING_LITERAL_UNSET:
11253- ADD_INSN1(ret, node, putchilledstring , lit);
11253+ ADD_INSN1(ret, node, dupchilledstring , lit);
1125411254 break;
1125511255 case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
11256- ADD_INSN1(ret, node, putstring , lit);
11256+ ADD_INSN1(ret, node, dupstring , lit);
1125711257 break;
1125811258 case ISEQ_FROZEN_STRING_LITERAL_ENABLED:
1125911259 ADD_INSN1(ret, node, putobject, lit);
0 commit comments