@@ -243,7 +243,7 @@ static void rvalue_stack_mark(void *ptr)
243243 long index ;
244244 if (stack && stack -> ptr ) {
245245 for (index = 0 ; index < stack -> head ; index ++ ) {
246- rb_gc_mark (stack -> ptr [index ]);
246+ rb_gc_mark_movable (stack -> ptr [index ]);
247247 }
248248 }
249249}
@@ -275,12 +275,24 @@ static size_t rvalue_stack_memsize(const void *ptr)
275275 return memsize ;
276276}
277277
278+ static void rvalue_stack_compact (void * ptr )
279+ {
280+ rvalue_stack * stack = (rvalue_stack * )ptr ;
281+ long index ;
282+ if (stack && stack -> ptr ) {
283+ for (index = 0 ; index < stack -> head ; index ++ ) {
284+ stack -> ptr [index ] = rb_gc_location (stack -> ptr [index ]);
285+ }
286+ }
287+ }
288+
278289static const rb_data_type_t JSON_Parser_rvalue_stack_type = {
279290 .wrap_struct_name = "JSON::Ext::Parser/rvalue_stack" ,
280291 .function = {
281292 .dmark = rvalue_stack_mark ,
282293 .dfree = rvalue_stack_free ,
283294 .dsize = rvalue_stack_memsize ,
295+ .dcompact = rvalue_stack_compact ,
284296 },
285297 .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE ,
286298};
@@ -1964,8 +1976,8 @@ static VALUE cParser_m_parse(VALUE klass, VALUE Vsource, VALUE opts)
19641976static void JSON_ParserConfig_mark (void * ptr )
19651977{
19661978 JSON_ParserConfig * config = ptr ;
1967- rb_gc_mark (config -> on_load_proc );
1968- rb_gc_mark (config -> decimal_class );
1979+ rb_gc_mark_movable (config -> on_load_proc );
1980+ rb_gc_mark_movable (config -> decimal_class );
19691981}
19701982
19711983static size_t JSON_ParserConfig_memsize (const void * ptr )
@@ -1977,12 +1989,20 @@ static size_t JSON_ParserConfig_memsize(const void *ptr)
19771989#endif
19781990}
19791991
1992+ static void JSON_ParserConfig_compact (void * ptr )
1993+ {
1994+ JSON_ParserConfig * config = ptr ;
1995+ config -> on_load_proc = rb_gc_location (config -> on_load_proc );
1996+ config -> decimal_class = rb_gc_location (config -> decimal_class );
1997+ }
1998+
19801999static const rb_data_type_t JSON_ParserConfig_type = {
19812000 .wrap_struct_name = "JSON::Ext::Parser/ParserConfig" ,
19822001 .function = {
1983- JSON_ParserConfig_mark ,
1984- RUBY_DEFAULT_FREE ,
1985- JSON_ParserConfig_memsize ,
2002+ .dmark = JSON_ParserConfig_mark ,
2003+ .dfree = RUBY_DEFAULT_FREE ,
2004+ .dsize = JSON_ParserConfig_memsize ,
2005+ .dcompact = JSON_ParserConfig_compact ,
19862006 },
19872007 .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_EMBEDDABLE ,
19882008};
0 commit comments