@@ -426,7 +426,6 @@ translate_bytecode_to_trace(
426
426
_Py_CODEUNIT * initial_instr = instr ;
427
427
int trace_length = 0 ;
428
428
int max_length = buffer_size ;
429
- int reserved = 0 ;
430
429
struct {
431
430
PyCodeObject * code ;
432
431
_Py_CODEUNIT * instr ;
@@ -456,8 +455,6 @@ translate_bytecode_to_trace(
456
455
(OPARG), \
457
456
(uint64_t)(OPERAND)); \
458
457
assert(trace_length < max_length); \
459
- assert(reserved > 0); \
460
- reserved--; \
461
458
trace[trace_length].opcode = (OPCODE); \
462
459
trace[trace_length].oparg = (OPARG); \
463
460
trace[trace_length].operand = (OPERAND); \
@@ -474,11 +471,10 @@ translate_bytecode_to_trace(
474
471
(opname), (n), max_length - trace_length); \
475
472
OPT_STAT_INC(trace_too_long); \
476
473
goto done; \
477
- } \
478
- reserved = (n); // Keep ADD_TO_TRACE honest
474
+ }
479
475
480
- // Reserve space for main+stub uops, plus 3 for _SET_IP, _CHECK_VALIDITY and _EXIT_TRACE
481
- #define RESERVE (main , stub ) RESERVE_RAW((main) + (stub ) + 3, _PyUopName(opcode))
476
+ // Reserve space for N uops, plus 3 for _SET_IP, _CHECK_VALIDITY and _EXIT_TRACE
477
+ #define RESERVE (needed ) RESERVE_RAW((needed ) + 3, _PyUopName(opcode))
482
478
483
479
// Trace stack operations (used by _PUSH_FRAME, _POP_FRAME)
484
480
#define TRACE_STACK_PUSH () \
@@ -543,7 +539,7 @@ translate_bytecode_to_trace(
543
539
case POP_JUMP_IF_FALSE :
544
540
case POP_JUMP_IF_TRUE :
545
541
{
546
- RESERVE (1 , 0 );
542
+ RESERVE (1 );
547
543
int counter = instr [1 ].cache ;
548
544
int bitcount = _Py_popcount32 (counter );
549
545
int jump_likely = bitcount > 8 ;
@@ -566,7 +562,7 @@ translate_bytecode_to_trace(
566
562
case JUMP_BACKWARD :
567
563
{
568
564
if (instr + 2 - oparg == initial_instr && code == initial_code ) {
569
- RESERVE (1 , 0 );
565
+ RESERVE (1 );
570
566
ADD_TO_TRACE (_JUMP_TO_TOP , 0 , 0 , 0 );
571
567
}
572
568
else {
@@ -578,7 +574,7 @@ translate_bytecode_to_trace(
578
574
579
575
case JUMP_FORWARD :
580
576
{
581
- RESERVE (0 , 0 );
577
+ RESERVE (0 );
582
578
// This will emit two _SET_IP instructions; leave it to the optimizer
583
579
instr += oparg ;
584
580
break ;
@@ -590,7 +586,7 @@ translate_bytecode_to_trace(
590
586
if (expansion -> nuops > 0 ) {
591
587
// Reserve space for nuops (+ _SET_IP + _EXIT_TRACE)
592
588
int nuops = expansion -> nuops ;
593
- RESERVE (nuops , 0 );
589
+ RESERVE (nuops );
594
590
if (expansion -> uops [nuops - 1 ].uop == _POP_FRAME ) {
595
591
// Check for trace stack underflow now:
596
592
// We can't bail e.g. in the middle of
@@ -737,13 +733,12 @@ translate_bytecode_to_trace(
737
733
if (trace_length > 4 ) {
738
734
ADD_TO_TRACE (_EXIT_TRACE , 0 , 0 , target );
739
735
DPRINTF (1 ,
740
- "Created a trace for %s (%s:%d) at byte offset %d -- length %d+%d \n" ,
736
+ "Created a trace for %s (%s:%d) at byte offset %d -- length %d\n" ,
741
737
PyUnicode_AsUTF8 (code -> co_qualname ),
742
738
PyUnicode_AsUTF8 (code -> co_filename ),
743
739
code -> co_firstlineno ,
744
740
2 * INSTR_IP (initial_instr , code ),
745
- trace_length ,
746
- buffer_size - max_length );
741
+ trace_length );
747
742
OPT_HIST (trace_length + buffer_size - max_length , trace_length_hist );
748
743
return 1 ;
749
744
}
0 commit comments