File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -564,7 +564,8 @@ translate_bytecode_to_trace(
564564 * Assumption: 67% reserved for trace, 33% for exit stubs
565565 * TODO: Compute the required number of exit stubs dynamically
566566 */
567- int max_length = (buffer_size * 2 ) / 3 ;
567+ int max_exit_stubs = (buffer_size * 33 ) / 100 ; // 33% for exit stubs
568+ int max_length = buffer_size - 2 - max_exit_stubs ;
568569 struct {
569570 PyFunctionObject * func ;
570571 PyCodeObject * code ;
@@ -724,9 +725,9 @@ translate_bytecode_to_trace(
724725 {
725726 const struct opcode_macro_expansion * expansion = & _PyOpcode_macro_expansion [opcode ];
726727 if (expansion -> nuops > 0 ) {
727- // Reserve space for nuops (+ _SET_IP + _EXIT_TRACE )
728+ // Reserve space for nuops (exit stub space already pre-reserved )
728729 int nuops = expansion -> nuops ;
729- RESERVE (nuops + 1 ); /* One extra for exit */
730+ RESERVE (nuops );
730731 int16_t last_op = expansion -> uops [nuops - 1 ].uop ;
731732 if (last_op == _RETURN_VALUE || last_op == _RETURN_GENERATOR || last_op == _YIELD_VALUE ) {
732733 // Check for trace stack underflow now:
You can’t perform that action at this time.
0 commit comments