mirror of
https://github.com/php/php-src.git
synced 2026-04-16 20:41:18 +02:00
Avoid redundand iterations, checks and reloads
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user