@@ -220,6 +220,7 @@ divmodv(VALUE n, VALUE d, VALUE *q, VALUE *r)
220220 typedef int64_t wideint_t ;
221221 typedef uint64_t WIDEVALUE ;
222222 typedef int64_t SIGNED_WIDEVALUE ;
223+ STATIC_ASSERT (FIXWINT_is_FIXNUM , RUBY_FIXNUM_FLAG == 1 );
223224# define WIDEVALUE_IS_WIDER 1
224225# define UWIDEINT_MAX UINT64_MAX
225226# define WIDEINT_MAX INT64_MAX
@@ -282,6 +283,18 @@ divmodv(VALUE n, VALUE d, VALUE *q, VALUE *r)
282283# define WINT2WV (wi ) WIDEVAL_WRAP(LONG2NUM(wi))
283284#endif
284285
286+ static inline bool
287+ NONFIXWV_P (wideval_t w )
288+ {
289+ wideint_t wi = WIDEVAL_GET (w );
290+ if (FIXWINT_P (wi )) return true;
291+ #if WIDEVALUE_IS_WIDER
292+ RUBY_ASSERT (wi == (VALUE )wi );
293+ #endif
294+ return false;
295+ }
296+ #define NONFIXWV_VALUE (wi ) (VALUE)WIDEVAL_GET(wi)
297+
285298static inline VALUE
286299w2v (wideval_t w )
287300{
@@ -1890,8 +1903,8 @@ static void
18901903time_mark (void * ptr )
18911904{
18921905 struct time_object * tobj = ptr ;
1893- if (!FIXWV_P (tobj -> timew )) {
1894- rb_gc_mark_movable (WIDEVAL_GET (tobj -> timew ));
1906+ if (!NONFIXWV_P (tobj -> timew )) {
1907+ rb_gc_mark_movable (NONFIXWV_VALUE (tobj -> timew ));
18951908 }
18961909 rb_gc_mark_movable (tobj -> vtm .year );
18971910 rb_gc_mark_movable (tobj -> vtm .subsecx );
@@ -1903,8 +1916,8 @@ static void
19031916time_compact (void * ptr )
19041917{
19051918 struct time_object * tobj = ptr ;
1906- if (!FIXWV_P (tobj -> timew )) {
1907- WIDEVAL_GET (tobj -> timew ) = rb_gc_location (WIDEVAL_GET (tobj -> timew ));
1919+ if (!NONFIXWV_P (tobj -> timew )) {
1920+ WIDEVAL_GET (tobj -> timew ) = rb_gc_location (NONFIXWV_VALUE (tobj -> timew ));
19081921 }
19091922
19101923 tobj -> vtm .year = rb_gc_location (tobj -> vtm .year );
0 commit comments