Fixed SCCP on PHI(partial_object#1, partial_object#2)

This commit is contained in:
Xinchen Hui 2017-09-02 18:38:51 +08:00
parent 8a7ba133c3
commit 7c9556db99
2 changed files with 26 additions and 4 deletions

View File

@ -144,16 +144,16 @@ static void set_value(scdf_ctx *scdf, sccp_ctx *ctx, int var, zval *new) {
return;
}
/* PARTIAL_ARRAY is lower than IS_ARRAY */
if (Z_TYPE_P(value) == IS_ARRAY && IS_PARTIAL_ARRAY(new)) {
/* Always replace PARTIAL_(ARRAY|OBJECT), as new maybe changed by join_partial_(arrays|object) */
if (IS_PARTIAL_ARRAY(new) || IS_PARTIAL_OBJECT(new)) {
zval_ptr_dtor_nogc(value);
ZVAL_COPY(value, new);
scdf_add_to_worklist(scdf, var);
/*?? scdf_add_to_worklist(scdf, var); */
return;
}
#if ZEND_DEBUG
ZEND_ASSERT(IS_PARTIAL_ARRAY(new) || IS_PARTIAL_OBJECT(new) || zend_is_identical(value, new));
ZEND_ASSERT(zend_is_identical(value, new));
#endif
}

View File

@ -0,0 +1,22 @@
--TEST--
SCCP 013: Conditional Constant Propagation of non-escaping object properties on PHI
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
function loadEntities($entity_information) {
$entity_types = new StdClass();
$entity_types->a = 1;
foreach ($entity_information as $info) {
$entity_types->a = 0;
}
var_dump((bool)($entity_types->a));
}
loadEntities(array("first", "second"));
--EXPECT--
bool(false)