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

ruby-changes:45753

From: nobu <ko1@a...>
Date: Fri, 10 Mar 2017 16:18:08 +0900 (JST)
Subject: [ruby-changes:45753] nobu:r57826 (trunk): debug_counter.c: debug_counter_names [ci skip]

nobu	2017-03-10 16:18:03 +0900 (Fri, 10 Mar 2017)

  New Revision: 57826

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

  Log:
    debug_counter.c: debug_counter_names [ci skip]
    
    * debug_counter.c (debug_counter_names): stringize debug counter
      names by preprocessor.
    
    * debug_counter.h (RB_DEBUG_COUNTER): define counter names outside
      the include guard, to expand multiple times.

  Removed files:
    trunk/tool/debug_counter.rb
  Modified files:
    trunk/common.mk
    trunk/debug_counter.c
    trunk/debug_counter.h
Index: common.mk
===================================================================
--- common.mk	(revision 57825)
+++ common.mk	(revision 57826)
@@ -886,15 +886,10 @@ incs: $(INSNS) {$(VPATH)}node_name.inc { https://github.com/ruby/ruby/blob/trunk/common.mk#L886
       {$(VPATH)}vm_call_iseq_optimized.inc $(srcdir)/revision.h \
       $(REVISION_H) \
       $(UNICODE_DATA_HEADERS) $(srcdir)/enc/jis/props.h \
-      {$(VPATH)}id.h {$(VPATH)}probes.dmyh \
-      {$(VPATH)}debug_counter_names.inc
+      {$(VPATH)}id.h {$(VPATH)}probes.dmyh
 
 insns: $(INSNS)
 
-debug_counter_names.inc: $(srcdir)/tool/debug_counter.rb $(srcdir)/debug_counter.h
-	$(ECHO) generating $@
-	$(Q) $(BASERUBY) $(srcdir)/tool/debug_counter.rb $(srcdir)/debug_counter.h > $@
-
 id.h: $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.h.tmpl $(srcdir)/defs/id.def
 	$(ECHO) generating $@
 	$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb --output=$@ \
@@ -1466,7 +1461,6 @@ debug.$(OBJEXT): {$(VPATH)}vm_core.h https://github.com/ruby/ruby/blob/trunk/common.mk#L1461
 debug.$(OBJEXT): {$(VPATH)}vm_debug.h
 debug.$(OBJEXT): {$(VPATH)}vm_opts.h
 debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.h
-debug_counter.$(OBJEXT): {$(VPATH)}debug_counter_names.inc
 debug_counter.$(OBJEXT): {$(VPATH)}debug_counter.c
 dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h
 dir.$(OBJEXT): $(top_srcdir)/include/ruby.h
Index: tool/debug_counter.rb
===================================================================
--- tool/debug_counter.rb	(revision 57825)
+++ tool/debug_counter.rb	(revision 57826)
@@ -1,6 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/tool/debug_counter.rb#L0
-
-ARGF.each_line{|line|
-  if /^\s+COUNTER\((.+)\),$/ =~ line
-    puts "\"#{$1}\","
-  end
-}
Index: debug_counter.c
===================================================================
--- debug_counter.c	(revision 57825)
+++ debug_counter.c	(revision 57826)
@@ -12,14 +12,16 @@ https://github.com/ruby/ruby/blob/trunk/debug_counter.c#L12
 #include <stdio.h>
 
 #if USE_DEBUG_COUNTER
+#include "internal.h"
 
-/* do not modify manually. use a script above */
-const char * const debug_counter_names[] = {
-#include "debug_counter_names.inc"
+static const char *const debug_counter_names[] = {
     ""
+#define RB_DEBUG_COUNTER(name) #name,
+#include "debug_counter.h"
+#undef RB_DEBUG_COUNTER
 };
 
-size_t rb_debug_counter[RB_DEBUG_COUNTER_MAX + 1];
+size_t rb_debug_counter[numberof(debug_counter_names)];
 
 __attribute__((destructor))
 static void
Index: debug_counter.h
===================================================================
--- debug_counter.h	(revision 57825)
+++ debug_counter.h	(revision 57826)
@@ -8,42 +8,46 @@ https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L8
 
 **********************************************************************/
 
-#ifndef RUBY_DEBUG_COUNTER_H
-#define RUBY_DEBUG_COUNTER_H 1
-
 #ifndef USE_DEBUG_COUNTER
 #define USE_DEBUG_COUNTER 0
 #endif
 
+#ifdef RB_DEBUG_COUNTER
+RB_DEBUG_COUNTER(mc_inline_hit)
+RB_DEBUG_COUNTER(mc_inline_miss)
+RB_DEBUG_COUNTER(mc_global_hit)
+RB_DEBUG_COUNTER(mc_global_miss)
+RB_DEBUG_COUNTER(mc_global_state_miss)
+RB_DEBUG_COUNTER(mc_class_serial_miss)
+RB_DEBUG_COUNTER(mc_cme_complement)
+RB_DEBUG_COUNTER(mc_cme_complement_hit)
+RB_DEBUG_COUNTER(mc_search_super)
+RB_DEBUG_COUNTER(ivar_get_hit)
+RB_DEBUG_COUNTER(ivar_get_miss)
+RB_DEBUG_COUNTER(ivar_set_hit)
+RB_DEBUG_COUNTER(ivar_set_miss)
+RB_DEBUG_COUNTER(ivar_get)
+RB_DEBUG_COUNTER(ivar_set)
+#endif
+
+#ifndef RUBY_DEBUG_COUNTER_H
+#define RUBY_DEBUG_COUNTER_H 1
+
 #if !defined(__GNUC__) && USE_DEBUG_COUNTER
 #error "USE_DEBUG_COUNTER is not supported by other than __GNUC__"
 #endif
 
 enum rb_debug_counter_type {
-#define COUNTER(name) RB_DEBUG_COUNTER_##name
-    COUNTER(mc_inline_hit),
-    COUNTER(mc_inline_miss),
-    COUNTER(mc_global_hit),
-    COUNTER(mc_global_miss),
-    COUNTER(mc_global_state_miss),
-    COUNTER(mc_class_serial_miss),
-    COUNTER(mc_cme_complement),
-    COUNTER(mc_cme_complement_hit),
-    COUNTER(mc_search_super),
-    COUNTER(ivar_get_hit),
-    COUNTER(ivar_get_miss),
-    COUNTER(ivar_set_hit),
-    COUNTER(ivar_set_miss),
-    COUNTER(ivar_get),
-    COUNTER(ivar_set),
+#define RB_DEBUG_COUNTER(name) RB_DEBUG_COUNTER_##name,
+#include "debug_counter.h"
     RB_DEBUG_COUNTER_MAX
-#undef COUNTER
+#undef RB_DEBUG_COUNTER
 };
 
 #if USE_DEBUG_COUNTER
 #include "ruby/ruby.h"
 
-extern size_t rb_debug_counter[RB_DEBUG_COUNTER_MAX + 1];
+extern size_t rb_debug_counter[];
 
 inline static int
 rb_debug_counter_add(enum rb_debug_counter_type type, int add, int cond)

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

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