self.assertIn("_GUARD_TYPE_VERSION", uops)
self.assertNotIn("_CHECK_ATTR_CLASS", uops)
+ def test_load_common_constant(self):
+ def testfunc(n):
+ for _ in range(n):
+ x = list(i for i in ())
+ return x
+ res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
+ self.assertEqual(res, list(()))
+ self.assertIsNotNone(ex)
+ uops = get_opnames(ex)
+ self.assertIn("_BUILD_LIST", uops)
+ self.assertNotIn("_LOAD_COMMON_CONSTANT", uops)
+
def test_load_small_int(self):
def testfunc(n):
x = 0
value = PyJitRef_Borrow(sym_new_const(ctx, val));
}
+ op(_LOAD_COMMON_CONSTANT, (-- value)) {
+ assert(oparg < NUM_COMMON_CONSTANTS);
+ PyObject *val = _PyInterpreterState_GET()->common_consts[oparg];
+ ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val);
+ value = PyJitRef_Borrow(sym_new_const(ctx, val));
+ }
+
op(_LOAD_SMALL_INT, (-- value)) {
PyObject *val = PyLong_FromLong(oparg);
assert(val);
case _LOAD_COMMON_CONSTANT: {
JitOptRef value;
- value = sym_new_not_null(ctx);
+ assert(oparg < NUM_COMMON_CONSTANTS);
+ PyObject *val = _PyInterpreterState_GET()->common_consts[oparg];
+ ADD_OP(_LOAD_CONST_INLINE_BORROW, 0, (uintptr_t)val);
+ value = PyJitRef_Borrow(sym_new_const(ctx, val));
CHECK_STACK_BOUNDS(1);
stack_pointer[0] = value;
stack_pointer += 1;