Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
392 changes: 390 additions & 2 deletions ext/io/console/console.c

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions ext/io/console/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
elsif have_func("rb_scheduler_timeout") # Ruby 3.0 (internal)
have_func("rb_io_wait") # Ruby 3.0
end
have_func("rb_category_warn")
have_const("RB_WARN_CATEGORY_DEPRECATED")
win32 or have_func("ttyname_r") or have_func("ttyname")
have_func("rb_prepend_module") # not exported by TruffleRuby
create_makefile("io/console") {|conf|
Expand Down
7 changes: 7 additions & 0 deletions ext/io/console/extract-vk.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
code = [+""]
ARGF.read.scan(/^\w+,\s*\KVK_\w+/) do |n|
puts("#ifndef #{n}\n# define #{n} UNDEFINED_VK\n#endif")
code << +"" if n.size + code.last.size > 60
code.last << " x(#{n})z"
end
puts ["#define EACH_VK(x,z)", code].join(" \\\n "), ""
2 changes: 2 additions & 0 deletions ext/io/console/io-console.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Gem::Specification.new do |s|
lib/ffi/io/console/native_console.rb
lib/ffi/io/console/stty_console.rb
lib/ffi/io/console/stub_console.rb
lib/ffi/io/console/windows_constants.rb
lib/ffi/io/console/windows_console.rb
lib/ffi/io/console/version.rb
])
end
Expand Down
44 changes: 44 additions & 0 deletions ext/io/console/win32_vk.inc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 27 additions & 13 deletions gc/default/default.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,10 @@ typedef struct rb_objspace {
rb_hrtime_t gc_stop_time;
rb_hrtime_t gc_mark_phase_wall_start_time;
rb_hrtime_t gc_sweep_phase_wall_start_time;
#if GC_PROFILE_MORE_DETAIL
size_t total_allocated_objects_at_gc_start;
size_t heap_used_at_gc_start;
size_t heap_total_slots_at_gc_start;
#endif

/* basic statistics */
size_t count;
Expand Down Expand Up @@ -7913,7 +7914,22 @@ gc_reset_malloc_info(rb_objspace_t *objspace, bool full_mark)
#endif
}

static void gc_start_global(rb_objspace_t *driver, bool compact);
/* What a collection records about itself before it runs. A global collection reports the
* driver's objspace, so it comes through here too. */
static void
gc_start_record(rb_objspace_t *objspace, unsigned int reason, bool full_mark)
{
objspace->profile.latest_gc_info = reason;
#if GC_PROFILE_MORE_DETAIL
objspace->profile.total_allocated_objects_at_gc_start = total_allocated_objects(objspace);
objspace->profile.heap_used_at_gc_start = rb_darray_size(objspace->heap_pages.sorted);
#endif
objspace->profile.weak_references_count = 0;
gc_prof_setup_new_record(objspace, reason);
gc_reset_malloc_info(objspace, full_mark);
}

static void gc_start_global(rb_objspace_t *driver, unsigned int reason, bool compact);

/* Decide whether this collection has to be global. A local GC can reclaim neither
* shareable objects nor zombie objspaces, so once those grow past their limits only a
Expand Down Expand Up @@ -7967,7 +7983,7 @@ gc_start_body(rb_objspace_t *objspace, unsigned int reason, bool allow_global)
* (only a global cycle reclaims dead shareable objects and zombie pages). The
* exception is the retire GC, which never promotes: a Ractor's death must not STW. */
if (allow_global && gc_need_global_p(objspace)) {
gc_start_global(objspace, false);
gc_start_global(objspace, reason, false);
return TRUE;
}

Expand Down Expand Up @@ -8072,13 +8088,7 @@ gc_start_body(rb_objspace_t *objspace, unsigned int reason, bool allow_global)
}

objspace->profile.count++;
objspace->profile.latest_gc_info = reason;
objspace->profile.total_allocated_objects_at_gc_start = total_allocated_objects(objspace);
objspace->profile.heap_used_at_gc_start = rb_darray_size(objspace->heap_pages.sorted);
objspace->profile.heap_total_slots_at_gc_start = objspace_available_slots(objspace);
objspace->profile.weak_references_count = 0;
gc_prof_setup_new_record(objspace, reason);
gc_reset_malloc_info(objspace, do_full_mark);
gc_start_record(objspace, reason, do_full_mark);

gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START);

Expand Down Expand Up @@ -8683,15 +8693,18 @@ gc_global_mark_generic_fields(rb_objspace_t *driver)
/* Two Ractors choosing a global GC at once are serialized by the barrier in gc_enter and
* simply run two cycles back to back. The second is wasted work, not an error. */
static void
gc_start_global(rb_objspace_t *driver, bool compact)
gc_start_global(rb_objspace_t *driver, unsigned int reason, bool compact)
{
unsigned int lock_lev;
gc_enter(driver, gc_enter_event_global, &lock_lev);

/* A global GC is a collection of the driver's objspace too, and its profile.count
* below says so, so report it like a local one. The driver is the objspace whose
* count moves, which is the one a hook reading GC.stat would compare against. */
* count moves, which is the one a hook reading GC.stat would compare against. For
* the same reason it records a profile entry and reports what triggered it. */
gc_start_record(driver, reason, true);
gc_event_hook(driver, RUBY_INTERNAL_EVENT_GC_START);
gc_prof_timer_start(driver);

GC_ASSERT(is_mark_stack_empty(&driver->mark_stack));

Expand Down Expand Up @@ -8915,6 +8928,7 @@ gc_start_global(rb_objspace_t *driver, bool compact)
* zombie_objspaces entry and posted the merge to main as a postponed job; the objspace
* stays enumerable until main absorbs it at its next safepoint. */

gc_prof_timer_stop(driver);
gc_exit(driver, gc_enter_event_global, &lock_lev);
}

Expand Down Expand Up @@ -9182,7 +9196,7 @@ rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool i
* collector that reclaims shareable and cross-objspace garbage. It stops the world,
* so auto_compact is honoured here too (mirroring full mark x autocompact locally). */
if (!rb_gc_single_objspace_p() && (reason & GPR_FLAG_FULL_MARK)) {
gc_start_global(objspace, compact || ruby_enable_autocompact);
gc_start_global(objspace, reason, compact || ruby_enable_autocompact);
}
else {
garbage_collect(objspace, reason);
Expand Down
2 changes: 1 addition & 1 deletion test/fiber/test_mutex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_mutex_fiber_deadlock_no_scheduler
mutex.lock
end.resume
end
assert_includes error.message, "deadlock; lock already owned by another fiber belonging to the same thread"
assert_include error.message, "deadlock; lock already owned by another fiber belonging to the same thread"
end
ensure
thr&.kill&.join
Expand Down
Loading