Skip to content

Commit 41cf6b1

Browse files
authored
Revert "Remove checking whether rb_gc_mark_movable exists (#876)" (#880)
This reverts commit 7e991e6.
1 parent 7e991e6 commit 41cf6b1

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

ext/oj/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
}
2525

2626
# Support for compaction.
27+
have_func('rb_gc_mark_movable')
2728
have_func('stpcpy')
2829
have_func('pthread_mutex_init')
2930
have_func('rb_enc_interned_str')

ext/oj/fast.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
// #define BATCH_SIZE (4096 / sizeof(struct _leaf) - 1)
2323
#define BATCH_SIZE 100
2424

25+
// Support for compaction
26+
#ifdef HAVE_RB_GC_MARK_MOVABLE
27+
#define mark rb_gc_mark_movable
28+
#else
29+
#define mark rb_gc_mark
30+
#endif
31+
2532
typedef struct _batch {
2633
struct _batch *next;
2734
int next_avail;
@@ -684,7 +691,7 @@ static void mark_leaf(Leaf leaf) {
684691
} while (e != first);
685692
}
686693
break;
687-
case RUBY_VAL: rb_gc_mark_movable(leaf->value); break;
694+
case RUBY_VAL: mark(leaf->value); break;
688695

689696
default: break;
690697
}
@@ -695,11 +702,11 @@ static void mark_doc(void *ptr) {
695702
if (NULL != ptr) {
696703
Doc doc = (Doc)ptr;
697704

698-
rb_gc_mark_movable(doc->self);
705+
mark(doc->self);
699706
mark_leaf(doc->data);
700707
}
701708
}
702-
709+
#ifdef HAVE_RB_GC_MARK_MOVABLE
703710
static void compact_leaf(Leaf leaf) {
704711
switch (leaf->value_type) {
705712
case COL_VAL:
@@ -727,14 +734,17 @@ static void compact_doc(void *ptr) {
727734
compact_leaf(doc->data);
728735
}
729736
}
737+
#endif
730738

731739
static const rb_data_type_t oj_doc_type = {
732740
"Oj/doc",
733741
{
734742
mark_doc,
735743
free_doc_cb,
736744
NULL,
745+
#ifdef HAVE_RB_GC_MARK_MOVABLE
737746
compact_doc,
747+
#endif
738748
},
739749
0,
740750
0,

0 commit comments

Comments
 (0)