gh-131798: Add _IS_NONE to the JIT optimizer (GH-148369)

This commit is contained in:
Wulian233 2026-04-11 23:02:46 +08:00 committed by GitHub
parent 1c89817f51
commit a059e85866
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 1 deletions

View file

@ -724,6 +724,16 @@ dummy_func(void) {
r = right;
}
op(_IS_NONE, (value -- b)) {
if (sym_is_const(ctx, value)) {
PyObject *value_o = sym_get_const(ctx, value);
b = sym_new_const(ctx, Py_IsNone(value_o) ? Py_True : Py_False);
}
else {
b = sym_new_type(ctx, &PyBool_Type);
}
}
op(_CONTAINS_OP, (left, right -- b, l, r)) {
b = sym_new_type(ctx, &PyBool_Type);
l = left;