[pypy-commit] pypy cpyext-gc-cycle: Removed obsolete code and TODOs
stevie_92
pypy.commits at gmail.com
Tue Sep 24 05:49:40 EDT 2019
Author: Stefan Beyer <home at sbeyer.at>
Branch: cpyext-gc-cycle
Changeset: r97597:5172b6ed9d6c
Date: 2019-09-24 11:49 +0200
http://bitbucket.org/pypy/pypy/changeset/5172b6ed9d6c/
Log: Removed obsolete code and TODOs
diff --git a/pypy/module/cpyext/state.py b/pypy/module/cpyext/state.py
--- a/pypy/module/cpyext/state.py
+++ b/pypy/module/cpyext/state.py
@@ -162,20 +162,6 @@
pyobj_dealloc_action = PyObjDeallocAction(space)
self.dealloc_trigger = lambda: pyobj_dealloc_action.fire()
- def _clear_weakref_callbacks(gcref):
- from pypy.module._weakref.interp__weakref import \
- W_Weakref, W_CallableProxy
- from pypy.module.gc.referents import \
- try_cast_gcref_to_w_root
- w_obj = try_cast_gcref_to_w_root(gcref)
- if type(w_obj) is W_Weakref:
- w_obj.w_callable = None
- elif type(w_obj) is W_CallableProxy:
- w_obj.w_callable = None
-
- self.clear_weakref_callbacks = \
- (lambda w_obj: _clear_weakref_callbacks(w_obj))
-
def _tp_traverse(pyobj_ptr, callback, args):
from pypy.module.cpyext.api import PyObject, \
generic_cpy_call
@@ -248,8 +234,6 @@
pypyobj_list, pypyobj_tuple_list,
self.C._PyPy_gc_as_pyobj, self.C._PyPy_pyobj_as_gc,
self.C._PyPy_finalizer_type,
- llhelper(rawrefcount.RAWREFCOUNT_CLEAR_WR_TYPE,
- self.clear_weakref_callbacks),
self.C._PyTuple_MaybeUntrack)
self.builder.attach_all(space)
diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -3094,7 +3094,6 @@
RAWREFCOUNT_GC_AS_PYOBJ = RawRefCountBaseGC.RAWREFCOUNT_GC_AS_PYOBJ
RAWREFCOUNT_PYOBJ_AS_GC = RawRefCountBaseGC.RAWREFCOUNT_PYOBJ_AS_GC
RAWREFCOUNT_FINALIZER_TYPE = RawRefCountBaseGC.RAWREFCOUNT_FINALIZER_TYPE
- RAWREFCOUNT_CLEAR_WR_TYPE = RawRefCountBaseGC.RAWREFCOUNT_CLEAR_WR_TYPE
RAWREFCOUNT_MAYBE_UNTRACK_TUPLE = \
RawRefCountBaseGC.RAWREFCOUNT_MAYBE_UNTRACK_TUPLE
@@ -3103,15 +3102,13 @@
def rawrefcount_init(self, dealloc_trigger_callback, tp_traverse,
pyobj_list, tuple_list, gc_as_pyobj, pyobj_as_gc,
- finalizer_type, clear_weakref_callback,
- tuple_maybe_untrack):
+ finalizer_type, tuple_maybe_untrack):
if not self.rrc_enabled:
gc_flags = (GCFLAG_VISITED_RMY, GCFLAG_VISITED,
GCFLAG_NO_HEAP_PTRS, GCFLAG_GARBAGE)
self.rrc_gc.init(self, gc_flags, dealloc_trigger_callback,
tp_traverse, pyobj_list, tuple_list, gc_as_pyobj,
- pyobj_as_gc, finalizer_type,
- clear_weakref_callback, tuple_maybe_untrack)
+ pyobj_as_gc, finalizer_type, tuple_maybe_untrack)
self.rrc_enabled = True
def activate_rawrefcount_cycle(self):
diff --git a/rpython/memory/gc/rrc/base.py b/rpython/memory/gc/rrc/base.py
--- a/rpython/memory/gc/rrc/base.py
+++ b/rpython/memory/gc/rrc/base.py
@@ -72,8 +72,6 @@
PYOBJ_GC_HDR_PTR))
RAWREFCOUNT_FINALIZER_TYPE = lltype.Ptr(lltype.FuncType([PYOBJ_GC_HDR_PTR],
lltype.Signed))
- RAWREFCOUNT_CLEAR_WR_TYPE = lltype.Ptr(lltype.FuncType([llmemory.GCREF],
- lltype.Void))
RAWREFCOUNT_MAYBE_UNTRACK_TUPLE = \
lltype.Ptr(lltype.FuncType([PYOBJ_HDR_PTR], lltype.Signed))
RAWREFCOUNT_FINALIZER_NONE = 0
@@ -90,7 +88,7 @@
def init(self, gc, gc_flags, dealloc_trigger_callback, tp_traverse,
pyobj_list, tuple_list, gc_as_pyobj, pyobj_as_gc, finalizer_type,
- clear_weakref_callback, tuple_maybe_untrack):
+ tuple_maybe_untrack):
# see pypy/doc/discussion/rawrefcount.rst
self.gc = gc
(self.GCFLAG_VISITED_RMY, self.GCFLAG_VISITED,
@@ -117,7 +115,6 @@
self.gc_as_pyobj = gc_as_pyobj
self.pyobj_as_gc = pyobj_as_gc
self.finalizer_type = finalizer_type
- self.clear_weakref_callback = clear_weakref_callback
self.tuple_maybe_untrack = tuple_maybe_untrack
self.state = self.STATE_DEFAULT
self.cycle_enabled = True
@@ -347,7 +344,6 @@
def _major_trace(self, pyobject, flags):
from rpython.rlib.rawrefcount import REFCNT_FROM_PYPY
from rpython.rlib.rawrefcount import REFCNT_FROM_PYPY_LIGHT
- # TODO: add flag; if set: if marked, keep rc-proxy
(use_cylicrefcnt, use_dict) = flags
#
pyobj = self._pyobj(pyobject)
@@ -575,8 +571,6 @@
elif pyobj.c_ob_pypy_link != 0:
pyobj.c_ob_refcnt += self.refcnt_add
if self.refcnt_add > 0:
- #intobj = pyobj.c_ob_pypy_link
- #obj = llmemory.cast_int_to_adr(intobj)
pyobject = llmemory.cast_ptr_to_adr(pyobj)
obj = self.refcnt_dict.get(pyobject)
self.gc.objects_to_trace.append(obj)
diff --git a/rpython/memory/gc/rrc/mark.py b/rpython/memory/gc/rrc/mark.py
--- a/rpython/memory/gc/rrc/mark.py
+++ b/rpython/memory/gc/rrc/mark.py
@@ -52,7 +52,7 @@
# mark all pypy objects at the border which are linked to live
# non-gc pyobjs which are not directly referenced by any gc pyobj
debug_print("use_cylicrc", use_cylicrc)
- self.p_list_old.foreach(self._major_trace, (use_cylicrc, True)) # TODO: set flag to keep marked, check other occurences
+ self.p_list_old.foreach(self._major_trace, (use_cylicrc, True))
self._debug_check_consistency(print_label="end-mark")
# fix refcnt back
@@ -61,7 +61,7 @@
self.refcnt_dict = self.gc.AddressDict()
self.use_refcntdict = False
else:
- self.p_list_old.foreach(self._major_trace, (False, False)) # TODO: set flag to keep marked, check other occurences
+ self.p_list_old.foreach(self._major_trace, (False, False))
self._debug_check_consistency(print_label="end-mark")
self.state = self.STATE_DEFAULT
diff --git a/rpython/memory/gc/test/test_rawrefcount.py b/rpython/memory/gc/test/test_rawrefcount.py
--- a/rpython/memory/gc/test/test_rawrefcount.py
+++ b/rpython/memory/gc/test/test_rawrefcount.py
@@ -72,14 +72,6 @@
else:
return RAWREFCOUNT_FINALIZER_NONE
- def rawrefcount_clear_wr(gc):
- cleared = False
- for weakrefs in self.pyobj_weakrefs:
- for weakref in weakrefs:
- if gc._obj.container == weakref.p._obj:
- weakref.callback_cleared = True
- cleared = True
-
def rawrefcount_tuple_maybe_untrack(obj):
#if foo:
# gchdr = rawrefcount_pyobj_as_gc(obj)
@@ -104,7 +96,6 @@
rawrefcount_gc_as_pyobj,
rawrefcount_pyobj_as_gc,
rawrefcount_finalizer_type,
- rawrefcount_clear_wr,
rawrefcount_tuple_maybe_untrack)
def _collect(self, major, expected_trigger=0):
diff --git a/rpython/memory/gctransform/framework.py b/rpython/memory/gctransform/framework.py
--- a/rpython/memory/gctransform/framework.py
+++ b/rpython/memory/gctransform/framework.py
@@ -494,7 +494,6 @@
SomePtr(GCClass.RAWREFCOUNT_GC_AS_PYOBJ),
SomePtr(GCClass.RAWREFCOUNT_PYOBJ_AS_GC),
SomePtr(GCClass.RAWREFCOUNT_FINALIZER_TYPE),
- SomePtr(GCClass.RAWREFCOUNT_CLEAR_WR_TYPE),
SomePtr(GCClass.RAWREFCOUNT_MAYBE_UNTRACK_TUPLE)],
annmodel.s_None)
self.rawrefcount_create_link_pypy_ptr = getfn(
@@ -1374,7 +1373,7 @@
def gct_gc_rawrefcount_init(self, hop):
[v_fnptr, v_fnptr2, v_pyobj_list, v_tuple_list, v_fnptr3, v_fnptr4,
- v_fnptr5, v_fnptr6, v_fnptr7] = hop.spaceop.args
+ v_fnptr5, v_fnptr6] = hop.spaceop.args
assert v_fnptr.concretetype == self.GCClass.RAWREFCOUNT_DEALLOC_TRIGGER
assert v_fnptr2.concretetype == self.GCClass.RAWREFCOUNT_TRAVERSE
# TODO add assert for v_pyobj_list, improve asserts (types not same but equal)
@@ -1383,7 +1382,7 @@
hop.genop("direct_call",
[self.rawrefcount_init_ptr, self.c_const_gc, v_fnptr,
v_fnptr2, v_pyobj_list, v_tuple_list, v_fnptr3, v_fnptr4,
- v_fnptr5, v_fnptr6, v_fnptr7])
+ v_fnptr5, v_fnptr6])
def gct_gc_rawrefcount_create_link_pypy(self, hop):
[v_gcobj, v_pyobject] = hop.spaceop.args
diff --git a/rpython/rlib/rawrefcount.py b/rpython/rlib/rawrefcount.py
--- a/rpython/rlib/rawrefcount.py
+++ b/rpython/rlib/rawrefcount.py
@@ -36,8 +36,6 @@
PYOBJ_HDR_PTR))
RAWREFCOUNT_PYOBJ_AS_GC = lltype.Ptr(lltype.FuncType([PYOBJ_HDR_PTR],
PYOBJ_GC_HDR_PTR))
-RAWREFCOUNT_CLEAR_WR_TYPE = lltype.Ptr(lltype.FuncType([llmemory.GCREF],
- lltype.Void))
def _build_pypy_link(p):
@@ -310,26 +308,24 @@
def compute_result_annotation(self, s_dealloc_callback, s_tp_traverse,
s_pyobj_list, v_tuple_list,
s_as_gc, s_as_pyobj,
- a_finalizer_type, a_clear_wr,
- a_maybe_untrack_tuple):
+ a_finalizer_type, a_maybe_untrack_tuple):
from rpython.rtyper.llannotation import SomePtr
assert isinstance(s_dealloc_callback, SomePtr) # ll-ptr-to-function
assert isinstance(s_tp_traverse, SomePtr)
assert isinstance(s_as_gc, SomePtr)
assert isinstance(s_as_pyobj, SomePtr)
assert isinstance(a_finalizer_type, SomePtr)
- assert isinstance(a_clear_wr, SomePtr)
assert isinstance(a_maybe_untrack_tuple, SomePtr)
def specialize_call(self, hop):
hop.exception_cannot_occur()
v_dealloc_callback, v_tp_traverse, v_pyobj_list, v_tuple_list, \
- v_as_gc, v_as_pyobj, v_finalizer_type, \
- v_clear_wr, v_maybe_untrack_tuple = hop.inputargs(*hop.args_r)
+ v_as_gc, v_as_pyobj, v_finalizer_type, v_maybe_untrack_tuple = \
+ hop.inputargs(*hop.args_r)
hop.genop('gc_rawrefcount_init', [v_dealloc_callback, v_tp_traverse,
v_pyobj_list, v_tuple_list,
v_as_gc, v_as_pyobj,
- v_finalizer_type, v_clear_wr,
+ v_finalizer_type,
v_maybe_untrack_tuple])
More information about the pypy-commit
mailing list