@@ -2175,6 +2175,21 @@ static int zend_jit_hybrid_profile_jit_stub(dasm_State **Dst)
2175
2175
return 1;
2176
2176
}
2177
2177
2178
+ static int zend_jit_hybrid_hot_code_stub(dasm_State **Dst)
2179
+ {
2180
+ if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
2181
+ return 1;
2182
+ }
2183
+
2184
+ |->hybrid_hot_code:
2185
+ | mov word [r2], ZEND_JIT_COUNTER_INIT
2186
+ | mov FCARG1a, FP
2187
+ | GET_IP FCARG2a
2188
+ | EXT_CALL zend_jit_hot_func, r0
2189
+ | JMP_IP
2190
+ return 1;
2191
+ }
2192
+
2178
2193
/*
2179
2194
* This code is based Mike Pall's "Hashed profile counters" idea, implemented
2180
2195
* in LuaJIT. The full description may be found in "LuaJIT 2.0 intellectual
@@ -2199,18 +2214,13 @@ static int zend_jit_hybrid_profile_jit_stub(dasm_State **Dst)
2199
2214
* }
2200
2215
*
2201
2216
*/
2202
- static int zend_jit_hybrid_func_hot_counter_stub (dasm_State **Dst)
2217
+ static int zend_jit_hybrid_hot_counter_stub (dasm_State **Dst, uint32_t cost )
2203
2218
{
2204
- if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
2205
- return 1;
2206
- }
2207
-
2208
- |->hybrid_func_hot_counter:
2209
2219
| mov r0, EX->func
2210
2220
| mov r1, aword [r0 + offsetof(zend_op_array, reserved[zend_func_info_rid])]
2211
2221
| mov r2, aword [r1 + offsetof(zend_jit_op_array_hot_extension, counter)]
2212
- | sub word [r2], ((ZEND_JIT_COUNTER_INIT + JIT_G(hot_func) - 1) / JIT_G(hot_func))
2213
- | jle >1
2222
+ | sub word [r2], cost
2223
+ | jle ->hybrid_hot_code
2214
2224
| GET_IP r2
2215
2225
| sub r2, aword [r0 + offsetof(zend_op_array, opcodes)]
2216
2226
| // divide by sizeof(zend_op)
@@ -2227,49 +2237,51 @@ static int zend_jit_hybrid_func_hot_counter_stub(dasm_State **Dst)
2227
2237
| .else
2228
2238
| jmp aword [r1+r2*4+offsetof(zend_jit_op_array_hot_extension, orig_handlers)]
2229
2239
| .endif
2230
- |1:
2231
- | mov word [r2], ZEND_JIT_COUNTER_INIT
2232
- | mov FCARG1a, FP
2233
- | GET_IP FCARG2a
2234
- | EXT_CALL zend_jit_hot_func, r0
2235
- | JMP_IP
2236
2240
return 1;
2237
2241
}
2238
2242
2243
+ static int zend_jit_hybrid_func_hot_counter_stub(dasm_State **Dst)
2244
+ {
2245
+ if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
2246
+ return 1;
2247
+ }
2248
+
2249
+ |->hybrid_func_hot_counter:
2250
+
2251
+ return zend_jit_hybrid_hot_counter_stub(Dst,
2252
+ ((ZEND_JIT_COUNTER_INIT + JIT_G(hot_func) - 1) / JIT_G(hot_func)));
2253
+ }
2254
+
2239
2255
static int zend_jit_hybrid_loop_hot_counter_stub(dasm_State **Dst)
2240
2256
{
2241
2257
if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
2242
2258
return 1;
2243
2259
}
2244
2260
2245
2261
|->hybrid_loop_hot_counter:
2246
- | mov r0, EX->func
2247
- | mov r1, aword [r0 + offsetof(zend_op_array, reserved[zend_func_info_rid])]
2248
- | mov r2, aword [r1 + offsetof(zend_jit_op_array_hot_extension, counter)]
2249
- | sub word [r2], ((ZEND_JIT_COUNTER_INIT + JIT_G(hot_loop) - 1) / JIT_G(hot_loop))
2250
- | jle >1
2251
- | GET_IP r2
2252
- | sub r2, aword [r0 + offsetof(zend_op_array, opcodes)]
2253
- | // divide by sizeof(zend_op)
2254
- | .if X64
2255
- || ZEND_ASSERT(sizeof(zend_op) == 32);
2256
- | sar r2, 5
2257
- | .else
2258
- || ZEND_ASSERT(sizeof(zend_op) == 28);
2259
- | sar r2, 2
2260
- | imul r2, 0xb6db6db7
2261
- | .endif
2262
- | .if X64
2263
- | jmp aword [r1+r2*8+offsetof(zend_jit_op_array_hot_extension, orig_handlers)]
2264
- | .else
2265
- | jmp aword [r1+r2*4+offsetof(zend_jit_op_array_hot_extension, orig_handlers)]
2266
- | .endif
2267
- |1:
2262
+
2263
+ return zend_jit_hybrid_hot_counter_stub(Dst,
2264
+ ((ZEND_JIT_COUNTER_INIT + JIT_G(hot_loop) - 1) / JIT_G(hot_loop)));
2265
+ }
2266
+
2267
+ static int zend_jit_hybrid_hot_trace_stub(dasm_State **Dst)
2268
+ {
2269
+ if (zend_jit_vm_kind != ZEND_VM_KIND_HYBRID) {
2270
+ return 1;
2271
+ }
2272
+
2273
+ |->hybrid_hot_trace:
2268
2274
| mov word [r2], ZEND_JIT_COUNTER_INIT
2269
2275
| mov FCARG1a, FP
2270
2276
| GET_IP FCARG2a
2271
- | EXT_CALL zend_jit_hot_func, r0
2277
+ | EXT_CALL zend_jit_trace_hot_root, r0
2278
+ | test eax, eax // TODO : remove this check at least for HYBRID VM ???
2279
+ | jl >1
2280
+ | MEM_OP2_2_ZTS mov, FP, aword, executor_globals, current_execute_data, r0
2281
+ | LOAD_OPLINE
2272
2282
| JMP_IP
2283
+ |1:
2284
+ | EXT_JMP zend_jit_halt_op->handler, r0
2273
2285
return 1;
2274
2286
}
2275
2287
@@ -2280,20 +2292,8 @@ static int zend_jit_hybrid_trace_counter_stub(dasm_State **Dst, uint32_t cost)
2280
2292
| mov r1, aword [r1 + offsetof(zend_jit_op_array_trace_extension, offset)]
2281
2293
| mov r2, aword [IP + r1 + offsetof(zend_op_trace_info, counter)]
2282
2294
| sub word [r2], cost
2283
- | jle >1
2295
+ | jle ->hybrid_hot_trace
2284
2296
| jmp aword [IP + r1]
2285
- |1:
2286
- | mov word [r2], ZEND_JIT_COUNTER_INIT
2287
- | mov FCARG1a, FP
2288
- | GET_IP FCARG2a
2289
- | EXT_CALL zend_jit_trace_hot_root, r0
2290
- | test eax, eax // TODO : remove this check at least for HYBRID VM ???
2291
- | jl >1
2292
- | MEM_OP2_2_ZTS mov, FP, aword, executor_globals, current_execute_data, r0
2293
- | LOAD_OPLINE
2294
- | JMP_IP
2295
- |1:
2296
- | EXT_JMP zend_jit_halt_op->handler, r0
2297
2297
return 1;
2298
2298
}
2299
2299
@@ -2572,8 +2572,10 @@ static const zend_jit_stub zend_jit_stubs[] = {
2572
2572
JIT_STUB(trace_escape),
2573
2573
JIT_STUB(hybrid_runtime_jit),
2574
2574
JIT_STUB(hybrid_profile_jit),
2575
+ JIT_STUB(hybrid_hot_code),
2575
2576
JIT_STUB(hybrid_func_hot_counter),
2576
2577
JIT_STUB(hybrid_loop_hot_counter),
2578
+ JIT_STUB(hybrid_hot_trace),
2577
2579
JIT_STUB(hybrid_func_trace_counter),
2578
2580
JIT_STUB(hybrid_ret_trace_counter),
2579
2581
JIT_STUB(hybrid_loop_trace_counter),
0 commit comments