com php-src: Eliminate unreachable live ranges: ext/opcache/Opt imizer/block_pass.c ext/opcache/Optimizer/zend_optimize r.c

From: Date: Wed, 18 Nov 2015 15:04:02 +0000
Subject: com php-src: Eliminate unreachable live ranges: ext/opcache/Opt imizer/block_pass.c ext/opcache/Optimizer/zend_optimize r.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89901@lists.php.net to get a copy of this message
Commit: 104a5971132aaeb915ad355c5f0f3f2784d54d75 Author: Dmitry Stogov <dmitry@zend.com> Wed, 18 Nov 2015 18:04:02 +0300 Parents: 66b953e0222e15f32f3426230daebac2e4a46a25 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=104a5971132aaeb915ad355c5f0f3f2784d54d75 Log: Eliminate unreachable live ranges Changed paths: M ext/opcache/Optimizer/block_pass.c M ext/opcache/Optimizer/zend_optimizer.c Diff: diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index a42aecf..c350826 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -711,31 +711,74 @@ static void zend_rebuild_access_path(zend_cfg *cfg, zend_op_array *op_array, int /* Walk thorough all paths */ zend_access_path(start, ctx); - /* Add brk/cont paths */ - if (op_array->last_live_range) { - int i; - for (i=0; i< op_array->last_live_range; i++) { - zend_access_path(cfg->live_range_start[i], ctx); - zend_access_path(cfg->live_range_end[i], ctx); - } - } + if (op_array->last_live_range || op_array->last_try_catch) { + int i, changed; - /* Add exception paths */ - if (op_array->last_try_catch) { - int changed; do { - int i; - changed = 0; - for (i=0; i< op_array->last_try_catch; i++) { - if (cfg->try[i]->access) { - if (!cfg->catch[i]->access) { + /* Add brk/cont paths */ + for (i = 0; i< op_array->last_live_range; i++) { + if (cfg->live_range_start[i]->access) { + if (!cfg->live_range_end[i]->access) { changed = 1; - zend_access_path(cfg->catch[i], ctx); + zend_access_path(cfg->live_range_end[i], ctx); + } + } else { + ZEND_ASSERT(!cfg->live_range_end[i]->access); + } + } + + /* Add exception paths */ + for (i = 0; i< op_array->last_try_catch; i++) { + if (cfg->try[i]->access) { + if (op_array->try_catch_array[i].catch_op) { + if (!cfg->catch[i]->access) { + changed = 1; + zend_access_path(cfg->catch[i], ctx); + } + } else { + ZEND_ASSERT(!cfg->catch[i]->access); } } } } while (changed); + + /* remove unused live ranges */ + if (op_array->last_live_range) { + int j = 0; + uint32_t *map; + ALLOCA_FLAG(use_heap); + + map = (uint32_t *)do_alloca(sizeof(uint32_t) * op_array->last_live_range, use_heap); + + for (i = 0; i < op_array->last_live_range; i++) { + if (!cfg->live_range_start[i]->access) { + ZEND_ASSERT(!cfg->live_range_end[i]->access); + } else { + map[i] = j; + if (i != j) { + op_array->live_range[j] = op_array->live_range[i]; + cfg->live_range_start[j] = cfg->live_range_start[i]; + cfg->live_range_end[j] = cfg->live_range_end[i]; + } + j++; + } + } + + if (i != j) { + zend_op *opline = op_array->opcodes; + zend_op *end = opline + op_array->last; + + op_array->last_live_range = j; + while (opline != end) { + if ((opline->opcode == ZEND_FREE || opline->opcode == ZEND_FE_FREE) && + opline->extended_value == ZEND_FREE_ON_RETURN) { + opline->op2.num = map[opline->op2.num]; + } + opline++; + } + } + } } } diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c index a1cfda5..bc7e875 100644 --- a/ext/opcache/Optimizer/zend_optimizer.c +++ b/ext/opcache/Optimizer/zend_optimizer.c @@ -440,8 +440,8 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array, int brk = op_array->last_live_range; zend_bool in_switch = 0; while (brk--) { - if (op_array->live_range[brk].start <= (opline - op_array->opcodes) && - op_array->live_range[brk].end > (opline - op_array->opcodes)) { + if (op_array->live_range[brk].start <= (uint32_t)(opline - op_array->opcodes) && + op_array->live_range[brk].end > (uint32_t)(opline - op_array->opcodes)) { in_switch = 1; break; }

« previous php.cvs (#89901) next »