summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--vm.c2
-rw-r--r--vm_core.h16
-rw-r--r--vm_insnhelper.c8
4 files changed, 26 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 1e9021e..dafe221 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu Jun 11 08:16:48 2015 Koichi Sasada <ko1@atdot.net>
+
+ * 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@atdot.net>
* vm_insnhelper.c (check_frame): check type of cref_or_me first.
diff --git a/vm.c b/vm.c
index b302674..80e3f05 100644
--- a/vm.c
+++ b/vm.c
@@ -146,8 +146,6 @@ static rb_serial_t ruby_vm_class_serial = 1;
#include "vm_method.c"
#include "vm_eval.c"
-#include <assert.h>
-
#define PROCDEBUG 0
rb_serial_t
diff --git a/vm_core.h b/vm_core.h
index c18611e..e1e3fb1 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -12,6 +12,22 @@
#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"
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 8b28471..926f342 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -16,14 +16,6 @@
#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