@@ -57,14 +57,14 @@ static uint8_t adaptive_opcodes[256] = {
5757
5858/* The number of cache entries required for a "family" of instructions. */
5959static uint8_t cache_requirements [256 ] = {
60- [LOAD_ATTR ] = 2 , /* _PyAdaptiveEntry and _PyAttrCache */
60+ [LOAD_ATTR ] = 1 , // _PyAdaptiveEntry
6161 [LOAD_GLOBAL ] = 2 , /* _PyAdaptiveEntry and _PyLoadGlobalCache */
6262 [LOAD_METHOD ] = 3 , /* _PyAdaptiveEntry, _PyAttrCache and _PyObjectCache */
6363 [BINARY_SUBSCR ] = 2 , /* _PyAdaptiveEntry, _PyObjectCache */
6464 [STORE_SUBSCR ] = 0 ,
6565 [CALL ] = 2 , /* _PyAdaptiveEntry and _PyObjectCache/_PyCallCache */
6666 [PRECALL ] = 2 , /* _PyAdaptiveEntry and _PyObjectCache/_PyCallCache */
67- [STORE_ATTR ] = 2 , /* _PyAdaptiveEntry and _PyAttrCache */
67+ [STORE_ATTR ] = 1 , // _PyAdaptiveEntry
6868 [BINARY_OP ] = 1 , // _PyAdaptiveEntry
6969 [COMPARE_OP ] = 1 , /* _PyAdaptiveEntry */
7070 [UNPACK_SEQUENCE ] = 1 , // _PyAdaptiveEntry
@@ -638,7 +638,7 @@ initial_counter_value(void) {
638638static int
639639specialize_module_load_attr (
640640 PyObject * owner , _Py_CODEUNIT * instr , PyObject * name ,
641- _PyAdaptiveEntry * cache0 , _PyAttrCache * cache1 , int opcode ,
641+ _PyAdaptiveEntry * cache0 , int opcode ,
642642 int opcode_module )
643643{
644644 PyModuleObject * m = (PyModuleObject * )owner ;
@@ -671,7 +671,7 @@ specialize_module_load_attr(
671671 SPECIALIZATION_FAIL (opcode , SPEC_FAIL_OUT_OF_VERSIONS );
672672 return -1 ;
673673 }
674- cache1 -> dk_version_or_hint = keys_version ;
674+ cache0 -> version = keys_version ;
675675 cache0 -> index = (uint16_t )index ;
676676 * instr = _Py_MAKECODEUNIT (opcode_module , _Py_OPARG (* instr ));
677677 return 0 ;
@@ -760,7 +760,7 @@ static int
760760specialize_dict_access (
761761 PyObject * owner , _Py_CODEUNIT * instr , PyTypeObject * type ,
762762 DescriptorClassification kind , PyObject * name ,
763- _PyAdaptiveEntry * cache0 , _PyAttrCache * cache1 ,
763+ _PyAdaptiveEntry * cache0 ,
764764 int base_op , int values_op , int hint_op )
765765{
766766 assert (kind == NON_OVERRIDING || kind == NON_DESCRIPTOR || kind == ABSENT ||
@@ -782,7 +782,7 @@ specialize_dict_access(
782782 SPECIALIZATION_FAIL (base_op , SPEC_FAIL_OUT_OF_RANGE );
783783 return 0 ;
784784 }
785- cache1 -> tp_version = type -> tp_version_tag ;
785+ cache0 -> version = type -> tp_version_tag ;
786786 cache0 -> index = (uint16_t )index ;
787787 * instr = _Py_MAKECODEUNIT (values_op , _Py_OPARG (* instr ));
788788 }
@@ -795,12 +795,12 @@ specialize_dict_access(
795795 PyObject * value = NULL ;
796796 Py_ssize_t hint =
797797 _PyDict_GetItemHint (dict , name , -1 , & value );
798- if (hint != (uint32_t )hint ) {
798+ if (hint != (uint16_t )hint ) {
799799 SPECIALIZATION_FAIL (base_op , SPEC_FAIL_OUT_OF_RANGE );
800800 return 0 ;
801801 }
802- cache1 -> dk_version_or_hint = (uint32_t )hint ;
803- cache1 -> tp_version = type -> tp_version_tag ;
802+ cache0 -> index = (uint16_t )hint ;
803+ cache0 -> version = type -> tp_version_tag ;
804804 * instr = _Py_MAKECODEUNIT (hint_op , _Py_OPARG (* instr ));
805805 }
806806 return 1 ;
810810_Py_Specialize_LoadAttr (PyObject * owner , _Py_CODEUNIT * instr , PyObject * name , SpecializedCacheEntry * cache )
811811{
812812 _PyAdaptiveEntry * cache0 = & cache -> adaptive ;
813- _PyAttrCache * cache1 = & cache [-1 ].attr ;
814813 if (PyModule_CheckExact (owner )) {
815- int err = specialize_module_load_attr (owner , instr , name , cache0 , cache1 ,
814+ int err = specialize_module_load_attr (owner , instr , name , cache0 ,
816815 LOAD_ATTR , LOAD_ATTR_MODULE );
817816 if (err ) {
818817 goto fail ;
@@ -853,7 +852,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, Sp
853852 assert (dmem -> type == T_OBJECT_EX );
854853 assert (offset > 0 );
855854 cache0 -> index = (uint16_t )offset ;
856- cache1 -> tp_version = type -> tp_version_tag ;
855+ cache0 -> version = type -> tp_version_tag ;
857856 * instr = _Py_MAKECODEUNIT (LOAD_ATTR_SLOT , _Py_OPARG (* instr ));
858857 goto success ;
859858 }
@@ -862,7 +861,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, Sp
862861 Py_ssize_t offset = offsetof(PyObject , ob_type );
863862 assert (offset == (uint16_t )offset );
864863 cache0 -> index = (uint16_t )offset ;
865- cache1 -> tp_version = type -> tp_version_tag ;
864+ cache0 -> version = type -> tp_version_tag ;
866865 * instr = _Py_MAKECODEUNIT (LOAD_ATTR_SLOT , _Py_OPARG (* instr ));
867866 goto success ;
868867 }
@@ -883,7 +882,7 @@ _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, Sp
883882 break ;
884883 }
885884 int err = specialize_dict_access (
886- owner , instr , type , kind , name , cache0 , cache1 ,
885+ owner , instr , type , kind , name , cache0 ,
887886 LOAD_ATTR , LOAD_ATTR_INSTANCE_VALUE , LOAD_ATTR_WITH_HINT
888887 );
889888 if (err < 0 ) {
908907_Py_Specialize_StoreAttr (PyObject * owner , _Py_CODEUNIT * instr , PyObject * name , SpecializedCacheEntry * cache )
909908{
910909 _PyAdaptiveEntry * cache0 = & cache -> adaptive ;
911- _PyAttrCache * cache1 = & cache [-1 ].attr ;
912910 PyTypeObject * type = Py_TYPE (owner );
913911 if (PyModule_CheckExact (owner )) {
914912 SPECIALIZATION_FAIL (STORE_ATTR , SPEC_FAIL_OVERRIDDEN );
@@ -942,7 +940,7 @@ _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, S
942940 assert (dmem -> type == T_OBJECT_EX );
943941 assert (offset > 0 );
944942 cache0 -> index = (uint16_t )offset ;
945- cache1 -> tp_version = type -> tp_version_tag ;
943+ cache0 -> version = type -> tp_version_tag ;
946944 * instr = _Py_MAKECODEUNIT (STORE_ATTR_SLOT , _Py_OPARG (* instr ));
947945 goto success ;
948946 }
@@ -965,7 +963,7 @@ _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name, S
965963 }
966964
967965 int err = specialize_dict_access (
968- owner , instr , type , kind , name , cache0 , cache1 ,
966+ owner , instr , type , kind , name , cache0 ,
969967 STORE_ATTR , STORE_ATTR_INSTANCE_VALUE , STORE_ATTR_WITH_HINT
970968 );
971969 if (err < 0 ) {
@@ -1066,7 +1064,7 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
10661064
10671065 PyTypeObject * owner_cls = Py_TYPE (owner );
10681066 if (PyModule_CheckExact (owner )) {
1069- int err = specialize_module_load_attr (owner , instr , name , cache0 , cache1 ,
1067+ int err = specialize_module_load_attr (owner , instr , name , cache0 ,
10701068 LOAD_METHOD , LOAD_METHOD_MODULE );
10711069 if (err ) {
10721070 goto fail ;
@@ -1111,7 +1109,7 @@ _Py_Specialize_LoadMethod(PyObject *owner, _Py_CODEUNIT *instr, PyObject *name,
11111109 SPECIALIZATION_FAIL (LOAD_METHOD , SPEC_FAIL_OUT_OF_VERSIONS );
11121110 goto fail ;
11131111 }
1114- cache1 -> dk_version_or_hint = keys_version ;
1112+ cache1 -> dk_version = keys_version ;
11151113 * instr = _Py_MAKECODEUNIT (LOAD_METHOD_CACHED , _Py_OPARG (* instr ));
11161114 }
11171115 else {
0 commit comments