xref: /PHP-7.3/ext/opcache/Optimizer/pass1_5.c (revision 9afce019)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend OPcache                                                         |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1998-2018 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Authors: Andi Gutmans <andi@php.net>                                 |
16    |          Zeev Suraski <zeev@php.net>                                 |
17    |          Stanislav Malyshev <stas@zend.com>                          |
18    |          Dmitry Stogov <dmitry@php.net>                              |
19    +----------------------------------------------------------------------+
20 */
21 
22 /* pass 1
23  * - substitute persistent constants (true, false, null, etc)
24  * - perform compile-time evaluation of constant binary and unary operations
25  * - convert CAST(IS_BOOL,x) into BOOL(x)
26  * - pre-evaluate constant function calls
27  */
28 
29 #include "php.h"
30 #include "Optimizer/zend_optimizer.h"
31 #include "Optimizer/zend_optimizer_internal.h"
32 #include "zend_API.h"
33 #include "zend_constants.h"
34 #include "zend_execute.h"
35 #include "zend_vm.h"
36 
zend_optimizer_pass1(zend_op_array * op_array,zend_optimizer_ctx * ctx)37 void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx)
38 {
39 	int i = 0;
40 	zend_op *opline = op_array->opcodes;
41 	zend_op *end = opline + op_array->last;
42 	zend_bool collect_constants = (ZEND_OPTIMIZER_PASS_15 & ctx->optimization_level)?
43 		(op_array == &ctx->script->main_op_array) : 0;
44 
45 	while (opline < end) {
46 		switch (opline->opcode) {
47 		case ZEND_ADD:
48 		case ZEND_SUB:
49 		case ZEND_MUL:
50 		case ZEND_DIV:
51 		case ZEND_MOD:
52 		case ZEND_POW:
53 		case ZEND_SL:
54 		case ZEND_SR:
55 		case ZEND_CONCAT:
56 		case ZEND_FAST_CONCAT:
57 		case ZEND_IS_EQUAL:
58 		case ZEND_IS_NOT_EQUAL:
59 		case ZEND_IS_SMALLER:
60 		case ZEND_IS_SMALLER_OR_EQUAL:
61 		case ZEND_IS_IDENTICAL:
62 		case ZEND_IS_NOT_IDENTICAL:
63 		case ZEND_BW_OR:
64 		case ZEND_BW_AND:
65 		case ZEND_BW_XOR:
66 		case ZEND_BOOL_XOR:
67 		case ZEND_SPACESHIP:
68 		case ZEND_CASE:
69 			if (opline->op1_type == IS_CONST &&
70 				opline->op2_type == IS_CONST) {
71 				/* binary operation with constant operands */
72 				zval result;
73 
74 				if (zend_optimizer_eval_binary_op(&result, opline->opcode, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline)) == SUCCESS) {
75 					literal_dtor(&ZEND_OP1_LITERAL(opline));
76 					literal_dtor(&ZEND_OP2_LITERAL(opline));
77 					if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_TMP_VAR, opline->result.var, &result)) {
78 						MAKE_NOP(opline);
79 					} else {
80 						opline->opcode = ZEND_QM_ASSIGN;
81 						SET_UNUSED(opline->op2);
82 						zend_optimizer_update_op1_const(op_array, opline, &result);
83 					}
84 				}
85 			}
86 			break;
87 
88 		case ZEND_CAST:
89 			if (opline->op1_type == IS_CONST) {
90 				/* cast of constant operand */
91 				zval result;
92 
93 				if (zend_optimizer_eval_cast(&result, opline->extended_value, &ZEND_OP1_LITERAL(opline)) == SUCCESS) {
94 					literal_dtor(&ZEND_OP1_LITERAL(opline));
95 					if (zend_optimizer_replace_by_const(op_array, opline + 1, opline->result_type, opline->result.var, &result)) {
96 						MAKE_NOP(opline);
97 					} else {
98 						opline->opcode = ZEND_QM_ASSIGN;
99 						opline->extended_value = 0;
100 						zend_optimizer_update_op1_const(op_array, opline, &result);
101 					}
102 					break;
103 				}
104 			}
105 
106 			if (opline->extended_value == _IS_BOOL) {
107 				/* T = CAST(X, IS_BOOL) => T = BOOL(X) */
108 				opline->opcode = ZEND_BOOL;
109 				opline->extended_value = 0;
110 			}
111 			break;
112 
113 		case ZEND_BW_NOT:
114 		case ZEND_BOOL_NOT:
115 			if (opline->op1_type == IS_CONST) {
116 				/* unary operation on constant operand */
117 				zval result;
118 
119 				if (zend_optimizer_eval_unary_op(&result, opline->opcode, &ZEND_OP1_LITERAL(opline)) == SUCCESS) {
120 					literal_dtor(&ZEND_OP1_LITERAL(opline));
121 					if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_TMP_VAR, opline->result.var, &result)) {
122 						MAKE_NOP(opline);
123 					} else {
124 						opline->opcode = ZEND_QM_ASSIGN;
125 						zend_optimizer_update_op1_const(op_array, opline, &result);
126 					}
127 				}
128 			}
129 			break;
130 
131 		case ZEND_FETCH_CONSTANT:
132 			if (opline->op2_type == IS_CONST &&
133 				Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING &&
134 				Z_STRLEN(ZEND_OP2_LITERAL(opline)) == sizeof("__COMPILER_HALT_OFFSET__") - 1 &&
135 				memcmp(Z_STRVAL(ZEND_OP2_LITERAL(opline)), "__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1) == 0) {
136 				/* substitute __COMPILER_HALT_OFFSET__ constant */
137 				zend_execute_data *orig_execute_data = EG(current_execute_data);
138 				zend_execute_data fake_execute_data;
139 				zval *offset;
140 
141 				memset(&fake_execute_data, 0, sizeof(zend_execute_data));
142 				fake_execute_data.func = (zend_function*)op_array;
143 				EG(current_execute_data) = &fake_execute_data;
144 				if ((offset = zend_get_constant_str("__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__") - 1)) != NULL) {
145 
146 					literal_dtor(&ZEND_OP2_LITERAL(opline));
147 					if (zend_optimizer_replace_by_const(op_array, opline, IS_TMP_VAR, opline->result.var, offset)) {
148 						MAKE_NOP(opline);
149 					} else {
150 						opline->opcode = ZEND_QM_ASSIGN;
151 						opline->extended_value = 0;
152 						SET_UNUSED(opline->op2);
153 						zend_optimizer_update_op1_const(op_array, opline, offset);
154 					}
155 				}
156 				EG(current_execute_data) = orig_execute_data;
157 				break;
158 			}
159 
160 			if (opline->op2_type == IS_CONST &&
161 				Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) {
162 				/* substitute persistent constants */
163 				zval c;
164 
165 				if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &c, 1)) {
166 					if (!ctx->constants || !zend_optimizer_get_collected_constant(ctx->constants, &ZEND_OP2_LITERAL(opline), &c)) {
167 						break;
168 					}
169 				}
170 				if (Z_TYPE(c) == IS_CONSTANT_AST) {
171 					break;
172 				}
173 				literal_dtor(&ZEND_OP2_LITERAL(opline));
174 				if (zend_optimizer_replace_by_const(op_array, opline, IS_TMP_VAR, opline->result.var, &c)) {
175 					MAKE_NOP(opline);
176 				} else {
177 					opline->opcode = ZEND_QM_ASSIGN;
178 					opline->extended_value = 0;
179 					SET_UNUSED(opline->op2);
180 					zend_optimizer_update_op1_const(op_array, opline, &c);
181 				}
182 			}
183 			break;
184 
185 		case ZEND_FETCH_CLASS_CONSTANT:
186 			if (opline->op2_type == IS_CONST &&
187 				Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) {
188 
189 				zend_class_entry *ce = NULL;
190 
191 				if (opline->op1_type == IS_CONST &&
192 			        Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING) {
193 					/* for A::B */
194 					if (op_array->scope &&
195 						!strncasecmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)),
196 						ZSTR_VAL(op_array->scope->name), Z_STRLEN(ZEND_OP1_LITERAL(opline)) + 1)) {
197 						ce = op_array->scope;
198 					} else {
199 						if ((ce = zend_hash_find_ptr(EG(class_table),
200 								Z_STR(op_array->literals[opline->op1.constant + 1]))) == NULL ||
201 								(ce->type == ZEND_INTERNAL_CLASS &&
202 								 ce->info.internal.module->type != MODULE_PERSISTENT) ||
203 								(ce->type == ZEND_USER_CLASS &&
204 								 ce->info.user.filename != op_array->filename)) {
205 							break;
206 						}
207 					}
208 				} else if (op_array->scope &&
209 					opline->op1_type == IS_UNUSED &&
210 					(opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF) {
211 					/* for self::B */
212 					ce = op_array->scope;
213 				} else if (op_array->scope &&
214 					opline->op1_type == IS_VAR &&
215 					(opline - 1)->opcode == ZEND_FETCH_CLASS &&
216 					((opline - 1)->op2_type == IS_UNUSED &&
217 					((opline - 1)->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF) &&
218 					(opline - 1)->result.var == opline->op1.var) {
219 					/* for self::B */
220 					ce = op_array->scope;
221 				}
222 
223 				if (ce) {
224 					zend_class_constant *cc;
225 					zval *c, t;
226 
227 					if ((cc = zend_hash_find_ptr(&ce->constants_table,
228 							Z_STR(ZEND_OP2_LITERAL(opline)))) != NULL &&
229 						(Z_ACCESS_FLAGS(cc->value) & ZEND_ACC_PPP_MASK) == ZEND_ACC_PUBLIC) {
230 						c = &cc->value;
231 						if (Z_TYPE_P(c) == IS_CONSTANT_AST) {
232 							zend_ast *ast = Z_ASTVAL_P(c);
233 							if (ast->kind != ZEND_AST_CONSTANT
234 							 || !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &t, 1)
235 							 || Z_TYPE(t) == IS_CONSTANT_AST) {
236 								break;
237 							}
238 						} else {
239 							ZVAL_COPY_OR_DUP(&t, c);
240 						}
241 
242 						if (opline->op1_type == IS_CONST) {
243 							literal_dtor(&ZEND_OP1_LITERAL(opline));
244 						} else if (opline->op1_type == IS_VAR) {
245 							MAKE_NOP((opline - 1));
246 						}
247 						literal_dtor(&ZEND_OP2_LITERAL(opline));
248 
249 						if (zend_optimizer_replace_by_const(op_array, opline, IS_TMP_VAR, opline->result.var, &t)) {
250 							MAKE_NOP(opline);
251 						} else {
252 							opline->opcode = ZEND_QM_ASSIGN;
253 							opline->extended_value = 0;
254 							SET_UNUSED(opline->op2);
255 							zend_optimizer_update_op1_const(op_array, opline, &t);
256 						}
257 					}
258 				}
259 			}
260 			break;
261 
262 		case ZEND_DO_ICALL: {
263 			zend_op *send1_opline = opline - 1;
264 			zend_op *send2_opline = NULL;
265 			zend_op *init_opline = NULL;
266 
267 			while (send1_opline->opcode == ZEND_NOP) {
268 				send1_opline--;
269 			}
270 			if (send1_opline->opcode != ZEND_SEND_VAL ||
271 			    send1_opline->op1_type != IS_CONST) {
272 				/* don't colllect constants after unknown function call */
273 				collect_constants = 0;
274 				break;
275 			}
276 			if (send1_opline->op2.num == 2) {
277 				send2_opline = send1_opline;
278 				send1_opline--;
279 				while (send1_opline->opcode == ZEND_NOP) {
280 					send1_opline--;
281 				}
282 				if (send1_opline->opcode != ZEND_SEND_VAL ||
283 				    send1_opline->op1_type != IS_CONST) {
284 					/* don't colllect constants after unknown function call */
285 					collect_constants = 0;
286 					break;
287 				}
288 			}
289 			init_opline = send1_opline - 1;
290 			while (init_opline->opcode == ZEND_NOP) {
291 				init_opline--;
292 			}
293 			if (init_opline->opcode != ZEND_INIT_FCALL ||
294 			    init_opline->op2_type != IS_CONST ||
295 			    Z_TYPE(ZEND_OP2_LITERAL(init_opline)) != IS_STRING) {
296 				/* don't colllect constants after unknown function call */
297 				collect_constants = 0;
298 				break;
299 			}
300 
301 			/* define("name", scalar); */
302 			if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("define")-1 &&
303 			    zend_binary_strcasecmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), Z_STRLEN(ZEND_OP2_LITERAL(init_opline)), "define", sizeof("define")-1) == 0) {
304 
305 				if (Z_TYPE(ZEND_OP1_LITERAL(send1_opline)) == IS_STRING &&
306 				    send2_opline &&
307 				    Z_TYPE(ZEND_OP1_LITERAL(send2_opline)) <= IS_STRING) {
308 
309 					if (collect_constants) {
310 						zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(send1_opline), &ZEND_OP1_LITERAL(send2_opline));
311 					}
312 
313 					if (RESULT_UNUSED(opline) &&
314 					    !zend_memnstr(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), "::", sizeof("::") - 1, Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)) + Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) {
315 
316 						opline->opcode = ZEND_DECLARE_CONST;
317 						opline->op1_type = IS_CONST;
318 						opline->op2_type = IS_CONST;
319 						opline->result_type = IS_UNUSED;
320 						opline->op1.constant = send1_opline->op1.constant;
321 						opline->op2.constant = send2_opline->op1.constant;
322 						opline->result.num = 0;
323 
324 						literal_dtor(&ZEND_OP2_LITERAL(init_opline));
325 						MAKE_NOP(init_opline);
326 						MAKE_NOP(send1_opline);
327 						MAKE_NOP(send2_opline);
328 					}
329 					break;
330 				}
331 			}
332 
333 			/* pre-evaluate constant functions:
334 			   constant(x)
335 			   function_exists(x)
336 			   is_callable(x)
337 			   extension_loaded(x)
338 			*/
339 			if (!send2_opline &&
340 			    Z_TYPE(ZEND_OP1_LITERAL(send1_opline)) == IS_STRING) {
341 				if ((Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("function_exists")-1 &&
342 					!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
343 						"function_exists", sizeof("function_exists")-1) &&
344 					!zend_optimizer_is_disabled_func("function_exists", sizeof("function_exists") - 1)) ||
345 					(Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("is_callable")-1 &&
346 					!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
347 						"is_callable", sizeof("is_callable")) &&
348 					!zend_optimizer_is_disabled_func("is_callable", sizeof("is_callable") - 1))) {
349 					zend_internal_function *func;
350 					zend_string *lc_name = zend_string_tolower(
351 							Z_STR(ZEND_OP1_LITERAL(send1_opline)));
352 
353 					if ((func = zend_hash_find_ptr(EG(function_table), lc_name)) != NULL
354 						 && func->type == ZEND_INTERNAL_FUNCTION
355 						 && func->module->type == MODULE_PERSISTENT
356 #ifdef ZEND_WIN32
357 						 && func->module->handle == NULL
358 #endif
359 						) {
360 						zval t;
361 						if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("is_callable") - 1 ||
362 								func->handler != ZEND_FN(display_disabled_function)) {
363 							ZVAL_TRUE(&t);
364 						} else {
365 							ZVAL_FALSE(&t);
366 						}
367 						literal_dtor(&ZEND_OP2_LITERAL(init_opline));
368 						MAKE_NOP(init_opline);
369 						literal_dtor(&ZEND_OP1_LITERAL(send1_opline));
370 						MAKE_NOP(send1_opline);
371 						if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, opline->result.var, &t)) {
372 							MAKE_NOP(opline);
373 						} else {
374 							opline->opcode = ZEND_QM_ASSIGN;
375 							opline->extended_value = 0;
376 							SET_UNUSED(opline->op2);
377 							zend_optimizer_update_op1_const(op_array, opline, &t);
378 						}
379 					}
380 					zend_string_release_ex(lc_name, 0);
381 					break;
382 				} else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("extension_loaded")-1 &&
383 					!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
384 						"extension_loaded", sizeof("extension_loaded")-1) &&
385 					!zend_optimizer_is_disabled_func("extension_loaded", sizeof("extension_loaded") - 1)) {
386 					zval t;
387 					zend_string *lc_name = zend_string_tolower(
388 							Z_STR(ZEND_OP1_LITERAL(send1_opline)));
389 					zend_module_entry *m = zend_hash_find_ptr(&module_registry,
390 							lc_name);
391 
392 					zend_string_release_ex(lc_name, 0);
393 					if (!m) {
394 						if (PG(enable_dl)) {
395 							break;
396 						} else {
397 							ZVAL_FALSE(&t);
398 						}
399 					} else {
400 						if (m->type == MODULE_PERSISTENT
401 #ifdef ZEND_WIN32
402 						 && m->handle == NULL
403 #endif
404 						) {
405 							ZVAL_TRUE(&t);
406 						} else {
407 							break;
408 						}
409 					}
410 
411 					literal_dtor(&ZEND_OP2_LITERAL(init_opline));
412 					MAKE_NOP(init_opline);
413 					literal_dtor(&ZEND_OP1_LITERAL(send1_opline));
414 					MAKE_NOP(send1_opline);
415 					if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, opline->result.var, &t)) {
416 						MAKE_NOP(opline);
417 					} else {
418 						opline->opcode = ZEND_QM_ASSIGN;
419 						opline->extended_value = 0;
420 						SET_UNUSED(opline->op2);
421 						zend_optimizer_update_op1_const(op_array, opline, &t);
422 					}
423 					break;
424 				} else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("constant")-1 &&
425 					!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
426 						"constant", sizeof("constant")-1) &&
427 					!zend_optimizer_is_disabled_func("constant", sizeof("constant") - 1)) {
428 					zval t;
429 
430 					if (zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(send1_opline)), &t, 1)) {
431 						literal_dtor(&ZEND_OP2_LITERAL(init_opline));
432 						MAKE_NOP(init_opline);
433 						literal_dtor(&ZEND_OP1_LITERAL(send1_opline));
434 						MAKE_NOP(send1_opline);
435 						if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, opline->result.var, &t)) {
436 							MAKE_NOP(opline);
437 						} else {
438 							opline->opcode = ZEND_QM_ASSIGN;
439 							opline->extended_value = 0;
440 							SET_UNUSED(opline->op2);
441 							zend_optimizer_update_op1_const(op_array, opline, &t);
442 						}
443 					}
444 					break;
445 				/* dirname(IS_CONST/IS_STRING) -> IS_CONST/IS_STRING */
446 				} else if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("dirname")-1 &&
447 					!memcmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)),
448 						"dirname", sizeof("dirname") - 1) &&
449 					!zend_optimizer_is_disabled_func("dirname", sizeof("dirname") - 1) &&
450 					IS_ABSOLUTE_PATH(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) {
451 					zend_string *dirname = zend_string_init(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)), 0);
452 					ZSTR_LEN(dirname) = zend_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname));
453 					if (IS_ABSOLUTE_PATH(ZSTR_VAL(dirname), ZSTR_LEN(dirname))) {
454 						zval t;
455 
456 						ZVAL_STR(&t, dirname);
457 						literal_dtor(&ZEND_OP2_LITERAL(init_opline));
458 						MAKE_NOP(init_opline);
459 						literal_dtor(&ZEND_OP1_LITERAL(send1_opline));
460 						MAKE_NOP(send1_opline);
461 						if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_VAR, opline->result.var, &t)) {
462 							MAKE_NOP(opline);
463 						} else {
464 							opline->opcode = ZEND_QM_ASSIGN;
465 							opline->extended_value = 0;
466 							SET_UNUSED(opline->op2);
467 							zend_optimizer_update_op1_const(op_array, opline, &t);
468 						}
469 					} else {
470 						zend_string_release_ex(dirname, 0);
471 					}
472 					break;
473 				}
474 			}
475 			/* don't colllect constants after any other function call */
476 			collect_constants = 0;
477 			break;
478 		}
479 		case ZEND_STRLEN:
480 			if (opline->op1_type == IS_CONST) {
481 				zval t;
482 
483 				if (zend_optimizer_eval_strlen(&t, &ZEND_OP1_LITERAL(opline)) == SUCCESS) {
484 					literal_dtor(&ZEND_OP1_LITERAL(opline));
485 					if (zend_optimizer_replace_by_const(op_array, opline + 1, IS_TMP_VAR, opline->result.var, &t)) {
486 						MAKE_NOP(opline);
487 					} else {
488 						opline->opcode = ZEND_QM_ASSIGN;
489 						zend_optimizer_update_op1_const(op_array, opline, &t);
490 					}
491 				}
492 			}
493 			break;
494 		case ZEND_DEFINED:
495 			{
496 				zval c;
497 				if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &c, 0)) {
498 					break;
499 				}
500 				ZVAL_TRUE(&c);
501 				literal_dtor(&ZEND_OP1_LITERAL(opline));
502 				if (zend_optimizer_replace_by_const(op_array, opline, IS_TMP_VAR, opline->result.var, &c)) {
503 					MAKE_NOP(opline);
504 				} else {
505 					opline->opcode = ZEND_QM_ASSIGN;
506 					zend_optimizer_update_op1_const(op_array, opline, &c);
507 				}
508 			}
509 			break;
510 		case ZEND_DECLARE_CONST:
511 			if (collect_constants &&
512 			    Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING &&
513 			    Z_TYPE(ZEND_OP2_LITERAL(opline)) <= IS_STRING) {
514 				zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(opline), &ZEND_OP2_LITERAL(opline));
515 			}
516 			break;
517 
518 		case ZEND_RETURN:
519 		case ZEND_RETURN_BY_REF:
520 		case ZEND_GENERATOR_RETURN:
521 		case ZEND_EXIT:
522 		case ZEND_THROW:
523 		case ZEND_CATCH:
524 		case ZEND_FAST_CALL:
525 		case ZEND_FAST_RET:
526 		case ZEND_JMP:
527 		case ZEND_JMPZNZ:
528 		case ZEND_JMPZ:
529 		case ZEND_JMPNZ:
530 		case ZEND_JMPZ_EX:
531 		case ZEND_JMPNZ_EX:
532 		case ZEND_FE_RESET_R:
533 		case ZEND_FE_RESET_RW:
534 		case ZEND_FE_FETCH_R:
535 		case ZEND_FE_FETCH_RW:
536 		case ZEND_JMP_SET:
537 		case ZEND_COALESCE:
538 		case ZEND_ASSERT_CHECK:
539 			collect_constants = 0;
540 			break;
541 		}
542 		opline++;
543 		i++;
544 	}
545 }
546