diff options
author | Guido van Rossum <guido@python.org> | 2024-02-28 22:38:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 22:38:01 (GMT) |
commit | 3409bc29c9f06051c28ae0791155e3aebd76ff2d (patch) | |
tree | 4b627c970a2d5a4b92fc48e320dbe24e579d4eab /Lib/test | |
parent | 75c6c05fea212330f4b0259602ffae1b2cb91be3 (diff) | |
download | cpython-3409bc29c9f06051c28ae0791155e3aebd76ff2d.zip cpython-3409bc29c9f06051c28ae0791155e3aebd76ff2d.tar.gz cpython-3409bc29c9f06051c28ae0791155e3aebd76ff2d.tar.bz2 |
gh-115859: Re-enable T2 optimizer pass by default (#116062)
This undoes the *temporary* default disabling of the T2 optimizer pass in gh-115860.
- Add a new test that reproduces Brandt's example from gh-115859; it indeed crashes before gh-116028 with PYTHONUOPSOPTIMIZE=1
- Re-enable the optimizer pass in T2, stop checking PYTHONUOPSOPTIMIZE
- Rename the env var to disable T2 entirely to PYTHON_UOPS_OPTIMIZE (must be explicitly set to 0 to disable)
- Fix skipIf conditions on tests in test_opt.py accordingly
- Export sym_is_bottom() (for debugging)
- Fix various things in the `_BINARY_OP_` specializations in the abstract interpreter:
- DECREF(temp)
- out-of-space check after sym_new_const()
- add sym_matches_type() checks, so even if we somehow reach a binary op with symbolic constants of the wrong type on the stack we won't trigger the type assert
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_capi/test_opt.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py index 25fc36d..e1aef21 100644 --- a/Lib/test/test_capi/test_opt.py +++ b/Lib/test/test_capi/test_opt.py @@ -210,6 +210,8 @@ class TestExecutorInvalidation(unittest.TestCase): exe = get_first_executor(f) self.assertIsNone(exe) + +@unittest.skipIf(os.getenv("PYTHON_UOPS_OPTIMIZE") == "0", "Needs uop optimizer to run.") class TestUops(unittest.TestCase): def test_basic_loop(self): @@ -570,7 +572,7 @@ class TestUops(unittest.TestCase): self.assertLessEqual(count, 2) -@unittest.skipIf(os.getenv("PYTHONUOPSOPTIMIZE", default=0) == 0, "Needs uop optimizer to run.") +@unittest.skipIf(os.getenv("PYTHON_UOPS_OPTIMIZE") == "0", "Needs uop optimizer to run.") class TestUopsOptimization(unittest.TestCase): def _run_with_optimizer(self, testfunc, arg): @@ -890,5 +892,22 @@ class TestUopsOptimization(unittest.TestCase): self.assertLessEqual(len(guard_both_float_count), 1) self.assertIn("_COMPARE_OP_STR", uops) + def test_type_inconsistency(self): + def testfunc(n): + for i in range(n): + x = _test_global + _test_global + # Must be a real global else it won't be optimized to _LOAD_CONST_INLINE + global _test_global + _test_global = 0 + _, ex = self._run_with_optimizer(testfunc, 16) + self.assertIsNone(ex) + _test_global = 1.2 + _, ex = self._run_with_optimizer(testfunc, 16) + self.assertIsNotNone(ex) + uops = get_opnames(ex) + self.assertIn("_GUARD_BOTH_INT", uops) + self.assertIn("_BINARY_OP_ADD_INT", uops) + + if __name__ == "__main__": unittest.main() |