com php-src: Avoid redundand iterations, checks and reloads: ext/opcache/Optimizer/escape_analysis.c

From: Date: Thu, 14 Sep 2017 08:25:03 +0000
Subject: com php-src: Avoid redundand iterations, checks and reloads: ext/opcache/Optimizer/escape_analysis.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99434@lists.php.net to get a copy of this message
Commit: ad68c6745fab5d09341ed3cb2994aeacae3bb23c Author: Dmitry Stogov <dmitry@zend.com> Thu, 14 Sep 2017 11:25:03 +0300 Parents: 80abd8134412b2566c12a8439d7a1a2d07e0346f Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ad68c6745fab5d09341ed3cb2994aeacae3bb23c Log: Avoid redundand iterations, checks and reloads Changed paths: M ext/opcache/Optimizer/escape_analysis.c Diff: diff --git a/ext/opcache/Optimizer/escape_analysis.c b/ext/opcache/Optimizer/escape_analysis.c index 357fcd2..d54f8a8 100644 --- a/ext/opcache/Optimizer/escape_analysis.c +++ b/ext/opcache/Optimizer/escape_analysis.c @@ -355,16 +355,17 @@ int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array, int num_non_escaped; ALLOCA_FLAG(use_heap) - if (!ssa->vars) { + if (!ssa_vars) { return SUCCESS; } has_allocations = 0; - for (i = 0; i < ssa_vars_count; i++) { - if (ssa_vars[i].definition >= 0) { - if (is_allocation_def(op_array, ssa, ssa_vars[i].definition, i, script)) { - has_allocations = 1; - } + for (i = op_array->last_var; i < ssa_vars_count; i++) { + if (ssa_vars[i].definition >= 0 + && (ssa->var_info[i].type & (MAY_BE_ARRAY|MAY_BE_OBJECT)) + && is_allocation_def(op_array, ssa, ssa_vars[i].definition, i, script)) { + has_allocations = 1; + break; } } if (!has_allocations) { @@ -373,7 +374,7 @@ int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array, /* 1. Build EES (Equi-Esape Sets) */ - ees = do_alloca(sizeof(int) * ssa->vars_count, use_heap); + ees = do_alloca(sizeof(int) * ssa_vars_count, use_heap); if (!ees) { return FAILURE; } @@ -384,14 +385,15 @@ int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array, /* 2. Identify Allocations */ num_non_escaped = 0; - for (i = 0; i < ssa_vars_count; i++) { + for (i = op_array->last_var; i < ssa_vars_count; i++) { if (ssa_vars[i].alias) { root = ees[i]; ssa_vars[root].escape_state = ESCAPE_STATE_GLOBAL_ESCAPE; } else if (ssa_vars[i].definition >= 0) { root = ees[i]; if (ssa_vars[root].escape_state == ESCAPE_STATE_UNKNOWN) { - if (is_allocation_def(op_array, ssa, ssa_vars[i].definition, i, script)) { + if ((ssa->var_info[i].type & (MAY_BE_ARRAY|MAY_BE_OBJECT)) + && is_allocation_def(op_array, ssa, ssa_vars[i].definition, i, script)) { ssa_vars[root].escape_state = ESCAPE_STATE_NO_ESCAPE; num_non_escaped++; } else { @@ -407,7 +409,7 @@ int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array, if (ssa_vars[i].use_chain >= 0) { root = ees[i]; if (ssa_vars[root].escape_state == ESCAPE_STATE_NO_ESCAPE) { - FOREACH_USE(ssa->vars + i, use) { + FOREACH_USE(ssa_vars + i, use) { if (is_escape_use(op_array, ssa, use, i)) { ssa_vars[root].escape_state = ESCAPE_STATE_GLOBAL_ESCAPE; num_non_escaped--; @@ -432,7 +434,7 @@ int zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array, if (ssa_vars[i].use_chain >= 0) { root = ees[i]; if (ssa_vars[root].escape_state == ESCAPE_STATE_NO_ESCAPE) { - FOREACH_USE(ssa->vars + i, use) { + FOREACH_USE(ssa_vars + i, use) { zend_ssa_op *op = ssa->ops + use; zend_op *opline = op_array->opcodes + use; int enclosing_root;

« previous php.cvs (#99434) next »