diff options
Diffstat (limited to 'ext/json')
-rw-r--r-- | ext/json/parser/extconf.rb | 5 | ||||
-rw-r--r-- | ext/json/parser/parser.c | 15 | ||||
-rw-r--r-- | ext/json/parser/parser.rl | 15 |
3 files changed, 32 insertions, 3 deletions
diff --git a/ext/json/parser/extconf.rb b/ext/json/parser/extconf.rb index 8705884127..c3c23d2cb4 100644 --- a/ext/json/parser/extconf.rb +++ b/ext/json/parser/extconf.rb @@ -1,9 +1,8 @@ # frozen_string_literal: true require 'mkmf' -have_func("rb_enc_raise", "ruby.h") -have_func("rb_enc_interned_str", "ruby.h") - +have_func("rb_enc_interned_str", "ruby.h") # RUBY_VERSION >= 3.0 +have_func("rb_gc_mark_locations") # Missing on TruffleRuby append_cflags("-std=c99") create_makefile 'json/ext/parser' diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index cdf8983a77..758dba4694 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -2115,6 +2115,19 @@ case 9: } } +#ifndef HAVE_RB_GC_MARK_LOCATIONS +// For TruffleRuby +void rb_gc_mark_locations(const VALUE *start, const VALUE *end) +{ + VALUE *value = start; + + while (value < end) { + rb_gc_mark(*value); + value++; + } +} +#endif + static void JSON_mark(void *ptr) { JSON_Parser *json = ptr; @@ -2124,6 +2137,8 @@ static void JSON_mark(void *ptr) rb_gc_mark(json->array_class); rb_gc_mark(json->decimal_class); rb_gc_mark(json->match_string); + const VALUE *name_cache_entries = &json->name_cache.entries[0]; + rb_gc_mark_locations(name_cache_entries, name_cache_entries + json->name_cache.length); } static void JSON_free(void *ptr) diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl index 3301f1608c..15ec2b6843 100644 --- a/ext/json/parser/parser.rl +++ b/ext/json/parser/parser.rl @@ -875,6 +875,19 @@ static VALUE cParser_parse(VALUE self) } } +#ifndef HAVE_RB_GC_MARK_LOCATIONS +// For TruffleRuby +void rb_gc_mark_locations(const VALUE *start, const VALUE *end) +{ + VALUE *value = start; + + while (value < end) { + rb_gc_mark(*value); + value++; + } +} +#endif + static void JSON_mark(void *ptr) { JSON_Parser *json = ptr; @@ -884,6 +897,8 @@ static void JSON_mark(void *ptr) rb_gc_mark(json->array_class); rb_gc_mark(json->decimal_class); rb_gc_mark(json->match_string); + const VALUE *name_cache_entries = &json->name_cache.entries[0]; + rb_gc_mark_locations(name_cache_entries, name_cache_entries + json->name_cache.length); } static void JSON_free(void *ptr) |