Skip to content

Commit f085055

Browse files
committed
Move GC object suffix to gc.h
1 parent 356c0cd commit f085055

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

gc/default/default.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,6 @@
9696
# include <mach/mach_port.h>
9797
#endif
9898

99-
#ifndef VM_CHECK_MODE
100-
# define VM_CHECK_MODE RUBY_DEBUG
101-
#endif
102-
103-
// From ractor_core.h
104-
#ifndef RACTOR_CHECK_MODE
105-
# define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
106-
#endif
107-
10899
#ifndef RUBY_DEBUG_LOG
109100
# define RUBY_DEBUG_LOG(...)
110101
#endif
@@ -691,10 +682,10 @@ typedef struct rb_objspace {
691682
#define HEAP_PAGE_ALIGN_LOG 16
692683
#endif
693684

694-
#if RACTOR_CHECK_MODE || GC_DEBUG
685+
#if RB_GC_OBJ_HAS_SUFFIX || GC_DEBUG
695686
struct rvalue_overhead {
696-
# if RACTOR_CHECK_MODE
697-
uint32_t _ractor_belonging_id;
687+
# ifdef RB_GC_OBJ_HAS_SUFFIX
688+
struct rb_gc_obj_suffix suffix;
698689
# endif
699690
# if GC_DEBUG
700691
const char *file;

gc/gc.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,32 @@
1010
* first introduced for [Feature #20470].
1111
*/
1212
#include "ruby/ruby.h"
13+
#include "ruby/assert.h"
1314

1415
#include "ruby/thread_native.h"
1516

17+
#ifndef VM_CHECK_MODE
18+
# define VM_CHECK_MODE RUBY_DEBUG
19+
#endif
20+
21+
// From ractor_core.h
22+
#ifndef RACTOR_CHECK_MODE
23+
# define RACTOR_CHECK_MODE (VM_CHECK_MODE || RUBY_DEBUG) && (SIZEOF_UINT64_T == SIZEOF_VALUE)
24+
#endif
25+
26+
#if RACTOR_CHECK_MODE
27+
void rb_ractor_setup_belonging(VALUE obj);
28+
29+
struct rb_gc_obj_suffix {
30+
uint32_t _ractor_belonging_id;
31+
};
32+
33+
# define RB_GC_OBJ_HAS_SUFFIX 1
34+
# define RB_GC_OBJ_SUFFIX_SIZE (sizeof(struct rb_gc_obj_suffix))
35+
#else
36+
# define RB_GC_OBJ_SUFFIX_SIZE 0
37+
#endif
38+
1639
struct rb_gc_vm_context {
1740
rb_nativethread_lock_t lock;
1841

0 commit comments

Comments
 (0)