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

ruby-changes:40556

From: ko1 <ko1@a...>
Date: Wed, 18 Nov 2015 17:08:18 +0900 (JST)
Subject: [ruby-changes:40556] ko1:r52635 (trunk): * gc.c (rb_raw_obj_info): fix trivial issues.

ko1	2015-11-18 17:08:09 +0900 (Wed, 18 Nov 2015)

  New Revision: 52635

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

  Log:
    * gc.c (rb_raw_obj_info): fix trivial issues.
    
      * support SPECIAL_CONSTs.
      * fix IMEMO/ment outputs.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52634)
+++ ChangeLog	(revision 52635)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 18 17:06:19 2015  Koichi Sasada  <ko1@a...>
+
+	* gc.c (rb_raw_obj_info): fix trivial issues.
+
+	  * support SPECIAL_CONSTs.
+	  * fix IMEMO/ment outputs.
+
 Wed Nov 18 11:32:15 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* compile.c (iseq_peephole_optimize): eliminate always/never
Index: gc.c
===================================================================
--- gc.c	(revision 52634)
+++ gc.c	(revision 52635)
@@ -8961,110 +8961,118 @@ method_type_name(rb_method_type_t type) https://github.com/ruby/ruby/blob/trunk/gc.c#L8961
 const char *
 rb_raw_obj_info(char *buff, const int buff_size, VALUE obj)
 {
-    const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
-    const int type = BUILTIN_TYPE(obj);
+    if (SPECIAL_CONST_P(obj)) {
+	snprintf(buff, buff_size, "%s", obj_type_name(obj));
+    }
+    else {
+	const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
+	const int type = TYPE(obj);
 
 #define TF(c) ((c) != 0 ? "true" : "false")
 #define C(c, s) ((c) != 0 ? (s) : " ")
-    snprintf(buff, buff_size, "%p [%d%s%s%s%s] %s",
-	     (void *)obj, age,
-	     C(RVALUE_UNCOLLECTIBLE_BITMAP(obj),  "L"),
-	     C(RVALUE_MARK_BITMAP(obj),           "M"),
-	     C(RVALUE_MARKING_BITMAP(obj),        "R"),
-	     C(RVALUE_WB_UNPROTECTED_BITMAP(obj), "U"),
-	     obj_type_name(obj));
+	snprintf(buff, buff_size, "%p [%d%s%s%s%s] %s",
+		 (void *)obj, age,
+		 C(RVALUE_UNCOLLECTIBLE_BITMAP(obj),  "L"),
+		 C(RVALUE_MARK_BITMAP(obj),           "M"),
+		 C(RVALUE_MARKING_BITMAP(obj),        "R"),
+		 C(RVALUE_WB_UNPROTECTED_BITMAP(obj), "U"),
+		 obj_type_name(obj));
 
-    if (internal_object_p(obj)) {
-	/* ignore */
-    }
-    else if (RBASIC(obj)->klass == 0) {
-	snprintf(buff, buff_size, "%s (temporary internal)", buff);
-    }
-    else {
-	VALUE class_path = rb_class_path_cached(RBASIC(obj)->klass);
-	if (!NIL_P(class_path)) {
-	    snprintf(buff, buff_size, "%s (%s)", buff, RSTRING_PTR(class_path));
+	if (internal_object_p(obj)) {
+	    /* ignore */
+	}
+	else if (RBASIC(obj)->klass == 0) {
+	    snprintf(buff, buff_size, "%s (temporary internal)", buff);
+	}
+	else {
+	    VALUE class_path = rb_class_path_cached(RBASIC(obj)->klass);
+	    if (!NIL_P(class_path)) {
+		snprintf(buff, buff_size, "%s (%s)", buff, RSTRING_PTR(class_path));
+	    }
 	}
-    }
 
 #if GC_DEBUG
-    snprintf(buff, buff_size, "%s @%s:%d", buff, RANY(obj)->file, RANY(obj)->line);
+	snprintf(buff, buff_size, "%s @%s:%d", buff, RANY(obj)->file, RANY(obj)->line);
 #endif
 
-    switch (type) {
-      case T_NODE:
-	snprintf(buff, buff_size, "%s (%s)", buff,
-		 ruby_node_name(nd_type(obj)));
-	break;
-      case T_ARRAY:
-	snprintf(buff, buff_size, "%s [%s%s] len: %d", buff,
-		 C(ARY_EMBED_P(obj),  "E"),
-		 C(ARY_SHARED_P(obj), "S"),
-		 (int)RARRAY_LEN(obj));
-	break;
-      case T_STRING: {
-	  snprintf(buff, buff_size, "%s %s", buff, RSTRING_PTR(obj));
-	  break;
-      }
-      case T_CLASS: {
-	  VALUE class_path = rb_class_path_cached(obj);
-	  if (!NIL_P(class_path)) {
-	      snprintf(buff, buff_size, "%s %s", buff, RSTRING_PTR(class_path));
+	switch (type) {
+	  case T_NODE:
+	    snprintf(buff, buff_size, "%s (%s)", buff,
+		     ruby_node_name(nd_type(obj)));
+	    break;
+	  case T_ARRAY:
+	    snprintf(buff, buff_size, "%s [%s%s] len: %d", buff,
+		     C(ARY_EMBED_P(obj),  "E"),
+		     C(ARY_SHARED_P(obj), "S"),
+		     (int)RARRAY_LEN(obj));
+	    break;
+	  case T_STRING: {
+	      snprintf(buff, buff_size, "%s %s", buff, RSTRING_PTR(obj));
+	      break;
+	  }
+	  case T_CLASS: {
+	      VALUE class_path = rb_class_path_cached(obj);
+	      if (!NIL_P(class_path)) {
+		  snprintf(buff, buff_size, "%s %s", buff, RSTRING_PTR(class_path));
+	      }
+	      break;
 	  }
-	  break;
-      }
-      case T_DATA: {
-	  const char * const type_name = rb_objspace_data_type_name(obj);
-	  if (type_name) {
-	      snprintf(buff, buff_size, "%s %s", buff, type_name);
+	  case T_DATA: {
+	      const char * const type_name = rb_objspace_data_type_name(obj);
+	      if (type_name) {
+		  snprintf(buff, buff_size, "%s %s", buff, type_name);
+	      }
+	      break;
 	  }
-	  break;
-      }
-      case T_IMEMO: {
-	  const char *imemo_name;
-	  switch (imemo_type(obj)) {
+	  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);
-	      IMEMO_NAME(ment);
-	      IMEMO_NAME(iseq);
-	    default: rb_bug("unknown IMEMO");
+		  IMEMO_NAME(none);
+		  IMEMO_NAME(cref);
+		  IMEMO_NAME(svar);
+		  IMEMO_NAME(throw_data);
+		  IMEMO_NAME(ifunc);
+		  IMEMO_NAME(memo);
+		  IMEMO_NAME(ment);
+		  IMEMO_NAME(iseq);
+		default: rb_bug("unknown IMEMO");
 #undef IMEMO_NAME
-	  }
-	  snprintf(buff, buff_size, "%s %s", buff, imemo_name);
+	      }
+	      snprintf(buff, buff_size, "%s %s", buff, imemo_name);
 
-	  switch (imemo_type(obj)) {
-	    case imemo_ment: {
-		const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment;
-		snprintf(buff, buff_size, "%s (called_id: %s, type: %s, alias: %d, class: %s)", buff,
-			 rb_id2name(me->called_id), method_type_name(me->def->type), me->def->alias_count, obj_info(me->defined_class));
-		break;
-	    }
-	    case imemo_iseq: {
-		const rb_iseq_t *iseq = (const rb_iseq_t *)obj;
+	      switch (imemo_type(obj)) {
+		case imemo_ment: {
+		    const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment;
+		    snprintf(buff, buff_size, "%s (called_id: %s, type: %s, alias: %d, owner: %s, defined_class: %s)", buff,
+			     rb_id2name(me->called_id),
+			     method_type_name(me->def->type),
+			     me->def->alias_count,
+			     obj_info(me->owner),
+			     obj_info(me->defined_class));
+		    break;
+		}
+		case imemo_iseq: {
+		    const rb_iseq_t *iseq = (const rb_iseq_t *)obj;
 
-		if (iseq->body->location.label) {
-		    snprintf(buff, buff_size, "%s %s@%s:%d", buff,
-			     RSTRING_PTR(iseq->body->location.label),
-			     RSTRING_PTR(iseq->body->location.path),
-			     FIX2INT(iseq->body->location.first_lineno));
+		    if (iseq->body->location.label) {
+			snprintf(buff, buff_size, "%s %s@%s:%d", buff,
+				 RSTRING_PTR(iseq->body->location.label),
+				 RSTRING_PTR(iseq->body->location.path),
+				 FIX2INT(iseq->body->location.first_lineno));
+		    }
+		    break;
 		}
-		break;
-	    }
-	    default:
-	      break;
+		default:
+		  break;
+	      }
 	  }
-      }
-      default:
-	break;
-    }
+	  default:
+	    break;
+	}
 #undef TF
 #undef C
-
+    }
     return buff;
 }
 

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

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