From b35e21b3889e95cf727f2da49abb881c3466bc75 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Fri, 12 Jan 2024 07:38:02 +0900 Subject: [PATCH] Remove reference counter from rb_parser_config It's allocated outside of parser then no need to track reference count in rb_parser_config. --- node.c | 1 - parse.y | 1 - ruby_parser.c | 2 -- rubyparser.h | 8 -------- 4 files changed, 12 deletions(-) diff --git a/node.c b/node.c index 9521238e38..79ef00f1b7 100644 --- a/node.c +++ b/node.c @@ -321,7 +321,6 @@ rb_ast_t * rb_ast_new(rb_parser_config_t *config) { node_buffer_t *nb = rb_node_buffer_new(config); - config->counter++; return config->ast_new((VALUE)nb); } #else diff --git a/parse.y b/parse.y index 23ca4c8ddc..6ebb237181 100644 --- a/parse.y +++ b/parse.y @@ -15970,7 +15970,6 @@ rb_ruby_parser_allocate(rb_parser_config_t *config) /* parser_initialize expects fields to be set to 0 */ rb_parser_t *p = (rb_parser_t *)config->calloc(1, sizeof(rb_parser_t)); p->config = config; - p->config->counter++; return p; } diff --git a/ruby_parser.c b/ruby_parser.c index 9f9b680646..47dc54df6c 100644 --- a/ruby_parser.c +++ b/ruby_parser.c @@ -618,8 +618,6 @@ extern VALUE rb_mRubyVMFrozenCore; VALUE rb_node_case_when_optimizable_literal(const NODE *const node); rb_parser_config_t rb_global_parser_config = (rb_parser_config_t) { - .counter = 0, - .malloc = ruby_xmalloc, .calloc = ruby_xcalloc, .realloc = ruby_xrealloc, diff --git a/rubyparser.h b/rubyparser.h index e78df79e7a..974a03992c 100644 --- a/rubyparser.h +++ b/rubyparser.h @@ -1194,14 +1194,6 @@ typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t; #ifdef UNIVERSAL_PARSER typedef struct rb_parser_config_struct { - /* - * Reference counter. - * This is needed because both parser and ast refer - * same config pointer. - * We can remove this, once decuple parser and ast from Ruby GC. - */ - int counter; - /* Memory */ void *(*malloc)(size_t size); void *(*calloc)(size_t number, size_t size);