diff --git a/C/amasm.c b/C/amasm.c index 668bfe1ba..bef13fc86 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -2099,7 +2099,7 @@ do_pass(void) /* index code */ if (log_update) { if (pass_no) { - cl_u->lui.ClFlags = LogUpdMask|IndexedPredFlag|IndexMask; + cl_u->lui.ClFlags = LogUpdMask|IndexedPredFlag|IndexMask|SwitchRootMask; cl_u->lui.ChildIndex = NULL; cl_u->lui.SiblingIndex = NULL; cl_u->lui.u.pred = CurrentPred; diff --git a/C/cdmgr.c b/C/cdmgr.c index ced593891..795cb7053 100644 --- a/C/cdmgr.c +++ b/C/cdmgr.c @@ -423,6 +423,13 @@ kill_first_log_iblock(LogUpdIndex *c, LogUpdIndex *cl, PredEntry *ap) Yap_FreeCodeSpace((CODEADDR)c); } else { c->ClFlags |= ErasedMask; + /* try to move up, so that we don't hold an index */ + if (cl != NULL && + cl->ClFlags & SwitchTableMask) { + c->u.ParentIndex = cl->u.ParentIndex; + cl->u.ParentIndex->ClRefCount++; + cl->ClRefCount--; + } c->ChildIndex = NULL; } } diff --git a/C/index.c b/C/index.c index 5c7f2982e..7bfe0dff2 100644 --- a/C/index.c +++ b/C/index.c @@ -4140,6 +4140,7 @@ ExpandIndex(PredEntry *ap) { /* insert myself in the indexing code chain */ nic->SiblingIndex = ic->ChildIndex; nic->u.ParentIndex = ic; + nic->ClFlags &= ~SwitchRootMask; ic->ChildIndex = nic; ic->ClRefCount++; } else { diff --git a/C/tracer.c b/C/tracer.c index 64102bb9b..15373f2bf 100644 --- a/C/tracer.c +++ b/C/tracer.c @@ -102,7 +102,7 @@ check_trail_consistency(void) { */ - static int vsc_xstop = FALSE; +static int vsc_xstop = FALSE; void low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)