PN_SIZE potion_mark_stack(Potion *P, int forward) { PN_SIZE n; struct PNMemory *M = P->mem; _PN *end, *start = M->cstack; POTION_ESP(&end); #if POTION_STACK_DIR > 0 n = end - start; #else n = start - end + 1; start = end; end = M->cstack; #endif if (n <= 0) return 0; return pngc_mark_array(P, start, n, forward); }
ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS PN_SIZE potion_mark_stack(Potion *P, int type) { long n; _PN *end, *start = P->mem->cstack; POTION_ESP(&end); #if POTION_STACK_DIR > 0 n = end - start; #else n = start - end + 1; start = end; end = P->mem->cstack; #endif DBG_Gv(P,"mark_stack (%p -> %p = %ld, type=%d)\n", start, end, n, type); if (n <= 0) return 0; return pngc_mark_array(P, start, n, type); }
void potion_dump_stack(Potion *P) { long n; PN *end, *ebp, *start = P->mem->cstack; struct PNMemory *M = P->mem; POTION_ESP(&end); POTION_EBP(&ebp); #if POTION_STACK_DIR > 0 n = end - start; #else n = start - end + 1; start = end; end = M->cstack; #endif printf("-- dumping %ld stack from %p to %p --\n", n, start, end); printf(" ebp = %p, *ebp = %lx\n", ebp, *ebp); while (n--) { vPN(Object) o = (struct PNObject*)*start; printf(" stack(%ld) = %p: %lx", n, start, *start); if (IS_GC_PROTECTED(*start)) printf(" vt=%x gc", PN_TYPE(o)); else if (IN_BIRTH_REGION(*start)) printf(" vt=%x gc(0)", PN_TYPE(o)); else if (IN_OLDER_REGION(*start)) printf(" vt=%x gc(1)", PN_TYPE(o)); if (*start == 0) printf(" nil\n"); else if (*start & 1) printf(" %ld INT\n", PN_INT(*start)); else if (*start & 2) printf(" %s BOOL\n", *start == 2 ? "false" : "true"); else printf(" \n"); start++; } }
PN_SIZE potion_stack_len(Potion *P, _PN **p) { _PN *esp, *c = P->mem->cstack; POTION_ESP(&esp); if (p) *p = STACK_UPPER(c, esp); return esp < c ? c - esp : esp - c + 1; }