Skip to content

Commit ee57c8b

Browse files
author
Kadir Selçuk
authored
Merge pull request #85 from ruby/master
[pull] master from ruby:master
2 parents 3da9d12 + ad2b719 commit ee57c8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2408
-1616
lines changed

.gdbinit

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ define rp
6767
printf "%sT_OBJECT%s: ", $color_type, $color_end
6868
print ((struct RObject *)($arg0))->basic
6969
if ($flags & ROBJECT_EMBED)
70-
print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (ROBJECT_EMBED_LEN_MAX+0)
70+
print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (rb_shape_get_shape($arg0)->capacity)
7171
else
7272
print (((struct RObject *)($arg0))->as.heap)
7373
if (((struct RObject*)($arg0))->as.heap.numiv) > 0
@@ -104,8 +104,8 @@ define rp
104104
(($rsflags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
105105
set print address off
106106
output *(char *)(($rsflags & RUBY_FL_USER1) ? \
107-
((struct RString*)$regsrc)->as.heap.ptr : \
108-
((struct RString*)$regsrc)->as.ary) @ $len
107+
((struct RString*)$regsrc)->as.heap.ptr : \
108+
((struct RString*)$regsrc)->as.ary) @ $len
109109
set print address on
110110
printf " len:%ld ", $len
111111
if $flags & RUBY_FL_USER6
@@ -126,26 +126,26 @@ define rp
126126
printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
127127
printf "(embed) "
128128
if ($len == 0)
129-
printf "{(empty)} "
129+
printf "{(empty)} "
130130
else
131-
print/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
132-
printf " "
131+
print/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
132+
printf " "
133133
end
134134
else
135135
set $len = ((struct RArray*)($arg0))->as.heap.len
136136
printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
137137
if ($flags & RUBY_FL_USER2)
138-
printf "(shared) shared="
139-
output/x ((struct RArray*)($arg0))->as.heap.aux.shared_root
140-
printf " "
138+
printf "(shared) shared="
139+
output/x ((struct RArray*)($arg0))->as.heap.aux.shared_root
140+
printf " "
141141
else
142-
printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
142+
printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
143143
end
144144
if ($len == 0)
145-
printf "{(empty)} "
145+
printf "{(empty)} "
146146
else
147-
print/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
148-
printf " "
147+
print/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
148+
printf " "
149149
end
150150
end
151151
print (struct RArray *)($arg0)
@@ -445,8 +445,8 @@ define output_string
445445
(($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
446446
if $len > 0
447447
output *(char *)(($flags & RUBY_FL_USER1) ? \
448-
((struct RString*)($arg0))->as.heap.ptr : \
449-
((struct RString*)($arg0))->as.ary) @ $len
448+
((struct RString*)($arg0))->as.heap.ptr : \
449+
((struct RString*)($arg0))->as.ary) @ $len
450450
else
451451
output ""
452452
end
@@ -459,8 +459,8 @@ define print_string
459459
(($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
460460
if $len > 0
461461
printf "%s", *(char *)(($flags & RUBY_FL_USER1) ? \
462-
((struct RString*)($arg0))->as.heap.ptr : \
463-
((struct RString*)($arg0))->as.ary) @ $len
462+
((struct RString*)($arg0))->as.heap.ptr : \
463+
((struct RString*)($arg0))->as.ary) @ $len
464464
end
465465
end
466466

@@ -868,22 +868,22 @@ define rb_numtable_entry
868868
set $rb_numtable_p = $rb_numtable_tbl->as.packed.bins
869869
while $rb_numtable_p && $rb_numtable_p < $rb_numtable_tbl->as.packed.bins+$rb_numtable_tbl->num_entries
870870
if $rb_numtable_p.k == $rb_numtable_id
871-
set $rb_numtable_key = $rb_numtable_p.k
872-
set $rb_numtable_rec = $rb_numtable_p.v
873-
set $rb_numtable_p = 0
871+
set $rb_numtable_key = $rb_numtable_p.k
872+
set $rb_numtable_rec = $rb_numtable_p.v
873+
set $rb_numtable_p = 0
874874
else
875-
set $rb_numtable_p = $rb_numtable_p + 1
875+
set $rb_numtable_p = $rb_numtable_p + 1
876876
end
877877
end
878878
else
879879
set $rb_numtable_p = $rb_numtable_tbl->as.big.bins[st_numhash($rb_numtable_id) % $rb_numtable_tbl->num_bins]
880880
while $rb_numtable_p
881881
if $rb_numtable_p->key == $rb_numtable_id
882-
set $rb_numtable_key = $rb_numtable_p->key
883-
set $rb_numtable_rec = $rb_numtable_p->record
884-
set $rb_numtable_p = 0
882+
set $rb_numtable_key = $rb_numtable_p->key
883+
set $rb_numtable_rec = $rb_numtable_p->record
884+
set $rb_numtable_p = 0
885885
else
886-
set $rb_numtable_p = $rb_numtable_p->next
886+
set $rb_numtable_p = $rb_numtable_p->next
887887
end
888888
end
889889
end
@@ -961,7 +961,7 @@ define iseq
961961
set $operand_size = ((INSN*)($arg0))->operand_size
962962
set $operands = ((INSN*)($arg0))->operands
963963
while $i < $operand_size
964-
rp $operands[$i++]
964+
rp $operands[$i++]
965965
end
966966
end
967967
end
@@ -1348,3 +1348,5 @@ define print_flags
13481348
printf "RUBY_FL_USER17 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER17 ? "1" : "0"
13491349
printf "RUBY_FL_USER18 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER18 ? "1" : "0"
13501350
end
1351+
1352+
source misc/gdb.py

.github/workflows/compilers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ jobs:
174174
# - { name: USE_SYMBOL_GC=0, env: { cppflags: '-DUSE_SYMBOL_GC=0' } }
175175
# - { name: USE_THREAD_CACHE=0, env: { cppflags: '-DUSE_THREAD_CACHE=0' } }
176176
# - { name: USE_TRANSIENT_HEAP=0, env: { cppflags: '-DUSE_TRANSIENT_HEAP=0' } }
177-
# - { name: USE_RUBY_DEBUG_LOG=1, env: { cppflags: '-DUSE_RUBY_DEBUG_LOG=1' } }
177+
- { name: USE_RUBY_DEBUG_LOG=1, env: { cppflags: '-DUSE_RUBY_DEBUG_LOG=1' } }
178178
- { name: USE_RVARGC=0, env: { cppflags: '-DUSE_RVARGC=0' } }
179179
# - { name: USE_RVARGC=1, env: { cppflags: '-DUSE_RVARGC=1' } }
180180
# - { name: USE_DEBUG_COUNTER, env: { cppflags: '-DUSE_DEBUG_COUNTER=1', RUBY_DEBUG_COUNTER_DISABLE: '1' } }

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
persist-credentials: false
3838

3939
- name: "Run analysis"
40-
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
40+
uses: ossf/scorecard-action@80e868c13c90f172d68d1f4501dee99e2479f7af # v2.1.3
4141
with:
4242
results_file: results.sarif
4343
results_format: sarif

array.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
17871787
* Related: #push, #pop, #shift.
17881788
*/
17891789

1790-
static VALUE
1790+
VALUE
17911791
rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
17921792
{
17931793
long len = RARRAY_LEN(ary);
@@ -1804,17 +1804,10 @@ rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
18041804
return ary;
18051805
}
18061806

1807-
/* non-static for yjit */
1808-
VALUE
1809-
rb_yjit_rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
1810-
{
1811-
return rb_ary_unshift_m(argc, argv, ary);
1812-
}
1813-
18141807
VALUE
18151808
rb_ary_unshift(VALUE ary, VALUE item)
18161809
{
1817-
return rb_ary_unshift_m(1,&item,ary);
1810+
return rb_ary_unshift_m(1, &item, ary);
18181811
}
18191812

18201813
/* faster version - use this if you don't need to treat negative offset */

bootstraptest/test_yjit.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,16 +3802,18 @@ def post(*args, &block)
38023802
}
38033803

38043804
# Test rest and kw_args
3805-
assert_equal '[[["test"], nil, true], [["test"], :base, true]]', %q{
3805+
assert_equal '[true, true, true, true]', %q{
38063806
def my_func(*args, base: nil, sort: true)
38073807
[args, base, sort]
38083808
end
38093809
38103810
def calling_my_func
3811-
result = []
3812-
result << my_func("test")
3813-
result << my_func("test", base: :base)
3811+
results = []
3812+
results << (my_func("test") == [["test"], nil, true])
3813+
results << (my_func("test", base: :base) == [["test"], :base, true])
3814+
results << (my_func("test", sort: false) == [["test"], nil, false])
3815+
results << (my_func("test", "other", base: :base) == [["test", "other"], :base, true])
3816+
results
38143817
end
3815-
38163818
calling_my_func
38173819
}

debug.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
533533
len += r;
534534
}
535535

536-
if (rb_current_execution_context(false)) {
536+
rb_execution_context_t *ec = rb_current_execution_context(false);
537+
538+
if (ec) {
537539
// Ruby location
538540
int ruby_line;
539541
const char *ruby_file = rb_source_location_cstr(&ruby_line);
@@ -547,22 +549,46 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
547549
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
548550
len += r;
549551
}
552+
}
553+
554+
#ifdef RUBY_NT_SERIAL
555+
// native thread information
556+
if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
557+
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tnt:%d", ruby_nt_serial);
558+
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
559+
len += r;
560+
}
561+
#endif
562+
563+
if (ec) {
564+
rb_thread_t *th = ec ? rb_ec_thread_ptr(ec) : NULL;
550565

551566
// ractor information
552567
if (ruby_single_main_ractor == NULL) {
553-
rb_ractor_t *cr = GET_RACTOR();
568+
rb_ractor_t *cr = th ? th->ractor : NULL;
569+
554570
if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
555-
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%u/%u",
556-
(unsigned int)rb_ractor_id(cr), GET_VM()->ractor.cnt);
571+
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%d/%u",
572+
cr ? (int)rb_ractor_id(cr) : -1, GET_VM()->ractor.cnt);
573+
557574
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
558575
len += r;
559576
}
560577
}
561578

562579
// thread information
563-
const rb_thread_t *th = GET_THREAD();
564-
if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
565-
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
580+
if (th && r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
581+
rb_execution_context_t *rec = th->ractor ? th->ractor->threads.running_ec : NULL;
582+
const rb_thread_t *rth = rec ? rec->thread_ptr : NULL;
583+
const rb_thread_t *sth = th->ractor ? th->ractor->threads.sched.running : NULL;
584+
585+
if (rth != th || sth != th) {
586+
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u (rth:%d,sth:%d)",
587+
rb_th_serial(th), rth ? (int)rb_th_serial(rth) : -1, sth ? (int)rb_th_serial(sth) : -1);
588+
}
589+
else {
590+
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
591+
}
566592
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
567593
len += r;
568594
}

gc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6875,6 +6875,7 @@ each_machine_stack_value(const rb_execution_context_t *ec, void (*cb)(rb_objspac
68756875
VALUE *stack_start, *stack_end;
68766876

68776877
GET_STACK_BOUNDS(stack_start, stack_end, 0);
6878+
RUBY_DEBUG_LOG("ec->th:%u stack_start:%p stack_end:%p", rb_ec_thread_ptr(ec)->serial, stack_start, stack_end);
68786879
each_stack_location(objspace, ec, stack_start, stack_end, cb);
68796880
}
68806881

gems/bundled_gems

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ net-smtp 0.3.3 https://github.com/ruby/net-smtp
1818
matrix 0.4.2 https://github.com/ruby/matrix
1919
prime 0.1.2 https://github.com/ruby/prime
2020
rbs 3.0.4 https://github.com/ruby/rbs c24c65ce867c7d1cc3cc1ca871fc002579bd8854
21-
typeprof 0.21.7 https://github.com/ruby/typeprof
21+
typeprof 0.21.7 https://github.com/ruby/typeprof aabc019684d8b4a1ed66c2a1ca48da7bbb18dcc0
2222
debug 1.7.2 https://github.com/ruby/debug

include/ruby/fiber/scheduler.h

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ VALUE rb_fiber_scheduler_io_selectv(VALUE scheduler, int argc, VALUE *argv);
267267
* Non-blocking read from the passed IO.
268268
*
269269
* @param[in] scheduler Target scheduler.
270-
* @param[out] io An io object to read from.
271-
* @param[out] buffer Return buffer.
272-
* @param[in] length Requested number of bytes to read.
273-
* @param[in] offset The offset in the buffer to read to.
270+
* @param[in] io An io object to read from.
271+
* @param[in] buffer The buffer to read to.
272+
* @param[in] length The minimum number of bytes to read.
273+
* @param[in] offset The offset in the buffer to read from.
274274
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
275275
* @return otherwise What `scheduler.io_read` returns `[-errno, size]`.
276276
*/
@@ -280,9 +280,9 @@ VALUE rb_fiber_scheduler_io_read(VALUE scheduler, VALUE io, VALUE buffer, size_t
280280
* Non-blocking write to the passed IO.
281281
*
282282
* @param[in] scheduler Target scheduler.
283-
* @param[out] io An io object to write to.
284-
* @param[in] buffer What to write.
285-
* @param[in] length Number of bytes to write.
283+
* @param[in] io An io object to write to.
284+
* @param[in] buffer The buffer to write from.
285+
* @param[in] length The minimum number of bytes to write.
286286
* @param[in] offset The offset in the buffer to write from.
287287
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
288288
* @return otherwise What `scheduler.io_write` returns `[-errno, size]`.
@@ -293,10 +293,10 @@ VALUE rb_fiber_scheduler_io_write(VALUE scheduler, VALUE io, VALUE buffer, size_
293293
* Non-blocking read from the passed IO at the specified offset.
294294
*
295295
* @param[in] scheduler Target scheduler.
296-
* @param[out] io An io object to read from.
297-
* @param[in] from The offset in the given IO to read the data from.
298-
* @param[out] buffer The buffer to read the data to.
299-
* @param[in] length Requested number of bytes to read.
296+
* @param[in] io An io object to read from.
297+
* @param[in] from The offset to read from.
298+
* @param[in] buffer The buffer to read to.
299+
* @param[in] length The minimum number of bytes to read.
300300
* @param[in] offset The offset in the buffer to read to.
301301
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
302302
* @return otherwise What `scheduler.io_read` returns.
@@ -307,10 +307,10 @@ VALUE rb_fiber_scheduler_io_pread(VALUE scheduler, VALUE io, rb_off_t from, VALU
307307
* Non-blocking write to the passed IO at the specified offset.
308308
*
309309
* @param[in] scheduler Target scheduler.
310-
* @param[out] io An io object to write to.
311-
* @param[in] from The offset in the given IO to write the data to.
312-
* @param[in] buffer The buffer to write the data from.
313-
* @param[in] length Number of bytes to write.
310+
* @param[in] io An io object to write to.
311+
* @param[in] from The offset to write to.
312+
* @param[in] buffer The buffer to write from.
313+
* @param[in] length The minimum number of bytes to write.
314314
* @param[in] offset The offset in the buffer to write from.
315315
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
316316
* @return otherwise What `scheduler.io_write` returns.
@@ -321,27 +321,55 @@ VALUE rb_fiber_scheduler_io_pwrite(VALUE scheduler, VALUE io, rb_off_t from, VAL
321321
* Non-blocking read from the passed IO using a native buffer.
322322
*
323323
* @param[in] scheduler Target scheduler.
324-
* @param[out] io An io object to read from.
325-
* @param[out] buffer Return buffer.
326-
* @param[in] size Size of the return buffer.
327-
* @param[in] length Requested number of bytes to read.
324+
* @param[in] io An io object to read from.
325+
* @param[in] base The memory to read to.
326+
* @param[in] size Size of the memory.
327+
* @param[in] length The minimum number of bytes to read.
328328
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
329329
* @return otherwise What `scheduler.io_read` returns.
330330
*/
331-
VALUE rb_fiber_scheduler_io_read_memory(VALUE scheduler, VALUE io, void *buffer, size_t size, size_t length);
331+
VALUE rb_fiber_scheduler_io_read_memory(VALUE scheduler, VALUE io, void *base, size_t size, size_t length);
332332

333333
/**
334334
* Non-blocking write to the passed IO using a native buffer.
335335
*
336336
* @param[in] scheduler Target scheduler.
337-
* @param[out] io An io object to write to.
338-
* @param[in] buffer What to write.
339-
* @param[in] size Size of the buffer.
340-
* @param[in] length Number of bytes to write.
337+
* @param[in] io An io object to write to.
338+
* @param[in] base The memory to write from.
339+
* @param[in] size Size of the memory.
340+
* @param[in] length The minimum number of bytes to write.
341+
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
342+
* @return otherwise What `scheduler.io_write` returns.
343+
*/
344+
VALUE rb_fiber_scheduler_io_write_memory(VALUE scheduler, VALUE io, const void *base, size_t size, size_t length);
345+
346+
/**
347+
* Non-blocking pread from the passed IO using a native buffer.
348+
*
349+
* @param[in] scheduler Target scheduler.
350+
* @param[in] io An io object to read from.
351+
* @param[in] from The offset to read from.
352+
* @param[in] base The memory to read to.
353+
* @param[in] size Size of the memory.
354+
* @param[in] length The minimum number of bytes to read.
355+
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
356+
* @return otherwise What `scheduler.io_read` returns.
357+
*/
358+
VALUE rb_fiber_scheduler_io_pread_memory(VALUE scheduler, VALUE io, rb_off_t from, void *base, size_t size, size_t length);
359+
360+
/**
361+
* Non-blocking pwrite to the passed IO using a native buffer.
362+
*
363+
* @param[in] scheduler Target scheduler.
364+
* @param[in] io An io object to write to.
365+
* @param[in] from The offset to write from.
366+
* @param[in] base The memory to write from.
367+
* @param[in] size Size of the memory.
368+
* @param[in] length The minimum number of bytes to write.
341369
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
342370
* @return otherwise What `scheduler.io_write` returns.
343371
*/
344-
VALUE rb_fiber_scheduler_io_write_memory(VALUE scheduler, VALUE io, const void *buffer, size_t size, size_t length);
372+
VALUE rb_fiber_scheduler_io_pwrite_memory(VALUE scheduler, VALUE io, rb_off_t from, const void *base, size_t size, size_t length);
345373

346374
/**
347375
* Non-blocking close the given IO.

0 commit comments

Comments
 (0)