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

ruby-changes:38740

From: ko1 <ko1@a...>
Date: Thu, 11 Jun 2015 08:25:40 +0900 (JST)
Subject: [ruby-changes:38740] ko1:r50821 (trunk): * vm_core.h: define VM_ASSERT() for assertion

ko1	2015-06-11 08:25:30 +0900 (Thu, 11 Jun 2015)

  New Revision: 50821

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

  Log:
    * vm_core.h: define VM_ASSERT() for assertion
      enabled only when (VM_CHECK_MODE > 0).
    * vm_insnhelper.c: move definition VM_CHECK_MODE
      from vm_insnhelper.c to vm_core.h.
    * vm.c: remove <assert.h>

  Modified files:
    trunk/ChangeLog
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50820)
+++ ChangeLog	(revision 50821)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 11 08:16:48 2015  Koichi Sasada  <ko1@a...>
+
+	* vm_core.h: define VM_ASSERT() for assertion
+	  enabled only when (VM_CHECK_MODE > 0).
+
+	* vm_insnhelper.c: move definition VM_CHECK_MODE
+	  from vm_insnhelper.c to vm_core.h.
+
+	* vm.c: remove <assert.h>
+
 Thu Jun 11 06:46:07 2015  Koichi Sasada  <ko1@a...>
 
 	* vm_insnhelper.c (check_frame): check type of cref_or_me first.
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 50820)
+++ vm_core.h	(revision 50821)
@@ -12,6 +12,22 @@ https://github.com/ruby/ruby/blob/trunk/vm_core.h#L12
 #ifndef RUBY_VM_CORE_H
 #define RUBY_VM_CORE_H
 
+/*
+ * Enable check mode.
+ *   1: enable local assertions.
+ */
+#ifndef VM_CHECK_MODE
+#define VM_CHECK_MODE 0
+#endif
+
+#if VM_CHECK_MODE > 0
+#define VM_ASSERT(expr) do { \
+    if(!(expr)) rb_bug("%s:%d assertion violation - %s", __FILE__, __LINE__, #expr); \
+} while (0)
+#else
+#define VM_ASSERT(expr)
+#endif
+
 #define RUBY_VM_THREAD_MODEL 2
 
 #include "ruby/ruby.h"
Index: vm.c
===================================================================
--- vm.c	(revision 50820)
+++ vm.c	(revision 50821)
@@ -146,8 +146,6 @@ static rb_serial_t ruby_vm_class_serial https://github.com/ruby/ruby/blob/trunk/vm.c#L146
 #include "vm_method.c"
 #include "vm_eval.c"
 
-#include <assert.h>
-
 #define PROCDEBUG 0
 
 rb_serial_t
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 50820)
+++ vm_insnhelper.c	(revision 50821)
@@ -16,14 +16,6 @@ https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L16
 #include "probes.h"
 #include "probes_helper.h"
 
-/*
- * Enable check mode.
- *   1: enable local assertions.
- */
-#ifndef VM_CHECK_MODE
-#define VM_CHECK_MODE 0
-#endif
-
 /* control stack frame */
 
 #ifndef INLINE

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

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