Standardize on the name "modular GC"
We have name fragmentation for this feature, including "shared GC", "modular GC", and "external GC". This commit standardizes the feature name to "modular GC" and the implementation to "GC library".
This commit is contained in:
parent
26ab20fec1
commit
ce1ad1b816
Notes:
git
2025-04-09 13:49:37 +00:00
12
.github/workflows/ubuntu.yml
vendored
12
.github/workflows/ubuntu.yml
vendored
@ -34,8 +34,8 @@ jobs:
|
||||
- test_task: check
|
||||
configure: '--enable-shared --enable-load-relative'
|
||||
- test_task: check
|
||||
shared_gc: true
|
||||
configure: '--with-shared-gc=/home/runner/ruby_gc'
|
||||
modular_gc: true
|
||||
configure: '--with-modular-gc=/home/runner/ruby_gc'
|
||||
- test_task: test-bundler-parallel
|
||||
timeout: 50
|
||||
- test_task: test-bundled-gems
|
||||
@ -99,12 +99,12 @@ jobs:
|
||||
|
||||
- run: $SETARCH make
|
||||
|
||||
- name: Build shared GC
|
||||
- name: Build modular GC
|
||||
run: |
|
||||
echo "RUBY_GC_LIBRARY=default" >> $GITHUB_ENV
|
||||
make shared-gc SHARED_GC=default
|
||||
make distclean-shared-gc SHARED_GC=default
|
||||
if: ${{ matrix.shared_gc }}
|
||||
make modular-gc MODULAR_GC=default
|
||||
make distclean-modular-gc MODULAR_GC=default
|
||||
if: ${{ matrix.modular_gc }}
|
||||
|
||||
- run: |
|
||||
$SETARCH make golf
|
||||
|
6
NEWS.md
6
NEWS.md
@ -315,13 +315,13 @@ details of the default gems or bundled gems.
|
||||
* Array#each is rewritten in Ruby for better performance [[Feature #20182]].
|
||||
|
||||
* Alternative GC implementations can be loaded dynamically. Configure Ruby
|
||||
`--with-shared-gc` to enable. Alternative GC libraries can be loaded at runtime
|
||||
`--with-modular-gc` to enable. Alternative GC libraries can be loaded at runtime
|
||||
using the environment variable `RUBY_GC_LIBRARY`. [[Feature #20351]],
|
||||
[[Feature #20470]]
|
||||
|
||||
* An experimental GC library is provided based on MMTk. Configure Ruby
|
||||
`--with-shared-gc`, build as normal, then build the GC library: `make
|
||||
shared-gc SHARED_GC=mmtk`. Enable with `RUBY_GC_LIBRARY=mmtk`. This
|
||||
`--with-modular-gc`, build as normal, then build the GC library: `make
|
||||
modular-gc MODULAR_GC=mmtk`. Enable with `RUBY_GC_LIBRARY=mmtk`. This
|
||||
requires a working Rust compiler, and Cargo on the build machine.
|
||||
[[Feature #20860]]
|
||||
|
||||
|
24
common.mk
24
common.mk
@ -1944,23 +1944,23 @@ rewindable:
|
||||
|
||||
HELP_EXTRA_TASKS = ""
|
||||
|
||||
shared-gc-precheck:
|
||||
shared-gc: probes.h shared-gc-precheck
|
||||
$(Q) $(MAKEDIRS) $(shared_gc_dir)
|
||||
modular-gc-precheck:
|
||||
modular-gc: probes.h modular-gc-precheck
|
||||
$(Q) $(MAKEDIRS) $(modular_gc_dir)
|
||||
$(Q) $(RUNRUBY) $(srcdir)/ext/extmk.rb \
|
||||
$(SCRIPT_ARGS) \
|
||||
--make='$(MAKE)' --make-flags="V=$(V) MINIRUBY='$(MINIRUBY)'" \
|
||||
--gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
|
||||
--ext-build-dir=gc --command-output=gc/$(SHARED_GC)/exts.mk -- \
|
||||
configure gc/$(SHARED_GC)
|
||||
$(CHDIR) gc/$(SHARED_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./
|
||||
$(CP) gc/$(SHARED_GC)/librubygc.$(SHARED_GC).$(DLEXT) $(shared_gc_dir)
|
||||
--ext-build-dir=gc --command-output=gc/$(MODULAR_GC)/exts.mk -- \
|
||||
configure gc/$(MODULAR_GC)
|
||||
$(CHDIR) gc/$(MODULAR_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./
|
||||
$(CP) gc/$(MODULAR_GC)/librubygc.$(MODULAR_GC).$(DLEXT) $(modular_gc_dir)
|
||||
|
||||
clean-shared-gc:
|
||||
- $(CHDIR) gc/$(SHARED_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./ clean || $(NULLCMD)
|
||||
distclean-shared-gc: clean-shared-gc
|
||||
- $(CHDIR) gc/$(SHARED_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./ distclean || $(NULLCMD)
|
||||
$(RMDIRS) gc/$(SHARED_GC)
|
||||
clean-modular-gc:
|
||||
- $(CHDIR) gc/$(MODULAR_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./ clean || $(NULLCMD)
|
||||
distclean-modular-gc: clean-modular-gc
|
||||
- $(CHDIR) gc/$(MODULAR_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./ distclean || $(NULLCMD)
|
||||
$(RMDIRS) gc/$(MODULAR_GC)
|
||||
|
||||
help: PHONY
|
||||
$(MESSAGE_BEGIN) \
|
||||
|
@ -45,7 +45,7 @@ RUBY_M4_INCLUDE([ruby_replace_type.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_require_funcs.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_rm_recursive.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_setjmp_type.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_shared_gc.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_modular_gc.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_stack_grow_direction.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_thread.m4])dnl
|
||||
RUBY_M4_INCLUDE([ruby_try_cflags.m4])dnl
|
||||
@ -3795,7 +3795,7 @@ AS_IF([test x"$gcov" = xyes], [
|
||||
])
|
||||
|
||||
RUBY_SETJMP_TYPE
|
||||
RUBY_SHARED_GC
|
||||
RUBY_MODULAR_GC
|
||||
}
|
||||
|
||||
[begin]_group "installation section" && {
|
||||
@ -4721,7 +4721,7 @@ config_summary "target OS" "$target_os"
|
||||
config_summary "compiler" "$CC"
|
||||
config_summary "with thread" "$THREAD_MODEL"
|
||||
config_summary "with coroutine" "$coroutine_type"
|
||||
config_summary "with shared GC" "$shared_gc_summary"
|
||||
config_summary "with modular GC" "$modular_gc_summary"
|
||||
config_summary "enable shared libs" "$ENABLE_SHARED"
|
||||
config_summary "dynamic library ext" "$DLEXT"
|
||||
config_summary "CFLAGS" "$cflags"
|
||||
|
166
gc.c
166
gc.c
@ -178,7 +178,7 @@ rb_gc_vm_barrier(void)
|
||||
rb_vm_barrier();
|
||||
}
|
||||
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
void *
|
||||
rb_gc_get_ractor_newobj_cache(void)
|
||||
{
|
||||
@ -617,9 +617,9 @@ rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
|
||||
static const char *obj_type_name(VALUE obj);
|
||||
#include "gc/default/default.c"
|
||||
|
||||
#if USE_SHARED_GC && !defined(HAVE_DLOPEN)
|
||||
# error "Shared GC requires dlopen"
|
||||
#elif USE_SHARED_GC
|
||||
#if USE_MODULAR_GC && !defined(HAVE_DLOPEN)
|
||||
# error "Modular GC requires dlopen"
|
||||
#elif USE_MODULAR_GC
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef struct gc_function_map {
|
||||
@ -702,7 +702,7 @@ typedef struct gc_function_map {
|
||||
// GC Identification
|
||||
const char *(*active_gc_name)(void);
|
||||
|
||||
bool external_gc_loaded_p;
|
||||
bool modular_gc_loaded_p;
|
||||
} rb_gc_function_map_t;
|
||||
|
||||
static rb_gc_function_map_t rb_gc_functions;
|
||||
@ -710,10 +710,10 @@ static rb_gc_function_map_t rb_gc_functions;
|
||||
# define RUBY_GC_LIBRARY "RUBY_GC_LIBRARY"
|
||||
|
||||
static void
|
||||
ruby_external_gc_init(void)
|
||||
ruby_modular_gc_init(void)
|
||||
{
|
||||
// Assert that the directory path ends with a /
|
||||
RUBY_ASSERT_ALWAYS(SHARED_GC_DIR[sizeof(SHARED_GC_DIR) - 2] == '/');
|
||||
RUBY_ASSERT_ALWAYS(MODULAR_GC_DIR[sizeof(MODULAR_GC_DIR) - 2] == '/');
|
||||
|
||||
char *gc_so_file = getenv(RUBY_GC_LIBRARY);
|
||||
|
||||
@ -737,14 +737,14 @@ ruby_external_gc_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
size_t gc_so_path_size = strlen(SHARED_GC_DIR "librubygc." DLEXT) + strlen(gc_so_file) + 1;
|
||||
size_t gc_so_path_size = strlen(MODULAR_GC_DIR "librubygc." DLEXT) + strlen(gc_so_file) + 1;
|
||||
gc_so_path = alloca(gc_so_path_size);
|
||||
{
|
||||
size_t gc_so_path_idx = 0;
|
||||
#define GC_SO_PATH_APPEND(str) do { \
|
||||
gc_so_path_idx += strlcpy(gc_so_path + gc_so_path_idx, str, gc_so_path_size - gc_so_path_idx); \
|
||||
} while (0)
|
||||
GC_SO_PATH_APPEND(SHARED_GC_DIR);
|
||||
GC_SO_PATH_APPEND(MODULAR_GC_DIR);
|
||||
GC_SO_PATH_APPEND("librubygc.");
|
||||
GC_SO_PATH_APPEND(gc_so_file);
|
||||
GC_SO_PATH_APPEND(DLEXT);
|
||||
@ -754,19 +754,19 @@ ruby_external_gc_init(void)
|
||||
|
||||
handle = dlopen(gc_so_path, RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!handle) {
|
||||
fprintf(stderr, "ruby_external_gc_init: Shared library %s cannot be opened: %s\n", gc_so_path, dlerror());
|
||||
fprintf(stderr, "ruby_modular_gc_init: Shared library %s cannot be opened: %s\n", gc_so_path, dlerror());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
gc_functions.external_gc_loaded_p = true;
|
||||
gc_functions.modular_gc_loaded_p = true;
|
||||
}
|
||||
|
||||
# define load_external_gc_func(name) do { \
|
||||
# define load_modular_gc_func(name) do { \
|
||||
if (handle) { \
|
||||
const char *func_name = "rb_gc_impl_" #name; \
|
||||
gc_functions.name = dlsym(handle, func_name); \
|
||||
if (!gc_functions.name) { \
|
||||
fprintf(stderr, "ruby_external_gc_init: %s function not exported by library %s\n", func_name, gc_so_path); \
|
||||
fprintf(stderr, "ruby_modular_gc_init: %s function not exported by library %s\n", func_name, gc_so_path); \
|
||||
exit(1); \
|
||||
} \
|
||||
} \
|
||||
@ -776,85 +776,85 @@ ruby_external_gc_init(void)
|
||||
} while (0)
|
||||
|
||||
// Bootup
|
||||
load_external_gc_func(objspace_alloc);
|
||||
load_external_gc_func(objspace_init);
|
||||
load_external_gc_func(objspace_free);
|
||||
load_external_gc_func(ractor_cache_alloc);
|
||||
load_external_gc_func(ractor_cache_free);
|
||||
load_external_gc_func(set_params);
|
||||
load_external_gc_func(init);
|
||||
load_external_gc_func(heap_sizes);
|
||||
load_modular_gc_func(objspace_alloc);
|
||||
load_modular_gc_func(objspace_init);
|
||||
load_modular_gc_func(objspace_free);
|
||||
load_modular_gc_func(ractor_cache_alloc);
|
||||
load_modular_gc_func(ractor_cache_free);
|
||||
load_modular_gc_func(set_params);
|
||||
load_modular_gc_func(init);
|
||||
load_modular_gc_func(heap_sizes);
|
||||
// Shutdown
|
||||
load_external_gc_func(shutdown_free_objects);
|
||||
load_modular_gc_func(shutdown_free_objects);
|
||||
// GC
|
||||
load_external_gc_func(start);
|
||||
load_external_gc_func(during_gc_p);
|
||||
load_external_gc_func(prepare_heap);
|
||||
load_external_gc_func(gc_enable);
|
||||
load_external_gc_func(gc_disable);
|
||||
load_external_gc_func(gc_enabled_p);
|
||||
load_external_gc_func(config_set);
|
||||
load_external_gc_func(config_get);
|
||||
load_external_gc_func(stress_set);
|
||||
load_external_gc_func(stress_get);
|
||||
load_modular_gc_func(start);
|
||||
load_modular_gc_func(during_gc_p);
|
||||
load_modular_gc_func(prepare_heap);
|
||||
load_modular_gc_func(gc_enable);
|
||||
load_modular_gc_func(gc_disable);
|
||||
load_modular_gc_func(gc_enabled_p);
|
||||
load_modular_gc_func(config_set);
|
||||
load_modular_gc_func(config_get);
|
||||
load_modular_gc_func(stress_set);
|
||||
load_modular_gc_func(stress_get);
|
||||
// Object allocation
|
||||
load_external_gc_func(new_obj);
|
||||
load_external_gc_func(obj_slot_size);
|
||||
load_external_gc_func(heap_id_for_size);
|
||||
load_external_gc_func(size_allocatable_p);
|
||||
load_modular_gc_func(new_obj);
|
||||
load_modular_gc_func(obj_slot_size);
|
||||
load_modular_gc_func(heap_id_for_size);
|
||||
load_modular_gc_func(size_allocatable_p);
|
||||
// Malloc
|
||||
load_external_gc_func(malloc);
|
||||
load_external_gc_func(calloc);
|
||||
load_external_gc_func(realloc);
|
||||
load_external_gc_func(free);
|
||||
load_external_gc_func(adjust_memory_usage);
|
||||
load_modular_gc_func(malloc);
|
||||
load_modular_gc_func(calloc);
|
||||
load_modular_gc_func(realloc);
|
||||
load_modular_gc_func(free);
|
||||
load_modular_gc_func(adjust_memory_usage);
|
||||
// Marking
|
||||
load_external_gc_func(mark);
|
||||
load_external_gc_func(mark_and_move);
|
||||
load_external_gc_func(mark_and_pin);
|
||||
load_external_gc_func(mark_maybe);
|
||||
load_external_gc_func(mark_weak);
|
||||
load_external_gc_func(remove_weak);
|
||||
load_modular_gc_func(mark);
|
||||
load_modular_gc_func(mark_and_move);
|
||||
load_modular_gc_func(mark_and_pin);
|
||||
load_modular_gc_func(mark_maybe);
|
||||
load_modular_gc_func(mark_weak);
|
||||
load_modular_gc_func(remove_weak);
|
||||
// Compaction
|
||||
load_external_gc_func(object_moved_p);
|
||||
load_external_gc_func(location);
|
||||
load_modular_gc_func(object_moved_p);
|
||||
load_modular_gc_func(location);
|
||||
// Write barriers
|
||||
load_external_gc_func(writebarrier);
|
||||
load_external_gc_func(writebarrier_unprotect);
|
||||
load_external_gc_func(writebarrier_remember);
|
||||
load_modular_gc_func(writebarrier);
|
||||
load_modular_gc_func(writebarrier_unprotect);
|
||||
load_modular_gc_func(writebarrier_remember);
|
||||
// Heap walking
|
||||
load_external_gc_func(each_objects);
|
||||
load_external_gc_func(each_object);
|
||||
load_modular_gc_func(each_objects);
|
||||
load_modular_gc_func(each_object);
|
||||
// Finalizers
|
||||
load_external_gc_func(make_zombie);
|
||||
load_external_gc_func(define_finalizer);
|
||||
load_external_gc_func(undefine_finalizer);
|
||||
load_external_gc_func(copy_finalizer);
|
||||
load_external_gc_func(shutdown_call_finalizer);
|
||||
load_modular_gc_func(make_zombie);
|
||||
load_modular_gc_func(define_finalizer);
|
||||
load_modular_gc_func(undefine_finalizer);
|
||||
load_modular_gc_func(copy_finalizer);
|
||||
load_modular_gc_func(shutdown_call_finalizer);
|
||||
// Object ID
|
||||
load_external_gc_func(object_id);
|
||||
load_external_gc_func(object_id_to_ref);
|
||||
load_modular_gc_func(object_id);
|
||||
load_modular_gc_func(object_id_to_ref);
|
||||
// Forking
|
||||
load_external_gc_func(before_fork);
|
||||
load_external_gc_func(after_fork);
|
||||
load_modular_gc_func(before_fork);
|
||||
load_modular_gc_func(after_fork);
|
||||
// Statistics
|
||||
load_external_gc_func(set_measure_total_time);
|
||||
load_external_gc_func(get_measure_total_time);
|
||||
load_external_gc_func(get_total_time);
|
||||
load_external_gc_func(gc_count);
|
||||
load_external_gc_func(latest_gc_info);
|
||||
load_external_gc_func(stat);
|
||||
load_external_gc_func(stat_heap);
|
||||
load_modular_gc_func(set_measure_total_time);
|
||||
load_modular_gc_func(get_measure_total_time);
|
||||
load_modular_gc_func(get_total_time);
|
||||
load_modular_gc_func(gc_count);
|
||||
load_modular_gc_func(latest_gc_info);
|
||||
load_modular_gc_func(stat);
|
||||
load_modular_gc_func(stat_heap);
|
||||
// Miscellaneous
|
||||
load_external_gc_func(obj_flags);
|
||||
load_external_gc_func(pointer_to_heap_p);
|
||||
load_external_gc_func(garbage_object_p);
|
||||
load_external_gc_func(set_event_hook);
|
||||
load_external_gc_func(copy_attributes);
|
||||
load_modular_gc_func(obj_flags);
|
||||
load_modular_gc_func(pointer_to_heap_p);
|
||||
load_modular_gc_func(garbage_object_p);
|
||||
load_modular_gc_func(set_event_hook);
|
||||
load_modular_gc_func(copy_attributes);
|
||||
//GC Identification
|
||||
load_external_gc_func(active_gc_name);
|
||||
load_modular_gc_func(active_gc_name);
|
||||
|
||||
# undef load_external_gc_func
|
||||
# undef load_modular_gc_func
|
||||
|
||||
rb_gc_functions = gc_functions;
|
||||
}
|
||||
@ -944,8 +944,8 @@ static VALUE initial_stress = Qfalse;
|
||||
void *
|
||||
rb_objspace_alloc(void)
|
||||
{
|
||||
#if USE_SHARED_GC
|
||||
ruby_external_gc_init();
|
||||
#if USE_MODULAR_GC
|
||||
ruby_modular_gc_init();
|
||||
#endif
|
||||
|
||||
void *objspace = rb_gc_impl_objspace_alloc();
|
||||
@ -2870,10 +2870,10 @@ rb_gc_copy_attributes(VALUE dest, VALUE obj)
|
||||
}
|
||||
|
||||
int
|
||||
rb_gc_external_gc_loaded_p(void)
|
||||
rb_gc_modular_gc_loaded_p(void)
|
||||
{
|
||||
#if USE_SHARED_GC
|
||||
return rb_gc_functions.external_gc_loaded_p;
|
||||
#if USE_MODULAR_GC
|
||||
return rb_gc_functions.modular_gc_loaded_p;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
@ -3298,7 +3298,7 @@ update_superclasses(void *objspace, VALUE obj)
|
||||
extern rb_symbols_t ruby_global_symbols;
|
||||
#define global_symbols ruby_global_symbols
|
||||
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
struct global_vm_table_foreach_data {
|
||||
vm_table_foreach_callback_func callback;
|
||||
vm_table_update_callback_func update_callback;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "gc/gc.h"
|
||||
#include "gc/gc_impl.h"
|
||||
|
||||
#ifndef BUILDING_SHARED_GC
|
||||
#ifndef BUILDING_MODULAR_GC
|
||||
# include "probes.h"
|
||||
#endif
|
||||
|
||||
@ -8466,7 +8466,7 @@ gc_prof_timer_stop(rb_objspace_t *objspace)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BUILDING_SHARED_GC
|
||||
#ifdef BUILDING_MODULAR_GC
|
||||
# define RUBY_DTRACE_GC_HOOK(name)
|
||||
#else
|
||||
# define RUBY_DTRACE_GC_HOOK(name) \
|
||||
|
@ -5,7 +5,7 @@ require "mkmf"
|
||||
srcdir = File.join(__dir__, "..")
|
||||
$INCFLAGS << " -I#{srcdir}"
|
||||
|
||||
$CPPFLAGS << " -DBUILDING_SHARED_GC"
|
||||
$CPPFLAGS << " -DBUILDING_MODULAR_GC"
|
||||
|
||||
append_cflags("-fPIC")
|
||||
|
||||
|
8
gc/gc.h
8
gc/gc.h
@ -11,7 +11,7 @@
|
||||
*/
|
||||
#include "ruby/ruby.h"
|
||||
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
#include "ruby/thread_native.h"
|
||||
|
||||
struct rb_gc_vm_context {
|
||||
@ -70,7 +70,7 @@ size_t rb_obj_memsize_of(VALUE obj);
|
||||
void rb_gc_prepare_heap_process_object(VALUE obj);
|
||||
bool ruby_free_at_exit_p(void);
|
||||
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
bool rb_gc_event_hook_required_p(rb_event_flag_t event);
|
||||
void *rb_gc_get_ractor_newobj_cache(void);
|
||||
void rb_gc_initialize_vm_context(struct rb_gc_vm_context *context);
|
||||
@ -85,7 +85,7 @@ void rb_ractor_finish_marking(void);
|
||||
// -------------------Private section begin------------------------
|
||||
// Functions in this section are private to the default GC and gc.c
|
||||
|
||||
#ifdef BUILDING_SHARED_GC
|
||||
#ifdef BUILDING_MODULAR_GC
|
||||
RBIMPL_WARNING_PUSH()
|
||||
RBIMPL_WARNING_IGNORED(-Wunused-function)
|
||||
#endif
|
||||
@ -222,7 +222,7 @@ type_sym(size_t type)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BUILDING_SHARED_GC
|
||||
#ifdef BUILDING_MODULAR_GC
|
||||
RBIMPL_WARNING_POP()
|
||||
#endif
|
||||
// -------------------Private section end------------------------
|
||||
|
@ -10,10 +10,10 @@
|
||||
*/
|
||||
#include "ruby/ruby.h"
|
||||
|
||||
#ifdef BUILDING_SHARED_GC
|
||||
#ifdef BUILDING_MODULAR_GC
|
||||
# define GC_IMPL_FN
|
||||
#else
|
||||
// `GC_IMPL_FN` is an implementation detail of `!USE_SHARED_GC` builds
|
||||
// `GC_IMPL_FN` is an implementation detail of `!USE_MODULAR_GC` builds
|
||||
// to have the default GC in the same translation unit as gc.c for
|
||||
// the sake of optimizer visibility. It expands to nothing unless
|
||||
// you're the default GC.
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include "ruby/ruby.h" /* for rb_event_flag_t */
|
||||
#include "vm_core.h" /* for GET_EC() */
|
||||
|
||||
#ifndef USE_SHARED_GC
|
||||
# define USE_SHARED_GC 0
|
||||
#ifndef USE_MODULAR_GC
|
||||
# define USE_MODULAR_GC 0
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) && !defined(_ILP32) && defined(__GNUC__)
|
||||
@ -253,10 +253,10 @@ void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, siz
|
||||
void ruby_sized_xfree(void *x, size_t size);
|
||||
|
||||
const char * rb_gc_active_gc_name(void);
|
||||
int rb_gc_external_gc_loaded_p(void);
|
||||
int rb_gc_modular_gc_loaded_p(void);
|
||||
|
||||
#if USE_SHARED_GC
|
||||
void ruby_load_external_gc_from_argv(int argc, char **argv);
|
||||
#if USE_MODULAR_GC
|
||||
void ruby_load_modular_gc_from_argv(int argc, char **argv);
|
||||
#endif
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
|
||||
|
2
main.c
2
main.c
@ -24,7 +24,7 @@
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#include <locale.h>
|
||||
#endif
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
#include "internal/gc.h"
|
||||
#endif
|
||||
|
||||
|
@ -68,7 +68,7 @@ UNIVERSAL_ARCHNAMES = @UNIVERSAL_ARCHNAMES@
|
||||
BUILTIN_BINARY = @X_BUILTIN_BINARY@
|
||||
|
||||
BUILTIN_GC = default
|
||||
shared_gc_dir = @shared_gc_dir@
|
||||
modular_gc_dir = @modular_gc_dir@
|
||||
|
||||
TESTUI = console
|
||||
TESTS =
|
||||
@ -348,13 +348,13 @@ $(ruby_pc): config.status Makefile
|
||||
$(Q)pkg_config=${PKG_CONFIG} && PKG_CONFIG_PATH=. $${pkg_config:-:} --print-errors ruby.tmp
|
||||
$(Q)$(MV) -f ruby.tmp.pc $(ruby_pc)
|
||||
|
||||
shared-gc-precheck:
|
||||
$(Q) if test -z $(shared_gc_dir); then \
|
||||
echo "You must configure with --with-shared-gc to use shared GC"; \
|
||||
modular-gc-precheck:
|
||||
$(Q) if test -z $(modular_gc_dir); then \
|
||||
echo "You must configure with --with-modular-gc to use modular GC"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(Q) if test -z $(SHARED_GC); then \
|
||||
echo "You must specify SHARED_GC with the GC to build"; \
|
||||
$(Q) if test -z $(MODULAR_GC); then \
|
||||
echo "You must specify MODULAR_GC with the GC to build"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
|
@ -310,7 +310,7 @@ class TestRubyOptions < Test::Unit::TestCase
|
||||
def test_enabled_gc
|
||||
omit unless /linux|darwin/ =~ RUBY_PLATFORM
|
||||
|
||||
if RbConfig::CONFIG['shared_gc_dir'].length > 0
|
||||
if RbConfig::CONFIG['modular_gc_dir'].length > 0
|
||||
assert_match(/\+GC/, RUBY_DESCRIPTION)
|
||||
else
|
||||
assert_no_match(/\+GC/, RUBY_DESCRIPTION)
|
||||
|
42
tool/m4/ruby_modular_gc.m4
Normal file
42
tool/m4/ruby_modular_gc.m4
Normal file
@ -0,0 +1,42 @@
|
||||
dnl -*- Autoconf -*-
|
||||
AC_DEFUN([RUBY_MODULAR_GC],[
|
||||
AC_ARG_WITH(modular-gc,
|
||||
AS_HELP_STRING([--with-modular-gc=DIR],
|
||||
[Enable replacement of Ruby's GC from a modular library in the specified directory.]),
|
||||
[modular_gc_dir=$withval], [unset modular_gc_dir]
|
||||
)
|
||||
|
||||
AS_IF([test "$modular_gc_dir" = yes], [
|
||||
AC_MSG_ERROR(you must specify a directory when using --with-modular-gc)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([if building with modular GC support])
|
||||
AS_IF([test x"$modular_gc_dir" != x], [
|
||||
AC_MSG_RESULT([yes])
|
||||
|
||||
# Ensure that modular_gc_dir is always an absolute path so that Ruby
|
||||
# never loads a modular GC from a relative path
|
||||
AS_CASE(["$modular_gc_dir"],
|
||||
[/*], [modular_gc_dir=$modular_gc_dir],
|
||||
[modular_gc_dir=`pwd`/$modular_gc_dir]
|
||||
)
|
||||
|
||||
# Ensure that modular_gc_dir always terminates with a /
|
||||
AS_CASE(["$modular_gc_dir"],
|
||||
[*/], [],
|
||||
[modular_gc_dir="$modular_gc_dir/"]
|
||||
)
|
||||
|
||||
AC_DEFINE([USE_MODULAR_GC], [1])
|
||||
AC_DEFINE_UNQUOTED([MODULAR_GC_DIR], "$modular_gc_dir")
|
||||
|
||||
modular_gc_summary="yes (in $modular_gc_dir)"
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
AC_DEFINE([USE_MODULAR_GC], [0])
|
||||
|
||||
modular_gc_summary="no"
|
||||
])
|
||||
|
||||
AC_SUBST(modular_gc_dir, "${modular_gc_dir}")
|
||||
])dnl
|
@ -1,42 +0,0 @@
|
||||
dnl -*- Autoconf -*-
|
||||
AC_DEFUN([RUBY_SHARED_GC],[
|
||||
AC_ARG_WITH(shared-gc,
|
||||
AS_HELP_STRING([--with-shared-gc=DIR],
|
||||
[Enable replacement of Ruby's GC from a shared library in the specified directory.]),
|
||||
[shared_gc_dir=$withval], [unset shared_gc_dir]
|
||||
)
|
||||
|
||||
AS_IF([test "$shared_gc_dir" = yes], [
|
||||
AC_MSG_ERROR(you must specify a directory when using --with-shared-gc)
|
||||
])
|
||||
|
||||
AC_MSG_CHECKING([if building with shared GC support])
|
||||
AS_IF([test x"$shared_gc_dir" != x], [
|
||||
AC_MSG_RESULT([yes])
|
||||
|
||||
# Ensure that shared_gc_dir is always an absolute path so that Ruby
|
||||
# never loads a shared GC from a relative path
|
||||
AS_CASE(["$shared_gc_dir"],
|
||||
[/*], [shared_gc_dir=$shared_gc_dir],
|
||||
[shared_gc_dir=`pwd`/$shared_gc_dir]
|
||||
)
|
||||
|
||||
# Ensure that shared_gc_dir always terminates with a /
|
||||
AS_CASE(["$shared_gc_dir"],
|
||||
[*/], [],
|
||||
[shared_gc_dir="$shared_gc_dir/"]
|
||||
)
|
||||
|
||||
AC_DEFINE([USE_SHARED_GC], [1])
|
||||
AC_DEFINE_UNQUOTED([SHARED_GC_DIR], "$shared_gc_dir")
|
||||
|
||||
shared_gc_summary="yes (in $shared_gc_dir)"
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
AC_DEFINE([USE_SHARED_GC], [0])
|
||||
|
||||
shared_gc_summary="no"
|
||||
])
|
||||
|
||||
AC_SUBST(shared_gc_dir, "${shared_gc_dir}")
|
||||
])dnl
|
@ -62,7 +62,7 @@ const int ruby_api_version[] = {
|
||||
#else
|
||||
#define YJIT_DESCRIPTION " +YJIT"
|
||||
#endif
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
#define GC_DESCRIPTION " +GC"
|
||||
#else
|
||||
#define GC_DESCRIPTION ""
|
||||
@ -173,7 +173,7 @@ define_ruby_description(const char *const jit_opt)
|
||||
+ rb_strlen_lit(YJIT_DESCRIPTION)
|
||||
+ rb_strlen_lit(" +MN")
|
||||
+ rb_strlen_lit(" +PRISM")
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
+ rb_strlen_lit(GC_DESCRIPTION)
|
||||
// Assume the active GC name can not be longer than 20 chars
|
||||
// so that we don't have to use strlen and remove the static
|
||||
@ -190,9 +190,9 @@ define_ruby_description(const char *const jit_opt)
|
||||
RUBY_ASSERT(n <= ruby_description_opt_point + (int)rb_strlen_lit(YJIT_DESCRIPTION));
|
||||
if (ruby_mn_threads_enabled) append(" +MN");
|
||||
if (rb_ruby_prism_p()) append(" +PRISM");
|
||||
#if USE_SHARED_GC
|
||||
#if USE_MODULAR_GC
|
||||
append(GC_DESCRIPTION);
|
||||
if (rb_gc_external_gc_loaded_p()) {
|
||||
if (rb_gc_modular_gc_loaded_p()) {
|
||||
append("[");
|
||||
append(rb_gc_active_gc_name());
|
||||
append("]");
|
||||
|
Loading…
x
Reference in New Issue
Block a user