[pypy-commit] pypy cpyext-gc-cycle: Removed unnecessary code

2019-01-11 Thread stevie_92
Author: Stefan Beyer 
Branch: cpyext-gc-cycle
Changeset: r95603:b74906a7ac4b
Date: 2018-05-10 11:12 +0200
http://bitbucket.org/pypy/pypy/changeset/b74906a7ac4b/

Log:Removed unnecessary code

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -43,6 +43,7 @@
 from rpython.rlib import rstackovf
 from pypy.objspace.std.typeobject import W_TypeObject, find_best_base
 from pypy.module.cpyext.cparser import CTypeSpace
+from rpython.rlib.debug import ll_assert, debug_print, debug_start, debug_stop
 
 DEBUG_WRAPPER = True
 
@@ -974,6 +975,8 @@
 # we hope that malloc removal removes the newtuple() that is
 # inserted exactly here by the varargs specializer
 
+print "start to pypy"
+
 # see "Handling of the GIL" above (careful, we don't have the GIL here)
 tid = rthread.get_or_make_ident()
 _gil_auto = False
@@ -1085,6 +1088,9 @@
 rffi.stackcounter.stacks_counter -= 1
 
 _restore_gil_state(pygilstate_release, gilstate, gil_release, 
_gil_auto, tid)
+
+print "end to pypy"
+
 return retval
 
 wrapper_second_level._dont_inline_ = True
@@ -1773,8 +1779,10 @@
 
 preexist_error = PyErr_Occurred(space)
 try:
+print "start cpyext_call"
 # Call the function
 result = call_external_function(func, *boxed_args)
+print "end cpyext_call"
 finally:
 assert cpyext_glob_tid_ptr[0] == tid
 cpyext_glob_tid_ptr[0] = tid_before
diff --git a/rpython/config/translationoption.py 
b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -105,6 +105,14 @@
  "asmgcc": [("translation.gctransformer", "framework"),
 ("translation.backend", "c")],
 }),
+ChoiceOption("cpyextgc", "Garbage Collection Strategy for cpyext",
+ ["boehm", "ref", "ref_trialdel", "none"],
+ default="ref",
+ requires={
+"boehm": [("translation.gc", "incminimark")],
+"ref_trialdel": [("translation.gc", "incminimark")],
+ },
+ cmdline="--cpyextgc"),
 
 # other noticeable options
 BoolOption("thread", "enable use of threading primitives",
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -177,6 +177,8 @@
 defines = defines.copy()
 if self.config.translation.countmallocs:
 defines['COUNT_OP_MALLOCS'] = 1
+if self.config.translation.cpyextgc == "boehm":
+defines['CPYEXT_BOEHM'] = 1
 if self.config.translation.sandbox:
 defines['RPY_SANDBOXED'] = 1
 if CBuilder.have___thread is None:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy cpyext-gc-cycle: Removed unnecessary code

2019-01-11 Thread stevie_92
Author: Stefan Beyer 
Branch: cpyext-gc-cycle
Changeset: r95602:65ead3f78618
Date: 2018-04-12 10:21 +0200
http://bitbucket.org/pypy/pypy/changeset/65ead3f78618/

Log:Removed unnecessary code

diff --git a/pypy/module/cpyext/include/object.h 
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -14,8 +14,7 @@
 #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
 
 #define PY_REFCNT_FROM_PYPY (4L << ((long)(log(PY_SSIZE_T_MAX) / log(2) - 2)))
-#define PY_REFCNT_GREEN (4L << ((long)(log(PY_SSIZE_T_MAX) / log(2) - 7)))
-#define PY_REFCNT_OVERFLOW (1L << ((long)(log(PY_SSIZE_T_MAX) / log(2) - 7) / 
2L - 1L))
+#define PY_REFCNT_OVERFLOW (1L << ((long)(log(PY_SSIZE_T_MAX) / log(2) - 4) - 
1L))
 #define PY_REFCNT_MASK ((PY_REFCNT_OVERFLOW << 1L) - 1L)
 #define Py_RETURN_NONE return (PyObject *)(Py_None))->ob_refcnt & 
PY_REFCNT_OVERFLOW) == 0) ? \
   ((PyObject *)(Py_None))->ob_refcnt++ : 
Py_IncRef((PyObject *)(Py_None))), Py_None
@@ -48,12 +47,11 @@
 Py_IncRef((PyObject *)(ob));   
 \
 } while (0)
 #define Py_DECREF(ob)   do {   
  \
-if (!(((PyObject *)(ob))->ob_refcnt & 
PY_REFCNT_GREEN) ||\
-(((PyObject *)(ob))->ob_refcnt & 
PY_REFCNT_OVERFLOW))\
-Py_DecRef((PyObject *)(ob));   
 \
+if PyObject *)(ob))->ob_refcnt & 
PY_REFCNT_OVERFLOW))\
+Py_DecRef((PyObject *)(ob));   
  \
 else if (--((PyObject *)(ob))->ob_refcnt & 
PY_REFCNT_MASK)   \
 ;  
  \
-else if ((!((PyObject *)(ob))->ob_refcnt) & 
PY_REFCNT_FROM_PYPY) \
+else   
  \
 _Py_Dealloc((PyObject *)(ob)); 
  \
 } while (0)
 
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -18,9 +18,8 @@
 from rpython.rtyper.annlowlevel import llhelper, cast_instance_to_base_ptr
 from rpython.rlib import rawrefcount, jit
 from rpython.rlib.debug import ll_assert, fatalerror, debug_print
-from rpython.rlib.rawrefcount import (
-REFCNT_MASK, REFCNT_FROM_PYPY, REFCNT_OVERFLOW, REFCNT_CYCLE_BUFFERED,
-REFCNT_CLR_MASK, REFCNT_CLR_GREEN, REFCNT_CLR_PURPLE)
+from rpython.rlib.rawrefcount import (REFCNT_MASK, REFCNT_FROM_PYPY,
+  REFCNT_OVERFLOW)
 from pypy.module.cpyext.api import slot_function
 from pypy.module.cpyext.typeobjectdefs import visitproc
 
@@ -401,31 +400,13 @@
 rawrefcount.decref(pyobj)
 rc = pyobj.c_ob_refcnt
 if rc & REFCNT_MASK == 0:
-if rc & REFCNT_FROM_PYPY == 0 and rc & REFCNT_CLR_MASK != 
REFCNT_CLR_PURPLE:
-state = space.fromcache(State)
-generic_cpy_call(space, state.C._Py_Dealloc, pyobj)
-elif rc & REFCNT_CLR_MASK != REFCNT_CLR_GREEN:
-possible_root(space, pyobj)
+state = space.fromcache(State)
+generic_cpy_call(space, state.C._Py_Dealloc, pyobj)
 #else:
 #w_obj = rawrefcount.to_obj(W_Root, ref)
 #if w_obj is not None:
 #assert pyobj.c_ob_refcnt >= rawrefcount.REFCNT_FROM_PYPY
 
-@jit.dont_look_inside
-def possible_root(space, obj):
-#debug_print("possible root", obj)
-rc = obj.c_ob_refcnt
-if not obj.c_ob_type or not obj.c_ob_type.c_tp_traverse:
-#debug_print("mark green", obj)
-rc = rc & ~REFCNT_CLR_MASK | REFCNT_CLR_GREEN
-elif rc & REFCNT_CLR_MASK != REFCNT_CLR_PURPLE:
-rc = rc & ~REFCNT_CLR_MASK | REFCNT_CLR_PURPLE
-if rc & REFCNT_CYCLE_BUFFERED == 0:
-#debug_print("mark purple", obj)
-rawrefcount.buffer_pyobj(obj)
-rc = rc | REFCNT_CYCLE_BUFFERED
-obj.c_ob_refcnt = rc
-
 @cpython_api([PyObject], lltype.Void)
 def Py_IncRef(space, obj):
 incref(space, obj)
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
@@ -3067,9 +3067,6 @@
 objint = llmemory.cast_adr_to_int(obj, "symbolic")
 self._pyobj(pyobject).c_ob_pypy_link = objint
 
-def rawrefcount_buffer_pyobj(self, pyobject):
-self.rrc_buffered.append(pyobject)
-
 def rawrefcount_from_obj(self, gcobj):
 obj = llmemory.cast_ptr_to_adr(gcobj)
 if self.is_in_nursery(obj):
@@ -3254,12