com php-src: Avoid code generation for BB with single VM instruction: ext/opcache/jit/zend_jit.c
| From: | Dmitry Stogov | Date: | Wed, 03 Apr 2019 21:47:51 +0000 |
| Subject: | com php-src: Avoid code generation for BB with single VM instruction: ext/opcache/jit/zend_jit.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105517@lists.php.net to get a copy of this message | ||
Commit: 21f249cfa4c78466f54223092d4f2b316450e802
Author: Dmitry Stogov <dmitry@zend.com> Thu, 4 Apr 2019 00:47:51 +0300
Parents: a146e6eea7aeb395cfac9e706d81107a97009ed1
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=21f249cfa4c78466f54223092d4f2b316450e802
Log:
Avoid code generation for BB with single VM instruction
Changed paths:
M ext/opcache/jit/zend_jit.c
Diff:
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index 84defa0..54fa2888 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -2026,8 +2026,16 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op
*rt_op
}
#ifndef CONTEXT_THREADED_JIT
if (ssa->cfg.blocks[b].flags & ZEND_BB_ENTRY) {
- if (!is_terminated && (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET)) {
- zend_jit_jmp(&dasm_state, b);
+ if (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET) {
+ if (!is_terminated) {
+ zend_jit_jmp(&dasm_state, b);
+ }
+ } else if (zend_jit_level < ZEND_JIT_LEVEL_INLINE &&
+ ssa->cfg.blocks[b].len == 1 &&
+ (ssa->cfg.blocks[b].flags & ZEND_BB_EXIT) &&
+ op_array->opcodes[ssa->cfg.blocks[b].start].opcode != ZEND_JMP) {
+ /* don't generate code for BB with single opcode */
+ continue;
}
zend_jit_label(&dasm_state, ssa->cfg.blocks_count + b);
zend_jit_prologue(&dasm_state);
@@ -2079,15 +2087,32 @@ static int zend_jit(zend_op_array *op_array, zend_ssa *ssa, const zend_op
*rt_op
} else {
if (recv_emited) {
zend_jit_jmp(&dasm_state, b);
+ } else if (zend_jit_level < ZEND_JIT_LEVEL_INLINE &&
+ ssa->cfg.blocks[b].len == 1 &&
+ (ssa->cfg.blocks[b].flags & ZEND_BB_EXIT)) {
+ /* don't generate code for BB with single opcode */
+ dasm_free(&dasm_state);
+
+ if (zend_jit_reg_alloc) {
+ zend_arena_release(&CG(arena), checkpoint);
+ }
+ return SUCCESS;
}
zend_jit_label(&dasm_state, ssa->cfg.blocks_count + b);
zend_jit_prologue(&dasm_state);
recv_emited = 1;
}
- } else {
- if (ssa->cfg.blocks[b].flags & ZEND_BB_TARGET) {
- zend_jit_jmp(&dasm_state, b);
+ } else if (zend_jit_level < ZEND_JIT_LEVEL_INLINE &&
+ ssa->cfg.blocks[b].len == 1 &&
+ (ssa->cfg.blocks[b].flags & ZEND_BB_EXIT)) {
+ /* don't generate code for BB with single opcode */
+ dasm_free(&dasm_state);
+
+ if (zend_jit_reg_alloc) {
+ zend_arena_release(&CG(arena), checkpoint);
}
+ return SUCCESS;
+ } else {
zend_jit_label(&dasm_state, ssa->cfg.blocks_count + b);
zend_jit_prologue(&dasm_state);
}