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

ruby-changes:46198

From: nobu <ko1@a...>
Date: Tue, 11 Apr 2017 13:17:49 +0900 (JST)
Subject: [ruby-changes:46198] nobu:r58313 (trunk): vm_insnhelper.c: CHECK_CFP_CONSISTENCY

nobu	2017-04-11 13:17:45 +0900 (Tue, 11 Apr 2017)

  New Revision: 58313

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

  Log:
    vm_insnhelper.c: CHECK_CFP_CONSISTENCY
    
    * vm_insnhelper.c (CHECK_CFP_CONSISTENCY): make [BUG] messages
      consistent.

  Modified files:
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 58312)
+++ vm_eval.c	(revision 58313)
@@ -92,9 +92,7 @@ vm_call0_cfunc(rb_thread_t* th, struct r https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L92
 	    th->passed_ci = 0;
 	}
 	else {
-	    if (reg_cfp != th->cfp + 1) {
-		rb_bug("vm_call0_cfunc: cfp consistency error");
-	    }
+	    CHECK_CFP_CONSISTENCY("vm_call0_cfunc");
 	    VM_PROFILE_UP(C2C_POPF);
 	    rb_vm_pop_frame(th);
 	}
@@ -131,9 +129,7 @@ vm_call0_cfunc_with_frame(rb_thread_t* t https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L129
 	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");
-	}
+	CHECK_CFP_CONSISTENCY("vm_call0_cfunc_with_frame");
 	VM_PROFILE_UP(C2C_POPF);
 	rb_vm_pop_frame(th);
     }
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 58312)
+++ vm_insnhelper.c	(revision 58313)
@@ -1715,6 +1715,10 @@ vm_profile_show_result(void) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1715
 #define VM_PROFILE_ATEXIT()
 #endif
 
+#define CHECK_CFP_CONSISTENCY(func) \
+    LIKELY(reg_cfp == th->cfp + 1) ? (void) 0 : \
+    rb_bug(func ": cfp consistency error (%p, %p)", reg_cfp, th->cfp+1)
+
 static inline
 const rb_method_cfunc_t *
 vm_method_cfunc_entry(const rb_callable_method_entry_t *me)
@@ -1768,9 +1772,7 @@ vm_call_cfunc_with_frame(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1772
     VM_PROFILE_UP(R2C_CALL);
     val = (*cfunc->invoker)(cfunc->func, recv, argc, reg_cfp->sp + 1);
 
-    if (reg_cfp != th->cfp + 1) {
-	rb_bug("vm_call_cfunc - cfp consistency error");
-    }
+    CHECK_CFP_CONSISTENCY("vm_call_cfunc");
 
     rb_vm_pop_frame(th);
 
@@ -1804,9 +1806,7 @@ vm_call_cfunc_latter(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1806
 	th->passed_ci = 0;
     }
     else {
-	if (UNLIKELY(reg_cfp != RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp))) {
-	    rb_bug("vm_call_cfunc_latter: cfp consistency error (%p, %p)", reg_cfp, th->cfp+1);
-	}
+	CHECK_CFP_CONSISTENCY("vm_call_cfunc_latter");
 	vm_pop_frame(th, reg_cfp, reg_cfp->ep);
 	VM_PROFILE_UP(R2C_POPF);
     }

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

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