summaryrefslogtreecommitdiffstats
path: root/Python/executor_cases.c.h
diff options
context:
space:
mode:
authorKen Jin <kenjin@python.org>2024-03-06 19:30:11 (GMT)
committerGitHub <noreply@github.com>2024-03-06 19:30:11 (GMT)
commit7114cf20c015b99123b32c1ba4f5475b7a6c3a13 (patch)
tree1c5392c31ac5d921cfb0b5856ff2df66cdfd4682 /Python/executor_cases.c.h
parent73807eb634315f70a464a18feaae33d9e065de09 (diff)
downloadcpython-7114cf20c015b99123b32c1ba4f5475b7a6c3a13.zip
cpython-7114cf20c015b99123b32c1ba4f5475b7a6c3a13.tar.gz
cpython-7114cf20c015b99123b32c1ba4f5475b7a6c3a13.tar.bz2
gh-116381: Specialize CONTAINS_OP (GH-116385)
* Specialize CONTAINS_OP * 📜🤖 Added by blurb_it. * Add PyAPI_FUNC for JIT --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r--Python/executor_cases.c.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index a057466..4420c40 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -2189,6 +2189,96 @@
break;
}
+ case _CONTAINS_OP_LIST: {
+ PyObject *right;
+ PyObject *left;
+ PyObject *b;
+ oparg = CURRENT_OPARG();
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ if (!PyList_CheckExact(right)) goto deoptimize;
+ int res = _PyList_Contains(right, left);
+ Py_DECREF(left);
+ Py_DECREF(right);
+ if (res < 0) goto pop_2_error_tier_two;
+ b = (res ^ oparg) ? Py_True : Py_False;
+ stack_pointer[-2] = b;
+ stack_pointer += -1;
+ break;
+ }
+
+ case _CONTAINS_OP_SET: {
+ PyObject *right;
+ PyObject *left;
+ PyObject *b;
+ oparg = CURRENT_OPARG();
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ if (!PySet_CheckExact(right)) goto deoptimize;
+ int res = _PySet_Contains((PySetObject *)right, left);
+ Py_DECREF(left);
+ Py_DECREF(right);
+ if (res < 0) goto pop_2_error_tier_two;
+ b = (res ^ oparg) ? Py_True : Py_False;
+ stack_pointer[-2] = b;
+ stack_pointer += -1;
+ break;
+ }
+
+ case _CONTAINS_OP_TUPLE: {
+ PyObject *right;
+ PyObject *left;
+ PyObject *b;
+ oparg = CURRENT_OPARG();
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ if (!PyTuple_CheckExact(right)) goto deoptimize;
+ int res = _PyTuple_Contains((PyTupleObject *)right, left);
+ Py_DECREF(left);
+ Py_DECREF(right);
+ if (res < 0) goto pop_2_error_tier_two;
+ b = (res ^ oparg) ? Py_True : Py_False;
+ stack_pointer[-2] = b;
+ stack_pointer += -1;
+ break;
+ }
+
+ case _CONTAINS_OP_DICT: {
+ PyObject *right;
+ PyObject *left;
+ PyObject *b;
+ oparg = CURRENT_OPARG();
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ if (!PyDict_CheckExact(right)) goto deoptimize;
+ int res = PyDict_Contains(right, left);
+ Py_DECREF(left);
+ Py_DECREF(right);
+ if (res < 0) goto pop_2_error_tier_two;
+ b = (res ^ oparg) ? Py_True : Py_False;
+ stack_pointer[-2] = b;
+ stack_pointer += -1;
+ break;
+ }
+
+ case _CONTAINS_OP_STR: {
+ PyObject *right;
+ PyObject *left;
+ PyObject *b;
+ oparg = CURRENT_OPARG();
+ right = stack_pointer[-1];
+ left = stack_pointer[-2];
+ if (!PyUnicode_CheckExact(right)) goto deoptimize;
+ int res = PyUnicode_Contains(right, left);
+ Py_DECREF(left);
+ Py_DECREF(right);
+ if (res < 0) goto pop_2_error_tier_two;
+ b = (res ^ oparg) ? Py_True : Py_False;
+ stack_pointer[-2] = b;
+ stack_pointer += -1;
+ break;
+ }
+
case _CHECK_EG_MATCH: {
PyObject *match_type;
PyObject *exc_value;