diff options
author | Guido van Rossum <guido@python.org> | 2000-04-24 15:40:53 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-04-24 15:40:53 (GMT) |
commit | e92e610a9e0ec78bf9dd4965b980f1b57eeb040e (patch) | |
tree | 460bc78b7e874de9aa11d45f14f3414a90488ab3 /Include | |
parent | db575db0d6503a8acdb0f56ce74a339bf63c9a08 (diff) | |
download | cpython-e92e610a9e0ec78bf9dd4965b980f1b57eeb040e.zip cpython-e92e610a9e0ec78bf9dd4965b980f1b57eeb040e.tar.gz cpython-e92e610a9e0ec78bf9dd4965b980f1b57eeb040e.tar.bz2 |
Christian Tismer -- total rewrite on trashcan code.
Improvements:
- does no longer need any extra memory
- has no relationship to tstate
- works in debug mode
- can easily be modified for free threading (hi Greg:)
Side effects:
Trashcan does change the order of object destruction.
Prevending that would be quite an immense effort, as
my attempts have shown. This version works always
the same, with debug mode or not. The slightly
changed destruction order should therefore be no problem.
Algorithm:
While the old idea of delaying the destruction of some
obejcts at a certain recursion level was kept, we now
no longer aloocate an object to hold these objects.
The delayed objects are instead chained together
via their ob_type field. The type is encoded via
ob_refcnt. When it comes to the destruction of the
chain of waiting objects, the topmost object is popped
off the chain and revived with type and refcount 1,
then it gets a normal Py_DECREF.
I am confident that this solution is near optimum
for minimizing side effects and code bloat.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/object.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/Include/object.h b/Include/object.h index fabf0b6..f6ceba5 100644 --- a/Include/object.h +++ b/Include/object.h @@ -536,6 +536,11 @@ times. Also, we could do an exact stack measure then. Unfortunately, deallocations also take place when the thread state is undefined. + + CT 2k0422 complete rewrite. + There is no need to allocate new objects. + Everything is done vialob_refcnt and ob_type now. + Adding support for free-threading should be easy, too. */ #define PyTrash_UNWIND_LEVEL 50 @@ -551,11 +556,11 @@ times. _PyTrash_deposit_object((PyObject*)op);\ --_PyTrash_delete_nesting; \ if (_PyTrash_delete_later && _PyTrash_delete_nesting <= 0) \ - _PyTrash_destroy_list(); \ + _PyTrash_destroy_chain(); \ } \ extern DL_IMPORT(void) _PyTrash_deposit_object Py_PROTO((PyObject*)); -extern DL_IMPORT(void) _PyTrash_destroy_list Py_PROTO(()); +extern DL_IMPORT(void) _PyTrash_destroy_chain Py_PROTO(()); extern DL_IMPORT(int) _PyTrash_delete_nesting; extern DL_IMPORT(PyObject *) _PyTrash_delete_later; @@ -564,6 +569,7 @@ extern DL_IMPORT(PyObject *) _PyTrash_delete_later; #define xxPy_TRASHCAN_SAFE_BEGIN(op) #define xxPy_TRASHCAN_SAFE_END(op) ; + #ifdef __cplusplus } #endif |