| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2832,6 +2832,18 @@ def testfunc(n): | |||
| 2832 | 2832 | self.assertIn("_GUARD_TYPE_VERSION", uops) | |
| 2833 | 2833 | self.assertNotIn("_CHECK_ATTR_CLASS", uops) | |
| 2834 | 2834 | ||
| 2835 | + def test_load_common_constant(self): | ||
| 2836 | + def testfunc(n): | ||
| 2837 | + for _ in range(n): | ||
| 2838 | + x = list(i for i in ()) | ||
| 2839 | + return x | ||
| 2840 | + res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD) | ||
| 2841 | + self.assertEqual(res, list(())) | ||
| 2842 | + self.assertIsNotNone(ex) | ||
| 2843 | + uops = get_opnames(ex) | ||
| 2844 | + self.assertIn("_BUILD_LIST", uops) | ||
| 2845 | + self.assertNotIn("_LOAD_COMMON_CONSTANT", uops) | ||
| 2846 | + | ||
| 2835 | 2847 | def test_load_small_int(self): | |
| 2836 | 2848 | def testfunc(n): | |
| 2837 | 2849 | x = 0 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -631,6 +631,13 @@ dummy_func(void) { | |||
| 631 | 631 | value = PyJitRef_Borrow(sym_new_const(ctx, val)); | |
| 632 | 632 | } | |
| 633 | 633 | ||
| 634 | + op(_LOAD_COMMON_CONSTANT, (-- value)) { | ||
| 635 | + assert(oparg < NUM_COMMON_CONSTANTS); | ||
| 636 | + PyObject *val = _PyInterpreterState_GET()->common_consts[oparg]; | ||
| 637 | + ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val); | ||
| 638 | + value = PyJitRef_Borrow(sym_new_const(ctx, val)); | ||
| 639 | + } | ||
| 640 | + | ||
| 634 | 641 | op(_LOAD_SMALL_INT, (-- value)) { | |
| 635 | 642 | PyObject *val = PyLong_FromLong(oparg); | |
| 636 | 643 | assert(val); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments