mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
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
This commit is contained in:
parent
75c6c05fea
commit
3409bc29c9
7 changed files with 96 additions and 28 deletions
|
|
@ -210,6 +210,8 @@ def f():
|
|||
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 @@ def testfunc(n):
|
|||
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 @@ def testfunc(n):
|
|||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue