mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
GH-131798: Narrow types more aggressively in the JIT (GH-134373)
This commit is contained in:
parent
e1c0c451a2
commit
2f0570caf4
10 changed files with 180 additions and 88 deletions
|
@ -2137,6 +2137,25 @@ class TestUopsOptimization(unittest.TestCase):
|
|||
self.assertNotIn("_TO_BOOL_BOOL", uops)
|
||||
self.assertIn("_GUARD_IS_TRUE_POP", uops)
|
||||
|
||||
def test_set_type_version_sets_type(self):
|
||||
class C:
|
||||
A = 1
|
||||
|
||||
def testfunc(n):
|
||||
x = 0
|
||||
c = C()
|
||||
for _ in range(n):
|
||||
x += c.A # Guarded.
|
||||
x += type(c).A # Unguarded!
|
||||
return x
|
||||
|
||||
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
|
||||
self.assertEqual(res, 2 * TIER2_THRESHOLD)
|
||||
self.assertIsNotNone(ex)
|
||||
uops = get_opnames(ex)
|
||||
self.assertIn("_GUARD_TYPE_VERSION", uops)
|
||||
self.assertNotIn("_CHECK_ATTR_CLASS", uops)
|
||||
|
||||
|
||||
def global_identity(x):
|
||||
return x
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue