Skip to content

Commit 066bcb1

Browse files
committed
opcache: re-enable PASS_15 (constant collection) by default
Was disabled in Dec 2015 to fix bug #71127. The bug no longer reproduces on current master -- bug71127.phpt passes with PASS_15 enabled.
1 parent 43b56c9 commit 066bcb1

4 files changed

Lines changed: 148 additions & 1 deletion

File tree

Zend/Optimizer/zend_optimizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
#define ZEND_OPTIMIZER_ALL_PASSES 0x7FFFFFFF
4848

49-
#define DEFAULT_OPTIMIZATION_LEVEL "0x7FFEBFFF"
49+
#define DEFAULT_OPTIMIZATION_LEVEL "0x7FFEFFFF"
5050

5151

5252
#define ZEND_DUMP_AFTER_PASS_1 ZEND_OPTIMIZER_PASS_1
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
const and define() at file scope are inlined by the optimizer
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable_cli=1
7+
opcache.opt_debug_level=0x20000
8+
--FILE--
9+
<?php
10+
11+
const CONST_VAL = 1;
12+
define('DEFINE_VAL', 2);
13+
14+
function use_const() {
15+
return CONST_VAL;
16+
}
17+
18+
function use_define() {
19+
return DEFINE_VAL;
20+
}
21+
22+
?>
23+
--EXPECTF--
24+
$_main:
25+
; (lines=%d, args=%d, vars=%d, tmps=%d)
26+
; (after optimizer)
27+
; %s
28+
0000 DECLARE_CONST string("CONST_VAL") int(1)
29+
0001 DECLARE_CONST string("DEFINE_VAL") int(2)
30+
0002 RETURN int(1)
31+
32+
use_const:
33+
; (lines=%d, args=%d, vars=%d, tmps=%d)
34+
; (after optimizer)
35+
; %s
36+
0000 RETURN int(1)
37+
38+
use_define:
39+
; (lines=%d, args=%d, vars=%d, tmps=%d)
40+
; (after optimizer)
41+
; %s
42+
0000 RETURN int(2)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
--TEST--
2+
Global and namespace const declarations are inlined by the optimizer
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable_cli=1
7+
opcache.opt_debug_level=0x20000
8+
--FILE--
9+
<?php
10+
11+
const GLOBAL_CONST = 42;
12+
13+
function use_global_const() {
14+
return GLOBAL_CONST;
15+
}
16+
17+
function use_global_const_fqn() {
18+
return \GLOBAL_CONST;
19+
}
20+
21+
class MyClass {
22+
const CLASS_CONST = 99;
23+
24+
public function use_class_const() {
25+
return self::CLASS_CONST;
26+
}
27+
}
28+
29+
function use_class_const_static() {
30+
return MyClass::CLASS_CONST;
31+
}
32+
33+
?>
34+
--EXPECTF--
35+
$_main:
36+
; (lines=%d, args=%d, vars=%d, tmps=%d)
37+
; (after optimizer)
38+
; %s
39+
0000 DECLARE_CONST string("GLOBAL_CONST") int(42)
40+
0001 RETURN int(1)
41+
42+
use_global_const:
43+
; (lines=%d, args=%d, vars=%d, tmps=%d)
44+
; (after optimizer)
45+
; %s
46+
0000 RETURN int(42)
47+
48+
use_global_const_fqn:
49+
; (lines=%d, args=%d, vars=%d, tmps=%d)
50+
; (after optimizer)
51+
; %s
52+
0000 RETURN int(42)
53+
54+
use_class_const_static:
55+
; (lines=%d, args=%d, vars=%d, tmps=%d)
56+
; (after optimizer)
57+
; %s
58+
0000 RETURN int(99)
59+
60+
MyClass::use_class_const:
61+
; (lines=%d, args=%d, vars=%d, tmps=%d)
62+
; (after optimizer)
63+
; %s
64+
0000 RETURN int(99)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--TEST--
2+
Namespace const declarations are inlined by the optimizer
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable_cli=1
7+
opcache.opt_debug_level=0x20000
8+
--FILE--
9+
<?php
10+
namespace MyNS;
11+
12+
const NS_CONST = 100;
13+
14+
function use_ns_const() {
15+
return NS_CONST;
16+
}
17+
18+
function use_ns_const_fqn() {
19+
return \MyNS\NS_CONST;
20+
}
21+
22+
?>
23+
--EXPECTF--
24+
$_main:
25+
; (lines=%d, args=%d, vars=%d, tmps=%d)
26+
; (after optimizer)
27+
; %s
28+
0000 DECLARE_CONST string("MyNS\\NS_CONST") int(100)
29+
0001 RETURN int(1)
30+
31+
MyNS\use_ns_const:
32+
; (lines=%d, args=%d, vars=%d, tmps=%d)
33+
; (after optimizer)
34+
; %s
35+
0000 RETURN int(100)
36+
37+
MyNS\use_ns_const_fqn:
38+
; (lines=%d, args=%d, vars=%d, tmps=%d)
39+
; (after optimizer)
40+
; %s
41+
0000 RETURN int(100)

0 commit comments

Comments
 (0)