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:
Sam Gross 2025-04-21 15:54:25 -04:00 committed by GitHub
parent 8dfa840773
commit da53660f35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 247 additions and 207 deletions

View file

@ -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, (--)) {