mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Rename imemo_alloc with imemo_tmpbuf
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									af0696782d
								
							
						
					
					
						commit
						e9303e1a00
					
				
					 5 changed files with 35 additions and 35 deletions
				
			
		| 
						 | 
				
			
			@ -625,7 +625,7 @@ count_imemo_objects(int argc, VALUE *argv, VALUE self)
 | 
			
		|||
	imemo_type_ids[5] = rb_intern("imemo_memo");
 | 
			
		||||
	imemo_type_ids[6] = rb_intern("imemo_ment");
 | 
			
		||||
	imemo_type_ids[7] = rb_intern("imemo_iseq");
 | 
			
		||||
	imemo_type_ids[8] = rb_intern("imemo_alloc");
 | 
			
		||||
	imemo_type_ids[8] = rb_intern("imemo_tmpbuf");
 | 
			
		||||
	imemo_type_ids[9] = rb_intern("imemo_parser_strterm");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -205,7 +205,7 @@ imemo_name(int imemo)
 | 
			
		|||
	TYPE_STR(memo);
 | 
			
		||||
	TYPE_STR(ment);
 | 
			
		||||
	TYPE_STR(iseq);
 | 
			
		||||
	TYPE_STR(alloc);
 | 
			
		||||
	TYPE_STR(tmpbuf);
 | 
			
		||||
	TYPE_STR(ast);
 | 
			
		||||
	TYPE_STR(parser_strterm);
 | 
			
		||||
      default:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								gc.c
									
										
									
									
									
								
							
							
						
						
									
										34
									
								
								gc.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -434,7 +434,7 @@ typedef struct RVALUE {
 | 
			
		|||
	    struct rb_method_entry_struct ment;
 | 
			
		||||
	    const rb_iseq_t iseq;
 | 
			
		||||
	    rb_env_t env;
 | 
			
		||||
	    struct rb_imemo_alloc_struct alloc;
 | 
			
		||||
	    struct rb_imemo_tmpbuf_struct alloc;
 | 
			
		||||
	    rb_ast_t ast;
 | 
			
		||||
	} imemo;
 | 
			
		||||
	struct {
 | 
			
		||||
| 
						 | 
				
			
			@ -2025,28 +2025,28 @@ rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static VALUE
 | 
			
		||||
rb_imemo_alloc_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
 | 
			
		||||
rb_imemo_tmpbuf_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
 | 
			
		||||
{
 | 
			
		||||
    VALUE flags = T_IMEMO | (imemo_alloc << FL_USHIFT);
 | 
			
		||||
    VALUE flags = T_IMEMO | (imemo_tmpbuf << FL_USHIFT);
 | 
			
		||||
    return newobj_of(v0, flags, v1, v2, v3, FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VALUE
 | 
			
		||||
rb_imemo_alloc_auto_free_pointer(void *buf)
 | 
			
		||||
rb_imemo_tmpbuf_auto_free_pointer(void *buf)
 | 
			
		||||
{
 | 
			
		||||
    return rb_imemo_new(imemo_alloc, (VALUE)buf, 0, 0, 0);
 | 
			
		||||
    return rb_imemo_new(imemo_tmpbuf, (VALUE)buf, 0, 0, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
VALUE
 | 
			
		||||
rb_imemo_alloc_auto_free_maybe_mark_buffer(void *buf, size_t cnt)
 | 
			
		||||
rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(void *buf, size_t cnt)
 | 
			
		||||
{
 | 
			
		||||
    return rb_imemo_alloc_new((VALUE)buf, 0, (VALUE)cnt, 0);
 | 
			
		||||
    return rb_imemo_tmpbuf_new((VALUE)buf, 0, (VALUE)cnt, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
rb_imemo_alloc_t *
 | 
			
		||||
rb_imemo_alloc_parser_heap(void *buf, rb_imemo_alloc_t *old_heap, size_t cnt)
 | 
			
		||||
rb_imemo_tmpbuf_t *
 | 
			
		||||
rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt)
 | 
			
		||||
{
 | 
			
		||||
    return (rb_imemo_alloc_t *)rb_imemo_alloc_new((VALUE)buf, (VALUE)old_heap, (VALUE)cnt, 0);
 | 
			
		||||
    return (rb_imemo_tmpbuf_t *)rb_imemo_tmpbuf_new((VALUE)buf, (VALUE)old_heap, (VALUE)cnt, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if IMEMO_DEBUG
 | 
			
		||||
| 
						 | 
				
			
			@ -2382,7 +2382,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
 | 
			
		|||
	    GC_ASSERT(VM_ENV_ESCAPED_P(RANY(obj)->as.imemo.env.ep));
 | 
			
		||||
	    xfree((VALUE *)RANY(obj)->as.imemo.env.env);
 | 
			
		||||
	    break;
 | 
			
		||||
	  case imemo_alloc:
 | 
			
		||||
	  case imemo_tmpbuf:
 | 
			
		||||
	    xfree(RANY(obj)->as.imemo.alloc.ptr);
 | 
			
		||||
	    break;
 | 
			
		||||
	  case imemo_ast:
 | 
			
		||||
| 
						 | 
				
			
			@ -3308,7 +3308,7 @@ obj_memsize_of(VALUE obj, int use_all_types)
 | 
			
		|||
      case T_RATIONAL:
 | 
			
		||||
      case T_COMPLEX:
 | 
			
		||||
      case T_IMEMO:
 | 
			
		||||
	if (imemo_type_p(obj, imemo_alloc)) {
 | 
			
		||||
	if (imemo_type_p(obj, imemo_tmpbuf)) {
 | 
			
		||||
	    size += RANY(obj)->as.imemo.alloc.cnt * sizeof(VALUE);
 | 
			
		||||
	}
 | 
			
		||||
	break;
 | 
			
		||||
| 
						 | 
				
			
			@ -4556,9 +4556,9 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
 | 
			
		|||
      case imemo_iseq:
 | 
			
		||||
	rb_iseq_mark((rb_iseq_t *)obj);
 | 
			
		||||
	return;
 | 
			
		||||
      case imemo_alloc:
 | 
			
		||||
      case imemo_tmpbuf:
 | 
			
		||||
	{
 | 
			
		||||
	    const rb_imemo_alloc_t *m = &RANY(obj)->as.imemo.alloc;
 | 
			
		||||
	    const rb_imemo_tmpbuf_t *m = &RANY(obj)->as.imemo.alloc;
 | 
			
		||||
	    do {
 | 
			
		||||
		rb_gc_mark_locations(m->ptr, m->ptr + m->cnt);
 | 
			
		||||
	    } while ((m = m->next) != NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -8143,7 +8143,7 @@ rb_alloc_tmp_buffer_with_count(volatile VALUE *store, size_t size, size_t cnt)
 | 
			
		|||
    void *ptr;
 | 
			
		||||
 | 
			
		||||
    ptr = ruby_xmalloc0(size);
 | 
			
		||||
    *store = rb_imemo_alloc_auto_free_maybe_mark_buffer(ptr, cnt);
 | 
			
		||||
    *store = rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(ptr, cnt);
 | 
			
		||||
    return ptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -8162,7 +8162,7 @@ rb_alloc_tmp_buffer(volatile VALUE *store, long len)
 | 
			
		|||
void
 | 
			
		||||
rb_free_tmp_buffer(volatile VALUE *store)
 | 
			
		||||
{
 | 
			
		||||
    rb_imemo_alloc_t *s = (rb_imemo_alloc_t*)ATOMIC_VALUE_EXCHANGE(*store, 0);
 | 
			
		||||
    rb_imemo_tmpbuf_t *s = (rb_imemo_tmpbuf_t*)ATOMIC_VALUE_EXCHANGE(*store, 0);
 | 
			
		||||
    if (s) {
 | 
			
		||||
	void *ptr = ATOMIC_PTR_EXCHANGE(s->ptr, 0);
 | 
			
		||||
	s->cnt = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -9397,7 +9397,7 @@ rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
 | 
			
		|||
		IMEMO_NAME(memo);
 | 
			
		||||
		IMEMO_NAME(ment);
 | 
			
		||||
		IMEMO_NAME(iseq);
 | 
			
		||||
		IMEMO_NAME(alloc);
 | 
			
		||||
		IMEMO_NAME(tmpbuf);
 | 
			
		||||
#undef IMEMO_NAME
 | 
			
		||||
	      default: UNREACHABLE;
 | 
			
		||||
	    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								internal.h
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								internal.h
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -864,7 +864,7 @@ enum imemo_type {
 | 
			
		|||
    imemo_memo           =  5,
 | 
			
		||||
    imemo_ment           =  6,
 | 
			
		||||
    imemo_iseq           =  7,
 | 
			
		||||
    imemo_alloc          =  8,
 | 
			
		||||
    imemo_tmpbuf         =  8,
 | 
			
		||||
    imemo_ast            =  9,
 | 
			
		||||
    imemo_parser_strterm = 10
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -952,17 +952,17 @@ rb_vm_ifunc_proc_new(VALUE (*func)(ANYARGS), const void *data)
 | 
			
		|||
    return rb_vm_ifunc_new(func, data, 0, UNLIMITED_ARGUMENTS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
typedef struct rb_imemo_alloc_struct {
 | 
			
		||||
typedef struct rb_imemo_tmpbuf_struct {
 | 
			
		||||
    VALUE flags;
 | 
			
		||||
    VALUE reserved;
 | 
			
		||||
    VALUE *ptr; /* malloc'ed buffer */
 | 
			
		||||
    struct rb_imemo_alloc_struct *next; /* next imemo */
 | 
			
		||||
    struct rb_imemo_tmpbuf_struct *next; /* next imemo */
 | 
			
		||||
    size_t cnt; /* buffer size in VALUE */
 | 
			
		||||
} rb_imemo_alloc_t;
 | 
			
		||||
} rb_imemo_tmpbuf_t;
 | 
			
		||||
 | 
			
		||||
VALUE rb_imemo_alloc_auto_free_pointer(void *buf);
 | 
			
		||||
VALUE rb_imemo_alloc_auto_free_maybe_mark_buffer(void *buf, size_t cnt);
 | 
			
		||||
rb_imemo_alloc_t *rb_imemo_alloc_parser_heap(void *buf, rb_imemo_alloc_t *old_heap, size_t cnt);
 | 
			
		||||
VALUE rb_imemo_tmpbuf_auto_free_pointer(void *buf);
 | 
			
		||||
VALUE rb_imemo_tmpbuf_auto_free_maybe_mark_buffer(void *buf, size_t cnt);
 | 
			
		||||
rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
 | 
			
		||||
 | 
			
		||||
void rb_strterm_mark(VALUE obj);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										18
									
								
								parse.y
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								parse.y
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -183,7 +183,7 @@ typedef struct rb_strterm_struct rb_strterm_t;
 | 
			
		|||
                     token
 | 
			
		||||
*/
 | 
			
		||||
struct parser_params {
 | 
			
		||||
    rb_imemo_alloc_t *heap;
 | 
			
		||||
    rb_imemo_tmpbuf_t *heap;
 | 
			
		||||
 | 
			
		||||
    YYSTYPE *lval;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2505,7 +2505,7 @@ primary		: literal
 | 
			
		|||
			NODE *args, *scope, *internal_var = NEW_DVAR(id, &@2);
 | 
			
		||||
			ID *tbl = ALLOC_N(ID, 2);
 | 
			
		||||
			tbl[0] = 1 /* length of local var table */; tbl[1] = id /* internal id */;
 | 
			
		||||
			add_mark_object(p, rb_imemo_alloc_auto_free_pointer(tbl));
 | 
			
		||||
			add_mark_object(p, rb_imemo_tmpbuf_auto_free_pointer(tbl));
 | 
			
		||||
 | 
			
		||||
			switch (nd_type($2)) {
 | 
			
		||||
			  case NODE_LASGN:
 | 
			
		||||
| 
						 | 
				
			
			@ -9988,7 +9988,7 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
 | 
			
		|||
    NODE *node;
 | 
			
		||||
 | 
			
		||||
    args = ZALLOC(struct rb_args_info);
 | 
			
		||||
    add_mark_object(p, rb_imemo_alloc_auto_free_pointer(args));
 | 
			
		||||
    add_mark_object(p, rb_imemo_tmpbuf_auto_free_pointer(args));
 | 
			
		||||
    node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC);
 | 
			
		||||
    if (p->error_p) return node;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -10350,7 +10350,7 @@ local_tbl(struct parser_params *p)
 | 
			
		|||
    if (--j < cnt) REALLOC_N(buf, ID, (cnt = j) + 1);
 | 
			
		||||
    buf[0] = cnt;
 | 
			
		||||
 | 
			
		||||
    add_mark_object(p, rb_imemo_alloc_auto_free_pointer(buf));
 | 
			
		||||
    add_mark_object(p, rb_imemo_tmpbuf_auto_free_pointer(buf));
 | 
			
		||||
 | 
			
		||||
    return buf;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -10975,7 +10975,7 @@ rb_parser_malloc(struct parser_params *p, size_t size)
 | 
			
		|||
{
 | 
			
		||||
    size_t cnt = HEAPCNT(1, size);
 | 
			
		||||
    void *ptr = xmalloc(size);
 | 
			
		||||
    p->heap = rb_imemo_alloc_parser_heap(ptr, p->heap, cnt);
 | 
			
		||||
    p->heap = rb_imemo_tmpbuf_parser_heap(ptr, p->heap, cnt);
 | 
			
		||||
    return p->heap->ptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -10984,14 +10984,14 @@ rb_parser_calloc(struct parser_params *p, size_t nelem, size_t size)
 | 
			
		|||
{
 | 
			
		||||
    size_t cnt = HEAPCNT(nelem, size);
 | 
			
		||||
    void *ptr = xcalloc(nelem, size);
 | 
			
		||||
    p->heap = rb_imemo_alloc_parser_heap(ptr, p->heap, cnt);
 | 
			
		||||
    p->heap = rb_imemo_tmpbuf_parser_heap(ptr, p->heap, cnt);
 | 
			
		||||
    return p->heap->ptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *
 | 
			
		||||
rb_parser_realloc(struct parser_params *p, void *ptr, size_t size)
 | 
			
		||||
{
 | 
			
		||||
    rb_imemo_alloc_t *n;
 | 
			
		||||
    rb_imemo_tmpbuf_t *n;
 | 
			
		||||
    size_t cnt = HEAPCNT(1, size);
 | 
			
		||||
 | 
			
		||||
    if (ptr && (n = p->heap) != NULL) {
 | 
			
		||||
| 
						 | 
				
			
			@ -11004,14 +11004,14 @@ rb_parser_realloc(struct parser_params *p, void *ptr, size_t size)
 | 
			
		|||
	} while ((n = n->next) != NULL);
 | 
			
		||||
    }
 | 
			
		||||
    ptr = xrealloc(ptr, size);
 | 
			
		||||
    p->heap = rb_imemo_alloc_parser_heap(ptr, p->heap, cnt);
 | 
			
		||||
    p->heap = rb_imemo_tmpbuf_parser_heap(ptr, p->heap, cnt);
 | 
			
		||||
    return p->heap->ptr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
rb_parser_free(struct parser_params *p, void *ptr)
 | 
			
		||||
{
 | 
			
		||||
    rb_imemo_alloc_t **prev = &p->heap, *n;
 | 
			
		||||
    rb_imemo_tmpbuf_t **prev = &p->heap, *n;
 | 
			
		||||
 | 
			
		||||
    while ((n = *prev) != NULL) {
 | 
			
		||||
	if (n->ptr == ptr) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue