Skip to content

Commit 1651cfd

Browse files
committed
backport 3.15
1 parent 6413901 commit 1651cfd

8 files changed

Lines changed: 180 additions & 168 deletions

File tree

‎Include/internal/pycore_uop_ids.h‎

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

‎Include/internal/pycore_uop_metadata.h‎

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

‎Lib/test/test_capi/test_opt.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,18 @@ def f(n):
24232423
self.assertEqual(uops.count("_STORE_SUBSCR_DICT_KNOWN_HASH"), 1)
24242424
self.assertEqual(uops.count("_GUARD_NOS_DICT_SUBSCRIPT"), 0)
24252425
self.assertEqual(uops.count("_GUARD_NOS_DICT_STORE_SUBSCRIPT"), 0)
2426-
self.assertEqual(uops.count("_GUARD_TYPE"), 1)
2426+
self.assertEqual(uops.count("_GUARD_NOS_TYPE"), 1)
2427+
2428+
def test_dict_subscr_probable_type(self):
2429+
def f(d):
2430+
for _ in range(TIER2_THRESHOLD):
2431+
value = d["key"]
2432+
return value
2433+
2434+
res, ex = self._run_with_optimizer(f, {"key": 1})
2435+
self.assertEqual(res, 1)
2436+
self.assertIsNotNone(ex)
2437+
self.assertIn("_GUARD_NOS_TYPE", get_opnames(ex))
24272438

24282439
def test_dict_subclass_subscr_with_override(self):
24292440
class MyDict(dict):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incorrect type guards for ``dict`` reads and writes in the experimental JIT.

‎Python/bytecodes.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,9 +3876,9 @@ dummy_func(
38763876
next = item;
38773877
}
38783878

3879-
tier2 op(_GUARD_TYPE_ITER, (expected_type/4, iter, null_or_index -- iter, null_or_index)) {
3880-
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
3881-
EXIT_IF(Py_TYPE(iter_o) != (PyTypeObject *)expected_type);
3879+
tier2 op(_GUARD_NOS_TYPE, (expected_type/4, nos, unused -- nos, unused)) {
3880+
PyObject *nos_o = PyStackRef_AsPyObjectBorrow(nos);
3881+
EXIT_IF(Py_TYPE(nos_o) != (PyTypeObject *)expected_type);
38823882
}
38833883

38843884
tier2 op(_ITER_NEXT_INLINE, (iternext_fn/4, iter, null_or_index -- iter, null_or_index, next)) {

0 commit comments

Comments
 (0)