com php-src: JIT code improvement for ocache.jit=1 (I P consistency): ext/opcache/jit/zend_jit.c ext/op cache/jit/zend_jit_x86.dasc
| From: | Dmitry Stogov | Date: | Wed, 03 Apr 2019 00:56:39 +0000 |
| Subject: | com php-src: JIT code improvement for ocache.jit=1 (I P consistency): ext/opcache/jit/zend_jit.c ext/op cache/jit/zend_jit_x86.dasc | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105505@lists.php.net to get a copy of this message | ||
Commit: b9c639d7ac16e7c3099ec03d3d38384d7d5092be
Author: Dmitry Stogov <dmitry@zend.com> Wed, 3 Apr 2019 03:56:39 +0300
Parents: 85c249c9fd9722b0c0cf14c90395acf0ca3c761b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b9c639d7ac16e7c3099ec03d3d38384d7d5092be
Log:
JIT code improvement for ocache.jit=1 (IP consistency)
Changed paths:
M ext/opcache/jit/zend_jit.c
M ext/opcache/jit/zend_jit_x86.dasc
Diff:
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index 4a1a27d..ca5b642 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -2059,7 +2059,22 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op
*rt_op
is_terminated = 0;
zend_jit_label(&dasm_state, b);
- if (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET) {
+ if (zend_jit_level < ZEND_JIT_LEVEL_INLINE) {
+ opline = op_array->opcodes + (ssa->cfg.blocks[b].start - 1);
+ if ((ssa->cfg.blocks[b].flags & ZEND_BB_FOLLOW)
+ && (opline->opcode == ZEND_NOP
+ || opline->opcode == ZEND_SWITCH_LONG
+ || opline->opcode == ZEND_SWITCH_STRING)) {
+ if (!zend_jit_reset_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start)
+ || !zend_jit_set_valid_ip(&dasm_state, op_array->opcodes +
ssa->cfg.blocks[b].start)) {
+ goto jit_failure;
+ }
+ } else {
+ if (!zend_jit_set_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start))
{
+ goto jit_failure;
+ }
+ }
+ } else if (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET) {
if (!zend_jit_reset_opline(&dasm_state, op_array->opcodes + ssa->cfg.blocks[b].start))
{
goto jit_failure;
}
@@ -2352,6 +2367,13 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op
*rt_op
case ZEND_SWITCH_STRING:
break;
case ZEND_JMP:
+ if (zend_jit_level < ZEND_JIT_LEVEL_INLINE) {
+ const zend_op *target = OP_JMP_ADDR(opline, opline->op1);
+
+ if (!zend_jit_set_ip(&dasm_state, target)) {
+ goto jit_failure;
+ }
+ }
if (!zend_jit_jmp(&dasm_state, ssa->cfg.blocks[b].successors[0])) {
goto jit_failure;
}
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index cefef3c..2787d9e 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -2653,19 +2653,23 @@ static int zend_jit_check_timeout(dasm_State **Dst, const zend_op *opline)
if (!zend_jit_set_valid_ip(Dst, opline)) {
return 0;
}
+ | MEM_OP2_1_ZTS cmp, byte, executor_globals, vm_interrupt, 0, r0
+ | jne ->interrupt_handler
#else
| MEM_OP2_1_ZTS cmp, byte, executor_globals, vm_interrupt, 0, r0
- | jne >1
- |.cold_code
- |1:
- | LOAD_IP_ADDR opline
- | jmp ->interrupt_handler
- |.code
+ if (last_valid_opline == opline) {
+ | jne ->interrupt_handler
+ } else {
+ | jne >1
+ |.cold_code
+ |1:
+ | LOAD_IP_ADDR opline
+ | jmp ->interrupt_handler
+ |.code
+ }
return 1;
#endif
}
- | MEM_OP2_1_ZTS cmp, byte, executor_globals, vm_interrupt, 0, r0
- | jne ->interrupt_handler
return 1;
}