Remove rb_imemo_tmpbuf_t
from parser
No parser semantic value types are `VALUE` then no need to use imemo for managing semantic value stack anymore.
This commit is contained in:
parent
e651395210
commit
e816ab0b0c
@ -2,7 +2,6 @@
|
|||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
#include "ruby/encoding.h"
|
#include "ruby/encoding.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "internal/imemo.h" /* needed by ruby_parser.h */
|
|
||||||
#include "rubyparser.h"
|
#include "rubyparser.h"
|
||||||
#define YYSTYPE_IS_DECLARED
|
#define YYSTYPE_IS_DECLARED
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "internal/bignum.h"
|
#include "internal/bignum.h"
|
||||||
#include "internal/compilers.h"
|
#include "internal/compilers.h"
|
||||||
#include "internal/complex.h"
|
#include "internal/complex.h"
|
||||||
#include "internal/imemo.h"
|
|
||||||
#include "internal/rational.h"
|
#include "internal/rational.h"
|
||||||
#include "rubyparser.h"
|
#include "rubyparser.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
4
node.h
4
node.h
@ -73,10 +73,6 @@ VALUE rb_parser_dump_tree(const NODE *node, int comment);
|
|||||||
const struct kwtable *rb_reserved_word(const char *, unsigned int);
|
const struct kwtable *rb_reserved_word(const char *, unsigned int);
|
||||||
|
|
||||||
struct parser_params;
|
struct parser_params;
|
||||||
void *rb_parser_malloc(struct parser_params *, size_t);
|
|
||||||
void *rb_parser_realloc(struct parser_params *, void *, size_t);
|
|
||||||
void *rb_parser_calloc(struct parser_params *, size_t, size_t);
|
|
||||||
void rb_parser_free(struct parser_params *, void *);
|
|
||||||
PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
|
PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
|
||||||
VALUE rb_node_set_type(NODE *n, enum node_type t);
|
VALUE rb_node_set_type(NODE *n, enum node_type t);
|
||||||
|
|
||||||
|
73
parse.y
73
parse.y
@ -49,7 +49,6 @@
|
|||||||
#include "internal/encoding.h"
|
#include "internal/encoding.h"
|
||||||
#include "internal/error.h"
|
#include "internal/error.h"
|
||||||
#include "internal/hash.h"
|
#include "internal/hash.h"
|
||||||
#include "internal/imemo.h"
|
|
||||||
#include "internal/io.h"
|
#include "internal/io.h"
|
||||||
#include "internal/numeric.h"
|
#include "internal/numeric.h"
|
||||||
#include "internal/parse.h"
|
#include "internal/parse.h"
|
||||||
@ -354,10 +353,6 @@ RBIMPL_WARNING_POP()
|
|||||||
|
|
||||||
#define yydebug (p->debug) /* disable the global variable definition */
|
#define yydebug (p->debug) /* disable the global variable definition */
|
||||||
|
|
||||||
#define YYMALLOC(size) rb_parser_malloc(p, (size))
|
|
||||||
#define YYREALLOC(ptr, size) rb_parser_realloc(p, (ptr), (size))
|
|
||||||
#define YYCALLOC(nelem, size) rb_parser_calloc(p, (nelem), (size))
|
|
||||||
#define YYFREE(ptr) rb_parser_free(p, (ptr))
|
|
||||||
#define YYFPRINTF(out, ...) rb_parser_printf(p, __VA_ARGS__)
|
#define YYFPRINTF(out, ...) rb_parser_printf(p, __VA_ARGS__)
|
||||||
#define YY_LOCATION_PRINT(File, loc, p) \
|
#define YY_LOCATION_PRINT(File, loc, p) \
|
||||||
rb_parser_printf(p, "%d.%d-%d.%d", \
|
rb_parser_printf(p, "%d.%d-%d.%d", \
|
||||||
@ -499,8 +494,6 @@ typedef struct parser_string_buffer {
|
|||||||
token
|
token
|
||||||
*/
|
*/
|
||||||
struct parser_params {
|
struct parser_params {
|
||||||
rb_imemo_tmpbuf_t *heap;
|
|
||||||
|
|
||||||
YYSTYPE *lval;
|
YYSTYPE *lval;
|
||||||
YYLTYPE *yylloc;
|
YYLTYPE *yylloc;
|
||||||
|
|
||||||
@ -16147,9 +16140,6 @@ rb_ruby_parser_mark(void *ptr)
|
|||||||
#endif
|
#endif
|
||||||
rb_gc_mark(p->debug_buffer);
|
rb_gc_mark(p->debug_buffer);
|
||||||
rb_gc_mark(p->debug_output);
|
rb_gc_mark(p->debug_output);
|
||||||
#ifdef YYMALLOC
|
|
||||||
rb_gc_mark((VALUE)p->heap);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -16610,69 +16600,6 @@ rb_ruby_ripper_parser_allocate(void)
|
|||||||
#endif /* RIPPER */
|
#endif /* RIPPER */
|
||||||
|
|
||||||
#ifndef RIPPER
|
#ifndef RIPPER
|
||||||
#ifdef YYMALLOC
|
|
||||||
#define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
|
|
||||||
/* Keep the order; NEWHEAP then xmalloc and ADD2HEAP to get rid of
|
|
||||||
* potential memory leak */
|
|
||||||
#define NEWHEAP() rb_imemo_tmpbuf_parser_heap(0, p->heap, 0)
|
|
||||||
#define ADD2HEAP(new, cnt, ptr) ((p->heap = (new))->ptr = (ptr), \
|
|
||||||
(new)->cnt = (cnt), (ptr))
|
|
||||||
|
|
||||||
void *
|
|
||||||
rb_parser_malloc(struct parser_params *p, size_t size)
|
|
||||||
{
|
|
||||||
size_t cnt = HEAPCNT(1, size);
|
|
||||||
rb_imemo_tmpbuf_t *n = NEWHEAP();
|
|
||||||
void *ptr = xmalloc(size);
|
|
||||||
|
|
||||||
return ADD2HEAP(n, cnt, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
rb_parser_calloc(struct parser_params *p, size_t nelem, size_t size)
|
|
||||||
{
|
|
||||||
size_t cnt = HEAPCNT(nelem, size);
|
|
||||||
rb_imemo_tmpbuf_t *n = NEWHEAP();
|
|
||||||
void *ptr = xcalloc(nelem, size);
|
|
||||||
|
|
||||||
return ADD2HEAP(n, cnt, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
rb_parser_realloc(struct parser_params *p, void *ptr, size_t size)
|
|
||||||
{
|
|
||||||
rb_imemo_tmpbuf_t *n;
|
|
||||||
size_t cnt = HEAPCNT(1, size);
|
|
||||||
|
|
||||||
if (ptr && (n = p->heap) != NULL) {
|
|
||||||
do {
|
|
||||||
if (n->ptr == ptr) {
|
|
||||||
n->ptr = ptr = xrealloc(ptr, size);
|
|
||||||
if (n->cnt) n->cnt = cnt;
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
} while ((n = n->next) != NULL);
|
|
||||||
}
|
|
||||||
n = NEWHEAP();
|
|
||||||
ptr = xrealloc(ptr, size);
|
|
||||||
return ADD2HEAP(n, cnt, ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
rb_parser_free(struct parser_params *p, void *ptr)
|
|
||||||
{
|
|
||||||
rb_imemo_tmpbuf_t **prev = &p->heap, *n;
|
|
||||||
|
|
||||||
while ((n = *prev) != NULL) {
|
|
||||||
if (n->ptr == ptr) {
|
|
||||||
*prev = n->next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
prev = &n->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_parser_printf(struct parser_params *p, const char *fmt, ...)
|
rb_parser_printf(struct parser_params *p, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -387,12 +387,6 @@ gc_guard(VALUE obj)
|
|||||||
RB_GC_GUARD(obj);
|
RB_GC_GUARD(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static rb_imemo_tmpbuf_t *
|
|
||||||
tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
|
|
||||||
{
|
|
||||||
return rb_imemo_tmpbuf_parser_heap(buf, old_heap, cnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
arg_error(void)
|
arg_error(void)
|
||||||
{
|
{
|
||||||
@ -462,7 +456,6 @@ static const rb_parser_config_t rb_global_parser_config = {
|
|||||||
.nonempty_memcpy = nonempty_memcpy,
|
.nonempty_memcpy = nonempty_memcpy,
|
||||||
.xmalloc_mul_add = rb_xmalloc_mul_add,
|
.xmalloc_mul_add = rb_xmalloc_mul_add,
|
||||||
|
|
||||||
.tmpbuf_parser_heap = tmpbuf_parser_heap,
|
|
||||||
.ast_new = ast_new,
|
.ast_new = ast_new,
|
||||||
|
|
||||||
.compile_callback = rb_suppress_tracing,
|
.compile_callback = rb_suppress_tracing,
|
||||||
|
@ -1241,7 +1241,6 @@ typedef struct rb_parser_config_struct {
|
|||||||
void *(*xmalloc_mul_add)(size_t x, size_t y, size_t z);
|
void *(*xmalloc_mul_add)(size_t x, size_t y, size_t z);
|
||||||
|
|
||||||
/* imemo */
|
/* imemo */
|
||||||
rb_imemo_tmpbuf_t *(*tmpbuf_parser_heap)(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
|
|
||||||
rb_ast_t *(*ast_new)(VALUE nb);
|
rb_ast_t *(*ast_new)(VALUE nb);
|
||||||
|
|
||||||
// VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
|
// VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
|
||||||
|
@ -61,16 +61,6 @@
|
|||||||
|
|
||||||
#define rb_encoding void
|
#define rb_encoding void
|
||||||
|
|
||||||
#ifndef INTERNAL_IMEMO_H
|
|
||||||
struct rb_imemo_tmpbuf_struct {
|
|
||||||
VALUE flags;
|
|
||||||
VALUE reserved;
|
|
||||||
VALUE *ptr; /* malloc'ed buffer */
|
|
||||||
struct rb_imemo_tmpbuf_struct *next; /* next imemo */
|
|
||||||
size_t cnt; /* buffer size in VALUE */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef xmalloc
|
#undef xmalloc
|
||||||
#define xmalloc p->config->malloc
|
#define xmalloc p->config->malloc
|
||||||
#undef xcalloc
|
#undef xcalloc
|
||||||
@ -95,8 +85,6 @@ struct rb_imemo_tmpbuf_struct {
|
|||||||
#undef MEMCPY
|
#undef MEMCPY
|
||||||
#define MEMCPY(p1,p2,type,n) (p->config->nonempty_memcpy((p1), (p2), sizeof(type), (n)))
|
#define MEMCPY(p1,p2,type,n) (p->config->nonempty_memcpy((p1), (p2), sizeof(type), (n)))
|
||||||
|
|
||||||
#define rb_imemo_tmpbuf_parser_heap p->config->tmpbuf_parser_heap
|
|
||||||
|
|
||||||
#define compile_callback p->config->compile_callback
|
#define compile_callback p->config->compile_callback
|
||||||
#define reg_named_capture_assign p->config->reg_named_capture_assign
|
#define reg_named_capture_assign p->config->reg_named_capture_assign
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user