@@ -7152,6 +7152,74 @@ static zend_jit_trace_stop zend_jit_compile_root_trace(zend_jit_trace_rec *trace
7152
7152
return ret ;
7153
7153
}
7154
7154
7155
+ /* Set counting handler back to original VM handler. */
7156
+ static void zend_jit_stop_hot_trace_counters (zend_op_array * op_array )
7157
+ {
7158
+ zend_jit_op_array_trace_extension * jit_extension ;
7159
+ uint32_t i ;
7160
+
7161
+ jit_extension = (zend_jit_op_array_trace_extension * )ZEND_FUNC_INFO (op_array );
7162
+ zend_shared_alloc_lock ();
7163
+ SHM_UNPROTECT ();
7164
+ for (i = 0 ; i < op_array -> last ; i ++ ) {
7165
+ /* Opline with Jit-ed code handler is skipped. */
7166
+ if (jit_extension -> trace_info [i ].trace_flags &
7167
+ (ZEND_JIT_TRACE_JITED |ZEND_JIT_TRACE_BLACKLISTED )) {
7168
+ continue ;
7169
+ }
7170
+ if (jit_extension -> trace_info [i ].trace_flags &
7171
+ (ZEND_JIT_TRACE_START_LOOP | ZEND_JIT_TRACE_START_ENTER | ZEND_JIT_TRACE_START_RETURN )) {
7172
+ op_array -> opcodes [i ].handler = jit_extension -> trace_info [i ].orig_handler ;
7173
+ }
7174
+ }
7175
+ SHM_PROTECT ();
7176
+ zend_shared_alloc_unlock ();
7177
+ }
7178
+
7179
+ /* Get the tracing op_array. */
7180
+ static void zend_jit_stop_persistent_op_array (zend_op_array * op_array ) {
7181
+ zend_func_info * func_info = ZEND_FUNC_INFO (op_array );
7182
+ if (!func_info ) {
7183
+ return ;
7184
+ }
7185
+ if (func_info -> flags & ZEND_FUNC_JIT_ON_HOT_TRACE ) {
7186
+ zend_jit_stop_hot_trace_counters (op_array );
7187
+ }
7188
+ }
7189
+
7190
+ /* Get all op_arrays with counter handler. */
7191
+ static void zend_jit_stop_persistent_script (zend_persistent_script * script ) {
7192
+ zend_class_entry * ce ;
7193
+ zend_op_array * op_array ;
7194
+
7195
+ zend_jit_stop_persistent_op_array (& script -> script .main_op_array );
7196
+
7197
+ ZEND_HASH_FOREACH_PTR (& script -> script .function_table , op_array ) {
7198
+ zend_jit_stop_persistent_op_array (op_array );
7199
+ } ZEND_HASH_FOREACH_END ();
7200
+
7201
+ ZEND_HASH_FOREACH_PTR (& script -> script .class_table , ce ) {
7202
+ ZEND_HASH_FOREACH_PTR (& ce -> function_table , op_array ) {
7203
+ if (op_array -> type == ZEND_USER_FUNCTION ) {
7204
+ zend_jit_stop_persistent_op_array (op_array );
7205
+ }
7206
+ } ZEND_HASH_FOREACH_END ();
7207
+ } ZEND_HASH_FOREACH_END ();
7208
+ }
7209
+
7210
+ /* Get all scripts which are accelerated by JIT */
7211
+ static void zend_jit_stop_counter_handlers () {
7212
+ for (uint32_t i = 0 ; i < ZCSG (hash ).max_num_entries ; i ++ ) {
7213
+ zend_accel_hash_entry * cache_entry ;
7214
+ for (cache_entry = ZCSG (hash ).hash_table [i ]; cache_entry ; cache_entry = cache_entry -> next ) {
7215
+ zend_persistent_script * script ;
7216
+ if (cache_entry -> indirect ) continue ;
7217
+ script = (zend_persistent_script * )cache_entry -> data ;
7218
+ zend_jit_stop_persistent_script (script );
7219
+ }
7220
+ }
7221
+ }
7222
+
7155
7223
static void zend_jit_blacklist_root_trace (const zend_op * opline , size_t offset )
7156
7224
{
7157
7225
zend_shared_alloc_lock ();
@@ -7532,6 +7600,7 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
7532
7600
7533
7601
if (ZEND_JIT_TRACE_NUM >= JIT_G (max_root_traces )) {
7534
7602
stop = ZEND_JIT_TRACE_STOP_TOO_MANY_TRACES ;
7603
+ zend_jit_stop_counter_handlers ();
7535
7604
goto abort ;
7536
7605
}
7537
7606
0 commit comments