Skip to content

Commit 8792cc5

Browse files
committed
Merge branch 'master' into jit-dynasm
* master: Support for implicit array/object allocations
2 parents c9b5ad0 + d1d523e commit 8792cc5

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

ext/opcache/Optimizer/escape_analysis.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "zend_bitset.h"
2323
#include "zend_cfg.h"
2424
#include "zend_ssa.h"
25+
#include "zend_inference.h"
2526
#include "zend_dump.h"
2627

2728
/*
@@ -198,28 +199,13 @@ static int is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, in
198199
return 1;
199200
}
200201
break;
201-
#if 0
202-
// TODO: implicit object/array allocation
203202
case ZEND_ASSIGN_DIM:
204203
case ZEND_ASSIGN_OBJ:
205-
return 1;
206-
case ZEND_ASSIGN_ADD:
207-
case ZEND_ASSIGN_SUB:
208-
case ZEND_ASSIGN_MUL:
209-
case ZEND_ASSIGN_DIV:
210-
case ZEND_ASSIGN_MOD:
211-
case ZEND_ASSIGN_SL:
212-
case ZEND_ASSIGN_SR:
213-
case ZEND_ASSIGN_CONCAT:
214-
case ZEND_ASSIGN_BW_OR:
215-
case ZEND_ASSIGN_BW_AND:
216-
case ZEND_ASSIGN_BW_XOR:
217-
case ZEND_ASSIGN_POW:
218-
if (opline->extended_value) {
204+
if (OP1_INFO() & (MAY_BE_UNDEF | MAY_BE_NULL | MAY_BE_FALSE)) {
205+
/* implicit object/array allocation */
219206
return 1;
220207
}
221208
break;
222-
#endif
223209
}
224210
}
225211

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
SCCP 009: Conditional Constant Propagation of non-escaping array elements
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.opt_debug_level=0x20000
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
function foo(int $x) {
13+
$a[0] = $x;
14+
$a[1] = 2;
15+
echo $a[1];
16+
}
17+
?>
18+
--EXPECTF--
19+
$_main: ; (lines=1, args=0, vars=0, tmps=0)
20+
; (after optimizer)
21+
; %ssccp_009.php:1-8
22+
L0: RETURN int(1)
23+
24+
foo: ; (lines=3, args=1, vars=1, tmps=1)
25+
; (after optimizer)
26+
; %ssccp_009.php:2-6
27+
L0: CV0($x) = RECV 1
28+
L1: ECHO int(2)
29+
L2: RETURN null

0 commit comments

Comments
 (0)