Permalink
Browse files

Add a "check every register access" GC debug mode.

Costly, but may help track down more issues.
  • Loading branch information...
1 parent 4d939e8 commit 8dd2f63e1921134d8d7a2174cc910d6e2e62f411 @jnthn jnthn committed Dec 7, 2016
Showing with 18 additions and 1 deletion.
  1. +13 −0 src/core/interp.c
  2. +5 −1 src/gc/debug.h
View
@@ -3,7 +3,20 @@
#include "platform/time.h"
/* Macros for getting things from the bytecode stream. */
+#if MVM_GC_DEBUG == 2
+MVM_STATIC_INLINE MVMuint16 check_reg(MVMThreadContext *tc, MVMRegister *reg_base, MVMuint16 idx) {
+ MVMFrame *f = tc->cur_frame;
+ MVMuint16 kind = f->spesh_cand && f->spesh_cand->local_types
+ ? f->spesh_cand->local_types[idx]
+ : f->static_info->body.local_types[idx];
+ if (kind == MVM_reg_obj || kind == MVM_reg_str)
+ MVM_ASSERT_NOT_FROMSPACE(tc, reg_base[idx].o);
+ return idx;
+}
+#define GET_REG(pc, idx) reg_base[check_reg(tc, reg_base, *((MVMuint16 *)(pc + idx)))]
+#else
#define GET_REG(pc, idx) reg_base[*((MVMuint16 *)(pc + idx))]
+#endif
#define GET_LEX(pc, idx, f) f->env[*((MVMuint16 *)(pc + idx))]
#define GET_I16(pc, idx) *((MVMint16 *)(pc + idx))
#define GET_UI16(pc, idx) *((MVMuint16 *)(pc + idx))
View
@@ -1,4 +1,8 @@
-/* Turn this flag on to enable various bits of GC debugging sanity checks. */
+/* This flag enables/disables various bits of GC debugging sanity checks:
+ * 0 = No checking
+ * 1 = Checks on reference assignments and other relatively cheap cases
+ * 2 = Checks on every object register access (slow)
+ */
#define MVM_GC_DEBUG 0
#define MVM_ASSERT_NOT_FROMSPACE(tc, c) do { \

0 comments on commit 8dd2f63

Please sign in to comment.