@@ -7763,13 +7763,98 @@ static bool zend_jit_trace_exit_is_hot(uint32_t trace_num, uint32_t exit_num)
7763
7763
return false;
7764
7764
}
7765
7765
7766
+ /**
7767
+ * Helper function for zend_jit_compile_side_trace().
7768
+ */
7769
+ static zend_jit_trace_stop _zend_jit_compile_side_trace (zend_jit_trace_rec * trace_buffer , uint32_t parent_num , uint32_t exit_num , uint32_t polymorphism )
7770
+ {
7771
+ zend_jit_trace_exit_info exit_info [ZEND_JIT_TRACE_MAX_EXITS ];
7772
+ zend_jit_trace_info * const t = & zend_jit_traces [ZEND_JIT_TRACE_NUM ];
7773
+
7774
+ t -> id = ZEND_JIT_TRACE_NUM ;
7775
+ t -> root = zend_jit_traces [parent_num ].root ;
7776
+ t -> parent = parent_num ;
7777
+ t -> link = 0 ;
7778
+ t -> exit_count = 0 ;
7779
+ t -> child_count = 0 ;
7780
+ t -> stack_map_size = 0 ;
7781
+ t -> flags = 0 ;
7782
+ t -> polymorphism = polymorphism ;
7783
+ t -> jmp_table_size = 0 ;
7784
+ t -> opline = NULL ;
7785
+ t -> exit_info = exit_info ;
7786
+ t -> stack_map = NULL ;
7787
+
7788
+ const uint8_t orig_trigger = JIT_G (trigger );
7789
+ JIT_G (trigger ) = ZEND_JIT_ON_HOT_TRACE ;
7790
+
7791
+ const void * const handler = zend_jit_trace (trace_buffer , parent_num , exit_num );
7792
+
7793
+ JIT_G (trigger ) = orig_trigger ;
7794
+
7795
+ if (handler ) {
7796
+ t -> exit_info = NULL ;
7797
+ if (t -> exit_count ) {
7798
+ /* reallocate exit_info into shared memory */
7799
+ t -> exit_info = (zend_jit_trace_exit_info * )zend_shared_alloc_copy (exit_info ,
7800
+ sizeof (zend_jit_trace_exit_info ) * t -> exit_count );
7801
+
7802
+ if (!t -> exit_info ) {
7803
+ if (t -> stack_map ) {
7804
+ efree (t -> stack_map );
7805
+ }
7806
+ return ZEND_JIT_TRACE_STOP_NO_SHM ;
7807
+ }
7808
+ }
7809
+
7810
+ if (t -> stack_map_size ) {
7811
+ zend_jit_trace_stack * shared_stack_map = (zend_jit_trace_stack * )zend_shared_alloc_copy (
7812
+ t -> stack_map ,
7813
+ t -> stack_map_size * sizeof (zend_jit_trace_stack ));
7814
+ efree (t -> stack_map );
7815
+ t -> stack_map = shared_stack_map ;
7816
+ if (!shared_stack_map ) {
7817
+ return ZEND_JIT_TRACE_STOP_NO_SHM ;
7818
+ }
7819
+ }
7820
+
7821
+ zend_jit_link_side_trace (
7822
+ zend_jit_traces [parent_num ].code_start ,
7823
+ zend_jit_traces [parent_num ].code_size ,
7824
+ zend_jit_traces [parent_num ].jmp_table_size ,
7825
+ exit_num ,
7826
+ handler );
7827
+
7828
+ t -> exit_counters = ZEND_JIT_EXIT_COUNTERS ;
7829
+ ZEND_JIT_EXIT_COUNTERS += t -> exit_count ;
7830
+
7831
+ zend_jit_traces [zend_jit_traces [parent_num ].root ].child_count ++ ;
7832
+ ZEND_JIT_TRACE_NUM ++ ;
7833
+ zend_jit_traces [parent_num ].exit_info [exit_num ].flags |= ZEND_JIT_EXIT_JITED ;
7834
+
7835
+ if ((JIT_G (debug ) & ZEND_JIT_DEBUG_TRACE_EXIT_INFO ) != 0
7836
+ && t -> exit_count > 0 ) {
7837
+ zend_jit_dump_exit_info (t );
7838
+ }
7839
+
7840
+ return ZEND_JIT_TRACE_STOP_COMPILED ;
7841
+ } else if (t -> exit_count >= ZEND_JIT_TRACE_MAX_EXITS ||
7842
+ ZEND_JIT_EXIT_COUNTERS + t -> exit_count >= JIT_G (max_exit_counters )) {
7843
+ if (t -> stack_map ) {
7844
+ efree (t -> stack_map );
7845
+ }
7846
+ return ZEND_JIT_TRACE_STOP_TOO_MANY_EXITS ;
7847
+ } else {
7848
+ if (t -> stack_map ) {
7849
+ efree (t -> stack_map );
7850
+ }
7851
+ return ZEND_JIT_TRACE_STOP_COMPILER_ERROR ;
7852
+ }
7853
+ }
7854
+
7766
7855
static zend_jit_trace_stop zend_jit_compile_side_trace (zend_jit_trace_rec * trace_buffer , uint32_t parent_num , uint32_t exit_num , uint32_t polymorphism )
7767
7856
{
7768
7857
zend_jit_trace_stop ret ;
7769
- const void * handler ;
7770
- uint8_t orig_trigger ;
7771
- zend_jit_trace_info * t ;
7772
- zend_jit_trace_exit_info exit_info [ZEND_JIT_TRACE_MAX_EXITS ];
7773
7858
bool do_bailout = false;
7774
7859
7775
7860
zend_shared_alloc_lock ();
@@ -7786,86 +7871,7 @@ static zend_jit_trace_stop zend_jit_compile_side_trace(zend_jit_trace_rec *trace
7786
7871
zend_jit_unprotect ();
7787
7872
7788
7873
zend_try {
7789
- t = & zend_jit_traces [ZEND_JIT_TRACE_NUM ];
7790
-
7791
- t -> id = ZEND_JIT_TRACE_NUM ;
7792
- t -> root = zend_jit_traces [parent_num ].root ;
7793
- t -> parent = parent_num ;
7794
- t -> link = 0 ;
7795
- t -> exit_count = 0 ;
7796
- t -> child_count = 0 ;
7797
- t -> stack_map_size = 0 ;
7798
- t -> flags = 0 ;
7799
- t -> polymorphism = polymorphism ;
7800
- t -> jmp_table_size = 0 ;
7801
- t -> opline = NULL ;
7802
- t -> exit_info = exit_info ;
7803
- t -> stack_map = NULL ;
7804
-
7805
- orig_trigger = JIT_G (trigger );
7806
- JIT_G (trigger ) = ZEND_JIT_ON_HOT_TRACE ;
7807
-
7808
- handler = zend_jit_trace (trace_buffer , parent_num , exit_num );
7809
-
7810
- JIT_G (trigger ) = orig_trigger ;
7811
-
7812
- if (handler ) {
7813
- t -> exit_info = NULL ;
7814
- if (t -> exit_count ) {
7815
- /* reallocate exit_info into shared memory */
7816
- t -> exit_info = (zend_jit_trace_exit_info * )zend_shared_alloc_copy (exit_info ,
7817
- sizeof (zend_jit_trace_exit_info ) * t -> exit_count );
7818
-
7819
- if (!t -> exit_info ) {
7820
- if (t -> stack_map ) {
7821
- efree (t -> stack_map );
7822
- }
7823
- ret = ZEND_JIT_TRACE_STOP_NO_SHM ;
7824
- goto exit ;
7825
- }
7826
- }
7827
-
7828
- if (t -> stack_map_size ) {
7829
- zend_jit_trace_stack * shared_stack_map = (zend_jit_trace_stack * )zend_shared_alloc_copy (
7830
- t -> stack_map ,
7831
- t -> stack_map_size * sizeof (zend_jit_trace_stack ));
7832
- efree (t -> stack_map );
7833
- t -> stack_map = shared_stack_map ;
7834
- if (!shared_stack_map ) {
7835
- ret = ZEND_JIT_TRACE_STOP_NO_SHM ;
7836
- goto exit ;
7837
- }
7838
- }
7839
-
7840
- zend_jit_link_side_trace (
7841
- zend_jit_traces [parent_num ].code_start ,
7842
- zend_jit_traces [parent_num ].code_size ,
7843
- zend_jit_traces [parent_num ].jmp_table_size ,
7844
- exit_num ,
7845
- handler );
7846
-
7847
- t -> exit_counters = ZEND_JIT_EXIT_COUNTERS ;
7848
- ZEND_JIT_EXIT_COUNTERS += t -> exit_count ;
7849
-
7850
- zend_jit_traces [zend_jit_traces [parent_num ].root ].child_count ++ ;
7851
- ZEND_JIT_TRACE_NUM ++ ;
7852
- zend_jit_traces [parent_num ].exit_info [exit_num ].flags |= ZEND_JIT_EXIT_JITED ;
7853
-
7854
- ret = ZEND_JIT_TRACE_STOP_COMPILED ;
7855
- } else if (t -> exit_count >= ZEND_JIT_TRACE_MAX_EXITS ||
7856
- ZEND_JIT_EXIT_COUNTERS + t -> exit_count >= JIT_G (max_exit_counters )) {
7857
- if (t -> stack_map ) {
7858
- efree (t -> stack_map );
7859
- }
7860
- ret = ZEND_JIT_TRACE_STOP_TOO_MANY_EXITS ;
7861
- } else {
7862
- if (t -> stack_map ) {
7863
- efree (t -> stack_map );
7864
- }
7865
- ret = ZEND_JIT_TRACE_STOP_COMPILER_ERROR ;
7866
- }
7867
-
7868
- exit :;
7874
+ ret = _zend_jit_compile_side_trace (trace_buffer , parent_num , exit_num , polymorphism );
7869
7875
} zend_catch {
7870
7876
do_bailout = true;
7871
7877
} zend_end_try ();
@@ -7880,12 +7886,6 @@ exit:;
7880
7886
zend_bailout ();
7881
7887
}
7882
7888
7883
- if ((JIT_G (debug ) & ZEND_JIT_DEBUG_TRACE_EXIT_INFO ) != 0
7884
- && ret == ZEND_JIT_TRACE_STOP_COMPILED
7885
- && t -> exit_count > 0 ) {
7886
- zend_jit_dump_exit_info (t );
7887
- }
7888
-
7889
7889
return ret ;
7890
7890
}
7891
7891
0 commit comments