forked from pbiggar/phc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FUTURE_WORK
207 lines (195 loc) · 5.45 KB
/
FUTURE_WORK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
The expansion of whole-program analysis should handle, in this order:
codegen/function_call_index.php
codegen/oop_method_invocation1.php
codegen/bench_fibo.php
3rdparty/shootout/raytrace.php
TODO: something with includes.
That should cover the vast majority of everything.
============================================================
Combine prints:
print ("str");
print ("str2");
into
print ("strstr2");
============================================================
Optimize pow:
pow ($a, 0) => 1
pow ($a, 1) => $a
We can only do the latter is $a is a number.
============================================================
Convert print to echo
It does actually make a minor difference
============================================================
CONSTANTs defined in the engine can be constant propagated
============================================================
Types and === can be converted to false
============================================================
Return types of built-in functions (as well as values)
============================================================
if ($a == true) can be converted to just if ($a)
Same for
if ($a != false)
============================================================
Remove echo ("")
============================================================
Pure functions:
strlen
zend_function
md5
sha1
crc32
pi
getrandmax
mt_getrandmax
ord
chr
strtoupper
strtoupper
strcmp
addslashes
htmlspecialchars
htmlentities
dirname
basename
realpath
version_compare
strncmp
strcasecmp
strncasecmp
dechex
hexdec
decbin
decoct
octdec
str_repeat
str_pad
intval
substr
abs
acos
acosh
asin
asinh
atan2
atan
atanh
base_convert
bindec
ceil
cos
cosh
decbin
dechex
decoct
deg2rad
exp
expm1
floor
fmod
getrandmax
hexdec
hypot
is_finite
is_infinite
is_nan
lcg_value
log10
log1p
log
max
min
mt_getrandmax
octdec
pi
pow
rad2deg
round
sin
sinh
sqrt
tan
tanh
ip2long
long2ip
trim
rtrim
ltrim
chop
php_logo_guide
zend_logo_guide
php_edgg_logo_guide
============================================================
Functions where we know the return type:
============================================================
Functions where we know the return value:
============================================================
Fcuntnio which can be optimized, unless the result is false, in which case it may later change:
extension_loaded
function_exists
class_exists
interface_exists
is_callable
php_version
get_cfg_var
============================================================
Unsafe function optimizations performed by APC optimizer:
ini_get
get_magic_quotes_qpc
============================================================
Function we probably break:
getlastmod - would be tough to support in a compiler
getmyuid
getmygid
getmyinode
============================================================
Function optimizations performed by APC which arent safe ahead-of-time, but are probably safe for APC:
get_current_user
php_sapi_name
php_ini_scanned_files
php_uname
============================================================
$x[5] is NULL for non-{string/array}
is this just scalars
============================================================
dont forget to lowercase all functions
============================================================
printf to echo
============================================================
merge constants into printf
============================================================
============================================================
============================================================
============================================================
============================================================
============================================================
============================================================
============================================================
optimize $x[5] for int and $x["str"] for strings
============================================================
Zend_call_function:
we can optimize this a lot. If we control the callee and the caller, then we can call it directly, and, importantly, skip the allocation and deallocation of return values.
if we control only the caller, we can pass the return value to avoid an allocation and deallocation.
============================================================
type-inference everywhere.
- remove extra array stuff
- use booleans for conditionals
- remove unnecessary casts
- remove concat with ""
- optimize array access even without constants
============================================================
Split every node which has > 1 predecessor.
Optimize
Merge nodes with > 1 predecessor where the predecessors are identical
I think this will see good results for uninitialized variables in particular.
============================================================
we could move constants into rvalues. Then we could get the constant zval
without copying it, and just use its result. This would help in heapsort's
gen_random as it just uses them for multiplies.
============================================================
Copy-propagation has a few useful places, notably strcat (I measure a 35% improvement).
However, there is a live-range problem, due to SSA. So we need to move the
modification of a variable after its use, if they are independent.
============================================================
============================================================
============================================================
============================================================