Skip to content

Commit ac80aeb

Browse files
authored
JIT/AArch64: Use 'tbnz/tbz' to check the signedness (#7123)
'tbnz/tbz' instruction can be used to check whether a given W or X register value is negative or positive. For example, ``` tst x0, x0 blt >1 ``` can be optimized as `tbnz x0, #63, >1` It's important to note that the jump range of 'tbnz/tbz' is limited, and it's better NOT to use 'tbnz/tbz' if the target of 'b.cond' is a label in section .cold_code or a global label, such as the instruction sequence `tst RETVALw, RETVALw; blt ->trace_halt` at function zend_jit_trace_exit_stub(), and the instruction sequence `tst REG0, REG0; blt >7` at function zend_jit_incdec_obj(). Minor updates: Use macros BW_OP_32_WITH_CONST and GC_ADDREF at function zend_jit_push_call_frame(). Change-Id: I1597609bdabf55ea2f9d24528e7a037bc3e5c3a1
1 parent ff2fbd0 commit ac80aeb

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,8 +1801,7 @@ static int zend_jit_exception_handler_stub(dasm_State **Dst)
18011801
| EXT_CALL handler, REG0
18021802
| ldp FP, RX, T2 // retore FP and IP
18031803
| ldp x29, x30, [sp], # NR_SPAD // stack alignment
1804-
| tst RETVALw, RETVALw
1805-
| blt >1
1804+
| tbnz RETVALw, #31, >1
18061805
| mov RETVALw, #1 // ZEND_VM_ENTER
18071806
|1:
18081807
| ret
@@ -2283,8 +2282,7 @@ static int zend_jit_hybrid_hot_trace_stub(dasm_State **Dst)
22832282
| mov FCARG1x, FP
22842283
| GET_IP FCARG2x
22852284
| EXT_CALL zend_jit_trace_hot_root, REG0
2286-
| cmp RETVALw, wzr // Result is < 0 on failure.
2287-
| blt >1
2285+
| tbnz RETVALw, #31, >1 // Result is < 0 on failure.
22882286
| MEM_LOAD_64_ZTS ldr, FP, executor_globals, current_execute_data, REG0
22892287
| LOAD_IP
22902288
| JMP_IP TMP1
@@ -8355,10 +8353,9 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, con
83558353
| LOAD_32BIT_VAL TMP1w, ZEND_CALL_HAS_THIS
83568354
| str TMP1w, EX:RX->This.u1.type_info
83578355
} else {
8358-
| LOAD_32BIT_VAL TMP1w, ZEND_CALL_HAS_THIS
8359-
| ldr TMP2w, EX:RX->This.u1.type_info
8360-
| orr TMP2w, TMP2w, TMP1w
8361-
| str TMP2w, EX:RX->This.u1.type_info
8356+
| ldr TMP1w, EX:RX->This.u1.type_info
8357+
| BW_OP_32_WITH_CONST orr, TMP1w, TMP1w, ZEND_CALL_HAS_THIS, TMP2w
8358+
| str TMP1w, EX:RX->This.u1.type_info
83628359
}
83638360
} else {
83648361
if (opline->op1_type == IS_CV) {
@@ -8381,9 +8378,7 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, con
83818378
} else {
83828379
if (opline->op2_type == IS_CV) {
83838380
| // GC_ADDREF(closure);
8384-
| ldr TMP1w, [REG0]
8385-
| add TMP1w, TMP1w, #1
8386-
| str TMP1w, [REG0]
8381+
| GC_ADDREF REG0, TMP1w
83878382
}
83888383
| // object_or_called_scope = closure->called_scope;
83898384
| ldr REG1, [REG0, #offsetof(zend_closure, called_scope)]

0 commit comments

Comments
 (0)