Skip to content

Commit 8ec0500

Browse files
committed
Merge branch 'master' into mmtk-with-master
2 parents a287393 + bb5ed8b commit 8ec0500

File tree

23 files changed

+240
-75
lines changed

23 files changed

+240
-75
lines changed

Diff for: .github/workflows/ubuntu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
- name: Set up Launchable
104104
uses: ./.github/actions/launchable/setup
105105
with:
106-
os: ${{ matrix.os }}
106+
os: ${{ matrix.os || 'ubuntu-22.04' }}
107107
test-opts: ${{ matrix.configure }}
108108
launchable-token: ${{ secrets.LAUNCHABLE_TOKEN }}
109109
builddir: build

Diff for: NEWS.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ Note that each entry is kept to a minimum, see links for details.
88
## Language changes
99

1010
* String literals in files without a `frozen_string_literal` comment now behave
11-
as if they were frozen. If they are mutated a deprecation warning is emited.
11+
as if they were frozen. If they are mutated a deprecation warning is emitted.
1212
These warnings can be enabled with `-W:deprecated` or by setting `Warning[:deprecated] = true`.
13-
To disable this change you can run Ruby with the `--disable-frozen-string-literal` command line
14-
argument. [[Feature #20205]]
13+
To disable this change, you can run Ruby with the `--disable-frozen-string-literal`
14+
command line argument. [[Feature #20205]]
1515

1616
* `it` is added to reference a block parameter. [[Feature #18980]]
1717

1818
* Keyword splatting `nil` when calling methods is now supported.
19-
`**nil` is treated similar to `**{}`, passing no keywords,
20-
and not calling any conversion methods.
21-
[[Bug #20064]]
19+
`**nil` is treated similarly to `**{}`, passing no keywords,
20+
and not calling any conversion methods. [[Bug #20064]]
2221

2322
* Block passing is no longer allowed in index. [[Bug #19918]]
2423

Diff for: compile.c

+13-19
Original file line numberDiff line numberDiff line change
@@ -4338,7 +4338,7 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons
43384338
while (list) {
43394339
const NODE *const head = list->nd_head;
43404340
if (nd_type_p(head, NODE_STR)) {
4341-
lit = rb_fstring(rb_node_str_string_val(head));
4341+
lit = rb_node_str_string_val(head);
43424342
ADD_INSN1(ret, head, putobject, lit);
43434343
RB_OBJ_WRITTEN(iseq, Qundef, lit);
43444344
lit = Qnil;
@@ -4377,7 +4377,7 @@ compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
43774377
{
43784378
int cnt;
43794379
if (!RNODE_DSTR(node)->nd_next) {
4380-
VALUE lit = rb_fstring(rb_node_dstr_string_val(node));
4380+
VALUE lit = rb_node_dstr_string_val(node);
43814381
ADD_INSN1(ret, node, putstring, lit);
43824382
RB_OBJ_WRITTEN(iseq, Qundef, lit);
43834383
}
@@ -4765,14 +4765,13 @@ static_literal_value(const NODE *node, rb_iseq_t *iseq)
47654765
case NODE_FILE:
47664766
case NODE_STR:
47674767
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
4768-
VALUE lit;
47694768
VALUE debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX((int)nd_line(node)));
4770-
lit = rb_str_dup(get_string_value(node));
4769+
VALUE lit = rb_str_dup(get_string_value(node));
47714770
rb_ivar_set(lit, id_debug_created_info, rb_obj_freeze(debug_info));
47724771
return rb_str_freeze(lit);
47734772
}
47744773
else {
4775-
return rb_fstring(get_string_value(node));
4774+
return get_string_value(node);
47764775
}
47774776
default:
47784777
rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
@@ -5142,9 +5141,9 @@ rb_node_case_when_optimizable_literal(const NODE *const node)
51425141
case NODE_LINE:
51435142
return rb_node_line_lineno_val(node);
51445143
case NODE_STR:
5145-
return rb_fstring(rb_node_str_string_val(node));
5144+
return rb_node_str_string_val(node);
51465145
case NODE_FILE:
5147-
return rb_fstring(rb_node_file_path_val(node));
5146+
return rb_node_file_path_val(node);
51485147
}
51495148
return Qundef;
51505149
}
@@ -5166,7 +5165,7 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
51665165

51675166
if (nd_type_p(val, NODE_STR) || nd_type_p(val, NODE_FILE)) {
51685167
debugp_param("nd_lit", get_string_value(val));
5169-
lit = rb_fstring(get_string_value(val));
5168+
lit = get_string_value(val);
51705169
ADD_INSN1(cond_seq, val, putobject, lit);
51715170
RB_OBJ_WRITTEN(iseq, Qundef, lit);
51725171
}
@@ -8445,7 +8444,7 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
84458444
get_nd_args(node) == NULL &&
84468445
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
84478446
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
8448-
VALUE str = rb_fstring(get_string_value(get_nd_recv(node)));
8447+
VALUE str = get_string_value(get_nd_recv(node));
84498448
if (get_node_call_nd_mid(node) == idUMinus) {
84508449
ADD_INSN2(ret, line_node, opt_str_uminus, str,
84518450
new_callinfo(iseq, idUMinus, 0, 0, NULL, FALSE));
@@ -8469,7 +8468,7 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
84698468
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
84708469
!frozen_string_literal_p(iseq) &&
84718470
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
8472-
VALUE str = rb_fstring(get_string_value(RNODE_LIST(get_nd_args(node))->nd_head));
8471+
VALUE str = get_string_value(RNODE_LIST(get_nd_args(node))->nd_head);
84738472
CHECK(COMPILE(ret, "recv", get_nd_recv(node)));
84748473
ADD_INSN2(ret, line_node, opt_aref_with, str,
84758474
new_callinfo(iseq, idAREF, 1, 0, NULL, FALSE));
@@ -9746,7 +9745,7 @@ compile_attrasgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
97469745
!frozen_string_literal_p(iseq) &&
97479746
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction)
97489747
{
9749-
VALUE str = rb_fstring(get_string_value(RNODE_LIST(RNODE_ATTRASGN(node)->nd_args)->nd_head));
9748+
VALUE str = get_string_value(RNODE_LIST(RNODE_ATTRASGN(node)->nd_args)->nd_head);
97509749
CHECK(COMPILE(ret, "recv", RNODE_ATTRASGN(node)->nd_recv));
97519750
CHECK(COMPILE(ret, "value", RNODE_LIST(RNODE_LIST(RNODE_ATTRASGN(node)->nd_args)->nd_next)->nd_head));
97529751
if (!popped) {
@@ -9971,7 +9970,7 @@ compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_pa
99719970
return COMPILE_OK;
99729971

99739972
case NODE_STR:{
9974-
VALUE lit = rb_fstring(rb_node_str_string_val(node));
9973+
VALUE lit = rb_node_str_string_val(node);
99759974
ADD_INSN1(ret, node, putobject, lit);
99769975
RB_OBJ_WRITTEN(iseq, Qundef, lit);
99779976
*value_p = lit;
@@ -9981,7 +9980,7 @@ compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_pa
99819980
}
99829981

99839982
case NODE_FILE:{
9984-
VALUE lit = rb_fstring(rb_node_file_path_val(node));
9983+
VALUE lit = rb_node_file_path_val(node);
99859984
ADD_INSN1(ret, node, putobject, lit);
99869985
RB_OBJ_WRITTEN(iseq, Qundef, lit);
99879986
*value_p = lit;
@@ -10576,12 +10575,10 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
1057610575
VALUE lit = get_string_value(node);
1057710576
switch (ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) {
1057810577
case ISEQ_FROZEN_STRING_LITERAL_UNSET:
10579-
lit = rb_fstring(lit);
1058010578
ADD_INSN1(ret, node, putchilledstring, lit);
1058110579
RB_OBJ_WRITTEN(iseq, Qundef, lit);
1058210580
break;
1058310581
case ISEQ_FROZEN_STRING_LITERAL_DISABLED:
10584-
lit = rb_fstring(lit);
1058510582
ADD_INSN1(ret, node, putstring, lit);
1058610583
RB_OBJ_WRITTEN(iseq, Qundef, lit);
1058710584
break;
@@ -10592,9 +10589,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
1059210589
rb_ivar_set(lit, id_debug_created_info, rb_obj_freeze(debug_info));
1059310590
lit = rb_str_freeze(lit);
1059410591
}
10595-
else {
10596-
lit = rb_fstring(lit);
10597-
}
1059810592
ADD_INSN1(ret, node, putobject, lit);
1059910593
RB_OBJ_WRITTEN(iseq, Qundef, lit);
1060010594
break;
@@ -10614,7 +10608,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
1061410608
}
1061510609
case NODE_XSTR:{
1061610610
ADD_CALL_RECEIVER(ret, node);
10617-
VALUE str = rb_fstring(rb_node_str_string_val(node));
10611+
VALUE str = rb_node_str_string_val(node);
1061810612
ADD_INSN1(ret, node, putobject, str);
1061910613
RB_OBJ_WRITTEN(iseq, Qundef, str);
1062010614
ADD_CALL(ret, node, idBackquote, INT2FIX(1));

Diff for: ext/pty/extconf.rb

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
if have_func("posix_openpt") or
1717
(util or have_func("openpty")) or
1818
have_func("_getpty") or
19+
have_func("ptsname_r") or
1920
have_func("ptsname") or
2021
have_func("ioctl")
2122
create_makefile('pty')

Diff for: ext/pty/pty.c

+19-6
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,21 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
256256
RB_GC_GUARD(carg.execarg_obj);
257257
}
258258

259-
#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_OPENPTY) || defined(HAVE_PTSNAME)
259+
#if defined(HAVE_PTSNAME) && !defined(HAVE_PTSNAME_R)
260+
/* glibc only, not obsolete interface on Tru64 or HP-UX */
261+
static int
262+
ptsname_r(int fd, char *buf, size_t buflen)
263+
{
264+
extern char *ptsname(int);
265+
char *name = ptsname(fd);
266+
if (!name) return -1;
267+
strlcpy(buf, name, buflen);
268+
return 0;
269+
}
270+
# define HAVE_PTSNAME_R 1
271+
#endif
272+
273+
#if defined(HAVE_POSIX_OPENPT) || defined(HAVE_OPENPTY) || defined(HAVE_PTSNAME_R)
260274
static int
261275
no_mesg(char *slavedevice, int nomesg)
262276
{
@@ -320,7 +334,8 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
320334
#endif
321335
if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
322336
if (unlockpt(masterfd) == -1) goto error;
323-
if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
337+
if (ptsname_r(masterfd, SlaveName, DEVICELEN) != 0) goto error;
338+
slavedevice = SlaveName;
324339
if (no_mesg(slavedevice, nomesg) == -1) goto error;
325340
if ((slavefd = rb_cloexec_open(slavedevice, O_RDWR|O_NOCTTY, 0)) == -1) goto error;
326341
rb_update_max_fd(slavefd);
@@ -333,7 +348,6 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
333348

334349
*master = masterfd;
335350
*slave = slavefd;
336-
strlcpy(SlaveName, slavedevice, DEVICELEN);
337351
return 0;
338352

339353
grantpt_error:
@@ -387,7 +401,6 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
387401
char *slavedevice;
388402
void (*s)();
389403

390-
extern char *ptsname(int);
391404
extern int unlockpt(int);
392405
extern int grantpt(int);
393406

@@ -405,7 +418,8 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
405418
#endif
406419
signal(SIGCHLD, s);
407420
if(unlockpt(masterfd) == -1) goto error;
408-
if((slavedevice = ptsname(masterfd)) == NULL) goto error;
421+
if (ptsname_r(masterfd, SlaveName, DEVICELEN) != 0) goto error;
422+
slavedevice = SlaveName;
409423
if (no_mesg(slavedevice, nomesg) == -1) goto error;
410424
if((slavefd = rb_cloexec_open(slavedevice, O_RDWR, 0)) == -1) goto error;
411425
rb_update_max_fd(slavefd);
@@ -416,7 +430,6 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
416430
#endif
417431
*master = masterfd;
418432
*slave = slavefd;
419-
strlcpy(SlaveName, slavedevice, DEVICELEN);
420433
return 0;
421434

422435
error:

Diff for: gc.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -4925,8 +4925,8 @@ id2ref(VALUE objid)
49254925
if (ptr == Qtrue) return Qtrue;
49264926
if (ptr == Qfalse) return Qfalse;
49274927
if (NIL_P(ptr)) return Qnil;
4928-
if (FIXNUM_P(ptr)) return (VALUE)ptr;
4929-
if (FLONUM_P(ptr)) return (VALUE)ptr;
4928+
if (FIXNUM_P(ptr)) return ptr;
4929+
if (FLONUM_P(ptr)) return ptr;
49304930

49314931
ptr = obj_id_to_ref(objid);
49324932
if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
@@ -9961,15 +9961,15 @@ gc_set_candidate_object_i(void *vstart, void *vend, size_t stride, void *data)
99619961
for (; v != (VALUE)vend; v += stride) {
99629962
asan_unpoisoning_object(v) {
99639963
switch (BUILTIN_TYPE(v)) {
9964-
case T_NONE:
9965-
case T_ZOMBIE:
9964+
case T_NONE:
9965+
case T_ZOMBIE:
99669966
break;
9967-
case T_STRING:
9967+
case T_STRING:
99689968
// precompute the string coderange. This both save time for when it will be
99699969
// eventually needed, and avoid mutating heap pages after a potential fork.
99709970
rb_enc_str_coderange(v);
99719971
// fall through
9972-
default:
9972+
default:
99739973
if (!RVALUE_OLD_P(v) && !RVALUE_WB_UNPROTECTED(v)) {
99749974
RVALUE_AGE_SET_CANDIDATE(objspace, v);
99759975
}

Diff for: include/ruby/internal/gc.h

+3
Original file line numberDiff line numberDiff line change
@@ -823,4 +823,7 @@ rb_obj_write(
823823
return a;
824824
}
825825

826+
RBIMPL_ATTR_DEPRECATED(("Will be removed soon"))
827+
static inline void rb_gc_force_recycle(VALUE obj){}
828+
826829
#endif /* RBIMPL_GC_H */

Diff for: internal/ruby_parser.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
1919
VALUE rb_parser_new(void);
2020
rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
2121
VALUE rb_str_new_parser_string(rb_parser_string_t *str);
22+
VALUE rb_str_new_mutable_parser_string(rb_parser_string_t *str);
2223

2324
VALUE rb_node_str_string_val(const NODE *);
2425
VALUE rb_node_sym_string_val(const NODE *);

Diff for: lib/irb.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,12 @@ def eval_input
10351035
@context.evaluate(statement.code, line_no)
10361036
when Statement::Command
10371037
ret = statement.command_class.execute(@context, statement.arg)
1038+
# TODO: Remove this output once we have a better way to handle it
1039+
# This is to notify `debug`'s test framework that the current input has been processed
1040+
# We also need to have a way to restart/stop threads around command execution
1041+
# when being used as `debug`'s console.
1042+
# https://github.com/ruby/debug/blob/master/lib/debug/irb_integration.rb#L8-L13
1043+
puts "INTERNAL_INFO: {}" if @context.with_debugger && ENV['RUBY_DEBUG_TEST_UI'] == 'terminal'
10381044
@context.set_last_value(ret)
10391045
end
10401046

Diff for: parse.y

+6-4
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ RBIMPL_WARNING_POP()
332332

333333
#define NO_LEX_CTXT (struct lex_context){0}
334334

335-
#define AREF(ary, i) RARRAY_AREF(ary, i)
336-
337335
#ifndef WARN_PAST_SCOPE
338336
# define WARN_PAST_SCOPE 0
339337
#endif
@@ -3447,7 +3445,7 @@ command : fcall command_args %prec tLOWEST
34473445
{
34483446
set_embraced_location($5, &@4, &@6);
34493447
$$ = new_command_qcall(p, idCOLON2, $1, $3, Qnull, $5, &@3, &@$);
3450-
/*% ripper: method_add_block!(command_call!($:1, $:2, $:3, Qundef), $:5) %*/
3448+
/*% ripper: method_add_block!(command_call!($:1, $:2, $:3, Qnil), $:5) %*/
34513449
}
34523450
| keyword_super command_args
34533451
{
@@ -7961,7 +7959,7 @@ nextline(struct parser_params *p, int set_encoding)
79617959
}
79627960
#ifndef RIPPER
79637961
if (p->debug_lines) {
7964-
VALUE v = rb_str_new_parser_string(str);
7962+
VALUE v = rb_str_new_mutable_parser_string(str);
79657963
if (set_encoding) rb_enc_associate(v, p->enc);
79667964
rb_ary_push(p->debug_lines, v);
79677965
}
@@ -13816,6 +13814,10 @@ new_bv(struct parser_params *p, ID name)
1381613814
}
1381713815
if (!shadowing_lvar_0(p, name)) return;
1381813816
dyna_var(p, name);
13817+
ID *vidp = 0;
13818+
if (dvar_defined_ref(p, name, &vidp)) {
13819+
if (vidp) *vidp |= LVAR_USED;
13820+
}
1381913821
}
1382013822

1382113823
static void

Diff for: prism/prism.c

+3
Original file line numberDiff line numberDiff line change
@@ -13859,6 +13859,7 @@ parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, pm_rescues_type
1385913859
case PM_RESCUES_LAMBDA: context = PM_CONTEXT_LAMBDA_RESCUE; break;
1386013860
case PM_RESCUES_MODULE: context = PM_CONTEXT_MODULE_RESCUE; break;
1386113861
case PM_RESCUES_SCLASS: context = PM_CONTEXT_SCLASS_RESCUE; break;
13862+
default: assert(false && "unreachable"); context = PM_CONTEXT_BEGIN_RESCUE; break;
1386213863
}
1386313864

1386413865
pm_statements_node_t *statements = parse_statements(parser, context);
@@ -13906,6 +13907,7 @@ parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, pm_rescues_type
1390613907
case PM_RESCUES_LAMBDA: context = PM_CONTEXT_LAMBDA_ELSE; break;
1390713908
case PM_RESCUES_MODULE: context = PM_CONTEXT_MODULE_ELSE; break;
1390813909
case PM_RESCUES_SCLASS: context = PM_CONTEXT_SCLASS_ELSE; break;
13910+
default: assert(false && "unreachable"); context = PM_CONTEXT_BEGIN_RESCUE; break;
1390913911
}
1391013912

1391113913
else_statements = parse_statements(parser, context);
@@ -13935,6 +13937,7 @@ parse_rescues(pm_parser_t *parser, pm_begin_node_t *parent_node, pm_rescues_type
1393513937
case PM_RESCUES_LAMBDA: context = PM_CONTEXT_LAMBDA_ENSURE; break;
1393613938
case PM_RESCUES_MODULE: context = PM_CONTEXT_MODULE_ENSURE; break;
1393713939
case PM_RESCUES_SCLASS: context = PM_CONTEXT_SCLASS_ENSURE; break;
13940+
default: assert(false && "unreachable"); context = PM_CONTEXT_BEGIN_RESCUE; break;
1393813941
}
1393913942

1394013943
ensure_statements = parse_statements(parser, context);

0 commit comments

Comments
 (0)