mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* internal.h (IMEMO_DEBUG): added.
* internal.h: remove unused FL_IMEMO_MARK_V[0-3]. * gc.c (rb_imemo_new_debug): added. * gc.c (obj_info): show imemo type name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
33aaa89a79
commit
05704f51fb
3 changed files with 52 additions and 5 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Thu Mar 19 04:55:53 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* internal.h (IMEMO_DEBUG): added.
|
||||||
|
|
||||||
|
* internal.h: remove unused FL_IMEMO_MARK_V[0-3].
|
||||||
|
|
||||||
|
* gc.c (rb_imemo_new_debug): added.
|
||||||
|
|
||||||
|
* gc.c (obj_info): show imemo type name.
|
||||||
|
|
||||||
Thu Mar 19 04:52:26 2015 Koichi Sasada <ko1@atdot.net>
|
Thu Mar 19 04:52:26 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* gc.c (RGENGC_OLD_NEWOBJ_CHECK): add check mechanism.
|
* gc.c (RGENGC_OLD_NEWOBJ_CHECK): add check mechanism.
|
||||||
|
|
26
gc.c
26
gc.c
|
@ -1796,6 +1796,17 @@ rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
|
||||||
return newobj_of(v0, flags, v1, v2, v3);
|
return newobj_of(v0, flags, v1, v2, v3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IMEMO_DEBUG
|
||||||
|
VALUE
|
||||||
|
rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line)
|
||||||
|
{
|
||||||
|
VALUE flags = T_IMEMO | (type << FL_USHIFT) | FL_WB_PROTECTED;
|
||||||
|
VALUE memo = newobj_of(v0, flags, v1, v2, v3);
|
||||||
|
fprintf(stderr, "memo %p (type: %d) @ %s:%d\n", memo, imemo_type(memo), file, line);
|
||||||
|
return memo;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
|
rb_data_object_alloc(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree)
|
||||||
{
|
{
|
||||||
|
@ -8831,6 +8842,21 @@ obj_info(VALUE obj)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case T_IMEMO: {
|
||||||
|
const char *imemo_name;
|
||||||
|
switch (imemo_type(obj)) {
|
||||||
|
#define IMEMO_NAME(x) case imemo_##x: imemo_name = #x; break;
|
||||||
|
IMEMO_NAME(none);
|
||||||
|
IMEMO_NAME(cref);
|
||||||
|
IMEMO_NAME(svar);
|
||||||
|
IMEMO_NAME(throw_data);
|
||||||
|
IMEMO_NAME(ifunc);
|
||||||
|
IMEMO_NAME(memo);
|
||||||
|
default: rb_bug("unknown IMEMO");
|
||||||
|
#undef IMEMO_NAME
|
||||||
|
}
|
||||||
|
snprintf(buff, OBJ_INFO_BUFFERS_SIZE, "%s %s", buff, imemo_name);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
21
internal.h
21
internal.h
|
@ -515,11 +515,9 @@ RCLASS_SET_SUPER(VALUE klass, VALUE super)
|
||||||
}
|
}
|
||||||
/* IMEMO: Internal memo object */
|
/* IMEMO: Internal memo object */
|
||||||
|
|
||||||
/* FL_USER0, FL_USER1, FL_USER2: type */
|
#ifndef IMEMO_DEBUG
|
||||||
#define FL_IMEMO_MARK_V0 FL_USER6
|
#define IMEMO_DEBUG 0
|
||||||
#define FL_IMEMO_MARK_V1 FL_USER3
|
#endif
|
||||||
#define FL_IMEMO_MARK_V2 FL_USER4
|
|
||||||
#define FL_IMEMO_MARK_V3 FL_USER5
|
|
||||||
|
|
||||||
struct RIMemo {
|
struct RIMemo {
|
||||||
VALUE flags;
|
VALUE flags;
|
||||||
|
@ -587,7 +585,11 @@ struct vm_ifunc {
|
||||||
ID id;
|
ID id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if IMEMO_DEBUG
|
||||||
|
#define IFUNC_NEW(a, b) ((struct vm_ifunc *)rb_imemo_new_debug(imemo_ifunc, (VALUE)(a), (VALUE)(b), 0, 0, __FILE__, __LINE__))
|
||||||
|
#else
|
||||||
#define IFUNC_NEW(a, b) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), 0, 0))
|
#define IFUNC_NEW(a, b) ((struct vm_ifunc *)rb_imemo_new(imemo_ifunc, (VALUE)(a), (VALUE)(b), 0, 0))
|
||||||
|
#endif
|
||||||
|
|
||||||
/* MEMO */
|
/* MEMO */
|
||||||
|
|
||||||
|
@ -608,7 +610,12 @@ struct MEMO {
|
||||||
#define MEMO_V2_SET(m, v) RB_OBJ_WRITE((memo), &(memo)->v2, (v))
|
#define MEMO_V2_SET(m, v) RB_OBJ_WRITE((memo), &(memo)->v2, (v))
|
||||||
|
|
||||||
#define MEMO_CAST(m) ((struct MEMO *)m)
|
#define MEMO_CAST(m) ((struct MEMO *)m)
|
||||||
|
|
||||||
|
#if IMEMO_DEBUG
|
||||||
|
#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new_debug(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0, __FILE__, __LINE__))
|
||||||
|
#else
|
||||||
#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
|
#define MEMO_NEW(a, b, c) ((struct MEMO *)rb_imemo_new(imemo_memo, (VALUE)(a), (VALUE)(b), (VALUE)(c), 0))
|
||||||
|
#endif
|
||||||
|
|
||||||
#define type_roomof(x, y) ((sizeof(x) + sizeof(y) - 1) / sizeof(y))
|
#define type_roomof(x, y) ((sizeof(x) + sizeof(y) - 1) / sizeof(y))
|
||||||
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
|
#define MEMO_FOR(type, value) ((type *)RARRAY_PTR(value))
|
||||||
|
@ -1288,6 +1295,10 @@ size_t rb_obj_memsize_of(VALUE);
|
||||||
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
|
||||||
void rb_gc_mark_values(long n, const VALUE *values);
|
void rb_gc_mark_values(long n, const VALUE *values);
|
||||||
|
|
||||||
|
#if IMEMO_DEBUG
|
||||||
|
VALUE rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0, const char *file, int line);
|
||||||
|
#endif
|
||||||
|
|
||||||
VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
|
VALUE rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0);
|
||||||
|
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
Loading…
Add table
Reference in a new issue