gh-131798: Add _IS_NONE to the JIT optimizer#148369
gh-131798: Add _IS_NONE to the JIT optimizer#148369Wulian233 wants to merge 3 commits intopython:mainfrom
_IS_NONE to the JIT optimizer#148369Conversation
Fidget-Spinner
left a comment
There was a problem hiding this comment.
Thanks for contributing to the JIT, and welcome!
| if (sym_is_const(ctx, value)) { | ||
| PyObject *value_o = sym_get_const(ctx, value); | ||
| assert(value_o != NULL); | ||
| b = sym_new_const(ctx, Py_IsNone(value_o) ? Py_True : Py_False); | ||
| } | ||
| else if (sym_has_type(value)) { | ||
| b = sym_new_const(ctx, sym_matches_type(value, &_PyNone_Type) ? Py_True : Py_False); | ||
| } | ||
| else { | ||
| b = sym_new_type(ctx, &PyBool_Type); | ||
| } | ||
| } |
There was a problem hiding this comment.
You can replace this whole chunk with
b = sym_new_type(ctx, &PyBool_Type);
REPLACE_OPCODE_IF_EVALUATES_PURE(value, b);
There was a problem hiding this comment.
Thank you! Currently, I have the following code in my local environment:
op(_IS_NONE, (value -- b)) {
b = sym_new_type(ctx, &PyBool_Type);
REPLACE_OPCODE_IF_EVALUATES_PURE(value, b);
}However, when running optimizer_generator.py, it throws the following error:
File "E:/cpython/Python/bytecodes.c", line 3519
^
SyntaxError: 'value' is cleared on some paths, but not all
next step, should I replace
Lines 3511 to 3520 in 72006a7
with the following?
op(_IS_NONE, (value -- b)) {
b = PyStackRef_IsNone(value) ? PyStackRef_True : PyStackRef_False;
DECREF_INPUTS();
}I apologize if this is a basic question
There was a problem hiding this comment.
Are you sure you're in the right file? You should be editing optimizer_bytecodes.c not bytecodes.c
There was a problem hiding this comment.
That's probably a bug in the cases generator then. Let's just use your current approach for now but fixed.

Hello! This is my first time submitting something to JIT. I'm still learning, so there may be some mistakes. Welcome corrections!