mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-131586: Avoid refcount contention in context managers (gh-131851)
This avoid reference count contention in the free threading build when calling special methods like `__enter__` and `__exit__`.
This commit is contained in:
parent
8dfa840773
commit
da53660f35
11 changed files with 247 additions and 207 deletions
|
@ -897,9 +897,14 @@ dummy_func(void) {
|
|||
}
|
||||
}
|
||||
|
||||
op(_LOAD_SPECIAL, (owner -- attr, self_or_null)) {
|
||||
attr = sym_new_not_null(ctx);
|
||||
self_or_null = sym_new_unknown(ctx);
|
||||
op(_INSERT_NULL, (self -- method_and_self[2])) {
|
||||
method_and_self[0] = sym_new_null(ctx);
|
||||
method_and_self[1] = self;
|
||||
}
|
||||
|
||||
op(_LOAD_SPECIAL, (method_and_self[2] -- method_and_self[2])) {
|
||||
method_and_self[0] = sym_new_not_null(ctx);
|
||||
method_and_self[1] = sym_new_unknown(ctx);
|
||||
}
|
||||
|
||||
op(_JUMP_TO_TOP, (--)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue