mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +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
22
Python/optimizer_cases.c.h
generated
22
Python/optimizer_cases.c.h
generated
|
|
@ -1553,18 +1553,26 @@
|
|||
break;
|
||||
}
|
||||
|
||||
case _LOAD_SPECIAL: {
|
||||
JitOptSymbol *attr;
|
||||
JitOptSymbol *self_or_null;
|
||||
attr = sym_new_not_null(ctx);
|
||||
self_or_null = sym_new_unknown(ctx);
|
||||
stack_pointer[-1] = attr;
|
||||
stack_pointer[0] = self_or_null;
|
||||
case _INSERT_NULL: {
|
||||
JitOptSymbol *self;
|
||||
JitOptSymbol **method_and_self;
|
||||
self = stack_pointer[-1];
|
||||
method_and_self = &stack_pointer[-1];
|
||||
method_and_self[0] = sym_new_null(ctx);
|
||||
method_and_self[1] = self;
|
||||
stack_pointer += 1;
|
||||
assert(WITHIN_STACK_BOUNDS());
|
||||
break;
|
||||
}
|
||||
|
||||
case _LOAD_SPECIAL: {
|
||||
JitOptSymbol **method_and_self;
|
||||
method_and_self = &stack_pointer[-2];
|
||||
method_and_self[0] = sym_new_not_null(ctx);
|
||||
method_and_self[1] = sym_new_unknown(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
case _WITH_EXCEPT_START: {
|
||||
JitOptSymbol *res;
|
||||
res = sym_new_not_null(ctx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue