@@ -457,6 +457,7 @@ static zend_ssa *zend_jit_trace_build_ssa(const zend_op_array *op_array, zend_sc
457
457
}
458
458
459
459
static void zend_jit_dump_trace (zend_jit_trace_rec * trace_buffer , zend_ssa * tssa );
460
+ static void zend_jit_dump_exit_info (zend_jit_trace_info * t );
460
461
461
462
static zend_always_inline int zend_jit_trace_op_len (const zend_op * opline )
462
463
{
@@ -3168,7 +3169,7 @@ static zend_jit_trace_stop zend_jit_compile_root_trace(zend_jit_trace_rec *trace
3168
3169
{
3169
3170
zend_jit_trace_stop ret ;
3170
3171
const void * handler ;
3171
- zend_jit_trace_info * t ;
3172
+ zend_jit_trace_info * t = NULL ;
3172
3173
zend_jit_trace_exit_info exit_info [ZEND_JIT_TRACE_MAX_EXITS ];
3173
3174
3174
3175
zend_shared_alloc_lock ();
@@ -3260,6 +3261,12 @@ static zend_jit_trace_stop zend_jit_compile_root_trace(zend_jit_trace_rec *trace
3260
3261
3261
3262
zend_shared_alloc_unlock ();
3262
3263
3264
+ if ((ZCG (accel_directives ).jit_debug & ZEND_JIT_DEBUG_TRACE_EXIT_INFO ) != 0
3265
+ && ret == ZEND_JIT_TRACE_STOP_COMPILED
3266
+ && t -> exit_count > 0 ) {
3267
+ zend_jit_dump_exit_info (t );
3268
+ }
3269
+
3263
3270
return ret ;
3264
3271
}
3265
3272
@@ -3499,6 +3506,47 @@ static void zend_jit_dump_trace(zend_jit_trace_rec *trace_buffer, zend_ssa *tssa
3499
3506
}
3500
3507
}
3501
3508
3509
+ static void zend_jit_dump_exit_info (zend_jit_trace_info * t )
3510
+ {
3511
+ int i , j ;
3512
+
3513
+ fprintf (stderr , "---- TRACE %d exit info\n" , t -> id );
3514
+ for (i = 0 ; i < t -> exit_count ; i ++ ) {
3515
+ uint32_t stack_size = t -> exit_info [i ].stack_size ;
3516
+ zend_jit_trace_stack * stack = t -> stack_map + t -> exit_info [i ].stack_offset ;
3517
+
3518
+ fprintf (stderr , " exit_%d:" , i );
3519
+ if (t -> exit_info [i ].opline ) {
3520
+ // TODO: print exit opline number ???
3521
+ //fprintf(stderr, " %04d/", t->exit_info[i].opline - op_array->opcodes);
3522
+ fprintf (stderr , " XXXX/" );
3523
+ } else {
3524
+ fprintf (stderr , " ----/" );
3525
+ }
3526
+ if (t -> exit_info [i ].stack_size ) {
3527
+ fprintf (stderr , "%04d/%d" , t -> exit_info [i ].stack_offset , t -> exit_info [i ].stack_size );
3528
+ } else {
3529
+ fprintf (stderr , "----/0" );
3530
+ }
3531
+ for (j = 0 ; j < stack_size ; j ++ ) {
3532
+ zend_uchar type = STACK_TYPE (stack , j );
3533
+ if (type != IS_UNKNOWN ) {
3534
+ // TODO: print CV insted of X ???
3535
+ fprintf (stderr , " X%d:" , j );
3536
+ if (type == IS_UNDEF ) {
3537
+ fprintf (stderr , "undef" );
3538
+ } else {
3539
+ fprintf (stderr , "%s" , zend_get_type_by_const (type ));
3540
+ if (STACK_REG (stack , j ) != ZREG_NONE ) {
3541
+ fprintf (stderr , "(%s)" , zend_reg_name [STACK_REG (stack , j )]);
3542
+ }
3543
+ }
3544
+ }
3545
+ }
3546
+ fprintf (stderr , "\n" );
3547
+ }
3548
+ }
3549
+
3502
3550
int ZEND_FASTCALL zend_jit_trace_hot_root (zend_execute_data * execute_data , const zend_op * opline )
3503
3551
{
3504
3552
const zend_op * orig_opline ;
@@ -3771,6 +3819,12 @@ static zend_jit_trace_stop zend_jit_compile_side_trace(zend_jit_trace_rec *trace
3771
3819
3772
3820
zend_shared_alloc_unlock ();
3773
3821
3822
+ if ((ZCG (accel_directives ).jit_debug & ZEND_JIT_DEBUG_TRACE_EXIT_INFO ) != 0
3823
+ && ret == ZEND_JIT_TRACE_STOP_COMPILED
3824
+ && t -> exit_count > 0 ) {
3825
+ zend_jit_dump_exit_info (t );
3826
+ }
3827
+
3774
3828
return ret ;
3775
3829
}
3776
3830
0 commit comments