@@ -8066,7 +8066,7 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
80668066
80678067	JIT_G (tracing ) =  1 ;
80688068	stop  =  zend_jit_trace_execute (execute_data , opline , trace_buffer ,
8069- 		ZEND_OP_TRACE_INFO (opline , offset )-> trace_flags  &  ZEND_JIT_TRACE_START_MASK , 0 );
8069+ 		ZEND_OP_TRACE_INFO (opline , offset )-> trace_flags  &  ZEND_JIT_TRACE_START_MASK , 0 ,  0 );
80708070	JIT_G (tracing ) =  0 ;
80718071
80728072	if  (stop  &  ZEND_JIT_TRACE_HALT ) {
@@ -8390,6 +8390,8 @@ int ZEND_FASTCALL zend_jit_trace_hot_side(zend_execute_data *execute_data, uint3
83908390	zend_jit_trace_rec  trace_buffer [ZEND_JIT_TRACE_MAX_LENGTH ];
83918391	uint32_t  is_megamorphic  =  0 ;
83928392	uint32_t  polymorphism  =  0 ;
8393+ 	uint32_t  root ;
8394+ 	int  ret_depth  =  0 ;
83938395
83948396	trace_num  =  ZEND_JIT_TRACE_NUM ;
83958397
@@ -8414,7 +8416,8 @@ int ZEND_FASTCALL zend_jit_trace_hot_side(zend_execute_data *execute_data, uint3
84148416		goto abort ;
84158417	}
84168418
8417- 	if  (zend_jit_traces [zend_jit_traces [parent_num ].root ].child_count  >= JIT_G (max_side_traces )) {
8419+ 	root  =  zend_jit_traces [parent_num ].root ;
8420+ 	if  (zend_jit_traces [root ].child_count  >= JIT_G (max_side_traces )) {
84188421		stop  =  ZEND_JIT_TRACE_STOP_TOO_MANY_CHILDREN ;
84198422		goto abort ;
84208423	}
@@ -8434,8 +8437,29 @@ int ZEND_FASTCALL zend_jit_trace_hot_side(zend_execute_data *execute_data, uint3
84348437		}
84358438	}
84368439
8440+ 	/* Check if this is a side trace of a root LOOP trace */ 
8441+ 	if  ((zend_jit_traces [root ].flags  &  ZEND_JIT_TRACE_LOOP )
8442+ 	 &&  zend_jit_traces [root ].op_array  !=  & EX (func )-> op_array ) {
8443+ 		const  zend_op_array  * op_array  =  zend_jit_traces [root ].op_array ;
8444+ 		const  zend_op  * opline  =  zend_jit_traces [root ].opline ;
8445+ 		zend_jit_op_array_trace_extension  * jit_extension  = 
8446+ 				(zend_jit_op_array_trace_extension * )ZEND_FUNC_INFO (op_array );
8447+ 
8448+ 		if  (jit_extension -> trace_info [opline  -  op_array -> opcodes ].trace_flags  &  ZEND_JIT_TRACE_START_LOOP ) {
8449+ 			zend_execute_data  * ex  =  execute_data ;
8450+ 			int  n  =  0 ;
8451+ 			do  {
8452+ 				ex  =  ex -> prev_execute_data ;
8453+ 				n ++ ;
8454+ 			} while  (ex  &&  zend_jit_traces [root ].op_array  !=  & ex -> func -> op_array );
8455+ 			if  (ex  &&  n  <= ZEND_JIT_TRACE_MAX_RET_DEPTH ) {
8456+ 				ret_depth  =  n ;
8457+ 			}
8458+ 		}
8459+ 	}
8460+ 
84378461	JIT_G (tracing ) =  1 ;
8438- 	stop  =  zend_jit_trace_execute (execute_data , EX (opline ), trace_buffer , ZEND_JIT_TRACE_START_SIDE , is_megamorphic );
8462+ 	stop  =  zend_jit_trace_execute (execute_data , EX (opline ), trace_buffer , ZEND_JIT_TRACE_START_SIDE , is_megamorphic ,  ret_depth );
84398463	JIT_G (tracing ) =  0 ;
84408464
84418465	if  (stop  &  ZEND_JIT_TRACE_HALT ) {
0 commit comments