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

ruby-changes:40262

From: nobu <ko1@a...>
Date: Thu, 29 Oct 2015 15:03:32 +0900 (JST)
Subject: [ruby-changes:40262] nobu:r52343 (trunk): vm_insnhelper.c: use enum and fix typo

nobu	2015-10-29 15:03:17 +0900 (Thu, 29 Oct 2015)

  New Revision: 52343

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

  Log:
    vm_insnhelper.c: use enum and fix typo
    
    * vm_insnhelper.c (VM_PROFILE_UP): use enum.
    
    * vm_insnhelper.c (vm_profile_show_result): fix typo, "r->c" at
      the last should be "c->c".

  Modified files:
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 52342)
+++ vm_eval.c	(revision 52343)
@@ -81,7 +81,7 @@ vm_call0_cfunc(rb_thread_t* th, struct r https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L81
 
 	th->passed_ci = ci;
 	cc->aux.inc_sp = 0;
-	VM_PROFILE_UP(2);
+	VM_PROFILE_UP(C2C_CALL);
 	val = (*cfunc->invoker)(cfunc->func, recv, argc, argv);
 
 	if (reg_cfp == th->cfp) {
@@ -94,7 +94,7 @@ vm_call0_cfunc(rb_thread_t* th, struct r https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L94
 	    if (reg_cfp != th->cfp + 1) {
 		rb_bug("vm_call0_cfunc: cfp consistency error");
 	    }
-	    VM_PROFILE_UP(3);
+	    VM_PROFILE_UP(C2C_POPF);
 	    vm_pop_frame(th);
 	}
     }
@@ -127,13 +127,13 @@ vm_call0_cfunc_with_frame(rb_thread_t* t https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L127
 
 	if (len >= 0) rb_check_arity(argc, len, len);
 
-	VM_PROFILE_UP(2);
+	VM_PROFILE_UP(C2C_CALL);
 	val = (*cfunc->invoker)(cfunc->func, recv, argc, argv);
 
 	if (UNLIKELY(reg_cfp != th->cfp + 1)) {
 		rb_bug("vm_call0_cfunc_with_frame: cfp consistency error");
 	}
-	VM_PROFILE_UP(3);
+	VM_PROFILE_UP(C2C_POPF);
 	vm_pop_frame(th);
     }
     EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, mid, me->owner, val);
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 52342)
+++ vm_insnhelper.c	(revision 52343)
@@ -1568,17 +1568,24 @@ call_cfunc_15(VALUE (*func)(ANYARGS), VA https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1568
 #endif
 
 #if VM_PROFILE
-static int vm_profile_counter[4];
-#define VM_PROFILE_UP(x) (vm_profile_counter[x]++)
+enum {
+    VM_PROFILE_R2C_CALL,
+    VM_PROFILE_R2C_POPF,
+    VM_PROFILE_C2C_CALL,
+    VM_PROFILE_C2C_POPF,
+    VM_PROFILE_COUNT
+};
+static int vm_profile_counter[VM_PROFILE_COUNT];
+#define VM_PROFILE_UP(x) (vm_profile_counter[VM_PROFILE_##x]++)
 #define VM_PROFILE_ATEXIT() atexit(vm_profile_show_result)
 static void
 vm_profile_show_result(void)
 {
     fprintf(stderr, "VM Profile results: \n");
-    fprintf(stderr, "r->c call: %d\n", vm_profile_counter[0]);
-    fprintf(stderr, "r->c popf: %d\n", vm_profile_counter[1]);
-    fprintf(stderr, "c->c call: %d\n", vm_profile_counter[2]);
-    fprintf(stderr, "r->c popf: %d\n", vm_profile_counter[3]);
+    fprintf(stderr, "r->c call: %d\n", vm_profile_counter[VM_PROFILE_R2C_CALL]);
+    fprintf(stderr, "r->c popf: %d\n", vm_profile_counter[VM_PROFILE_R2C_POPF]);
+    fprintf(stderr, "c->c call: %d\n", vm_profile_counter[VM_PROFILE_C2C_CALL]);
+    fprintf(stderr, "c->c popf: %d\n", vm_profile_counter[VM_PROFILE_C2C_POPF]);
 }
 #else
 #define VM_PROFILE_UP(x)
@@ -1635,7 +1642,7 @@ vm_call_cfunc_with_frame(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1642
     if (len >= 0) rb_check_arity(argc, len, len);
 
     reg_cfp->sp -= argc + 1;
-    VM_PROFILE_UP(0);
+    VM_PROFILE_UP(R2C_CALL);
     val = (*cfunc->invoker)(cfunc->func, recv, argc, reg_cfp->sp + 1);
 
     if (reg_cfp != th->cfp + 1) {
@@ -1663,7 +1670,7 @@ vm_call_cfunc_latter(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1670
     th->passed_calling = calling;
     reg_cfp->sp -= argc + 1;
     ci->aux.inc_sp = argc + 1;
-    VM_PROFILE_UP(0);
+    VM_PROFILE_UP(R2C_CALL);
     val = (*cfunc->invoker)(cfunc->func, recv, argc, argv);
 
     /* check */
@@ -1678,7 +1685,7 @@ vm_call_cfunc_latter(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1685
 	    rb_bug("vm_call_cfunc_latter: cfp consistency error (%p, %p)", reg_cfp, th->cfp+1);
 	}
 	vm_pop_frame(th);
-	VM_PROFILE_UP(1);
+	VM_PROFILE_UP(R2C_POPF);
     }
 
     return val;

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

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