@@ -738,10 +738,8 @@ unspecialize(_Py_CODEUNIT *instr)
738738}
739739
740740static int function_kind (PyCodeObject * code );
741- #ifndef Py_GIL_DISABLED
742741static bool function_check_args (PyObject * o , int expected_argcount , int opcode );
743742static uint32_t function_get_version (PyObject * o , int opcode );
744- #endif
745743static uint32_t type_get_version (PyTypeObject * t , int opcode );
746744
747745static int
@@ -1012,7 +1010,9 @@ specialize_attr_loadclassattr(PyObject *owner, _Py_CODEUNIT *instr,
10121010 PyObject * name , PyObject * descr ,
10131011 DescriptorClassification kind , bool is_method ,
10141012 uint32_t shared_keys_version );
1013+ #ifndef Py_GIL_DISABLED
10151014static int specialize_class_load_attr (PyObject * owner , _Py_CODEUNIT * instr , PyObject * name );
1015+ #endif
10161016
10171017/* Returns true if instances of obj's class are
10181018 * likely to have `name` in their __dict__.
@@ -1046,6 +1046,20 @@ instance_has_key(PyObject *obj, PyObject *name, uint32_t *shared_keys_version)
10461046 return true;
10471047}
10481048
1049+ #ifdef Py_GIL_DISABLED
1050+
1051+ #define FT_UNIMPLEMENTED () \
1052+ do { \
1053+ SPECIALIZATION_FAIL(LOAD_ATTR, SPEC_FAIL_EXPECTED_ERROR); \
1054+ return -1; \
1055+ } while (0)
1056+
1057+ #else
1058+
1059+ #define FT_UNIMPLEMENTED ()
1060+
1061+ #endif
1062+
10491063static int
10501064specialize_instance_load_attr (PyObject * owner , _Py_CODEUNIT * instr , PyObject * name )
10511065{
@@ -1066,6 +1080,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
10661080 return -1 ;
10671081 case METHOD :
10681082 {
1083+ FT_UNIMPLEMENTED ();
10691084 if (shadow ) {
10701085 goto try_instance ;
10711086 }
@@ -1085,6 +1100,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
10851100 }
10861101 case PROPERTY :
10871102 {
1103+ FT_UNIMPLEMENTED ();
10881104 _PyLoadMethodCache * lm_cache = (_PyLoadMethodCache * )(instr + 1 );
10891105 assert (Py_TYPE (descr ) == & PyProperty_Type );
10901106 PyObject * fget = ((_PyPropertyObject * )descr )-> prop_get ;
@@ -1116,6 +1132,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11161132 }
11171133 case OBJECT_SLOT :
11181134 {
1135+ FT_UNIMPLEMENTED ();
11191136 PyMemberDescrObject * member = (PyMemberDescrObject * )descr ;
11201137 struct PyMemberDef * dmem = member -> d_member ;
11211138 Py_ssize_t offset = dmem -> offset ;
@@ -1140,6 +1157,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11401157 }
11411158 case DUNDER_CLASS :
11421159 {
1160+ FT_UNIMPLEMENTED ();
11431161 Py_ssize_t offset = offsetof(PyObject , ob_type );
11441162 assert (offset == (uint16_t )offset );
11451163 cache -> index = (uint16_t )offset ;
@@ -1160,6 +1178,7 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11601178 {
11611179 assert (type -> tp_getattro == _Py_slot_tp_getattro );
11621180 assert (Py_IS_TYPE (descr , & PyFunction_Type ));
1181+ FT_UNIMPLEMENTED ();
11631182 _PyLoadMethodCache * lm_cache = (_PyLoadMethodCache * )(instr + 1 );
11641183 if (!function_check_args (descr , 2 , LOAD_ATTR )) {
11651184 return -1 ;
@@ -1191,6 +1210,8 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
11911210 }
11921211 return -1 ;
11931212 case NON_DESCRIPTOR :
1213+ FT_UNIMPLEMENTED ();
1214+
11941215 if (shadow ) {
11951216 goto try_instance ;
11961217 }
@@ -1211,6 +1232,8 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
12111232 }
12121233 Py_UNREACHABLE ();
12131234try_instance :
1235+ FT_UNIMPLEMENTED ();
1236+
12141237 if (specialize_dict_access (owner , instr , type , kind , name , LOAD_ATTR ,
12151238 LOAD_ATTR_INSTANCE_VALUE , LOAD_ATTR_WITH_HINT ))
12161239 {
@@ -1219,6 +1242,8 @@ specialize_instance_load_attr(PyObject* owner, _Py_CODEUNIT* instr, PyObject* na
12191242 return -1 ;
12201243}
12211244
1245+ #undef FT_UNIMPLEMENTED
1246+
12221247void
12231248_Py_Specialize_LoadAttr (_PyStackRef owner_st , _Py_CODEUNIT * instr , PyObject * name )
12241249{
@@ -1457,6 +1482,8 @@ specialize_class_load_attr(PyObject *owner, _Py_CODEUNIT *instr,
14571482 }
14581483}
14591484
1485+ #endif // Py_GIL_DISABLED
1486+
14601487// Please collect stats carefully before and after modifying. A subtle change
14611488// can cause a significant drop in cache hits. A possible test is
14621489// python.exe -m test_typing test_re test_dis test_zlib.
@@ -1536,8 +1563,6 @@ specialize_attr_loadclassattr(PyObject *owner, _Py_CODEUNIT *instr,
15361563 return 1 ;
15371564}
15381565
1539- #endif // Py_GIL_DISABLED
1540-
15411566
15421567static void
15431568specialize_load_global_lock_held (
@@ -1684,7 +1709,6 @@ function_kind(PyCodeObject *code) {
16841709 return SIMPLE_FUNCTION ;
16851710}
16861711
1687- #ifndef Py_GIL_DISABLED
16881712/* Returning false indicates a failure. */
16891713static bool
16901714function_check_args (PyObject * o , int expected_argcount , int opcode )
@@ -1717,7 +1741,6 @@ function_get_version(PyObject *o, int opcode)
17171741 }
17181742 return version ;
17191743}
1720- #endif // Py_GIL_DISABLED
17211744
17221745/* Returning 0 indicates a failure. */
17231746static uint32_t
0 commit comments