def belongs_to_current_thread(framedata): # xxx obscure: the answer is Yes if, as a pointer, framedata # lies between the start of the current stack and the top of it. stack_start = gcdata.aid2stack.get(get_aid(), llmemory.NULL) ll_assert(stack_start != llmemory.NULL, "current thread not found in gcdata.aid2stack!") stack_stop = llop.stack_current(llmemory.Address) return (stack_start <= framedata <= stack_stop or stack_start >= framedata >= stack_stop)
def stack_check(): if not we_are_translated(): return # # Load the "current" stack position, or at least some address that # points close to the current stack head current = llop.stack_current(lltype.Signed) # # Load these variables from C code end = _stack_get_end() length = _stack_get_length() # # Common case: if 'current' is within [end-length:end], everything # is fine ofs = r_uint(end - current) if ofs <= r_uint(length): return # # Else call the slow path stack_check_slowpath(current)
def thread_start(): value = llop.stack_current(llmemory.Address) gcdata.aid2stack.setitem(get_aid(), value)