28
28
29
29
#define MAX_EXECUTORS_SIZE 256
30
30
31
+ #define _PyExecutorObject_CAST (op ) ((_PyExecutorObject *)(op))
32
+
31
33
static bool
32
34
has_space_for_executor (PyCodeObject * code , _Py_CODEUNIT * instr )
33
35
{
@@ -199,11 +201,12 @@ get_oparg(PyObject *self, PyObject *Py_UNUSED(ignored))
199
201
200
202
///////////////////// Experimental UOp Optimizer /////////////////////
201
203
202
- static int executor_clear (_PyExecutorObject * executor );
204
+ static int executor_clear (PyObject * executor );
203
205
static void unlink_executor (_PyExecutorObject * executor );
204
206
205
207
static void
206
- uop_dealloc (_PyExecutorObject * self ) {
208
+ uop_dealloc (PyObject * op ) {
209
+ _PyExecutorObject * self = _PyExecutorObject_CAST (op );
207
210
_PyObject_GC_UNTRACK (self );
208
211
assert (self -> vm_data .code == NULL );
209
212
unlink_executor (self );
@@ -260,15 +263,17 @@ _PyUOpPrint(const _PyUOpInstruction *uop)
260
263
#endif
261
264
262
265
static Py_ssize_t
263
- uop_len (_PyExecutorObject * self )
266
+ uop_len (PyObject * op )
264
267
{
268
+ _PyExecutorObject * self = _PyExecutorObject_CAST (op );
265
269
return self -> code_size ;
266
270
}
267
271
268
272
static PyObject *
269
- uop_item (_PyExecutorObject * self , Py_ssize_t index )
273
+ uop_item (PyObject * op , Py_ssize_t index )
270
274
{
271
- Py_ssize_t len = uop_len (self );
275
+ _PyExecutorObject * self = _PyExecutorObject_CAST (op );
276
+ Py_ssize_t len = uop_len (op );
272
277
if (index < 0 || index >= len ) {
273
278
PyErr_SetNone (PyExc_IndexError );
274
279
return NULL ;
@@ -304,14 +309,14 @@ uop_item(_PyExecutorObject *self, Py_ssize_t index)
304
309
}
305
310
306
311
PySequenceMethods uop_as_sequence = {
307
- .sq_length = ( lenfunc ) uop_len ,
308
- .sq_item = ( ssizeargfunc ) uop_item ,
312
+ .sq_length = uop_len ,
313
+ .sq_item = uop_item ,
309
314
};
310
315
311
316
static int
312
317
executor_traverse (PyObject * o , visitproc visit , void * arg )
313
318
{
314
- _PyExecutorObject * executor = ( _PyExecutorObject * ) o ;
319
+ _PyExecutorObject * executor = _PyExecutorObject_CAST ( o ) ;
315
320
for (uint32_t i = 0 ; i < executor -> exit_count ; i ++ ) {
316
321
Py_VISIT (executor -> exits [i ].executor );
317
322
}
@@ -325,7 +330,7 @@ get_jit_code(PyObject *self, PyObject *Py_UNUSED(ignored))
325
330
PyErr_SetString (PyExc_RuntimeError , "JIT support not enabled." );
326
331
return NULL ;
327
332
#else
328
- _PyExecutorObject * executor = ( _PyExecutorObject * ) self ;
333
+ _PyExecutorObject * executor = _PyExecutorObject_CAST ( self ) ;
329
334
if (executor -> jit_code == NULL || executor -> jit_size == 0 ) {
330
335
Py_RETURN_NONE ;
331
336
}
@@ -353,11 +358,11 @@ PyTypeObject _PyUOpExecutor_Type = {
353
358
.tp_basicsize = offsetof(_PyExecutorObject , exits ),
354
359
.tp_itemsize = 1 ,
355
360
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION | Py_TPFLAGS_HAVE_GC ,
356
- .tp_dealloc = ( destructor ) uop_dealloc ,
361
+ .tp_dealloc = uop_dealloc ,
357
362
.tp_as_sequence = & uop_as_sequence ,
358
363
.tp_methods = uop_executor_methods ,
359
364
.tp_traverse = executor_traverse ,
360
- .tp_clear = ( inquiry ) executor_clear ,
365
+ .tp_clear = executor_clear ,
361
366
.tp_is_gc = executor_is_gc ,
362
367
};
363
368
@@ -1422,8 +1427,9 @@ _Py_ExecutorDetach(_PyExecutorObject *executor)
1422
1427
}
1423
1428
1424
1429
static int
1425
- executor_clear (_PyExecutorObject * executor )
1430
+ executor_clear (PyObject * op )
1426
1431
{
1432
+ _PyExecutorObject * executor = _PyExecutorObject_CAST (op );
1427
1433
if (!executor -> vm_data .valid ) {
1428
1434
return 0 ;
1429
1435
}
@@ -1479,7 +1485,7 @@ _Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj, int is
1479
1485
exec = next ;
1480
1486
}
1481
1487
for (Py_ssize_t i = 0 ; i < PyList_GET_SIZE (invalidate ); i ++ ) {
1482
- _PyExecutorObject * exec = ( _PyExecutorObject * ) PyList_GET_ITEM (invalidate , i );
1488
+ PyObject * exec = PyList_GET_ITEM (invalidate , i );
1483
1489
executor_clear (exec );
1484
1490
if (is_invalidation ) {
1485
1491
OPT_STAT_INC (executors_invalidated );
@@ -1506,7 +1512,7 @@ _Py_Executors_InvalidateAll(PyInterpreterState *interp, int is_invalidation)
1506
1512
_PyCode_Clear_Executors (executor -> vm_data .code );
1507
1513
}
1508
1514
else {
57A6
div>
1509
- executor_clear (executor );
1515
+ executor_clear (( PyObject * ) executor );
1510
1516
}
1511
1517
if (is_invalidation ) {
1512
1518
OPT_STAT_INC (executors_invalidated );
@@ -1540,7 +1546,7 @@ _Py_Executors_InvalidateCold(PyInterpreterState *interp)
1540
1546
exec = next ;
1541
1547
}
1542
1548
for (Py_ssize_t i = 0 ; i < PyList_GET_SIZE (invalidate ); i ++ ) {
1543
- _PyExecutorObject * exec = ( _PyExecutorObject * ) PyList_GET_ITEM (invalidate , i );
1549
+ PyObject * exec = PyList_GET_ITEM (invalidate , i );
1544
1550
executor_clear (exec );
1545
1551
}
1546
1552
Py_DECREF (invalidate );
0 commit comments