Skip to content

Commit 6a42001

Browse files
Add back test properly
1 parent 8806c74 commit 6a42001

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5189,6 +5189,9 @@ def testfunc(n):
51895189
self.assertIn("_CHECK_FUNCTION_VERSION", uops)
51905190

51915191
global_identity_code_will_be_modified.__code__ = (lambda a: 0xdeadead).__code__
5192+
_testinternalcapi.clear_executor_deletion_list()
5193+
ex = get_first_executor(testfunc)
5194+
self.assertIsNone(ex)
51925195
# JItted code should've deopted.
51935196
self.assertEqual(global_identity_code_will_be_modified(None), 0xdeadead)
51945197

Objects/funcobject.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ handle_func_event(PyFunction_WatchEvent event, PyFunctionObject *func,
6464
case PyFunction_EVENT_MODIFY_DEFAULTS:
6565
case PyFunction_EVENT_MODIFY_KWDEFAULTS:
6666
case PyFunction_EVENT_MODIFY_QUALNAME:
67+
#if _Py_TIER2
68+
// Note: we only invalidate JIT code if a function version changes.
69+
// Not when the function is deallocated.
70+
// Function deallocation occurs frequently (think: lambdas),
71+
// so we want to minimize dependency invalidation there.
72+
_Py_Executors_InvalidateDependency(interp, func, 1);
73+
#endif
6774
RARE_EVENT_INTERP_INC(interp, func_modification);
6875
break;
6976
default:

Python/optimizer_bytecodes.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,10 +1009,7 @@ dummy_func(void) {
10091009
}
10101010
// Guarded on this, so it can be promoted.
10111011
sym_set_const(callable, func);
1012-
// We do not need to add func to the bloom filter, as we never remove
1013-
// this guard. Note: we generally do not want to add functions to our dependencies,
1014-
// as we want to avoid having to invalidate all executors on every function
1015-
// deallocation, which is a common procedure (e.g. lambdas).
1012+
_Py_BloomFilter_Add(dependencies, func);
10161013
}
10171014

10181015
op(_CHECK_METHOD_VERSION, (func_version/2, callable, null, unused[oparg] -- callable, null, unused[oparg])) {

Python/optimizer_cases.c.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)