@@ -320,13 +320,7 @@ uop_name(int index) {
320
320
static Py_ssize_t
321
321
uop_len (_PyUOpExecutorObject * self )
322
322
{
323
- int count = 0 ;
324
- for (; count < _Py_UOP_MAX_TRACE_LENGTH ; count ++ ) {
325
- if (self -> trace [count ].opcode == 0 ) {
326
- break ;
327
- }
328
- }
329
- return count ;
323
+ return Py_SIZE (self );
330
324
}
331
325
332
326
static PyObject *
@@ -368,8 +362,8 @@ PySequenceMethods uop_as_sequence = {
368
362
static PyTypeObject UOpExecutor_Type = {
369
363
PyVarObject_HEAD_INIT (& PyType_Type , 0 )
370
364
.tp_name = "uop_executor" ,
371
- .tp_basicsize = sizeof (_PyUOpExecutorObject ),
372
- .tp_itemsize = 0 ,
365
+ .tp_basicsize = sizeof (_PyUOpExecutorObject ) - sizeof ( _PyUOpInstruction ) ,
366
+ .tp_itemsize = sizeof ( _PyUOpInstruction ) ,
373
367
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION ,
374
368
.tp_dealloc = (destructor )uop_dealloc ,
375
369
.tp_as_sequence = & uop_as_sequence ,
@@ -699,15 +693,12 @@ uop_optimize(
699
693
return trace_length ;
700
694
}
701
695
OBJECT_STAT_INC (optimization_traces_created );
702
- _PyUOpExecutorObject * executor = PyObject_New (_PyUOpExecutorObject , & UOpExecutor_Type );
696
+ _PyUOpExecutorObject * executor = PyObject_NewVar (_PyUOpExecutorObject , & UOpExecutor_Type , trace_length );
703
697
if (executor == NULL ) {
704
698
return -1 ;
705
699
}
706
700
executor -> base .execute = _PyUopExecute ;
707
701
memcpy (executor -> trace , trace , trace_length * sizeof (_PyUOpInstruction ));
708
- if (trace_length < _Py_UOP_MAX_TRACE_LENGTH ) {
709
- executor -> trace [trace_length ].opcode = 0 ; // Sentinel
710
- }
711
702
* exec_ptr = (_PyExecutorObject * )executor ;
712
703
return 1 ;
713
704
}
0 commit comments