Esempio n. 1
0
def get_referrers(space, args_w):
    """Return the list of objects that directly refer to any of objs."""
    roots = rgc.get_rpy_roots()
    pending_w = _get_objects_from_rpy(roots)
    arguments_w = {}
    for w_obj in args_w:
        arguments_w[w_obj] = None
    # continue by following every W_Root.  Same remark about hashes as
    # in get_objects().
    result_w = {}
    seen_w = {}
    while len(pending_w) > 0:
        previous_w = pending_w
        pending_w = []
        for w_obj in previous_w:
            if w_obj not in seen_w:
                seen_w[w_obj] = None
                gcref = rgc.cast_instance_to_gcref(w_obj)
                referents_w = []
                _list_w_obj_referents(gcref, referents_w)
                for w_subobj in referents_w:
                    if w_subobj in arguments_w:
                        result_w[w_obj] = None
                pending_w += referents_w
    return space.newlist(result_w.keys())
Esempio n. 2
0
 def g(s):
     lst = rgc.get_rpy_roots()
     found = False
     for x in lst:
         if x == lltype.cast_opaque_ptr(llmemory.GCREF, s):
             found = True
         if x == lltype.cast_opaque_ptr(llmemory.GCREF, s.u):
             os.write(2, "s.u should not be found!\n")
             assert False
     return found == 1
Esempio n. 3
0
 def g(s):
     lst = rgc.get_rpy_roots()
     found = False
     for x in lst:
         if x == lltype.cast_opaque_ptr(llmemory.GCREF, s):
             found = True
         if x == lltype.cast_opaque_ptr(llmemory.GCREF, s.u):
             os.write(2, "s.u should not be found!\n")
             assert False
     return found == 1
Esempio n. 4
0
def get_objects(space):
    """Return a list of all app-level objects."""
    roots = rgc.get_rpy_roots()
    pending_w = _get_objects_from_rpy(roots)
    # continue by following every W_Root.  Note that this will force a hash
    # on every W_Root, which is kind of bad, but not on every RPython object,
    # which is really good.
    result_w = {}
    while len(pending_w) > 0:
        previous_w = pending_w
        pending_w = []
        for w_obj in previous_w:
            if w_obj not in result_w:
                result_w[w_obj] = None
                gcref = rgc.cast_instance_to_gcref(w_obj)
                _list_w_obj_referents(gcref, pending_w)
    return space.newlist(result_w.keys())
Esempio n. 5
0
def get_rpy_roots(space):
    lst = rgc.get_rpy_roots()
    if lst is None:
        raise missing_operation(space)
    return space.newlist([wrap(space, gcref) for gcref in lst if gcref])