mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Remove unused temporaries from taken map
If the result has no uses we need to allocate it when visiting the defining instruction. However, we should still go through the logic to remove the temporary from the taken map afterwards, as the temporary can still be reused prior to the defining instruction.
This commit is contained in:
parent
517c01b79b
commit
ae1132b01a
1 changed files with 18 additions and 22 deletions
|
@ -150,31 +150,27 @@ void zend_optimize_temporary_variables(zend_op_array *op_array, zend_optimizer_c
|
|||
|
||||
if (opline->result_type & (IS_VAR | IS_TMP_VAR)) {
|
||||
currT = VAR_NUM(opline->result.var) - offset;
|
||||
if (zend_bitset_in(valid_T, currT)) {
|
||||
if (start_of_T[currT] == opline) {
|
||||
/* ZEND_FAST_CALL can not share temporary var with others
|
||||
* since the fast_var could also be set by ZEND_HANDLE_EXCEPTION
|
||||
* which could be ahead of it */
|
||||
if (opline->opcode != ZEND_FAST_CALL) {
|
||||
zend_bitset_excl(taken_T, map_T[currT]);
|
||||
}
|
||||
}
|
||||
opline->result.var = NUM_VAR(map_T[currT] + offset);
|
||||
if (opline->opcode == ZEND_ROPE_INIT) {
|
||||
if (start_of_T[currT] == opline) {
|
||||
uint32_t num = ((opline->extended_value * sizeof(zend_string*)) + (sizeof(zval) - 1)) / sizeof(zval);
|
||||
while (num > 1) {
|
||||
num--;
|
||||
zend_bitset_excl(taken_T, map_T[currT]+num);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Code which gets here is using a wrongly built opcode such as RECV() */
|
||||
if (!zend_bitset_in(valid_T, currT)) {
|
||||
/* As a result of DCE, an opcode may have an unused result. */
|
||||
GET_AVAILABLE_T();
|
||||
map_T[currT] = i;
|
||||
zend_bitset_incl(valid_T, currT);
|
||||
opline->result.var = NUM_VAR(i + offset);
|
||||
}
|
||||
opline->result.var = NUM_VAR(map_T[currT] + offset);
|
||||
if (start_of_T[currT] == opline) {
|
||||
/* ZEND_FAST_CALL can not share temporary var with others
|
||||
* since the fast_var could also be set by ZEND_HANDLE_EXCEPTION
|
||||
* which could be ahead of it */
|
||||
if (opline->opcode != ZEND_FAST_CALL) {
|
||||
zend_bitset_excl(taken_T, map_T[currT]);
|
||||
}
|
||||
if (opline->opcode == ZEND_ROPE_INIT) {
|
||||
uint32_t num = ((opline->extended_value * sizeof(zend_string*)) + (sizeof(zval) - 1)) / sizeof(zval);
|
||||
while (num > 1) {
|
||||
num--;
|
||||
zend_bitset_excl(taken_T, map_T[currT]+num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue