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

ruby-changes:30814

From: nobu <ko1@a...>
Date: Mon, 9 Sep 2013 14:17:34 +0900 (JST)
Subject: [ruby-changes:30814] nobu:r42894 (trunk): vm_insnhelper.c: debugging

nobu	2013-09-09 14:17:19 +0900 (Mon, 09 Sep 2013)

  New Revision: 42894

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

  Log:
    vm_insnhelper.c: debugging
    
    * vm_insnhelper.c (vm_method_cfunc_entry): check method type if
      debugging.

  Modified files:
    trunk/vm_insnhelper.c
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 42893)
+++ vm_insnhelper.c	(revision 42894)
@@ -1478,12 +1478,39 @@ vm_profile_show_result(void) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1478
 #define VM_PROFILE_ATEXIT()
 #endif
 
+static inline
+const rb_method_cfunc_t *
+vm_method_cfunc_entry(const rb_method_entry_t *me)
+{
+#if VM_DEBUG_VERIFY_METHOD_CACHE
+    switch (me->def->type) {
+      case VM_METHOD_TYPE_CFUNC:
+      case VM_METHOD_TYPE_NOTIMPLEMENTED:
+	break;
+# define METHOD_BUG(t) case VM_METHOD_TYPE_##t: rb_bug("wrong method type: " #t)
+	METHOD_BUG(ISEQ);
+	METHOD_BUG(ATTRSET);
+	METHOD_BUG(IVAR);
+	METHOD_BUG(BMETHOD);
+	METHOD_BUG(ZSUPER);
+	METHOD_BUG(UNDEF);
+	METHOD_BUG(OPTIMIZED);
+	METHOD_BUG(MISSING);
+	METHOD_BUG(REFINED);
+# undef METHOD_BUG
+      default:
+	rb_bug("wrong method type: %d", me->def->type);
+    }
+#endif
+    return &me->def->body.cfunc;
+}
+
 static VALUE
 vm_call_cfunc_with_frame(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci)
 {
     VALUE val;
     const rb_method_entry_t *me = ci->me;
-    const rb_method_cfunc_t *cfunc = &me->def->body.cfunc;
+    const rb_method_cfunc_t *cfunc = vm_method_cfunc_entry(me);
     int len = cfunc->argc;
 
     /* don't use `ci' after EXEC_EVENT_HOOK because ci can be override */
@@ -1523,7 +1550,7 @@ vm_call_cfunc_latter(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1550
     VALUE val;
     int argc = ci->argc;
     VALUE *argv = STACK_ADDR_FROM_TOP(argc);
-    const rb_method_cfunc_t *cfunc = &ci->me->def->body.cfunc;
+    const rb_method_cfunc_t *cfunc = vm_method_cfunc_entry(ci->me);
 
     th->passed_ci = ci;
     reg_cfp->sp -= argc + 1;
@@ -1554,7 +1581,7 @@ vm_call_cfunc(rb_thread_t *th, rb_contro https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1581
 {
     VALUE val;
     const rb_method_entry_t *me = ci->me;
-    int len = me->def->body.cfunc.argc;
+    int len = vm_method_cfunc_entry(me)->argc;
     VALUE recv = ci->recv;
 
     if (len >= 0) rb_check_arity(ci->argc, len, len);

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

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