diff options
author | Armin Rigo <arigo@tunes.org> | 2016-03-18 17:52:25 +0000 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2016-03-18 17:52:25 +0000 |
commit | e868a862dba520db0e1ebaa010d79edccee1f9e9 (patch) | |
tree | 4d55c2ee95969724e4aefdcd6ed69c8702aa207c /pypy/module/cpyext | |
parent | merge heads (diff) | |
download | pypy-release-5.0.1.tar.gz pypy-release-5.0.1.tar.bz2 pypy-release-5.0.1.zip |
Add some "add_memory_pressure=True" at all places that malloc somethingrelease-5.0.1
that is likely to be a PyObject or attached to a PyObject, and thus
relying on our GC to know when it must be freed. This change helps a
lot on some examples.
Diffstat (limited to 'pypy/module/cpyext')
-rw-r--r-- | pypy/module/cpyext/bytesobject.py | 3 | ||||
-rw-r--r-- | pypy/module/cpyext/object.py | 3 | ||||
-rw-r--r-- | pypy/module/cpyext/pyobject.py | 3 | ||||
-rw-r--r-- | pypy/module/cpyext/tupleobject.py | 9 | ||||
-rw-r--r-- | pypy/module/cpyext/typeobject.py | 3 | ||||
-rw-r--r-- | pypy/module/cpyext/unicodeobject.py | 3 |
6 files changed, 16 insertions, 8 deletions
diff --git a/pypy/module/cpyext/bytesobject.py b/pypy/module/cpyext/bytesobject.py index 3a01515706..29ac9321de 100644 --- a/pypy/module/cpyext/bytesobject.py +++ b/pypy/module/cpyext/bytesobject.py @@ -80,7 +80,8 @@ def new_empty_str(space, length): buflen = length + 1 py_str.c_size = length py_str.c_buffer = lltype.malloc(rffi.CCHARP.TO, buflen, - flavor='raw', zero=True) + flavor='raw', zero=True, + add_memory_pressure=True) return py_str def string_attach(space, py_obj, w_obj): diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py index d0b3939afe..65e815c10a 100644 --- a/pypy/module/cpyext/object.py +++ b/pypy/module/cpyext/object.py @@ -17,7 +17,8 @@ import pypy.module.__builtin__.operation as operation @cpython_api([Py_ssize_t], rffi.VOIDP) def PyObject_MALLOC(space, size): return lltype.malloc(rffi.VOIDP.TO, size, - flavor='raw', zero=True) + flavor='raw', zero=True, + add_memory_pressure=True) @cpython_api([rffi.VOIDP], lltype.Void) def PyObject_FREE(space, ptr): diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py index 793bac0354..e4dba23f4e 100644 --- a/pypy/module/cpyext/pyobject.py +++ b/pypy/module/cpyext/pyobject.py @@ -50,7 +50,8 @@ class BaseCpyTypedescr(object): size += itemcount * pytype.c_tp_itemsize assert size >= rffi.sizeof(PyObject.TO) buf = lltype.malloc(rffi.VOIDP.TO, size, - flavor='raw', zero=True) + flavor='raw', zero=True, + add_memory_pressure=True) pyobj = rffi.cast(PyObject, buf) pyobj.c_ob_refcnt = 1 pyobj.c_ob_type = pytype diff --git a/pypy/module/cpyext/tupleobject.py b/pypy/module/cpyext/tupleobject.py index 938fb50b91..155987d67d 100644 --- a/pypy/module/cpyext/tupleobject.py +++ b/pypy/module/cpyext/tupleobject.py @@ -59,7 +59,8 @@ def new_empty_tuple(space, length): py_tup = rffi.cast(PyTupleObject, py_obj) py_tup.c_ob_item = lltype.malloc(ObjectItems, length, - flavor='raw', zero=True) + flavor='raw', zero=True, + add_memory_pressure=True) py_tup.c_ob_size = length return py_tup @@ -70,7 +71,8 @@ def tuple_attach(space, py_obj, w_obj): """ items_w = space.fixedview(w_obj) l = len(items_w) - p = lltype.malloc(ObjectItems, l, flavor='raw') + p = lltype.malloc(ObjectItems, l, flavor='raw', + add_memory_pressure=True) i = 0 try: while i < l: @@ -177,7 +179,8 @@ def _PyTuple_Resize(space, p_ref, newsize): ref = rffi.cast(PyTupleObject, ref) oldsize = ref.c_ob_size oldp = ref.c_ob_item - newp = lltype.malloc(ObjectItems, newsize, zero=True, flavor='raw') + newp = lltype.malloc(ObjectItems, newsize, zero=True, flavor='raw', + add_memory_pressure=True) try: if oldsize < newsize: to_cp = oldsize diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py index e8fa4e9e00..f30fc04a0a 100644 --- a/pypy/module/cpyext/typeobject.py +++ b/pypy/module/cpyext/typeobject.py @@ -421,7 +421,8 @@ def type_alloc(space, w_metatype): Py_DecRef(space, w_metatype) heaptype = lltype.malloc(PyHeapTypeObject.TO, - flavor='raw', zero=True) + flavor='raw', zero=True, + add_memory_pressure=True) pto = heaptype.c_ht_type pto.c_ob_refcnt = 1 pto.c_ob_type = metatype diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py index fb0d39eea0..c4290d5533 100644 --- a/pypy/module/cpyext/unicodeobject.py +++ b/pypy/module/cpyext/unicodeobject.py @@ -55,7 +55,8 @@ def new_empty_unicode(space, length): buflen = length + 1 py_uni.c_size = length py_uni.c_buffer = lltype.malloc(rffi.CWCHARP.TO, buflen, - flavor='raw', zero=True) + flavor='raw', zero=True, + add_memory_pressure=True) return py_uni def unicode_attach(space, py_obj, w_obj): |