Граф коммитов

2568 Коммитов

Автор SHA1 Сообщение Дата
Peter Zhu 5460d5b119 Move error handling for GC.stat_heap to gc.c 2024-10-23 13:18:09 -04:00
Peter Zhu d3aaca9785 Make rb_gc_impl_stat_heap return a VALUE instead of size_t 2024-10-23 13:18:09 -04:00
Peter Zhu c0b50d05c7 Move error handling for GC.stat to gc.c 2024-10-23 13:18:09 -04:00
Peter Zhu 9dea0fae25 Make rb_gc_impl_stat return a VALUE instead of size_t 2024-10-23 13:18:09 -04:00
Peter Zhu c2af84b244 Move error handling for GC.latest_gc_info to gc.c 2024-10-23 13:18:09 -04:00
Peter Zhu 5131fb5dbe Don't clear out flags in rb_gc_obj_free
If there's a crash after rb_gc_obj_free, it's hard to debug because the
flags have been cleared out already.
2024-10-21 12:48:53 -04:00
Peter Zhu 3ddaf24cd2 Move object processing in Process.warmup to gc.c 2024-10-18 09:06:46 -04:00
Peter Zhu d641b7d172 Improve RUBY_GC_LIBRARY
Instead of passing the full GC SO file name to RUBY_GC_LIBRARY, we now
only need to pass the GC name.

For example, before we needed to pass `RUBY_GC_LIBRARY=librubygc.default.so`
but now we only need to pass `RUBY_GC_LIBRARY=default`.
2024-10-11 08:56:36 -04:00
Peter Zhu 3d8fe462df Move return value of rb_gc_impl_config_set to gc.c 2024-10-10 14:34:54 -04:00
Nobuyoshi Nakada 9a90cd2284 Cast via `uintptr_t` function pointer between object pointer
- ISO C forbids conversion of function pointer to object pointer type
- ISO C forbids conversion of object pointer to function pointer type
2024-10-08 23:29:49 +09:00
Peter Zhu 7cdbf93a89 Improve error message in load_external_gc_func 2024-10-08 09:48:48 -04:00
Peter Zhu a1c222801d Non-zero exit when error in loading shared GC
Before this commit, when there is an error in loading the shared GC, an
error was outputted but it did not exit, causing it to segfault later on.
2024-10-05 13:58:10 -04:00
Matt Valentine-House 8e7df4b7c6 Rename size_pool -> heap
Now that we've inlined the eden_heap into the size_pool, we should
rename the size_pool to heap. So that Ruby contains multiple heaps, with
different sized objects.

The term heap as a collection of memory pages is more in memory
management nomenclature, whereas size_pool was a name chosen out of
necessity during the development of the Variable Width Allocation
features of Ruby.

The concept of size pools was introduced in order to facilitate
different sized objects (other than the default 40 bytes). They wrapped
the eden heap and the tomb heap, and some related state, and provided a
reasonably simple way of duplicating all related concerns, to provide
multiple pools that all shared the same structure but held different
objects.

Since then various changes have happend in Ruby's memory layout:

* The concept of tomb heaps has been replaced by a global free pages list,
  with each page having it's slot size reconfigured at the point when it
  is resurrected
* the eden heap has been inlined into the size pool itself, so that now
  the size pool directly controls the free_pages list, the sweeping
  page, the compaction cursor and the other state that was previously
  being managed by the eden heap.

Now that there is no need for a heap wrapper, we should refer to the
collection of pages containing Ruby objects as a heap again rather than
a size pool
2024-10-03 21:20:09 +01:00
Peter Zhu bf8a8820ba Deduplicate RGENGC_CHECK_MODE into gc/gc.h 2024-10-02 11:47:45 -04:00
Peter Zhu 30507a4aed Move RUBY_INTERNAL_EVENT_FREEOBJ into GC implementation
Instead of calling rb_gc_event_hook inside of rb_gc_obj_free, it should
be up to the GC implementation to call the event.
2024-09-30 14:23:32 -04:00
Nobuyoshi Nakada c30a3ed027
Fix the last character index in an assertion
Also, when `RUBY_DEBUG` is enabled, objects allocated in shared-gc
fail at `rb_ractor_confirm_belonging`, so assert it always.
2024-09-30 18:17:42 +09:00
Nobuyoshi Nakada 28a01e306a Ruby exception cannot work here
Just show error messages then ignore the invalid library.
2024-09-30 10:27:30 +09:00
Nobuyoshi Nakada a0838a3902
Raise fatal error instead of BUG
Failures due to the external setting is not a bug of ruby itself.
2024-09-30 00:20:35 +09:00
Peter Zhu 167fba52f0 Remove rb_gc_impl_initial_stress_set 2024-09-19 08:21:10 -04:00
Peter Zhu f8e1c93fe1 Move more of GC.latest_gc_info into Ruby 2024-09-18 12:58:05 -04:00
Peter Zhu 5df5eba465 Change rb_gc_impl_get_measure_total_time to return a bool 2024-09-18 10:18:47 -04:00
Peter Zhu 5307c65c76 Make rb_gc_impl_set_measure_total_time return void 2024-09-17 16:35:52 -04:00
Peter Zhu dc61c7fc7d Rename rb_gc_impl_get_profile_total_time to rb_gc_impl_get_total_time 2024-09-17 15:22:43 -04:00
Peter Zhu 2af080bd30 Change rb_gc_impl_get_profile_total_time to return unsigned long long 2024-09-17 15:22:43 -04:00
Peter Zhu 0fc8422a05 Move checks for heap traversal to rb_gc_mark_weak
If we are during heap traversal, we don't want to call rb_gc_impl_mark_weak.
This commit moves that check from rb_gc_impl_mark_weak to rb_gc_mark_weak.
2024-09-12 16:03:28 -04:00
Peter Zhu 92b7b78e06 Assert that we are during GC when marking 2024-09-12 16:03:28 -04:00
Peter Zhu 661f64e876 Add variable objspace in RB_GC_MARK_OR_TRAVERSE 2024-09-12 16:03:28 -04:00
Peter Zhu 606db2c423 Move special const checks to rb_gc_mark_weak 2024-09-12 16:03:28 -04:00
Nobuyoshi Nakada a2ae7450d7
Suppress discards qualifiers warning with ASN 2024-09-09 16:25:43 +09:00
Jonathan Calvert c1a510a8df
[Bug #20718] Free non-`RTypedData` objects
Allow objects that are not of type `RTypedData` to use the default
free function, as `RTYPEDDATA_EMBEDDED_P` can return a false positive
when casting non-`RTypedData` objects.
2024-09-07 12:19:47 +09:00
Peter Zhu ef42e04a1a Don't traverse garbage objects in heap traversal
The object could be garbage (e.g. T_NONE, T_MOVED, or T_ZOMBIE) so we
don't want to traverse those.
2024-09-03 13:44:09 -04:00
Peter Zhu 3c63a01295 Move responsibility of heap walking into Ruby
This commit removes the need for the GC implementation to implement heap
walking and instead Ruby will implement it.
2024-09-03 10:05:38 -04:00
Peter Zhu 89bbb9a888 Fix call to each_location_ptr for ASAN 2024-08-30 10:45:25 -04:00
Peter Zhu ca7b3d467d Combine gc_mark_locations and each_stack_location
Also renames the new function each_location_ptr to be consistent with
each_location.
2024-08-30 10:03:17 -04:00
Peter Zhu e3f00df227 Drop support for Motorola 68000
The last Motorla 68000 architecture CPU was released 1994, so we can
probably drop support for it.
2024-08-30 10:03:17 -04:00
Peter Zhu 22d9260f05 Remove unused ec argument in each_stack_location 2024-08-29 16:03:48 -04:00
Peter Zhu 1f114464fc Change each_stack_location to accept data instead of objspace
The callers were abusing each_stack_location and passing data into the objspace
argument.
2024-08-29 14:37:01 -04:00
Peter Zhu c162da69e7 Change each_location to accept data instead of objspace
The callers were abusing each_location and passing data into the objspace
argument.
2024-08-29 14:37:01 -04:00
Peter Zhu 6b08a50a62 Move checks for special const for marking
This commit moves checks to RB_SPECIAL_CONST_P out of the GC implmentation
and into gc.c.
2024-08-29 09:11:40 -04:00
Peter Zhu ddd2b17845 Move marking code together in gc.c 2024-08-29 09:11:40 -04:00
Peter Zhu 165635049a Don't use gc_impl.h inside of gc/gc.h
Using gc_impl.h inside of gc/gc.h will cause gc/gc.h to use the functions
in gc/default.c when builing with shared GC support because gc/gc.h is
included into gc.c before the rb_gc_impl functions are overridden by the
preprocessor.
2024-08-22 13:50:17 -04:00
Peter Zhu 8312c5be74 Fix GC_ASSERT for gc.c and gc/default.c
gc.c mistakenly defined GC_ASSERT as blank, which caused it to be a
no-op. This caused all assertions in gc.c and gc/default.c to not do
anything. This commit fixes it by moving the definition of GC_ASSERT
to gc/gc.h.
2024-08-15 10:38:24 -04:00
Peter Zhu 264175dbb9 [DOC] Update comment about how object ID is calculated
The object ID no longer treats symbols in a special way so we can simplify
the comment about how it is calculated.
2024-08-14 10:51:02 -04:00
Peter Zhu b80b839926 Don't set stack end in rb_gc_mark_roots
We don't need to set the stack end in rb_gc_mark_roots because it is
already set in mark_current_machine_context.
2024-08-13 15:53:14 -04:00
Peter Zhu c91ec7ba1e Remove rb_gc_impl_objspace_mark
It's not necessary for the GC implementation to call rb_gc_mark_roots
which calls back into the GC implementation's rb_gc_impl_objspace_mark.
2024-08-09 10:27:40 -04:00
Peter Zhu 0bff07644b
Make YJIT a GC root rather than an object (#11343)
YJIT currently uses the YJIT root object to mark objects during GC and
update references during compaction. This object otherwise serves no
purpose.

This commit changes it YJIT to be step when marking the GC root. This
saves some memory from being allocated from the system and the GC.
2024-08-08 12:19:35 -04:00
Alan Wu a06cfa7e89 Fix a -Wmaybe-uninitialized
With the body of functions available, GCC noticed that lev is
uninitialized in rb_gc_vm_lock_no_barrier() in single ractor
mode.
2024-07-26 11:44:34 -04:00
Alan Wu 0ada02abe2 Put the default GC implementation back into gc.o
We discovered that having gc.o and gc_impl.o in separate translation
units diminishes codegen quality with GCC 11 on x86-64. This commit
solves that problem by including default/gc.c into gc.c, letting the
optimizer have visibility into the body of functions again in builds
not using link-time optimization, which are common.

This effectively restores things to the way they were before
[Feature #20470] from the optimizer's perspective while maintaining the
ability to build gc/default.c as a DSO.

There were a few functions duplicated across gc.c and gc/default.c.
Extract them and put them into gc/gc.h.
2024-07-26 11:44:34 -04:00
Alan Wu 5617fec1f8 newobj_of(): Use parameter instead of GET_RACTOR()
No point repeating the work callers to this function already do.
2024-07-22 20:00:59 -04:00
Peter Zhu 5e3b8010ed Add newline when printing dlopen error message 2024-07-22 10:25:44 -04:00