@@ -1489,27 +1489,19 @@ PyCode_GetFreevars(PyCodeObject *code)
14891489static void
14901490clear_executors (PyCodeObject * co )
14911491{
1492+ assert (co -> co_executors );
14921493 for (int i = 0 ; i < co -> co_executors -> size ; i ++ ) {
1493- Py_CLEAR (co -> co_executors -> executors [i ]);
1494+ if (co -> co_executors -> executors [i ]) {
1495+ _Py_ExecutorClear (co -> co_executors -> executors [i ]);
1496+ }
14941497 }
14951498 PyMem_Free (co -> co_executors );
14961499 co -> co_executors = NULL ;
14971500}
14981501
14991502void
1500- _PyCode_Clear_Executors (PyCodeObject * code ) {
1501- int code_len = (int )Py_SIZE (code );
1502- for (int i = 0 ; i < code_len ; i += _PyInstruction_GetLength (code , i )) {
1503- _Py_CODEUNIT * instr = & _PyCode_CODE (code )[i ];
1504- uint8_t opcode = instr -> op .code ;
1505- uint8_t oparg = instr -> op .arg ;
1506- if (opcode == ENTER_EXECUTOR ) {
1507- _PyExecutorObject * exec = code -> co_executors -> executors [oparg ];
1508- assert (exec -> vm_data .opcode != ENTER_EXECUTOR );
1509- instr -> op .code = exec -> vm_data .opcode ;
1510- instr -> op .arg = exec -> vm_data .oparg ;
1511- }
1512- }
1503+ _PyCode_Clear_Executors (PyCodeObject * code )
1504+ {
15131505 clear_executors (code );
15141506}
15151507
@@ -2360,10 +2352,10 @@ _PyCode_ConstantKey(PyObject *op)
23602352void
23612353_PyStaticCode_Fini (PyCodeObject * co )
23622354{
2363- deopt_code (co , _PyCode_CODE (co ));
23642355 if (co -> co_executors != NULL ) {
23652356 clear_executors (co );
23662357 }
2358+ deopt_code (co , _PyCode_CODE (co ));
23672359 PyMem_Free (co -> co_extra );
23682360 if (co -> _co_cached != NULL ) {
23692361 Py_CLEAR (co -> _co_cached -> _co_code );
0 commit comments