1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 00:48:25 +02:00

Support for implicit array/object allocations

This commit is contained in:
Dmitry Stogov
2017-08-30 17:41:45 +03:00
parent 44064529a8
commit d1d523ef50
2 changed files with 32 additions and 17 deletions
+3 -17
View File
@@ -22,6 +22,7 @@
#include "zend_bitset.h"
#include "zend_cfg.h"
#include "zend_ssa.h"
#include "zend_inference.h"
#include "zend_dump.h"
/*
@@ -198,28 +199,13 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in
return 1;
}
break;
#if 0
// TODO: implicit object/array allocation
case ZEND_ASSIGN_DIM:
case ZEND_ASSIGN_OBJ:
return 1;
case ZEND_ASSIGN_ADD:
case ZEND_ASSIGN_SUB:
case ZEND_ASSIGN_MUL:
case ZEND_ASSIGN_DIV:
case ZEND_ASSIGN_MOD:
case ZEND_ASSIGN_SL:
case ZEND_ASSIGN_SR:
case ZEND_ASSIGN_CONCAT:
case ZEND_ASSIGN_BW_OR:
case ZEND_ASSIGN_BW_AND:
case ZEND_ASSIGN_BW_XOR:
case ZEND_ASSIGN_POW:
if (opline->extended_value) {
if (OP1_INFO() & (MAY_BE_UNDEF | MAY_BE_NULL | MAY_BE_FALSE)) {
/* implicit object/array allocation */
return 1;
}
break;
#endif
}
}
+29
View File
@@ -0,0 +1,29 @@
--TEST--
SCCP 009: Conditional Constant Propagation of non-escaping array elements
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.opt_debug_level=0x20000
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
function foo(int $x) {
$a[0] = $x;
$a[1] = 2;
echo $a[1];
}
?>
--EXPECTF--
$_main: ; (lines=1, args=0, vars=0, tmps=0)
; (after optimizer)
; %ssccp_009.php:1-8
L0: RETURN int(1)
foo: ; (lines=3, args=1, vars=1, tmps=1)
; (after optimizer)
; %ssccp_009.php:2-6
L0: CV0($x) = RECV 1
L1: ECHO int(2)
L2: RETURN null