mirror of
https://github.com/python/cpython.git
synced 2026-02-22 07:00:51 +00:00
gh-141510: Update specializer to support frozendict (gh-144949)
This commit is contained in:
parent
a18e0fa4c0
commit
3e2f5c133f
8 changed files with 70 additions and 27 deletions
|
|
@ -1058,12 +1058,12 @@ dummy_func(
|
|||
|
||||
op(_GUARD_NOS_DICT, (nos, unused -- nos, unused)) {
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
|
||||
EXIT_IF(!PyDict_CheckExact(o));
|
||||
EXIT_IF(!PyAnyDict_CheckExact(o));
|
||||
}
|
||||
|
||||
op(_GUARD_TOS_DICT, (tos -- tos)) {
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(tos);
|
||||
EXIT_IF(!PyDict_CheckExact(o));
|
||||
EXIT_IF(!PyAnyDict_CheckExact(o));
|
||||
}
|
||||
|
||||
macro(BINARY_OP_SUBSCR_DICT) =
|
||||
|
|
@ -1073,7 +1073,7 @@ dummy_func(
|
|||
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
|
||||
PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st);
|
||||
|
||||
assert(PyDict_CheckExact(dict));
|
||||
assert(PyAnyDict_CheckExact(dict));
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
PyObject *res_o;
|
||||
int rc = PyDict_GetItemRef(dict, sub, &res_o);
|
||||
|
|
@ -2940,7 +2940,7 @@ dummy_func(
|
|||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
|
||||
assert(PyDict_CheckExact(right_o));
|
||||
assert(PyAnyDict_CheckExact(right_o));
|
||||
STAT_INC(CONTAINS_OP, hit);
|
||||
int res = PyDict_Contains(right_o, left_o);
|
||||
if (res < 0) {
|
||||
|
|
|
|||
20
Python/executor_cases.c.h
generated
20
Python/executor_cases.c.h
generated
|
|
@ -5920,7 +5920,7 @@
|
|||
_PyStackRef nos;
|
||||
nos = stack_pointer[-2];
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
|
|
@ -5941,7 +5941,7 @@
|
|||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
nos = stack_pointer[-1];
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache0 = _stack_item_0;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
|
|
@ -5964,7 +5964,7 @@
|
|||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
nos = _stack_item_0;
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache1 = _stack_item_1;
|
||||
_tos_cache0 = nos;
|
||||
|
|
@ -5987,7 +5987,7 @@
|
|||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
nos = _stack_item_1;
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache2 = _stack_item_2;
|
||||
_tos_cache1 = nos;
|
||||
|
|
@ -6009,7 +6009,7 @@
|
|||
_PyStackRef tos;
|
||||
tos = stack_pointer[-1];
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(tos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
SET_CURRENT_CACHED_VALUES(0);
|
||||
JUMP_TO_JUMP_TARGET();
|
||||
|
|
@ -6029,7 +6029,7 @@
|
|||
_PyStackRef _stack_item_0 = _tos_cache0;
|
||||
tos = _stack_item_0;
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(tos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache0 = tos;
|
||||
SET_CURRENT_CACHED_VALUES(1);
|
||||
|
|
@ -6049,7 +6049,7 @@
|
|||
_PyStackRef _stack_item_1 = _tos_cache1;
|
||||
tos = _stack_item_1;
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(tos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache1 = tos;
|
||||
_tos_cache0 = _stack_item_0;
|
||||
|
|
@ -6072,7 +6072,7 @@
|
|||
_PyStackRef _stack_item_2 = _tos_cache2;
|
||||
tos = _stack_item_2;
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(tos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UOP_STAT_INC(uopcode, miss);
|
||||
_tos_cache2 = tos;
|
||||
_tos_cache1 = _stack_item_1;
|
||||
|
|
@ -6102,7 +6102,7 @@
|
|||
dict_st = _stack_item_0;
|
||||
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
|
||||
PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st);
|
||||
assert(PyDict_CheckExact(dict));
|
||||
assert(PyAnyDict_CheckExact(dict));
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
PyObject *res_o;
|
||||
stack_pointer[0] = dict_st;
|
||||
|
|
@ -10393,7 +10393,7 @@
|
|||
left = _stack_item_0;
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
assert(PyDict_CheckExact(right_o));
|
||||
assert(PyAnyDict_CheckExact(right_o));
|
||||
STAT_INC(CONTAINS_OP, hit);
|
||||
stack_pointer[0] = left;
|
||||
stack_pointer[1] = right;
|
||||
|
|
|
|||
10
Python/generated_cases.c.h
generated
10
Python/generated_cases.c.h
generated
|
|
@ -642,7 +642,7 @@
|
|||
{
|
||||
nos = stack_pointer[-2];
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UPDATE_MISS_STATS(BINARY_OP);
|
||||
assert(_PyOpcode_Deopt[opcode] == (BINARY_OP));
|
||||
JUMP_TO_PREDICTED(BINARY_OP);
|
||||
|
|
@ -655,7 +655,7 @@
|
|||
dict_st = nos;
|
||||
PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
|
||||
PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st);
|
||||
assert(PyDict_CheckExact(dict));
|
||||
assert(PyAnyDict_CheckExact(dict));
|
||||
STAT_INC(BINARY_OP, hit);
|
||||
PyObject *res_o;
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
|
|
@ -5139,7 +5139,7 @@
|
|||
{
|
||||
tos = stack_pointer[-1];
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(tos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UPDATE_MISS_STATS(CONTAINS_OP);
|
||||
assert(_PyOpcode_Deopt[opcode] == (CONTAINS_OP));
|
||||
JUMP_TO_PREDICTED(CONTAINS_OP);
|
||||
|
|
@ -5152,7 +5152,7 @@
|
|||
left = stack_pointer[-2];
|
||||
PyObject *left_o = PyStackRef_AsPyObjectBorrow(left);
|
||||
PyObject *right_o = PyStackRef_AsPyObjectBorrow(right);
|
||||
assert(PyDict_CheckExact(right_o));
|
||||
assert(PyAnyDict_CheckExact(right_o));
|
||||
STAT_INC(CONTAINS_OP, hit);
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
int res = PyDict_Contains(right_o, left_o);
|
||||
|
|
@ -11479,7 +11479,7 @@
|
|||
{
|
||||
nos = stack_pointer[-2];
|
||||
PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
|
||||
if (!PyDict_CheckExact(o)) {
|
||||
if (!PyAnyDict_CheckExact(o)) {
|
||||
UPDATE_MISS_STATS(STORE_SUBSCR);
|
||||
assert(_PyOpcode_Deopt[opcode] == (STORE_SUBSCR));
|
||||
JUMP_TO_PREDICTED(STORE_SUBSCR);
|
||||
|
|
|
|||
|
|
@ -2287,7 +2287,7 @@ _Py_Specialize_BinaryOp(_PyStackRef lhs_st, _PyStackRef rhs_st, _Py_CODEUNIT *in
|
|||
}
|
||||
}
|
||||
}
|
||||
if (PyDict_CheckExact(lhs)) {
|
||||
if (PyAnyDict_CheckExact(lhs)) {
|
||||
specialize(instr, BINARY_OP_SUBSCR_DICT);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2767,7 +2767,7 @@ _Py_Specialize_ContainsOp(_PyStackRef value_st, _Py_CODEUNIT *instr)
|
|||
|
||||
assert(ENABLE_SPECIALIZATION);
|
||||
assert(_PyOpcode_Caches[CONTAINS_OP] == INLINE_CACHE_ENTRIES_COMPARE_OP);
|
||||
if (PyDict_CheckExact(value)) {
|
||||
if (PyAnyDict_CheckExact(value)) {
|
||||
specialize(instr, CONTAINS_OP_DICT);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue