Skip to content

Commit 317e805

Browse files
committed
Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport
* origin/PHP-5.6: Fixed issue #183 (TMP_VAR is not only used once) Fix broken Junit output with --disable-cgi Added folder mark
2 parents 1d28acb + 24a86db commit 317e805

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

Zend/zend_operators.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ *
962962
}
963963
/* }}} */
964964

965-
ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
965+
ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
966966
{
967967
zval op1_copy, op2_copy;
968968
int converted = 0;
@@ -1044,6 +1044,7 @@ ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
10441044
}
10451045
}
10461046
}
1047+
/* }}} */
10471048

10481049
ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
10491050
{

ext/opcache/Optimizer/zend_optimizer.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,20 +367,41 @@ static void replace_tmp_by_const(zend_op_array *op_array,
367367
if (ZEND_OP1_TYPE(opline) == IS_TMP_VAR &&
368368
ZEND_OP1(opline).var == var) {
369369

370-
update_op1_const(op_array, opline, val TSRMLS_CC);
371-
/* TMP_VAR my be used only once */
372-
break;
370+
/* In most cases IS_TMP_VAR operand may be used only once.
371+
* The operands are usually destroyed by the opcode handler.
372+
* ZEND_CASE is an exception, that keeps operand unchanged,
373+
* and allows its reuse. The number of ZEND_CASE instructions
374+
* usually terminated by ZEND_FREE that finally kills the value.
375+
*/
376+
if (opline->opcode == ZEND_CASE) {
377+
zval old_val;
378+
old_val = *val;
379+
zval_copy_ctor(val);
380+
update_op1_const(op_array, opline, val TSRMLS_CC);
381+
*val = old_val;
382+
} else if (opline->opcode == ZEND_FREE) {
383+
MAKE_NOP(opline);
384+
break;
385+
} else {
386+
update_op1_const(op_array, opline, val TSRMLS_CC);
387+
val = NULL;
388+
break;
389+
}
373390
}
374391

375392
if (ZEND_OP2_TYPE(opline) == IS_TMP_VAR &&
376393
ZEND_OP2(opline).var == var) {
377394

378395
update_op2_const(op_array, opline, val TSRMLS_CC);
379-
/* TMP_VAR my be used only once */
396+
/* TMP_VAR may be used only once */
397+
val = NULL;
380398
break;
381399
}
382400
opline++;
383401
}
402+
if (val) {
403+
zval_dtor(val);
404+
}
384405
}
385406

386407
#include "Optimizer/nop_removal.c"

run-tests.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,7 @@ function run_test($php, $file, $env)
13561356
} else {
13571357
show_result('SKIP', $tested, $tested_file, "reason: CGI not available");
13581358

1359+
junit_init_suite(junit_get_suitename_for($shortname));
13591360
junit_mark_test_as('SKIP', $shortname, $tested, 0, 'CGI not available');
13601361
return 'SKIPPED';
13611362
}

0 commit comments

Comments
 (0)