@@ -7125,6 +7125,74 @@ static zend_jit_trace_stop zend_jit_compile_root_trace(zend_jit_trace_rec *trace
7125
7125
return ret ;
7126
7126
}
7127
7127
7128
+ /* Set counting handler back to original VM handler. */
7129
+ static void zend_jit_stop_hot_trace_counters (zend_op_array * op_array )
7130
+ {
7131
+ zend_jit_op_array_trace_extension * jit_extension ;
7132
+ uint32_t i ;
7133
+
7134
+ jit_extension = (zend_jit_op_array_trace_extension * )ZEND_FUNC_INFO (op_array );
7135
+ zend_shared_alloc_lock ();
7136
+ SHM_UNPROTECT ();
7137
+ for (i = 0 ; i < op_array -> last ; i ++ ) {
7138
+ /* Opline with Jit-ed code handler is skipped. */
7139
+ if (jit_extension -> trace_info [i ].trace_flags &
7140
+ (ZEND_JIT_TRACE_JITED |ZEND_JIT_TRACE_BLACKLISTED )) {
7141
+ continue ;
7142
+ }
7143
+ if (jit_extension -> trace_info [i ].trace_flags &
7144
+ (ZEND_JIT_TRACE_START_LOOP | ZEND_JIT_TRACE_START_ENTER | ZEND_JIT_TRACE_START_RETURN )) {
7145
+ op_array -> opcodes [i ].handler = jit_extension -> trace_info [i ].orig_handler ;
7146
+ }
7147
+ }
7148
+ SHM_PROTECT ();
7149
+ zend_shared_alloc_unlock ();
7150
+ }
7151
+
7152
+ /* Get the tracing op_array. */
7153
+ static void zend_jit_stop_persistent_op_array (zend_op_array * op_array ) {
7154
+ zend_func_info * func_info = ZEND_FUNC_INFO (op_array );
7155
+ if (!func_info ) {
7156
+ return ;
7157
+ }
7158
+ if (func_info -> flags & ZEND_FUNC_JIT_ON_HOT_TRACE ) {
7159
+ zend_jit_stop_hot_trace_counters (op_array );
7160
+ }
7161
+ }
7162
+
7163
+ /* Get all op_arrays with counter handler. */
7164
+ static void zend_jit_stop_persistent_script (zend_persistent_script * script ) {
7165
+ zend_class_entry * ce ;
7166
+ zend_op_array * op_array ;
7167
+
7168
+ zend_jit_stop_persistent_op_array (& script -> script .main_op_array );
7169
+
7170
+ ZEND_HASH_FOREACH_PTR (& script -> script .function_table , op_array ) {
7171
+ zend_jit_stop_persistent_op_array (op_array );
7172
+ } ZEND_HASH_FOREACH_END ();
7173
+
7174
+ ZEND_HASH_FOREACH_PTR (& script -> script .class_table , ce ) {
7175
+ ZEND_HASH_FOREACH_PTR (& ce -> function_table , op_array ) {
7176
+ if (op_array -> type == ZEND_USER_FUNCTION ) {
7177
+ zend_jit_stop_persistent_op_array (op_array );
7178
+ }
7179
+ } ZEND_HASH_FOREACH_END ();
7180
+ } ZEND_HASH_FOREACH_END ();
7181
+ }
7182
+
7183
+ /* Get all scripts which are accelerated by JIT */
7184
+ static void zend_jit_stop_counter_handlers () {
7185
+ for (uint32_t i = 0 ; i < ZCSG (hash ).max_num_entries ; i ++ ) {
7186
+ zend_accel_hash_entry * cache_entry ;
7187
+ for (cache_entry = ZCSG (hash ).hash_table [i ]; cache_entry ; cache_entry = cache_entry -> next ) {
7188
+ zend_persistent_script * script ;
7189
+ if (cache_entry -> indirect ) continue ;
7190
+ script = (zend_persistent_script * )cache_entry -> data ;
7191
+ zend_jit_stop_persistent_script (script );
7192
+ }
7193
+ }
7194
+ }
7195
+
7128
7196
static void zend_jit_blacklist_root_trace (const zend_op * opline , size_t offset )
7129
7197
{
7130
7198
zend_shared_alloc_lock ();
@@ -7505,6 +7573,7 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
7505
7573
7506
7574
if (ZEND_JIT_TRACE_NUM >= JIT_G (max_root_traces )) {
7507
7575
stop = ZEND_JIT_TRACE_STOP_TOO_MANY_TRACES ;
7576
+ zend_jit_stop_counter_handlers ();
7508
7577
goto abort ;
7509
7578
}
7510
7579
0 commit comments