[前][次][番号順一覧][スレッド一覧]

ruby-changes:37933

From: ko1 <ko1@a...>
Date: Thu, 19 Mar 2015 04:58:03 +0900 (JST)
Subject: [ruby-changes:37933] ko1:r50014 (trunk): * internal.h (IMEMO_DEBUG): added.

ko1	2015-03-19 04:57:53 +0900 (Thu, 19 Mar 2015)

  New Revision: 50014

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50014

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
    trunk/internal.h
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50013)
+++ ChangeLog	(revision 50014)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Mar 19 04:55:53 2015  Koichi Sasada  <ko1@a...>
+
+	* 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@a...>
 
 	* gc.c (RGENGC_OLD_NEWOBJ_CHECK): add check mechanism.
Index: gc.c
===================================================================
--- gc.c	(revision 50013)
+++ gc.c	(revision 50014)
@@ -1796,6 +1796,17 @@ rb_imemo_new(enum imemo_type type, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L1796
     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) https://github.com/ruby/ruby/blob/trunk/gc.c#L8842
 	  }
 	  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;
     }
Index: internal.h
===================================================================
--- internal.h	(revision 50013)
+++ internal.h	(revision 50014)
@@ -515,11 +515,9 @@ RCLASS_SET_SUPER(VALUE klass, VALUE supe https://github.com/ruby/ruby/blob/trunk/internal.h#L515
 }
 /* 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 { https://github.com/ruby/ruby/blob/trunk/internal.h#L585
     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 { https://github.com/ruby/ruby/blob/trunk/internal.h#L610
 #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); https://github.com/ruby/ruby/blob/trunk/internal.h#L1295
 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]