Skip to content

Commit f78e8c8

Browse files
fix test, more locks!
1 parent f05e61c commit f78e8c8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ def test_modified_local_is_seen_by_optimized_code(self):
11671167
self.assertIs(type(s), float)
11681168
self.assertEqual(s, 1024.0)
11691169

1170+
@unittest.skipIf(Py_GIL_DISABLED, "FT build only specializes on deferred methods/functions/classes")
11701171
def test_guard_type_version_removed(self):
11711172
def thing(a):
11721173
x = 0
@@ -1185,6 +1186,7 @@ class Foo:
11851186
guard_type_version_count = opnames.count("_GUARD_TYPE_VERSION")
11861187
self.assertEqual(guard_type_version_count, 1)
11871188

1189+
@unittest.skipIf(Py_GIL_DISABLED, "FT build only specializes on deferred methods/functions/classes")
11881190
def test_guard_type_version_removed_inlined(self):
11891191
"""
11901192
Verify that the guard type version if we have an inlined function
@@ -1211,6 +1213,7 @@ class Foo:
12111213
guard_type_version_count = opnames.count("_GUARD_TYPE_VERSION")
12121214
self.assertEqual(guard_type_version_count, 1)
12131215

1216+
@unittest.skipIf(Py_GIL_DISABLED, "FT build only specializes on deferred methods/functions")
12141217
def test_guard_type_version_removed_invalidation(self):
12151218

12161219
def thing(a):
@@ -1241,6 +1244,7 @@ class Bar:
12411244
self.assertEqual(opnames[:load_attr_top].count("_GUARD_TYPE_VERSION"), 1)
12421245
self.assertEqual(opnames[call:load_attr_bottom].count("_CHECK_VALIDITY"), 2)
12431246

1247+
@unittest.skipIf(Py_GIL_DISABLED, "FT build only specializes on deferred methods/functions")
12441248
def test_guard_type_version_removed_escaping(self):
12451249

12461250
def thing(a):
@@ -1264,6 +1268,7 @@ class Foo:
12641268
self.assertEqual(opnames[:load_attr_top].count("_GUARD_TYPE_VERSION"), 1)
12651269
self.assertEqual(opnames[call:load_attr_bottom].count("_CHECK_VALIDITY"), 2)
12661270

1271+
@unittest.skipIf(Py_GIL_DISABLED, "FT build only specializes on deferred methods/functions/classes")
12671272
def test_guard_type_version_executor_invalidated(self):
12681273
"""
12691274
Verify that the executor is invalided on a type change.
@@ -2033,6 +2038,7 @@ def testfunc(n):
20332038
self.assertNotIn("_GUARD_NOS_INT", uops)
20342039
self.assertNotIn("_GUARD_TOS_INT", uops)
20352040

2041+
@unittest.skipIf(Py_GIL_DISABLED, "FT build immortalizes constants")
20362042
def test_call_len_known_length_small_int(self):
20372043
# Make sure that len(t) is optimized for a tuple of length 5.
20382044
# See https://github.com/python/cpython/issues/139393.
@@ -2057,6 +2063,7 @@ def testfunc(n):
20572063
self.assertNotIn("_POP_CALL_LOAD_CONST_INLINE_BORROW", uops)
20582064
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops)
20592065

2066+
@unittest.skipIf(Py_GIL_DISABLED, "FT build immortalizes constants")
20602067
def test_call_len_known_length(self):
20612068
# Make sure that len(t) is not optimized for a tuple of length 2048.
20622069
# See https://github.com/python/cpython/issues/139393.
@@ -2308,6 +2315,7 @@ def testfunc(n):
23082315
self.assertNotIn("_TO_BOOL_BOOL", uops)
23092316
self.assertIn("_GUARD_IS_TRUE_POP", uops)
23102317

2318+
@unittest.skipIf(Py_GIL_DISABLED, "FT build only specializes on deferred methods/functions/classes")
23112319
def test_set_type_version_sets_type(self):
23122320
class C:
23132321
A = 1
@@ -2340,6 +2348,7 @@ def testfunc(n):
23402348
self.assertNotIn("_LOAD_SMALL_INT", uops)
23412349
self.assertIn("_LOAD_CONST_INLINE_BORROW", uops)
23422350

2351+
@unittest.skipIf(Py_GIL_DISABLED, "FT build only specializes on deferred methods/functions")
23432352
def test_cached_attributes(self):
23442353
class C:
23452354
A = 1

Python/optimizer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ make_executor_from_uops(_PyUOpInstruction *buffer, int length, const _PyBloomFil
13171317
// from being immediately detected as cold and invalidated.
13181318
executor->vm_data.warm = true;
13191319
if (_PyJIT_Compile(executor, executor->trace, length)) {
1320-
Py_DECREF(executor);
1320+
executor->vm_data.warm = false;
13211321
return NULL;
13221322
}
13231323
#endif
@@ -1399,8 +1399,10 @@ uop_optimize(
13991399
OPT_HIST(effective_trace_length(buffer, length), optimized_trace_length_hist);
14001400
length = prepare_for_execution(buffer, length);
14011401
assert(length <= UOP_MAX_TRACE_LENGTH);
1402+
HEAD_LOCK(&_PyRuntime);
14021403
_PyExecutorObject *executor = make_executor_from_uops(
14031404
buffer, length, dependencies, _tstate->jit_tracer_state.initial_state.chain_depth);
1405+
HEAD_UNLOCK(&_PyRuntime);
14041406
if (executor == NULL) {
14051407
return -1;
14061408
}

0 commit comments

Comments
 (0)