def thread_setup(): """Called once when the program starts.""" aid = get_aid() gcdata.main_thread = aid gcdata.active_thread = aid gcdata.thread_stacks = AddressDict() # {aid: root_stack_top} gcdata._fresh_rootstack = llmemory.NULL gcdata.dead_threads_count = 0
def __init__(self, gc, fd): self.gc = gc self.gcflag = gc.gcflag_extra self.fd = rffi.cast(rffi.INT, fd) self.writebuffer = lltype.malloc(rffi.LONGP.TO, self.BUFSIZE, flavor='raw') self.buf_count = 0 if self.gcflag == 0: self.seen = AddressDict() self.pending = AddressStack()
def debug_check_consistency(self): """To use after a collection. If self.DEBUG is set, this enumerates all roots and traces all objects to check if we didn't accidentally free a reachable object or forgot to update a pointer to an object that moved. """ if self.DEBUG: from pypy.rlib.objectmodel import we_are_translated from pypy.rpython.memory.support import AddressDict self._debug_seen = AddressDict() self._debug_pending = self.AddressStack() if not we_are_translated(): self.root_walker._walk_prebuilt_gc(self._debug_record) self.enumerate_all_roots(GCBase._debug_callback, self) pending = self._debug_pending while pending.non_empty(): obj = pending.pop() self.trace(obj, self._debug_callback2, None) self._debug_seen.delete() self._debug_pending.delete()
def thread_setup(): gcdata.aid2stack = AddressDict() gcdata.dead_threads_count = 0 # to also register the main thread's stack thread_start()