summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-18 19:57:53 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-18 19:57:53 +0000
commit05704f51fb2d3e183535fa52fd43ac0b7227cdb7 (patch)
tree09e291c644eab9ffaa7e743176fcc4bd6ff0381e
parent33aaa89a79b4969655b1c4ee1ba52f6b22d17a4a (diff)
* 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
-rw-r--r--ChangeLog10
-rw-r--r--gc.c26
-rw-r--r--internal.h21
3 files changed, 52 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8639253..d99346f 100644
--- a/ChangeLog
+++ b/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>
* gc.c (RGENGC_OLD_NEWOBJ_CHECK): add check mechanism.
diff --git a/gc.c b/gc.c
index c0fd8f5..dd5a4bd 100644
--- a/gc.c
+++ b/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);
}
+#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
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;
}
+ 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:
break;
}
diff --git a/internal.h b/internal.h
index e6335c0..f8b54c0 100644
--- a/internal.h
+++ b/internal.h
@@ -515,11 +515,9 @@ RCLASS_SET_SUPER(VALUE klass, VALUE super)
}
/* IMEMO: Internal memo object */
-/* FL_USER0, FL_USER1, FL_USER2: type */
-#define FL_IMEMO_MARK_V0 FL_USER6
-#define FL_IMEMO_MARK_V1 FL_USER3
-#define FL_IMEMO_MARK_V2 FL_USER4
-#define FL_IMEMO_MARK_V3 FL_USER5
+#ifndef IMEMO_DEBUG
+#define IMEMO_DEBUG 0
+#endif
struct RIMemo {
VALUE flags;
@@ -587,7 +585,11 @@ struct vm_ifunc {
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))
+#endif
/* MEMO */
@@ -608,7 +610,12 @@ struct MEMO {
#define MEMO_V2_SET(m, v) RB_OBJ_WRITE((memo), &(memo)->v2, (v))
#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))
+#endif
#define type_roomof(x, y) ((sizeof(x) + sizeof(y) - 1) / sizeof(y))
#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);
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);
RUBY_SYMBOL_EXPORT_END