diff --git a/runtime/gc/dfs-mark.c b/runtime/gc/dfs-mark.c index 95d0e706c..bf7a1b95e 100644 --- a/runtime/gc/dfs-mark.c +++ b/runtime/gc/dfs-mark.c @@ -140,7 +140,7 @@ size_t dfsMarkByMode (GC_state s, pointer root, assert (objptrIndex < numObjptrs); // next = *(pointer*)todo; next = fetchObjptrToPointer (todo, s->heap.start); - if (not isPointer (next)) { + if (not isPointerInHeap (s, next)) { markNextInNormal: assert (objptrIndex < numObjptrs); objptrIndex++; @@ -170,7 +170,7 @@ size_t dfsMarkByMode (GC_state s, pointer root, if (DEBUG_WEAK) fprintf (stderr, "marking weak "FMTPTR" ", (uintptr_t)w); - if (isObjptr (w->objptr)) { + if (isObjptrInHeap (s, w->objptr)) { if (DEBUG_WEAK) fprintf (stderr, "linking\n"); w->link = s->weaks; @@ -216,7 +216,7 @@ size_t dfsMarkByMode (GC_state s, pointer root, assert (todo == indexSequenceAtObjptrIndex (s, cur, sequenceIndex, objptrIndex)); // next = *(pointer*)todo; next = fetchObjptrToPointer (todo, s->heap.start); - if (not (isPointer(next))) { + if (not (isPointerInHeap(s, next))) { markNextInSequence: assert (sequenceIndex < getSequenceLength (cur)); assert (objptrIndex < numObjptrs); @@ -279,7 +279,7 @@ size_t dfsMarkByMode (GC_state s, pointer root, " offset %u todo "FMTPTR" next = "FMTPTR"\n", frameOffsets [objptrIndex + 1], (uintptr_t)todo, (uintptr_t)next); - if (not isPointer (next)) { + if (not isPointerInHeap (s, next)) { objptrIndex++; goto markInFrame; } diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index e0fe7bc15..a454885c3 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -39,13 +39,11 @@ typedef struct GC_heap { static inline bool isPointerInOldGen (GC_state s, pointer p); static inline bool isPointerInNursery (GC_state s, pointer p); -#if ASSERT +static inline bool isPointerInHeap (GC_state s, pointer p); static inline bool isObjptrInOldGen (GC_state s, objptr op); -#endif static inline bool isObjptrInNursery (GC_state s, objptr op); -#if ASSERT static inline bool isObjptrInFromSpace (GC_state s, objptr op); -#endif +static inline bool isObjptrInHeap (GC_state s, objptr op); static inline bool hasHeapBytesFree (GC_state s, size_t oldGen, size_t nursery); static inline bool isHeapInit (GC_heap h); diff --git a/runtime/gc/heap_predicates.c b/runtime/gc/heap_predicates.c index bb279aab9..dfbfb5a6c 100644 --- a/runtime/gc/heap_predicates.c +++ b/runtime/gc/heap_predicates.c @@ -18,7 +18,6 @@ bool isPointerInNursery (GC_state s, pointer p) { and p <= s->frontier)); } -#if ASSERT bool isObjptrInOldGen (GC_state s, objptr op) { pointer p; if (not (isObjptr(op))) @@ -26,7 +25,6 @@ bool isObjptrInOldGen (GC_state s, objptr op) { p = objptrToPointer (op, s->heap.start); return isPointerInOldGen (s, p); } -#endif bool isObjptrInNursery (GC_state s, objptr op) { pointer p; @@ -36,12 +34,19 @@ bool isObjptrInNursery (GC_state s, objptr op) { return isPointerInNursery (s, p); } -#if ASSERT bool isObjptrInFromSpace (GC_state s, objptr op) { return (isObjptrInOldGen (s, op) or isObjptrInNursery (s, op)); } -#endif + +bool isObjptrInHeap (GC_state s, objptr op) { + return isObjptrInFromSpace(s, op); +} + +bool isPointerInHeap (GC_state s, pointer p) { + return (isPointerInOldGen (s, p) + or isPointerInNursery (s, p)); +} bool hasHeapBytesFree (GC_state s, size_t oldGen, size_t nursery) { size_t total;