Skip to content

Commit 8a475d1

Browse files
committed
Implement dcompact for Time objects
1 parent 7db0e07 commit 8a475d1

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

time.c

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,23 +1890,38 @@ static void
18901890
time_mark(void *ptr)
18911891
{
18921892
struct time_object *tobj = ptr;
1893-
if (!FIXWV_P(tobj->timew))
1894-
rb_gc_mark(w2v(tobj->timew));
1895-
rb_gc_mark(tobj->vtm.year);
1896-
rb_gc_mark(tobj->vtm.subsecx);
1897-
rb_gc_mark(tobj->vtm.utc_offset);
1898-
rb_gc_mark(tobj->vtm.zone);
1893+
if (!FIXWV_P(tobj->timew)) {
1894+
rb_gc_mark_movable(WIDEVAL_GET(tobj->timew));
1895+
}
1896+
rb_gc_mark_movable(tobj->vtm.year);
1897+
rb_gc_mark_movable(tobj->vtm.subsecx);
1898+
rb_gc_mark_movable(tobj->vtm.utc_offset);
1899+
rb_gc_mark_movable(tobj->vtm.zone);
1900+
}
1901+
1902+
static void
1903+
time_compact(void *ptr)
1904+
{
1905+
struct time_object *tobj = ptr;
1906+
if (!FIXWV_P(tobj->timew)) {
1907+
WIDEVAL_GET(tobj->timew) = rb_gc_location(WIDEVAL_GET(tobj->timew));
1908+
}
1909+
1910+
tobj->vtm.year = rb_gc_location(tobj->vtm.year);
1911+
tobj->vtm.subsecx = rb_gc_location(tobj->vtm.subsecx);
1912+
tobj->vtm.utc_offset = rb_gc_location(tobj->vtm.utc_offset);
1913+
tobj->vtm.zone = rb_gc_location(tobj->vtm.zone);
18991914
}
19001915

19011916
static const rb_data_type_t time_data_type = {
1902-
"time",
1903-
{
1904-
time_mark,
1905-
RUBY_TYPED_DEFAULT_FREE,
1906-
NULL, // No external memory to report,
1917+
.wrap_struct_name = "time",
1918+
.function = {
1919+
.dmark = time_mark,
1920+
.dfree = RUBY_TYPED_DEFAULT_FREE,
1921+
.dsize = NULL,
1922+
.dcompact = time_compact,
19071923
},
1908-
0, 0,
1909-
(RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE),
1924+
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
19101925
};
19111926

19121927
static VALUE

0 commit comments

Comments
 (0)