def ll_keyeq(d, weakkey1, realkey2): # only called by ll_dict_lookup() with the first arg coming from an # entry.key, and the 2nd arg being the argument to ll_dict_lookup(). if not weakkey1: assert bool(realkey2) return False return weakref_deref(rclass.OBJECTPTR, weakkey1) == realkey2
def ll_get(self, d, llkey): hash = self.ll_keyhash(llkey) i = rdict.ll_dict_lookup(d, llkey, hash) & rdict.MASK #llop.debug_print(lltype.Void, i, 'get') valueref = d.entries[i].value if valueref: return weakref_deref(rclass.OBJECTPTR, valueref) else: return lltype.nullptr(rclass.OBJECTPTR.TO)
def ll_get(self, d, llkey): if d.resize_counter < 0: self.ll_weakdict_rehash_after_translation(d) hash = self.ll_keyhash(llkey) i = rdict.ll_dict_lookup(d, llkey, hash) & rdict.MASK #llop.debug_print(lltype.Void, i, 'get') valueref = d.entries[i].value if valueref: return weakref_deref(rclass.OBJECTPTR, valueref) else: return lltype.nullptr(rclass.OBJECTPTR.TO)
def ll_valid(entries, i): key = entries[i].key if not key: return False elif weakref_deref(rclass.OBJECTPTR, key): return True else: # The entry might be a dead weakref still holding a strong # reference to the value; for this case, we clear the old # value from the entry, if any. entries[i].value = NULLVALUE return False
def ll_valid(entries, i): value = entries[i].value return bool(value) and bool(weakref_deref(rclass.OBJECTPTR, value))
def f(): w = g() rgc.collect() return llmemory.weakref_deref(lltype.Ptr(S), w)
def g(): s = lltype.malloc(S) w = llmemory.weakref_create(s) assert llmemory.weakref_deref(lltype.Ptr(S), w) == s assert llmemory.weakref_deref(lltype.Ptr(S), w) == s return w # 's' is forgotten here