summaryrefslogtreecommitdiff
path: root/gc.c
AgeCommit message (Collapse)Author
2024-11-29RUBY_DEBUG: Verify PC correctness every allocJohn Hawthorn
Notes: Merged: https://github.com/ruby/ruby/pull/12204
2024-11-29prefer ruby_memerror instead卜部昌平
This could be out of GVL Notes: Merged: https://github.com/ruby/ruby/pull/12188
2024-11-29rb_gc_impl_malloc can return NULL卜部昌平
Let there be rooms for each GC implementations how to handle multi threaded situations. They can be totally reentrant, or can have their own mutex, or can rely on rb_thread_call_with_gvl. In any ways the allocator (has been, but now officially is) expected to run properly without a GVL. This means there need be a way for them to inform the interpreter about their allocation failures, without relying on raising exceptions. Let them do so by returning NULL. Notes: Merged: https://github.com/ruby/ruby/pull/12188
2024-11-25define rb_current_ec_set in all casesMatt Valentine-House
Notes: Merged: https://github.com/ruby/ruby/pull/12149
2024-11-25Place all non-default GC API behind USE_SHARED_GCMatt Valentine-House
So that it doesn't get included in the generated binaries for builds that don't support loading shared GC modules Co-Authored-By: Peter Zhu <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/12149
2024-11-25Use extconf to build external GC modulesMatt Valentine-House
Co-Authored-By: Peter Zhu <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/12149
2024-11-24Fix a build failure with muslEarlopain
``` compiling gc.c In file included from gc.c:80: /usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map' 88 | struct prctl_mm_map { | ^~~~~~~~~~~~ In file included from gc.c:79: /usr/include/linux/prctl.h:134:8: note: originally defined here 134 | struct prctl_mm_map { | ^~~~~~~~~~~~ ``` The first include is not needed and is what causes this issue. Two other places in ruby exclusively use the sys import. See https://github.com/seccomp/libseccomp/issues/19 for a similar problem. Notes: Merged: https://github.com/ruby/ruby/pull/12154
2024-11-21Annotate anonymous mmapKunshan Wang
Use PR_SET_VMA_ANON_NAME to set human-readable names for anonymous virtual memory areas mapped by `mmap()` when compiled and run on Linux 5.17 or higher. This makes it convenient for developers to debug mmap. Notes: Merged: https://github.com/ruby/ruby/pull/12119
2024-11-17Fix format modifier for `size_t`Nobuyoshi Nakada
Also fix the message, just `RB_GC_MAX_NAME_LEN` chars long is OK.
2024-11-15`rb_bug` prints a newline after the given message [ci skip]Nobuyoshi Nakada
2024-11-14rb_bug if rb_gc_impl_active_gc_name is too longMatt Valentine-House
This avoids the need to malloc, and reduces the complexity of truncating the long string for display in RUBY_DESCRIPTION. The developer of a GC implementation should be responsible for giving it a succinct name. Notes: Merged: https://github.com/ruby/ruby/pull/11872
2024-11-14Include the currently active GC in RUBY_DESCRIPTIONMatt Valentine-House
This will add +MOD_GC to the version string and Ruby description when Ruby is compiled with shared gc support. When shared GC support is compiled in and a GC module has been loaded using RUBY_GC_LIBRARY, the version string will include the name of the currently active GC as reported by the rb_gc_active_gc_name function in the form +MOD_GC[gc_name] [Feature #20794] Notes: Merged: https://github.com/ruby/ruby/pull/11872
2024-11-14Expose GC.config[:implementation], to query the currently active GCMatt Valentine-House
And a default and readonly key to the GC.config hash that names the current GC implementation. This is provided by each implementation by the API function rb_gc_impl_active_gc_name Notes: Merged: https://github.com/ruby/ruby/pull/11872
2024-10-23Move error handling for GC.stat_heap to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Make rb_gc_impl_stat_heap return a VALUE instead of size_tPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Move error handling for GC.stat to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Make rb_gc_impl_stat return a VALUE instead of size_tPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-23Move error handling for GC.latest_gc_info to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11932
2024-10-21Don't clear out flags in rb_gc_obj_freePeter Zhu
If there's a crash after rb_gc_obj_free, it's hard to debug because the flags have been cleared out already. Notes: Merged: https://github.com/ruby/ruby/pull/11925
2024-10-18Move object processing in Process.warmup to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11904
2024-10-11Improve RUBY_GC_LIBRARYPeter Zhu
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`. Notes: Merged: https://github.com/ruby/ruby/pull/11866
2024-10-10Move return value of rb_gc_impl_config_set to gc.cPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11870
2024-10-08Cast via `uintptr_t` function pointer between object pointerNobuyoshi Nakada
- ISO C forbids conversion of function pointer to object pointer type - ISO C forbids conversion of object pointer to function pointer type
2024-10-08Improve error message in load_external_gc_funcPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11817
2024-10-05Non-zero exit when error in loading shared GCPeter Zhu
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. Notes: Merged: https://github.com/ruby/ruby/pull/11784
2024-10-03Rename size_pool -> heapMatt Valentine-House
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 Notes: Merged: https://github.com/ruby/ruby/pull/11771
2024-10-02Deduplicate RGENGC_CHECK_MODE into gc/gc.hPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11764
2024-09-30Move RUBY_INTERNAL_EVENT_FREEOBJ into GC implementationPeter Zhu
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. Notes: Merged: https://github.com/ruby/ruby/pull/11742
2024-09-30Fix the last character index in an assertionNobuyoshi Nakada
Also, when `RUBY_DEBUG` is enabled, objects allocated in shared-gc fail at `rb_ractor_confirm_belonging`, so assert it always.
2024-09-30Ruby exception cannot work hereNobuyoshi Nakada
Just show error messages then ignore the invalid library.
2024-09-30Raise fatal error instead of BUGNobuyoshi Nakada
Failures due to the external setting is not a bug of ruby itself. Notes: Merged: https://github.com/ruby/ruby/pull/11726
2024-09-19Remove rb_gc_impl_initial_stress_setPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11646
2024-09-18Move more of GC.latest_gc_info into RubyPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11636
2024-09-18Change rb_gc_impl_get_measure_total_time to return a boolPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11638
2024-09-17Make rb_gc_impl_set_measure_total_time return voidPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11637
2024-09-17Rename rb_gc_impl_get_profile_total_time to rb_gc_impl_get_total_timePeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11639
2024-09-17Change rb_gc_impl_get_profile_total_time to return unsigned long longPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11639
2024-09-12Move checks for heap traversal to rb_gc_mark_weakPeter Zhu
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. Notes: Merged: https://github.com/ruby/ruby/pull/11606
2024-09-12Assert that we are during GC when markingPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11606
2024-09-12Add variable objspace in RB_GC_MARK_OR_TRAVERSEPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11606
2024-09-12Move special const checks to rb_gc_mark_weakPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11606
2024-09-09Suppress discards qualifiers warning with ASNNobuyoshi Nakada
2024-09-07[Bug #20718] Free non-`RTypedData` objectsJonathan Calvert
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. Notes: Merged: https://github.com/ruby/ruby/pull/11563 Merged-By: nobu <[email protected]>
2024-09-03Don't traverse garbage objects in heap traversalPeter Zhu
The object could be garbage (e.g. T_NONE, T_MOVED, or T_ZOMBIE) so we don't want to traverse those.
2024-09-03Move responsibility of heap walking into RubyPeter Zhu
This commit removes the need for the GC implementation to implement heap walking and instead Ruby will implement it. Notes: Merged: https://github.com/ruby/ruby/pull/11511
2024-08-30Fix call to each_location_ptr for ASANPeter Zhu
2024-08-30Combine gc_mark_locations and each_stack_locationPeter Zhu
Also renames the new function each_location_ptr to be consistent with each_location. Notes: Merged: https://github.com/ruby/ruby/pull/11504
2024-08-30Drop support for Motorola 68000Peter Zhu
The last Motorla 68000 architecture CPU was released 1994, so we can probably drop support for it. Notes: Merged: https://github.com/ruby/ruby/pull/11504
2024-08-29Remove unused ec argument in each_stack_locationPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/11503
2024-08-29Change each_stack_location to accept data instead of objspacePeter Zhu
The callers were abusing each_stack_location and passing data into the objspace argument. Notes: Merged: https://github.com/ruby/ruby/pull/11481