1/*
2   +----------------------------------------------------------------------+
3   | Zend Engine                                                          |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt.                                |
11   | If you did not receive a copy of the Zend license and are unable to  |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@zend.com so we can mail you a copy immediately.              |
14   +----------------------------------------------------------------------+
15   | Authors: Andi Gutmans <andi@zend.com>                                |
16   |          Zeev Suraski <zeev@zend.com>                                |
17   |          Dmitry Stogov <dmitry@zend.com>                             |
18   +----------------------------------------------------------------------+
19*/
20
21/* $Id$ */
22
23/* If you change this file, please regenerate the zend_vm_execute.h and
24 * zend_vm_opcodes.h files by running:
25 * php zend_vm_gen.php
26 */
27
28ZEND_VM_HANDLER(1, ZEND_ADD, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
29{
30	USE_OPLINE
31	zend_free_op free_op1, free_op2;
32	zval *op1, *op2, *result;
33
34	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
35	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
36	if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
37		if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
38			result = EX_VAR(opline->result.var);
39			fast_long_add_function(result, op1, op2);
40			ZEND_VM_NEXT_OPCODE();
41		} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
42			result = EX_VAR(opline->result.var);
43			ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2));
44			ZEND_VM_NEXT_OPCODE();
45		}
46	} else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
47		if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
48			result = EX_VAR(opline->result.var);
49			ZVAL_DOUBLE(result, Z_DVAL_P(op1) + Z_DVAL_P(op2));
50			ZEND_VM_NEXT_OPCODE();
51		} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
52			result = EX_VAR(opline->result.var);
53			ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2)));
54			ZEND_VM_NEXT_OPCODE();
55		}
56	}
57
58	SAVE_OPLINE();
59	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
60		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
61	}
62	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
63		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
64	}
65	add_function(EX_VAR(opline->result.var), op1, op2);
66	FREE_OP1();
67	FREE_OP2();
68	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
69}
70
71ZEND_VM_HANDLER(2, ZEND_SUB, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
72{
73	USE_OPLINE
74	zend_free_op free_op1, free_op2;
75	zval *op1, *op2, *result;
76
77	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
78	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
79	if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
80		if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
81			result = EX_VAR(opline->result.var);
82			fast_long_sub_function(result, op1, op2);
83			ZEND_VM_NEXT_OPCODE();
84		} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
85			result = EX_VAR(opline->result.var);
86			ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) - Z_DVAL_P(op2));
87			ZEND_VM_NEXT_OPCODE();
88		}
89	} else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
90		if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
91			result = EX_VAR(opline->result.var);
92			ZVAL_DOUBLE(result, Z_DVAL_P(op1) - Z_DVAL_P(op2));
93			ZEND_VM_NEXT_OPCODE();
94		} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
95			result = EX_VAR(opline->result.var);
96			ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2)));
97			ZEND_VM_NEXT_OPCODE();
98		}
99	}
100
101	SAVE_OPLINE();
102	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
103		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
104	}
105	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
106		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
107	}
108	sub_function(EX_VAR(opline->result.var), op1, op2);
109	FREE_OP1();
110	FREE_OP2();
111	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
112}
113
114ZEND_VM_HANDLER(3, ZEND_MUL, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
115{
116	USE_OPLINE
117	zend_free_op free_op1, free_op2;
118	zval *op1, *op2, *result;
119
120	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
121	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
122	if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
123		if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
124			zend_long overflow;
125
126			result = EX_VAR(opline->result.var);
127			ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1), Z_LVAL_P(op2), Z_LVAL_P(result), Z_DVAL_P(result), overflow);
128			Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_LONG;
129			ZEND_VM_NEXT_OPCODE();
130		} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
131			result = EX_VAR(opline->result.var);
132			ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) * Z_DVAL_P(op2));
133			ZEND_VM_NEXT_OPCODE();
134		}
135	} else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
136		if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
137			result = EX_VAR(opline->result.var);
138			ZVAL_DOUBLE(result, Z_DVAL_P(op1) * Z_DVAL_P(op2));
139			ZEND_VM_NEXT_OPCODE();
140		} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
141			result = EX_VAR(opline->result.var);
142			ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2)));
143			ZEND_VM_NEXT_OPCODE();
144		}
145	}
146
147	SAVE_OPLINE();
148	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
149		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
150	}
151	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
152		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
153	}
154	mul_function(EX_VAR(opline->result.var), op1, op2);
155	FREE_OP1();
156	FREE_OP2();
157	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
158}
159
160ZEND_VM_HANDLER(4, ZEND_DIV, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
161{
162	USE_OPLINE
163	zend_free_op free_op1, free_op2;
164	zval *op1, *op2;
165
166	SAVE_OPLINE();
167	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
168	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
169	fast_div_function(EX_VAR(opline->result.var), op1, op2);
170	FREE_OP1();
171	FREE_OP2();
172	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
173}
174
175ZEND_VM_HANDLER(5, ZEND_MOD, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
176{
177	USE_OPLINE
178	zend_free_op free_op1, free_op2;
179	zval *op1, *op2, *result;
180
181	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
182	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
183	if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
184		if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
185			result = EX_VAR(opline->result.var);
186			if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
187				SAVE_OPLINE();
188				zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero");
189				HANDLE_EXCEPTION();
190			} else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
191				/* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
192				ZVAL_LONG(result, 0);
193			} else {
194				ZVAL_LONG(result, Z_LVAL_P(op1) % Z_LVAL_P(op2));
195			}
196			ZEND_VM_NEXT_OPCODE();
197		}
198	}
199
200	SAVE_OPLINE();
201	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
202		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
203	}
204	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
205		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
206	}
207	mod_function(EX_VAR(opline->result.var), op1, op2);
208	FREE_OP1();
209	FREE_OP2();
210	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
211}
212
213ZEND_VM_HANDLER(6, ZEND_SL, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
214{
215	USE_OPLINE
216	zend_free_op free_op1, free_op2;
217	zval *op1, *op2;
218
219	SAVE_OPLINE();
220	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
221	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
222	shift_left_function(EX_VAR(opline->result.var), op1, op2);
223	FREE_OP1();
224	FREE_OP2();
225	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
226}
227
228ZEND_VM_HANDLER(7, ZEND_SR, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
229{
230	USE_OPLINE
231	zend_free_op free_op1, free_op2;
232	zval *op1, *op2;
233
234	SAVE_OPLINE();
235	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
236	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
237	shift_right_function(EX_VAR(opline->result.var), op1, op2);
238	FREE_OP1();
239	FREE_OP2();
240	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
241}
242
243ZEND_VM_HANDLER(166, ZEND_POW, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
244{
245	USE_OPLINE
246	zend_free_op free_op1, free_op2;
247	zval *op1, *op2;
248
249	SAVE_OPLINE();
250	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
251	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
252	pow_function(EX_VAR(opline->result.var), op1, op2);
253	FREE_OP1();
254	FREE_OP2();
255	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
256}
257
258ZEND_VM_HANDLER(8, ZEND_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
259{
260	USE_OPLINE
261	zend_free_op free_op1, free_op2;
262	zval *op1, *op2;
263
264	SAVE_OPLINE();
265	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
266	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
267
268	do {
269		if ((OP1_TYPE == IS_CONST || EXPECTED(Z_TYPE_P(op1) == IS_STRING)) &&
270		    (OP2_TYPE == IS_CONST || EXPECTED(Z_TYPE_P(op2) == IS_STRING))) {
271			zend_string *op1_str = Z_STR_P(op1);
272			zend_string *op2_str = Z_STR_P(op2);
273			zend_string *str;
274
275			if (OP1_TYPE != IS_CONST) {
276				if (UNEXPECTED(ZSTR_LEN(op1_str) == 0)) {
277					ZVAL_STR_COPY(EX_VAR(opline->result.var), op2_str);
278					FREE_OP1();
279					break;
280				}
281			}
282			if (OP2_TYPE != IS_CONST) {
283				if (UNEXPECTED(ZSTR_LEN(op2_str) == 0)) {
284					ZVAL_STR_COPY(EX_VAR(opline->result.var), op1_str);
285					FREE_OP1();
286					break;
287				}
288			}
289			if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_CV &&
290			    !ZSTR_IS_INTERNED(op1_str) && GC_REFCOUNT(op1_str) == 1) {
291			    size_t len = ZSTR_LEN(op1_str);
292
293				str = zend_string_extend(op1_str, len + ZSTR_LEN(op2_str), 0);
294				memcpy(ZSTR_VAL(str) + len, ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
295				ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
296				break;
297			} else {
298				str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
299				memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
300				memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
301				ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
302			}
303		} else {
304			if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
305				op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
306			}
307			if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
308				op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
309			}
310			concat_function(EX_VAR(opline->result.var), op1, op2);
311		}
312		FREE_OP1();
313	} while (0);
314	FREE_OP2();
315	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
316}
317
318ZEND_VM_HANDLER(15, ZEND_IS_IDENTICAL, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV)
319{
320	USE_OPLINE
321	zend_free_op free_op1, free_op2;
322	zval *op1, *op2;
323	int result;
324
325	SAVE_OPLINE();
326	op1 = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
327	op2 = GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R);
328	result = fast_is_identical_function(op1, op2);
329	FREE_OP1();
330	FREE_OP2();
331	ZEND_VM_SMART_BRANCH(result, 1);
332	ZVAL_BOOL(EX_VAR(opline->result.var), result);
333	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
334}
335
336ZEND_VM_HANDLER(16, ZEND_IS_NOT_IDENTICAL, CONST|TMP|VAR|CV, CONST|TMP|VAR|CV)
337{
338	USE_OPLINE
339	zend_free_op free_op1, free_op2;
340	zval *op1, *op2;
341	int result;
342
343	SAVE_OPLINE();
344	op1 = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
345	op2 = GET_OP2_ZVAL_PTR_DEREF(BP_VAR_R);
346	result = fast_is_not_identical_function(op1, op2);
347	FREE_OP1();
348	FREE_OP2();
349	ZEND_VM_SMART_BRANCH(result, 1);
350	ZVAL_BOOL(EX_VAR(opline->result.var), result);
351	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
352}
353
354ZEND_VM_HANDLER(17, ZEND_IS_EQUAL, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
355{
356	USE_OPLINE
357	zend_free_op free_op1, free_op2;
358	zval *op1, *op2, *result;
359
360	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
361	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
362	do {
363		int result;
364
365		if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
366			if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
367				result = (Z_LVAL_P(op1) == Z_LVAL_P(op2));
368			} else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
369				result = ((double)Z_LVAL_P(op1) == Z_DVAL_P(op2));
370			} else {
371				break;
372			}
373		} else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
374			if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
375				result = (Z_DVAL_P(op1) == Z_DVAL_P(op2));
376			} else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
377				result = (Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2)));
378			} else {
379				break;
380			}
381		} else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
382			if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
383				if (Z_STR_P(op1) == Z_STR_P(op2)) {
384					result = 1;
385				} else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
386					if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
387						result = 0;
388					} else {
389						result = (memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0);
390					}
391				} else {
392					result = (zendi_smart_strcmp(Z_STR_P(op1), Z_STR_P(op2)) == 0);
393				}
394				FREE_OP1();
395				FREE_OP2();
396			} else {
397				break;
398			}
399		} else {
400			break;
401		}
402		ZEND_VM_SMART_BRANCH(result, 0);
403		ZVAL_BOOL(EX_VAR(opline->result.var), result);
404		ZEND_VM_NEXT_OPCODE();
405	} while (0);
406
407	SAVE_OPLINE();
408	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
409		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
410	}
411	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
412		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
413	}
414	result = EX_VAR(opline->result.var);
415	compare_function(result, op1, op2);
416	ZVAL_BOOL(result, Z_LVAL_P(result) == 0);
417	FREE_OP1();
418	FREE_OP2();
419	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
420}
421
422ZEND_VM_HANDLER(18, ZEND_IS_NOT_EQUAL, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
423{
424	USE_OPLINE
425	zend_free_op free_op1, free_op2;
426	zval *op1, *op2, *result;
427
428	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
429	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
430	do {
431		int result;
432
433		if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
434			if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
435				result = (Z_LVAL_P(op1) != Z_LVAL_P(op2));
436			} else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
437				result = ((double)Z_LVAL_P(op1) != Z_DVAL_P(op2));
438			} else {
439				break;
440			}
441		} else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
442			if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
443				result = (Z_DVAL_P(op1) != Z_DVAL_P(op2));
444			} else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
445				result = (Z_DVAL_P(op1) != ((double)Z_LVAL_P(op2)));
446			} else {
447				break;
448			}
449		} else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
450			if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
451				if (Z_STR_P(op1) == Z_STR_P(op2)) {
452					result = 0;
453				} else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
454					if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
455						result = 1;
456					} else {
457						result = (memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) != 0);
458					}
459				} else {
460					result = (zendi_smart_strcmp(Z_STR_P(op1), Z_STR_P(op2)) != 0);
461				}
462				FREE_OP1();
463				FREE_OP2();
464			} else {
465				break;
466			}
467		} else {
468			break;
469		}
470		ZEND_VM_SMART_BRANCH(result, 0);
471		ZVAL_BOOL(EX_VAR(opline->result.var), result);
472		ZEND_VM_NEXT_OPCODE();
473	} while (0);
474
475	SAVE_OPLINE();
476	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
477		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
478	}
479	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
480		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
481	}
482	result = EX_VAR(opline->result.var);
483	compare_function(result, op1, op2);
484	ZVAL_BOOL(result, Z_LVAL_P(result) != 0);
485	FREE_OP1();
486	FREE_OP2();
487	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
488}
489
490ZEND_VM_HANDLER(19, ZEND_IS_SMALLER, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
491{
492	USE_OPLINE
493	zend_free_op free_op1, free_op2;
494	zval *op1, *op2, *result;
495
496	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
497	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
498	do {
499		int result;
500
501		if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
502			if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
503				result = (Z_LVAL_P(op1) < Z_LVAL_P(op2));
504			} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
505				result = ((double)Z_LVAL_P(op1) < Z_DVAL_P(op2));
506			} else {
507				break;
508			}
509		} else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
510			if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
511				result = (Z_DVAL_P(op1) < Z_DVAL_P(op2));
512			} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
513				result = (Z_DVAL_P(op1) < ((double)Z_LVAL_P(op2)));
514			} else {
515				break;
516			}
517		} else {
518			break;
519		}
520		ZEND_VM_SMART_BRANCH(result, 0);
521		ZVAL_BOOL(EX_VAR(opline->result.var), result);
522		ZEND_VM_NEXT_OPCODE();
523	} while (0);
524
525	SAVE_OPLINE();
526	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
527		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
528	}
529	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
530		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
531	}
532	result = EX_VAR(opline->result.var);
533	compare_function(result, op1, op2);
534	ZVAL_BOOL(result, Z_LVAL_P(result) < 0);
535	FREE_OP1();
536	FREE_OP2();
537	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
538}
539
540ZEND_VM_HANDLER(20, ZEND_IS_SMALLER_OR_EQUAL, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
541{
542	USE_OPLINE
543	zend_free_op free_op1, free_op2;
544	zval *op1, *op2, *result;
545
546	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
547	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
548	do {
549		int result;
550
551		if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_LONG)) {
552			if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
553				result = (Z_LVAL_P(op1) <= Z_LVAL_P(op2));
554			} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
555				result = ((double)Z_LVAL_P(op1) <= Z_DVAL_P(op2));
556			} else {
557				break;
558			}
559		} else if (EXPECTED(Z_TYPE_INFO_P(op1) == IS_DOUBLE)) {
560			if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_DOUBLE)) {
561				result = (Z_DVAL_P(op1) <= Z_DVAL_P(op2));
562			} else if (EXPECTED(Z_TYPE_INFO_P(op2) == IS_LONG)) {
563				result = (Z_DVAL_P(op1) <= ((double)Z_LVAL_P(op2)));
564			} else {
565				break;
566			}
567		} else {
568			break;
569		}
570		ZEND_VM_SMART_BRANCH(result, 0);
571		ZVAL_BOOL(EX_VAR(opline->result.var), result);
572		ZEND_VM_NEXT_OPCODE();
573	} while (0);
574
575	SAVE_OPLINE();
576	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op1) == IS_UNDEF)) {
577		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
578	}
579	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(op2) == IS_UNDEF)) {
580		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
581	}
582	result = EX_VAR(opline->result.var);
583	compare_function(result, op1, op2);
584	ZVAL_BOOL(result, Z_LVAL_P(result) <= 0);
585	FREE_OP1();
586	FREE_OP2();
587	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
588}
589
590ZEND_VM_HANDLER(170, ZEND_SPACESHIP, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
591{
592	USE_OPLINE
593	zend_free_op free_op1, free_op2;
594	zval *op1, *op2;
595
596	SAVE_OPLINE();
597	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
598	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
599	compare_function(EX_VAR(opline->result.var), op1, op2);
600	FREE_OP1();
601	FREE_OP2();
602	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
603}
604
605ZEND_VM_HANDLER(9, ZEND_BW_OR, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
606{
607	USE_OPLINE
608	zend_free_op free_op1, free_op2;
609	zval *op1, *op2;
610
611	SAVE_OPLINE();
612	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
613	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
614	bitwise_or_function(EX_VAR(opline->result.var), op1, op2);
615	FREE_OP1();
616	FREE_OP2();
617	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
618}
619
620ZEND_VM_HANDLER(10, ZEND_BW_AND, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
621{
622	USE_OPLINE
623	zend_free_op free_op1, free_op2;
624	zval *op1, *op2;
625
626	SAVE_OPLINE();
627	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
628	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
629	bitwise_and_function(EX_VAR(opline->result.var), op1, op2);
630	FREE_OP1();
631	FREE_OP2();
632	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
633}
634
635ZEND_VM_HANDLER(11, ZEND_BW_XOR, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
636{
637	USE_OPLINE
638	zend_free_op free_op1, free_op2;
639	zval *op1, *op2;
640
641	SAVE_OPLINE();
642	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
643	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
644	bitwise_xor_function(EX_VAR(opline->result.var), op1, op2);
645	FREE_OP1();
646	FREE_OP2();
647	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
648}
649
650ZEND_VM_HANDLER(14, ZEND_BOOL_XOR, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
651{
652	USE_OPLINE
653	zend_free_op free_op1, free_op2;
654	zval *op1, *op2;
655
656	SAVE_OPLINE();
657	op1 = GET_OP1_ZVAL_PTR(BP_VAR_R);
658	op2 = GET_OP2_ZVAL_PTR(BP_VAR_R);
659	boolean_xor_function(EX_VAR(opline->result.var), op1, op2);
660	FREE_OP1();
661	FREE_OP2();
662	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
663}
664
665ZEND_VM_HANDLER(12, ZEND_BW_NOT, CONST|TMPVAR|CV, ANY)
666{
667	USE_OPLINE
668	zend_free_op free_op1;
669
670	SAVE_OPLINE();
671	bitwise_not_function(EX_VAR(opline->result.var),
672		GET_OP1_ZVAL_PTR(BP_VAR_R));
673	FREE_OP1();
674	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
675}
676
677ZEND_VM_HANDLER(13, ZEND_BOOL_NOT, CONST|TMPVAR|CV, ANY)
678{
679	USE_OPLINE
680	zval *val;
681	zend_free_op free_op1;
682
683	val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
684	if (Z_TYPE_INFO_P(val) == IS_TRUE) {
685		ZVAL_FALSE(EX_VAR(opline->result.var));
686	} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
687		ZVAL_TRUE(EX_VAR(opline->result.var));
688		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
689			SAVE_OPLINE();
690			GET_OP1_UNDEF_CV(val, BP_VAR_R);
691			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
692		}
693	} else {
694		SAVE_OPLINE();
695		ZVAL_BOOL(EX_VAR(opline->result.var), !i_zend_is_true(val));
696		FREE_OP1();
697		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
698	}
699	ZEND_VM_NEXT_OPCODE();
700}
701
702ZEND_VM_HELPER(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, binary_op_type binary_op)
703{
704	USE_OPLINE
705	zend_free_op free_op1, free_op2, free_op_data1;
706	zval *object;
707	zval *property;
708	zval *value;
709	zval *zptr;
710
711	SAVE_OPLINE();
712	object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
713
714	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) == IS_UNDEF)) {
715		zend_throw_error(NULL, "Using $this when not in object context");
716		FREE_UNFETCHED_OP((opline+1)->op1_type, (opline+1)->op1.var);
717		FREE_UNFETCHED_OP2();
718		HANDLE_EXCEPTION();
719	}
720
721	property = GET_OP2_ZVAL_PTR(BP_VAR_R);
722
723	do {
724		value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
725
726		if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
727			ZVAL_DEREF(object);
728			if (UNEXPECTED(!make_real_object(object))) {
729				zend_error(E_WARNING, "Attempt to assign property of non-object");
730				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
731					ZVAL_NULL(EX_VAR(opline->result.var));
732				}
733				break;
734			}
735		}
736
737		/* here we are sure we are dealing with an object */
738		if (EXPECTED(Z_OBJ_HT_P(object)->get_property_ptr_ptr)
739			&& EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL))) != NULL)) {
740			if (UNEXPECTED(Z_ISERROR_P(zptr))) {
741				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
742					ZVAL_NULL(EX_VAR(opline->result.var));
743				}
744			} else {
745				ZVAL_DEREF(zptr);
746				SEPARATE_ZVAL_NOREF(zptr);
747
748				binary_op(zptr, zptr, value);
749				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
750					ZVAL_COPY(EX_VAR(opline->result.var), zptr);
751				}
752			}
753		} else {
754			zend_assign_op_overloaded_property(object, property, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), value, binary_op, (UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL));
755		}
756	} while (0);
757
758	FREE_OP(free_op_data1);
759	FREE_OP2();
760	FREE_OP1_VAR_PTR();
761	/* assign_obj has two opcodes! */
762	ZEND_VM_NEXT_OPCODE_EX(1, 2);
763}
764
765ZEND_VM_HELPER(zend_binary_assign_op_dim_helper, VAR|UNUSED|CV, CONST|TMPVAR|UNUSED|CV, binary_op_type binary_op)
766{
767	USE_OPLINE
768	zend_free_op free_op1, free_op2, free_op_data1;
769	zval *var_ptr;
770	zval *value, *container, *dim;
771
772	SAVE_OPLINE();
773	container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
774	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
775		zend_throw_error(NULL, "Using $this when not in object context");
776		FREE_UNFETCHED_OP((opline+1)->op1_type, (opline+1)->op1.var);
777		FREE_UNFETCHED_OP2();
778		HANDLE_EXCEPTION();
779	}
780
781	if (OP1_TYPE != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
782ZEND_VM_C_LABEL(assign_dim_op_array):
783		SEPARATE_ARRAY(container);
784ZEND_VM_C_LABEL(assign_dim_op_new_array):
785		if (OP2_TYPE == IS_UNUSED) {
786			var_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(container), &EG(uninitialized_zval));
787			if (UNEXPECTED(!var_ptr)) {
788				zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
789				ZEND_VM_C_GOTO(assign_dim_op_ret_null);
790			}
791		} else {
792			dim = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
793
794			if (OP2_TYPE == IS_CONST) {
795				var_ptr = zend_fetch_dimension_address_inner_RW_CONST(Z_ARRVAL_P(container), dim);
796			} else {
797				var_ptr = zend_fetch_dimension_address_inner_RW(Z_ARRVAL_P(container), dim);
798			}
799			if (UNEXPECTED(!var_ptr)) {
800				ZEND_VM_C_GOTO(assign_dim_op_ret_null);
801			}
802			ZVAL_DEREF(var_ptr);
803			SEPARATE_ZVAL_NOREF(var_ptr);
804		}
805
806		value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
807
808		binary_op(var_ptr, var_ptr, value);
809
810		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
811			ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
812		}
813	} else {
814		if (OP1_TYPE != IS_UNUSED) {
815			if (EXPECTED(Z_ISREF_P(container))) {
816				container = Z_REFVAL_P(container);
817				if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
818					ZEND_VM_C_GOTO(assign_dim_op_array);
819				}
820			} else if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(container) == IS_UNDEF)) {
821				container = GET_OP1_UNDEF_CV(container, BP_VAR_RW);
822				ZEND_VM_C_GOTO(assign_dim_op_convert_to_array);
823			}
824		}
825
826		dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
827
828		if (OP1_TYPE == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
829			value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
830			zend_binary_assign_op_obj_dim(container, dim, value, UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL, binary_op);
831		} else if (OP1_TYPE != IS_UNUSED) {
832			if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) {
833				if (UNEXPECTED(Z_STRLEN_P(container) == 0)) {
834					zval_ptr_dtor_nogc(container);
835ZEND_VM_C_LABEL(assign_dim_op_convert_to_array):
836					ZVAL_NEW_ARR(container);
837					zend_hash_init(Z_ARRVAL_P(container), 8, NULL, ZVAL_PTR_DTOR, 0);
838					ZEND_VM_C_GOTO(assign_dim_op_new_array);
839				}
840
841				if (OP2_TYPE == IS_UNUSED) {
842					zend_throw_error(NULL, "[] operator not supported for strings");
843				} else {
844					zend_check_string_offset(dim, BP_VAR_RW);
845					zend_wrong_string_offset();
846				}
847			} else {
848				if (EXPECTED(Z_TYPE_P(container) <= IS_FALSE)) {
849					ZEND_VM_C_GOTO(assign_dim_op_convert_to_array);
850				}
851				if (UNEXPECTED(!Z_ISERROR_P(container))) {
852					zend_error(E_WARNING, "Cannot use a scalar value as an array");
853				}
854ZEND_VM_C_LABEL(assign_dim_op_ret_null):
855				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
856					ZVAL_NULL(EX_VAR(opline->result.var));
857				}
858			}
859			value = get_zval_ptr_r((opline+1)->op1_type, (opline+1)->op1, execute_data, &free_op_data1);
860		}
861	}
862
863	FREE_OP2();
864	FREE_OP(free_op_data1);
865	FREE_OP1_VAR_PTR();
866	ZEND_VM_NEXT_OPCODE_EX(1, 2);
867}
868
869ZEND_VM_HELPER(zend_binary_assign_op_helper, VAR|CV, CONST|TMPVAR|CV, binary_op_type binary_op)
870{
871	USE_OPLINE
872	zend_free_op free_op1, free_op2;
873	zval *var_ptr;
874	zval *value;
875
876	SAVE_OPLINE();
877	value = GET_OP2_ZVAL_PTR(BP_VAR_R);
878	var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW);
879
880	if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
881		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
882			ZVAL_NULL(EX_VAR(opline->result.var));
883		}
884	} else {
885		ZVAL_DEREF(var_ptr);
886		SEPARATE_ZVAL_NOREF(var_ptr);
887
888		binary_op(var_ptr, var_ptr, value);
889
890		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
891			ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
892		}
893	}
894
895	FREE_OP2();
896	FREE_OP1_VAR_PTR();
897	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
898}
899
900ZEND_VM_HANDLER(23, ZEND_ASSIGN_ADD, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
901{
902#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
903	USE_OPLINE
904
905# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
906	if (EXPECTED(opline->extended_value == 0)) {
907		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, add_function);
908	}
909# endif
910	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
911		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, add_function);
912	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
913		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, add_function);
914	}
915#else
916	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, add_function);
917#endif
918}
919
920ZEND_VM_HANDLER(24, ZEND_ASSIGN_SUB, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
921{
922#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
923	USE_OPLINE
924
925# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
926	if (EXPECTED(opline->extended_value == 0)) {
927		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, sub_function);
928	}
929# endif
930	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
931		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, sub_function);
932	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
933		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, sub_function);
934	}
935#else
936	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, sub_function);
937#endif
938}
939
940ZEND_VM_HANDLER(25, ZEND_ASSIGN_MUL, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
941{
942#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
943	USE_OPLINE
944
945# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
946	if (EXPECTED(opline->extended_value == 0)) {
947		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, mul_function);
948	}
949# endif
950	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
951		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, mul_function);
952	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
953		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, mul_function);
954	}
955#else
956	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, mul_function);
957#endif
958}
959
960ZEND_VM_HANDLER(26, ZEND_ASSIGN_DIV, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
961{
962#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
963	USE_OPLINE
964
965# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
966	if (EXPECTED(opline->extended_value == 0)) {
967		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, div_function);
968	}
969# endif
970	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
971		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, div_function);
972	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
973		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, div_function);
974	}
975#else
976	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, div_function);
977#endif
978}
979
980ZEND_VM_HANDLER(27, ZEND_ASSIGN_MOD, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
981{
982#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
983	USE_OPLINE
984
985# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
986	if (EXPECTED(opline->extended_value == 0)) {
987		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, mod_function);
988	}
989# endif
990	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
991		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, mod_function);
992	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
993		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, mod_function);
994	}
995#else
996	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, mod_function);
997#endif
998}
999
1000ZEND_VM_HANDLER(28, ZEND_ASSIGN_SL, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
1001{
1002#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
1003	USE_OPLINE
1004
1005# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
1006	if (EXPECTED(opline->extended_value == 0)) {
1007		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, shift_left_function);
1008	}
1009# endif
1010	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
1011		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, shift_left_function);
1012	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
1013		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, shift_left_function);
1014	}
1015#else
1016	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, shift_left_function);
1017#endif
1018}
1019
1020ZEND_VM_HANDLER(29, ZEND_ASSIGN_SR, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
1021{
1022#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
1023	USE_OPLINE
1024
1025# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
1026	if (EXPECTED(opline->extended_value == 0)) {
1027		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, shift_right_function);
1028	}
1029# endif
1030	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
1031		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, shift_right_function);
1032	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
1033		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, shift_right_function);
1034	}
1035#else
1036	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, shift_right_function);
1037#endif
1038}
1039
1040ZEND_VM_HANDLER(30, ZEND_ASSIGN_CONCAT, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
1041{
1042#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
1043	USE_OPLINE
1044
1045# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
1046	if (EXPECTED(opline->extended_value == 0)) {
1047		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, concat_function);
1048	}
1049# endif
1050	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
1051		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, concat_function);
1052	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
1053		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, concat_function);
1054	}
1055#else
1056	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, concat_function);
1057#endif
1058}
1059
1060ZEND_VM_HANDLER(31, ZEND_ASSIGN_BW_OR, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
1061{
1062#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
1063	USE_OPLINE
1064
1065# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
1066	if (EXPECTED(opline->extended_value == 0)) {
1067		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, bitwise_or_function);
1068	}
1069# endif
1070	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
1071		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, bitwise_or_function);
1072	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
1073		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, bitwise_or_function);
1074	}
1075#else
1076	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, bitwise_or_function);
1077#endif
1078}
1079
1080ZEND_VM_HANDLER(32, ZEND_ASSIGN_BW_AND, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
1081{
1082#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
1083	USE_OPLINE
1084
1085# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
1086	if (EXPECTED(opline->extended_value == 0)) {
1087		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, bitwise_and_function);
1088	}
1089# endif
1090	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
1091		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, bitwise_and_function);
1092	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
1093		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, bitwise_and_function);
1094	}
1095#else
1096	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, bitwise_and_function);
1097#endif
1098}
1099
1100ZEND_VM_HANDLER(33, ZEND_ASSIGN_BW_XOR, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
1101{
1102#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
1103	USE_OPLINE
1104
1105# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
1106	if (EXPECTED(opline->extended_value == 0)) {
1107		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, bitwise_xor_function);
1108	}
1109# endif
1110	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
1111		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, bitwise_xor_function);
1112	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
1113		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, bitwise_xor_function);
1114	}
1115#else
1116	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, bitwise_xor_function);
1117#endif
1118}
1119
1120ZEND_VM_HANDLER(167, ZEND_ASSIGN_POW, VAR|UNUSED|THIS|CV, CONST|TMPVAR|UNUSED|NEXT|CV, DIM_OBJ, SPEC(DIM_OBJ))
1121{
1122#if !defined(ZEND_VM_SPEC) || (OP2_TYPE != IS_UNUSED)
1123	USE_OPLINE
1124
1125# if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
1126	if (EXPECTED(opline->extended_value == 0)) {
1127		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_helper, binary_op, pow_function);
1128	}
1129# endif
1130	if (EXPECTED(opline->extended_value == ZEND_ASSIGN_DIM)) {
1131		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, pow_function);
1132	} else /* if (EXPECTED(opline->extended_value == ZEND_ASSIGN_OBJ)) */ {
1133		ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_obj_helper, binary_op, pow_function);
1134	}
1135#else
1136	ZEND_VM_DISPATCH_TO_HELPER(zend_binary_assign_op_dim_helper, binary_op, pow_function);
1137#endif
1138}
1139
1140ZEND_VM_HELPER(zend_pre_incdec_property_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, int inc)
1141{
1142	USE_OPLINE
1143	zend_free_op free_op1, free_op2;
1144	zval *object;
1145	zval *property;
1146	zval *zptr;
1147
1148	SAVE_OPLINE();
1149	object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
1150
1151	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) == IS_UNDEF)) {
1152		zend_throw_error(NULL, "Using $this when not in object context");
1153		FREE_UNFETCHED_OP2();
1154		HANDLE_EXCEPTION();
1155	}
1156
1157	property = GET_OP2_ZVAL_PTR(BP_VAR_R);
1158
1159	do {
1160		if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
1161			ZVAL_DEREF(object);
1162			if (UNEXPECTED(!make_real_object(object))) {
1163				zend_error(E_WARNING, "Attempt to increment/decrement property of non-object");
1164				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1165					ZVAL_NULL(EX_VAR(opline->result.var));
1166				}
1167				break;
1168			}
1169		}
1170
1171		/* here we are sure we are dealing with an object */
1172		if (EXPECTED(Z_OBJ_HT_P(object)->get_property_ptr_ptr)
1173			&& EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL))) != NULL)) {
1174			if (UNEXPECTED(Z_ISERROR_P(zptr))) {
1175				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1176					ZVAL_NULL(EX_VAR(opline->result.var));
1177				}
1178			} else {
1179				if (EXPECTED(Z_TYPE_P(zptr) == IS_LONG)) {
1180					if (inc) {
1181						fast_long_increment_function(zptr);
1182					} else {
1183						fast_long_decrement_function(zptr);
1184					}
1185				} else {
1186					ZVAL_DEREF(zptr);
1187					SEPARATE_ZVAL_NOREF(zptr);
1188
1189					if (inc) {
1190						increment_function(zptr);
1191					} else {
1192						decrement_function(zptr);
1193					}
1194				}
1195				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1196					ZVAL_COPY(EX_VAR(opline->result.var), zptr);
1197				}
1198			}
1199		} else {
1200			zend_pre_incdec_overloaded_property(object, property, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), inc, (UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL));
1201		}
1202	} while (0);
1203
1204	FREE_OP2();
1205	FREE_OP1_VAR_PTR();
1206	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1207}
1208
1209ZEND_VM_HANDLER(132, ZEND_PRE_INC_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1210{
1211	ZEND_VM_DISPATCH_TO_HELPER(zend_pre_incdec_property_helper, inc, 1);
1212}
1213
1214ZEND_VM_HANDLER(133, ZEND_PRE_DEC_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1215{
1216	ZEND_VM_DISPATCH_TO_HELPER(zend_pre_incdec_property_helper, inc, 0);
1217}
1218
1219ZEND_VM_HELPER(zend_post_incdec_property_helper, VAR|UNUSED|CV, CONST|TMPVAR|CV, int inc)
1220{
1221	USE_OPLINE
1222	zend_free_op free_op1, free_op2;
1223	zval *object;
1224	zval *property;
1225	zval *zptr;
1226
1227	SAVE_OPLINE();
1228	object = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
1229
1230	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) == IS_UNDEF)) {
1231		zend_throw_error(NULL, "Using $this when not in object context");
1232		FREE_UNFETCHED_OP2();
1233		HANDLE_EXCEPTION();
1234	}
1235
1236	property = GET_OP2_ZVAL_PTR(BP_VAR_R);
1237
1238	do {
1239		if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
1240			ZVAL_DEREF(object);
1241			if (UNEXPECTED(!make_real_object(object))) {
1242				zend_error(E_WARNING, "Attempt to increment/decrement property of non-object");
1243				ZVAL_NULL(EX_VAR(opline->result.var));
1244				break;
1245			}
1246		}
1247
1248		/* here we are sure we are dealing with an object */
1249
1250		if (EXPECTED(Z_OBJ_HT_P(object)->get_property_ptr_ptr)
1251			&& EXPECTED((zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property, BP_VAR_RW, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL))) != NULL)) {
1252			if (UNEXPECTED(Z_ISERROR_P(zptr))) {
1253				ZVAL_NULL(EX_VAR(opline->result.var));
1254			} else {
1255				if (EXPECTED(Z_TYPE_P(zptr) == IS_LONG)) {
1256					ZVAL_COPY_VALUE(EX_VAR(opline->result.var), zptr);
1257					if (inc) {
1258						fast_long_increment_function(zptr);
1259					} else {
1260						fast_long_decrement_function(zptr);
1261					}
1262				} else {
1263					ZVAL_DEREF(zptr);
1264					ZVAL_COPY_VALUE(EX_VAR(opline->result.var), zptr);
1265					zval_opt_copy_ctor(zptr);
1266					if (inc) {
1267						increment_function(zptr);
1268					} else {
1269						decrement_function(zptr);
1270					}
1271				}
1272			}
1273		} else {
1274			zend_post_incdec_overloaded_property(object, property, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), inc, EX_VAR(opline->result.var));
1275		}
1276	} while (0);
1277
1278	FREE_OP2();
1279	FREE_OP1_VAR_PTR();
1280	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1281}
1282
1283ZEND_VM_HANDLER(134, ZEND_POST_INC_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1284{
1285	ZEND_VM_DISPATCH_TO_HELPER(zend_post_incdec_property_helper, inc, 1);
1286}
1287
1288ZEND_VM_HANDLER(135, ZEND_POST_DEC_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1289{
1290	ZEND_VM_DISPATCH_TO_HELPER(zend_post_incdec_property_helper, inc, 0);
1291}
1292
1293ZEND_VM_HANDLER(34, ZEND_PRE_INC, VAR|CV, ANY, SPEC(RETVAL))
1294{
1295	USE_OPLINE
1296	zend_free_op free_op1;
1297	zval *var_ptr;
1298
1299	var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
1300
1301	if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) {
1302		fast_long_increment_function(var_ptr);
1303		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1304			ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr);
1305		}
1306		ZEND_VM_NEXT_OPCODE();
1307	}
1308
1309	if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
1310		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1311			ZVAL_NULL(EX_VAR(opline->result.var));
1312		}
1313		ZEND_VM_NEXT_OPCODE();
1314	}
1315
1316	SAVE_OPLINE();
1317	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
1318		var_ptr = GET_OP1_UNDEF_CV(var_ptr, BP_VAR_RW);
1319	}
1320	ZVAL_DEREF(var_ptr);
1321	SEPARATE_ZVAL_NOREF(var_ptr);
1322
1323	increment_function(var_ptr);
1324
1325	if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1326		ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
1327	}
1328
1329	FREE_OP1_VAR_PTR();
1330	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1331}
1332
1333ZEND_VM_HANDLER(35, ZEND_PRE_DEC, VAR|CV, ANY, SPEC(RETVAL))
1334{
1335	USE_OPLINE
1336	zend_free_op free_op1;
1337	zval *var_ptr;
1338
1339	var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
1340
1341	if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) {
1342		fast_long_decrement_function(var_ptr);
1343		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1344			ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr);
1345		}
1346		ZEND_VM_NEXT_OPCODE();
1347	}
1348
1349	if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
1350		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1351			ZVAL_NULL(EX_VAR(opline->result.var));
1352		}
1353		ZEND_VM_NEXT_OPCODE();
1354	}
1355
1356	SAVE_OPLINE();
1357	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
1358		var_ptr = GET_OP1_UNDEF_CV(var_ptr, BP_VAR_RW);
1359	}
1360	ZVAL_DEREF(var_ptr);
1361	SEPARATE_ZVAL_NOREF(var_ptr);
1362
1363	decrement_function(var_ptr);
1364
1365	if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
1366		ZVAL_COPY(EX_VAR(opline->result.var), var_ptr);
1367	}
1368
1369	FREE_OP1_VAR_PTR();
1370	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1371}
1372
1373ZEND_VM_HANDLER(36, ZEND_POST_INC, VAR|CV, ANY)
1374{
1375	USE_OPLINE
1376	zend_free_op free_op1;
1377	zval *var_ptr;
1378
1379	var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
1380
1381	if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) {
1382		ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr);
1383		fast_long_increment_function(var_ptr);
1384		ZEND_VM_NEXT_OPCODE();
1385	}
1386
1387	if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
1388		ZVAL_NULL(EX_VAR(opline->result.var));
1389		ZEND_VM_NEXT_OPCODE();
1390	}
1391
1392	SAVE_OPLINE();
1393	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
1394		var_ptr = GET_OP1_UNDEF_CV(var_ptr, BP_VAR_RW);
1395	}
1396	ZVAL_DEREF(var_ptr);
1397	ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr);
1398	zval_opt_copy_ctor(var_ptr);
1399
1400	increment_function(var_ptr);
1401
1402	FREE_OP1_VAR_PTR();
1403	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1404}
1405
1406ZEND_VM_HANDLER(37, ZEND_POST_DEC, VAR|CV, ANY)
1407{
1408	USE_OPLINE
1409	zend_free_op free_op1;
1410	zval *var_ptr;
1411
1412	var_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
1413
1414	if (EXPECTED(Z_TYPE_P(var_ptr) == IS_LONG)) {
1415		ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr);
1416		fast_long_decrement_function(var_ptr);
1417		ZEND_VM_NEXT_OPCODE();
1418	}
1419
1420	if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(var_ptr))) {
1421		ZVAL_NULL(EX_VAR(opline->result.var));
1422		ZEND_VM_NEXT_OPCODE();
1423	}
1424
1425	SAVE_OPLINE();
1426	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
1427		var_ptr = GET_OP1_UNDEF_CV(var_ptr, BP_VAR_RW);
1428	}
1429	ZVAL_DEREF(var_ptr);
1430	ZVAL_COPY_VALUE(EX_VAR(opline->result.var), var_ptr);
1431	zval_opt_copy_ctor(var_ptr);
1432
1433	decrement_function(var_ptr);
1434
1435	FREE_OP1_VAR_PTR();
1436	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1437}
1438
1439ZEND_VM_HANDLER(40, ZEND_ECHO, CONST|TMPVAR|CV, ANY)
1440{
1441	USE_OPLINE
1442	zend_free_op free_op1;
1443	zval *z;
1444
1445	SAVE_OPLINE();
1446	z = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
1447
1448	if (Z_TYPE_P(z) == IS_STRING) {
1449		zend_string *str = Z_STR_P(z);
1450
1451		if (ZSTR_LEN(str) != 0) {
1452			zend_write(ZSTR_VAL(str), ZSTR_LEN(str));
1453		}
1454	} else {
1455		zend_string *str = _zval_get_string_func(z);
1456
1457		if (ZSTR_LEN(str) != 0) {
1458			zend_write(ZSTR_VAL(str), ZSTR_LEN(str));
1459		} else if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(z) == IS_UNDEF)) {
1460			GET_OP1_UNDEF_CV(z, BP_VAR_R);
1461		}
1462		zend_string_release(str);
1463	}
1464
1465	FREE_OP1();
1466	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1467}
1468
1469ZEND_VM_HELPER(zend_fetch_var_address_helper, CONST|TMPVAR|CV, UNUSED, int type)
1470{
1471	USE_OPLINE
1472	zend_free_op free_op1;
1473	zval *varname;
1474	zval *retval;
1475	zend_string *name;
1476	HashTable *target_symbol_table;
1477
1478	SAVE_OPLINE();
1479	varname = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
1480
1481 	if (OP1_TYPE == IS_CONST) {
1482		name = Z_STR_P(varname);
1483	} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
1484		name = Z_STR_P(varname);
1485		zend_string_addref(name);
1486	} else {
1487		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
1488			GET_OP1_UNDEF_CV(varname, BP_VAR_R);
1489		}
1490		name = zval_get_string(varname);
1491	}
1492
1493	target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK);
1494	retval = zend_hash_find(target_symbol_table, name);
1495	if (retval == NULL) {
1496		switch (type) {
1497			case BP_VAR_R:
1498			case BP_VAR_UNSET:
1499				zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name));
1500				/* break missing intentionally */
1501			case BP_VAR_IS:
1502				retval = &EG(uninitialized_zval);
1503				break;
1504			case BP_VAR_RW:
1505				zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name));
1506				retval = zend_hash_update(target_symbol_table, name, &EG(uninitialized_zval));
1507				break;
1508			case BP_VAR_W:
1509				retval = zend_hash_add_new(target_symbol_table, name, &EG(uninitialized_zval));
1510				break;
1511			EMPTY_SWITCH_DEFAULT_CASE()
1512		}
1513	/* GLOBAL or $$name variable may be an INDIRECT pointer to CV */
1514	} else if (Z_TYPE_P(retval) == IS_INDIRECT) {
1515		retval = Z_INDIRECT_P(retval);
1516		if (Z_TYPE_P(retval) == IS_UNDEF) {
1517			switch (type) {
1518				case BP_VAR_R:
1519				case BP_VAR_UNSET:
1520					zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name));
1521					/* break missing intentionally */
1522				case BP_VAR_IS:
1523					retval = &EG(uninitialized_zval);
1524					break;
1525				case BP_VAR_RW:
1526					zend_error(E_NOTICE,"Undefined variable: %s", ZSTR_VAL(name));
1527					/* break missing intentionally */
1528				case BP_VAR_W:
1529					ZVAL_NULL(retval);
1530					break;
1531				EMPTY_SWITCH_DEFAULT_CASE()
1532			}
1533		}
1534	}
1535
1536	if ((opline->extended_value & ZEND_FETCH_TYPE_MASK) != ZEND_FETCH_GLOBAL_LOCK) {
1537		FREE_OP1();
1538	}
1539
1540	if (OP1_TYPE != IS_CONST) {
1541		zend_string_release(name);
1542	}
1543
1544	ZEND_ASSERT(retval != NULL);
1545	if (type == BP_VAR_R || type == BP_VAR_IS) {
1546		if (/*type == BP_VAR_R &&*/ Z_ISREF_P(retval) && Z_REFCOUNT_P(retval) == 1) {
1547			ZVAL_UNREF(retval);
1548		}
1549		ZVAL_COPY(EX_VAR(opline->result.var), retval);
1550	} else {
1551		ZVAL_INDIRECT(EX_VAR(opline->result.var), retval);
1552	}
1553	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1554}
1555
1556ZEND_VM_HANDLER(80, ZEND_FETCH_R, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
1557{
1558	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_R);
1559}
1560
1561ZEND_VM_HANDLER(83, ZEND_FETCH_W, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
1562{
1563	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_W);
1564}
1565
1566ZEND_VM_HANDLER(86, ZEND_FETCH_RW, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
1567{
1568	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_RW);
1569}
1570
1571ZEND_VM_HANDLER(92, ZEND_FETCH_FUNC_ARG, CONST|TMPVAR|CV, UNUSED, VAR_FETCH|ARG_NUM)
1572{
1573	USE_OPLINE
1574
1575	if (zend_is_by_ref_func_arg_fetch(opline, EX(call))) {
1576		ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_W);
1577	} else {
1578		ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_R);
1579	}
1580}
1581
1582ZEND_VM_HANDLER(95, ZEND_FETCH_UNSET, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
1583{
1584	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_UNSET);
1585}
1586
1587ZEND_VM_HANDLER(89, ZEND_FETCH_IS, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
1588{
1589	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_var_address_helper, type, BP_VAR_IS);
1590}
1591
1592ZEND_VM_HELPER(zend_fetch_static_prop_helper, CONST|TMPVAR|CV, UNUSED|CONST|VAR, int type)
1593{
1594	USE_OPLINE
1595	zend_free_op free_op1;
1596	zval *varname;
1597	zval *retval;
1598	zend_string *name;
1599	zend_class_entry *ce;
1600
1601	SAVE_OPLINE();
1602	varname = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
1603
1604 	if (OP1_TYPE == IS_CONST) {
1605		name = Z_STR_P(varname);
1606	} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
1607		name = Z_STR_P(varname);
1608		zend_string_addref(name);
1609	} else {
1610		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
1611			GET_OP1_UNDEF_CV(varname, BP_VAR_R);
1612		}
1613		name = zval_get_string(varname);
1614	}
1615
1616	if (OP2_TYPE == IS_CONST) {
1617		if (OP1_TYPE == IS_CONST && EXPECTED((ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) != NULL)) {
1618			retval = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)) + sizeof(void*));
1619
1620			/* check if static properties were destoyed */
1621			if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
1622				zend_throw_error(NULL, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
1623				FREE_OP1();
1624				HANDLE_EXCEPTION();
1625			}
1626
1627			ZEND_VM_C_GOTO(fetch_static_prop_return);
1628		} else if (UNEXPECTED((ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) == NULL)) {
1629			ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op2)), EX_CONSTANT(opline->op2) + 1, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
1630			if (UNEXPECTED(ce == NULL)) {
1631				if (OP1_TYPE != IS_CONST) {
1632					zend_string_release(name);
1633				}
1634				FREE_OP1();
1635				ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1636			}
1637			CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce);
1638		}
1639	} else {
1640		if (OP2_TYPE == IS_UNUSED) {
1641			ce = zend_fetch_class(NULL, opline->op2.num);
1642			if (UNEXPECTED(ce == NULL)) {
1643				ZEND_ASSERT(EG(exception));
1644				if (OP1_TYPE != IS_CONST) {
1645					zend_string_release(name);
1646				}
1647				FREE_OP1();
1648				HANDLE_EXCEPTION();
1649			}
1650		} else {
1651			ce = Z_CE_P(EX_VAR(opline->op2.var));
1652		}
1653		if (OP1_TYPE == IS_CONST &&
1654		    (retval = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce)) != NULL) {
1655
1656			/* check if static properties were destoyed */
1657			if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
1658				zend_throw_error(NULL, "Access to undeclared static property: %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(name));
1659				FREE_OP1();
1660				HANDLE_EXCEPTION();
1661			}
1662
1663			ZEND_VM_C_GOTO(fetch_static_prop_return);
1664		}
1665	}
1666	retval = zend_std_get_static_property(ce, name, 0);
1667	if (UNEXPECTED(EG(exception))) {
1668		if (OP1_TYPE != IS_CONST) {
1669			zend_string_release(name);
1670		}
1671		FREE_OP1();
1672		HANDLE_EXCEPTION();
1673	}
1674	if (OP1_TYPE == IS_CONST && retval) {
1675		CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce, retval);
1676	}
1677
1678	FREE_OP1();
1679
1680	if (OP1_TYPE != IS_CONST) {
1681		zend_string_release(name);
1682	}
1683
1684ZEND_VM_C_LABEL(fetch_static_prop_return):
1685	ZEND_ASSERT(retval != NULL);
1686	if (type == BP_VAR_R || type == BP_VAR_IS) {
1687		if (/*type == BP_VAR_R &&*/ Z_ISREF_P(retval) && Z_REFCOUNT_P(retval) == 1) {
1688			ZVAL_UNREF(retval);
1689		}
1690		ZVAL_COPY(EX_VAR(opline->result.var), retval);
1691	} else {
1692		ZVAL_INDIRECT(EX_VAR(opline->result.var), retval);
1693	}
1694	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1695}
1696
1697ZEND_VM_HANDLER(173, ZEND_FETCH_STATIC_PROP_R, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
1698{
1699	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_R);
1700}
1701
1702ZEND_VM_HANDLER(174, ZEND_FETCH_STATIC_PROP_W, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
1703{
1704	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_W);
1705}
1706
1707ZEND_VM_HANDLER(175, ZEND_FETCH_STATIC_PROP_RW, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
1708{
1709	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_RW);
1710}
1711
1712ZEND_VM_HANDLER(177, ZEND_FETCH_STATIC_PROP_FUNC_ARG, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR, NUM)
1713{
1714	USE_OPLINE
1715
1716	if (zend_is_by_ref_func_arg_fetch(opline, EX(call))) {
1717		ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_W);
1718	} else {
1719		ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_R);
1720	}
1721}
1722
1723ZEND_VM_HANDLER(178, ZEND_FETCH_STATIC_PROP_UNSET, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
1724{
1725	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_UNSET);
1726}
1727
1728ZEND_VM_HANDLER(176, ZEND_FETCH_STATIC_PROP_IS, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
1729{
1730	ZEND_VM_DISPATCH_TO_HELPER(zend_fetch_static_prop_helper, type, BP_VAR_IS);
1731}
1732
1733ZEND_VM_HANDLER(81, ZEND_FETCH_DIM_R, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
1734{
1735	USE_OPLINE
1736	zend_free_op free_op1, free_op2;
1737	zval *container, *dim, *value, *result;
1738
1739	SAVE_OPLINE();
1740	container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
1741	dim = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
1742	if (OP1_TYPE != IS_CONST) {
1743		if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
1744ZEND_VM_C_LABEL(fetch_dim_r_array):
1745			value = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, OP2_TYPE, BP_VAR_R);
1746			result = EX_VAR(opline->result.var);
1747			ZVAL_COPY(result, value);
1748		} else if (EXPECTED(Z_TYPE_P(container) == IS_REFERENCE)) {
1749			container = Z_REFVAL_P(container);
1750			if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
1751				ZEND_VM_C_GOTO(fetch_dim_r_array);
1752			} else {
1753				ZEND_VM_C_GOTO(fetch_dim_r_slow);
1754			}
1755		} else {
1756ZEND_VM_C_LABEL(fetch_dim_r_slow):
1757			result = EX_VAR(opline->result.var);
1758			zend_fetch_dimension_address_read_R_slow(result, container, dim);
1759		}
1760	} else {
1761		result = EX_VAR(opline->result.var);
1762		zend_fetch_dimension_address_read_R(result, container, dim, OP2_TYPE);
1763	}
1764	FREE_OP2();
1765	FREE_OP1();
1766	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1767}
1768
1769ZEND_VM_HANDLER(84, ZEND_FETCH_DIM_W, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV)
1770{
1771	USE_OPLINE
1772	zend_free_op free_op1, free_op2;
1773	zval *container;
1774
1775	SAVE_OPLINE();
1776	container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
1777
1778	zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
1779	FREE_OP2();
1780	if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
1781		EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
1782	}
1783	FREE_OP1_VAR_PTR();
1784	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1785}
1786
1787ZEND_VM_HANDLER(87, ZEND_FETCH_DIM_RW, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV)
1788{
1789	USE_OPLINE
1790	zend_free_op free_op1, free_op2;
1791	zval *container;
1792
1793	SAVE_OPLINE();
1794	container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_RW);
1795
1796	zend_fetch_dimension_address_RW(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
1797	FREE_OP2();
1798	if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
1799		EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
1800	}
1801	FREE_OP1_VAR_PTR();
1802	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1803}
1804
1805ZEND_VM_HANDLER(90, ZEND_FETCH_DIM_IS, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
1806{
1807	USE_OPLINE
1808	zend_free_op free_op1, free_op2;
1809	zval *container;
1810
1811	SAVE_OPLINE();
1812	container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_IS);
1813	zend_fetch_dimension_address_read_IS(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
1814	FREE_OP2();
1815	FREE_OP1();
1816	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1817}
1818
1819ZEND_VM_HANDLER(93, ZEND_FETCH_DIM_FUNC_ARG, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV, NUM)
1820{
1821	USE_OPLINE
1822	zval *container;
1823	zend_free_op free_op1, free_op2;
1824
1825	SAVE_OPLINE();
1826
1827	if (zend_is_by_ref_func_arg_fetch(opline, EX(call))) {
1828        if ((OP1_TYPE & (IS_CONST|IS_TMP_VAR))) {
1829            zend_throw_error(NULL, "Cannot use temporary expression in write context");
1830			FREE_UNFETCHED_OP2();
1831			FREE_UNFETCHED_OP1();
1832			HANDLE_EXCEPTION();
1833        }
1834		container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
1835		zend_fetch_dimension_address_W(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
1836		if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
1837			EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
1838		}
1839		FREE_OP2();
1840		FREE_OP1_VAR_PTR();
1841	} else {
1842		if (OP2_TYPE == IS_UNUSED) {
1843			zend_throw_error(NULL, "Cannot use [] for reading");
1844			FREE_UNFETCHED_OP2();
1845			FREE_UNFETCHED_OP1();
1846			HANDLE_EXCEPTION();
1847		}
1848		container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
1849		zend_fetch_dimension_address_read_R(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
1850		FREE_OP2();
1851		FREE_OP1();
1852	}
1853	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1854}
1855
1856ZEND_VM_HANDLER(96, ZEND_FETCH_DIM_UNSET, VAR|CV, CONST|TMPVAR|CV)
1857{
1858	USE_OPLINE
1859	zend_free_op free_op1, free_op2;
1860	zval *container;
1861
1862	SAVE_OPLINE();
1863	container = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_UNSET);
1864
1865	zend_fetch_dimension_address_UNSET(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R), OP2_TYPE);
1866	FREE_OP2();
1867	if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
1868		EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
1869	}
1870	FREE_OP1_VAR_PTR();
1871	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1872}
1873
1874ZEND_VM_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMP|VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1875{
1876	USE_OPLINE
1877	zend_free_op free_op1;
1878	zval *container;
1879	zend_free_op free_op2;
1880	zval *offset;
1881
1882	SAVE_OPLINE();
1883	container = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R);
1884
1885	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
1886		zend_throw_error(NULL, "Using $this when not in object context");
1887		FREE_UNFETCHED_OP2();
1888		HANDLE_EXCEPTION();
1889	}
1890
1891	offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
1892
1893	if (OP1_TYPE == IS_CONST ||
1894	    (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT))) {
1895		if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(container)) {
1896			container = Z_REFVAL_P(container);
1897			if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
1898				ZEND_VM_C_GOTO(fetch_obj_r_no_object);
1899			}
1900		} else {
1901			ZEND_VM_C_GOTO(fetch_obj_r_no_object);
1902		}
1903	}
1904
1905	/* here we are sure we are dealing with an object */
1906	do {
1907		zend_object *zobj = Z_OBJ_P(container);
1908		zval *retval;
1909
1910		if (OP2_TYPE == IS_CONST &&
1911			EXPECTED(zobj->ce == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) {
1912			uint32_t prop_offset = (uint32_t)(intptr_t)CACHED_PTR(Z_CACHE_SLOT_P(offset) + sizeof(void*));
1913
1914			if (EXPECTED(prop_offset != (uint32_t)ZEND_DYNAMIC_PROPERTY_OFFSET)) {
1915				retval = OBJ_PROP(zobj, prop_offset);
1916				if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) {
1917					ZVAL_COPY(EX_VAR(opline->result.var), retval);
1918					break;
1919				}
1920			} else if (EXPECTED(zobj->properties != NULL)) {
1921				retval = zend_hash_find(zobj->properties, Z_STR_P(offset));
1922				if (EXPECTED(retval)) {
1923					ZVAL_COPY(EX_VAR(opline->result.var), retval);
1924					break;
1925				}
1926			}
1927		}
1928
1929		if (UNEXPECTED(zobj->handlers->read_property == NULL)) {
1930ZEND_VM_C_LABEL(fetch_obj_r_no_object):
1931			zend_error(E_NOTICE, "Trying to get property of non-object");
1932			ZVAL_NULL(EX_VAR(opline->result.var));
1933		} else {
1934			retval = zobj->handlers->read_property(container, offset, BP_VAR_R, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var));
1935
1936			if (retval != EX_VAR(opline->result.var)) {
1937				ZVAL_COPY(EX_VAR(opline->result.var), retval);
1938			}
1939		}
1940	} while (0);
1941
1942	FREE_OP2();
1943	FREE_OP1();
1944	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1945}
1946
1947ZEND_VM_HANDLER(85, ZEND_FETCH_OBJ_W, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1948{
1949	USE_OPLINE
1950	zend_free_op free_op1, free_op2;
1951	zval *property;
1952	zval *container;
1953
1954	SAVE_OPLINE();
1955	property = GET_OP2_ZVAL_PTR(BP_VAR_R);
1956
1957	container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
1958	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
1959		zend_throw_error(NULL, "Using $this when not in object context");
1960		FREE_OP2();
1961		HANDLE_EXCEPTION();
1962	}
1963
1964	zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W);
1965	FREE_OP2();
1966	if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
1967		EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
1968	}
1969	FREE_OP1_VAR_PTR();
1970	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1971}
1972
1973ZEND_VM_HANDLER(88, ZEND_FETCH_OBJ_RW, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1974{
1975	USE_OPLINE
1976	zend_free_op free_op1, free_op2;
1977	zval *property;
1978	zval *container;
1979
1980	SAVE_OPLINE();
1981	property = GET_OP2_ZVAL_PTR(BP_VAR_R);
1982	container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
1983
1984	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
1985		zend_throw_error(NULL, "Using $this when not in object context");
1986		FREE_OP2();
1987		HANDLE_EXCEPTION();
1988	}
1989	zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_RW);
1990	FREE_OP2();
1991	if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
1992		EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
1993	}
1994	FREE_OP1_VAR_PTR();
1995	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
1996}
1997
1998ZEND_VM_HANDLER(91, ZEND_FETCH_OBJ_IS, CONST|TMPVAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
1999{
2000	USE_OPLINE
2001	zend_free_op free_op1;
2002	zval *container;
2003	zend_free_op free_op2;
2004	zval *offset;
2005
2006	SAVE_OPLINE();
2007	container = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_IS);
2008
2009	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
2010		zend_throw_error(NULL, "Using $this when not in object context");
2011		FREE_UNFETCHED_OP2();
2012		HANDLE_EXCEPTION();
2013	}
2014
2015	offset  = GET_OP2_ZVAL_PTR(BP_VAR_R);
2016
2017	if (OP1_TYPE == IS_CONST ||
2018	    (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT))) {
2019		if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(container)) {
2020			container = Z_REFVAL_P(container);
2021			if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
2022				ZEND_VM_C_GOTO(fetch_obj_is_no_object);
2023			}
2024		} else {
2025			ZEND_VM_C_GOTO(fetch_obj_is_no_object);
2026		}
2027	}
2028
2029	/* here we are sure we are dealing with an object */
2030	do {
2031		zend_object *zobj = Z_OBJ_P(container);
2032		zval *retval;
2033
2034		if (OP2_TYPE == IS_CONST &&
2035			EXPECTED(zobj->ce == CACHED_PTR(Z_CACHE_SLOT_P(offset)))) {
2036			uint32_t prop_offset = (uint32_t)(intptr_t)CACHED_PTR(Z_CACHE_SLOT_P(offset) + sizeof(void*));
2037
2038			if (EXPECTED(prop_offset != (uint32_t)ZEND_DYNAMIC_PROPERTY_OFFSET)) {
2039				retval = OBJ_PROP(zobj, prop_offset);
2040				if (EXPECTED(Z_TYPE_P(retval) != IS_UNDEF)) {
2041					ZVAL_COPY(EX_VAR(opline->result.var), retval);
2042					break;
2043				}
2044			} else if (EXPECTED(zobj->properties != NULL)) {
2045				retval = zend_hash_find(zobj->properties, Z_STR_P(offset));
2046				if (EXPECTED(retval)) {
2047					ZVAL_COPY(EX_VAR(opline->result.var), retval);
2048					break;
2049				}
2050			}
2051		}
2052
2053		if (UNEXPECTED(zobj->handlers->read_property == NULL)) {
2054ZEND_VM_C_LABEL(fetch_obj_is_no_object):
2055			ZVAL_NULL(EX_VAR(opline->result.var));
2056		} else {
2057
2058			retval = zobj->handlers->read_property(container, offset, BP_VAR_IS, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(offset)) : NULL), EX_VAR(opline->result.var));
2059
2060			if (retval != EX_VAR(opline->result.var)) {
2061				ZVAL_COPY(EX_VAR(opline->result.var), retval);
2062			}
2063		}
2064	} while (0);
2065
2066	FREE_OP2();
2067	FREE_OP1();
2068	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2069}
2070
2071ZEND_VM_HANDLER(94, ZEND_FETCH_OBJ_FUNC_ARG, CONST|TMP|VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, NUM)
2072{
2073	USE_OPLINE
2074	zval *container;
2075
2076	if (zend_is_by_ref_func_arg_fetch(opline, EX(call))) {
2077		/* Behave like FETCH_OBJ_W */
2078		zend_free_op free_op1, free_op2;
2079		zval *property;
2080
2081		SAVE_OPLINE();
2082		property = GET_OP2_ZVAL_PTR(BP_VAR_R);
2083		container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
2084
2085		if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
2086			zend_throw_error(NULL, "Using $this when not in object context");
2087			FREE_OP2();
2088			HANDLE_EXCEPTION();
2089		}
2090		if ((OP1_TYPE & (IS_CONST|IS_TMP_VAR))) {
2091			zend_throw_error(NULL, "Cannot use temporary expression in write context");
2092			FREE_OP2();
2093			FREE_OP1_VAR_PTR();
2094			HANDLE_EXCEPTION();
2095		}
2096		zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_W);
2097		FREE_OP2();
2098		if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
2099			EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
2100		}
2101		FREE_OP1_VAR_PTR();
2102		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2103	} else {
2104		ZEND_VM_DISPATCH_TO_HANDLER(ZEND_FETCH_OBJ_R);
2105	}
2106}
2107
2108ZEND_VM_HANDLER(97, ZEND_FETCH_OBJ_UNSET, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
2109{
2110	USE_OPLINE
2111	zend_free_op free_op1, free_op2;
2112	zval *container, *property;
2113
2114	SAVE_OPLINE();
2115	container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
2116
2117	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
2118		zend_throw_error(NULL, "Using $this when not in object context");
2119		FREE_UNFETCHED_OP2();
2120		HANDLE_EXCEPTION();
2121	}
2122
2123	property = GET_OP2_ZVAL_PTR(BP_VAR_R);
2124
2125	zend_fetch_property_address(EX_VAR(opline->result.var), container, OP1_TYPE, property, OP2_TYPE, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property)) : NULL), BP_VAR_UNSET);
2126	FREE_OP2();
2127	if (OP1_TYPE == IS_VAR && READY_TO_DESTROY(free_op1)) {
2128		EXTRACT_ZVAL_PTR(EX_VAR(opline->result.var));
2129	}
2130	FREE_OP1_VAR_PTR();
2131	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2132}
2133
2134ZEND_VM_HANDLER(98, ZEND_FETCH_LIST, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
2135{
2136	USE_OPLINE
2137	zend_free_op free_op1, free_op2;
2138	zval *container;
2139
2140	SAVE_OPLINE();
2141	container = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2142	zend_fetch_dimension_address_read_LIST(EX_VAR(opline->result.var), container, GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R));
2143	FREE_OP2();
2144	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2145}
2146
2147ZEND_VM_HANDLER(136, ZEND_ASSIGN_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, SPEC(OP_DATA=CONST|TMP|VAR|CV))
2148{
2149	USE_OPLINE
2150	zend_free_op free_op1, free_op2, free_op_data;
2151	zval *object, *property_name, *value, tmp;
2152
2153	SAVE_OPLINE();
2154	object = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
2155
2156	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) == IS_UNDEF)) {
2157		zend_throw_error(NULL, "Using $this when not in object context");
2158		FREE_UNFETCHED_OP2();
2159		HANDLE_EXCEPTION();
2160	}
2161
2162	property_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
2163	value = GET_OP_DATA_ZVAL_PTR(BP_VAR_R);
2164
2165	if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
2166		do {
2167			if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(object))) {
2168				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2169					ZVAL_NULL(EX_VAR(opline->result.var));
2170				}
2171				FREE_OP_DATA();
2172				ZEND_VM_C_GOTO(exit_assign_obj);
2173			}
2174			if (Z_ISREF_P(object)) {
2175				object = Z_REFVAL_P(object);
2176				if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) {
2177					break;
2178				}
2179			}
2180			if (EXPECTED(Z_TYPE_P(object) <= IS_FALSE ||
2181			    (Z_TYPE_P(object) == IS_STRING && Z_STRLEN_P(object) == 0))) {
2182				zend_object *obj;
2183
2184				zval_ptr_dtor(object);
2185				object_init(object);
2186				Z_ADDREF_P(object);
2187				obj = Z_OBJ_P(object);
2188				zend_error(E_WARNING, "Creating default object from empty value");
2189				if (GC_REFCOUNT(obj) == 1) {
2190					/* the enclosing container was deleted, obj is unreferenced */
2191					if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2192						ZVAL_NULL(EX_VAR(opline->result.var));
2193					}
2194					FREE_OP_DATA();
2195					OBJ_RELEASE(obj);
2196					ZEND_VM_C_GOTO(exit_assign_obj);
2197				}
2198				Z_DELREF_P(object);
2199			} else {
2200				zend_error(E_WARNING, "Attempt to assign property of non-object");
2201				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2202					ZVAL_NULL(EX_VAR(opline->result.var));
2203				}
2204				FREE_OP_DATA();
2205				ZEND_VM_C_GOTO(exit_assign_obj);
2206			}
2207		} while (0);
2208	}
2209
2210	if (OP2_TYPE == IS_CONST &&
2211	    EXPECTED(Z_OBJCE_P(object) == CACHED_PTR(Z_CACHE_SLOT_P(property_name)))) {
2212		uint32_t prop_offset = (uint32_t)(intptr_t)CACHED_PTR(Z_CACHE_SLOT_P(property_name) + sizeof(void*));
2213		zend_object *zobj = Z_OBJ_P(object);
2214		zval *property;
2215
2216		if (EXPECTED(prop_offset != (uint32_t)ZEND_DYNAMIC_PROPERTY_OFFSET)) {
2217			property = OBJ_PROP(zobj, prop_offset);
2218			if (Z_TYPE_P(property) != IS_UNDEF) {
2219ZEND_VM_C_LABEL(fast_assign_obj):
2220				value = zend_assign_to_variable(property, value, OP_DATA_TYPE);
2221				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2222					ZVAL_COPY(EX_VAR(opline->result.var), value);
2223				}
2224				ZEND_VM_C_GOTO(exit_assign_obj);
2225			}
2226		} else {
2227			if (EXPECTED(zobj->properties != NULL)) {
2228				if (UNEXPECTED(GC_REFCOUNT(zobj->properties) > 1)) {
2229					if (EXPECTED(!(GC_FLAGS(zobj->properties) & IS_ARRAY_IMMUTABLE))) {
2230						GC_REFCOUNT(zobj->properties)--;
2231					}
2232					zobj->properties = zend_array_dup(zobj->properties);
2233				}
2234				property = zend_hash_find(zobj->properties, Z_STR_P(property_name));
2235				if (property) {
2236					ZEND_VM_C_GOTO(fast_assign_obj);
2237				}
2238			}
2239
2240			if (!zobj->ce->__set) {
2241
2242				if (EXPECTED(zobj->properties == NULL)) {
2243					rebuild_object_properties(zobj);
2244				}
2245				/* separate our value if necessary */
2246				if (OP_DATA_TYPE == IS_CONST) {
2247					if (UNEXPECTED(Z_OPT_REFCOUNTED_P(value))) {
2248						Z_ADDREF_P(value);
2249					}
2250				} else if (OP_DATA_TYPE != IS_TMP_VAR) {
2251					if (Z_ISREF_P(value)) {
2252						if (OP_DATA_TYPE == IS_VAR) {
2253							zend_reference *ref = Z_REF_P(value);
2254							if (--GC_REFCOUNT(ref) == 0) {
2255								ZVAL_COPY_VALUE(&tmp, Z_REFVAL_P(value));
2256								efree_size(ref, sizeof(zend_reference));
2257								value = &tmp;
2258							} else {
2259								value = Z_REFVAL_P(value);
2260								if (Z_REFCOUNTED_P(value)) {
2261									Z_ADDREF_P(value);
2262								}
2263							}
2264						} else {
2265							value = Z_REFVAL_P(value);
2266							if (Z_REFCOUNTED_P(value)) {
2267								Z_ADDREF_P(value);
2268							}
2269						}
2270					} else if (OP_DATA_TYPE == IS_CV && Z_REFCOUNTED_P(value)) {
2271						Z_ADDREF_P(value);
2272					}
2273				}
2274				zend_hash_add_new(zobj->properties, Z_STR_P(property_name), value);
2275				if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2276					ZVAL_COPY(EX_VAR(opline->result.var), value);
2277				}
2278				ZEND_VM_C_GOTO(exit_assign_obj);
2279			}
2280		}
2281	}
2282
2283	if (!Z_OBJ_HT_P(object)->write_property) {
2284		zend_error(E_WARNING, "Attempt to assign property of non-object");
2285		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2286			ZVAL_NULL(EX_VAR(opline->result.var));
2287		}
2288		FREE_OP_DATA();
2289		ZEND_VM_C_GOTO(exit_assign_obj);
2290	}
2291
2292	/* separate our value if necessary */
2293	if (OP_DATA_TYPE == IS_CONST) {
2294		if (UNEXPECTED(Z_OPT_REFCOUNTED_P(value))) {
2295			Z_ADDREF_P(value);
2296		}
2297	} else if (OP_DATA_TYPE != IS_TMP_VAR) {
2298		ZVAL_DEREF(value);
2299	}
2300
2301	Z_OBJ_HT_P(object)->write_property(object, property_name, value, (OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(property_name)) : NULL);
2302
2303	if (UNEXPECTED(RETURN_VALUE_USED(opline)) && EXPECTED(!EG(exception))) {
2304		ZVAL_COPY(EX_VAR(opline->result.var), value);
2305	}
2306	if (OP_DATA_TYPE == IS_CONST) {
2307		zval_ptr_dtor_nogc(value);
2308	} else {
2309		FREE_OP_DATA();
2310	}
2311ZEND_VM_C_LABEL(exit_assign_obj):
2312	FREE_OP2();
2313	FREE_OP1_VAR_PTR();
2314	/* assign_obj has two opcodes! */
2315	ZEND_VM_NEXT_OPCODE_EX(1, 2);
2316}
2317
2318ZEND_VM_HANDLER(147, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV, SPEC(OP_DATA=CONST|TMP|VAR|CV))
2319{
2320	USE_OPLINE
2321	zend_free_op free_op1;
2322	zval *object_ptr;
2323	zend_free_op free_op2, free_op_data;
2324	zval *value;
2325	zval *variable_ptr;
2326	zval *dim;
2327
2328	SAVE_OPLINE();
2329	object_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
2330
2331	if (EXPECTED(Z_TYPE_P(object_ptr) == IS_ARRAY)) {
2332ZEND_VM_C_LABEL(try_assign_dim_array):
2333		SEPARATE_ARRAY(object_ptr);
2334		if (OP2_TYPE == IS_UNUSED) {
2335			variable_ptr = zend_hash_next_index_insert(Z_ARRVAL_P(object_ptr), &EG(uninitialized_zval));
2336			if (UNEXPECTED(variable_ptr == NULL)) {
2337				zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
2338				ZEND_VM_C_GOTO(assign_dim_error);
2339			}
2340		} else {
2341			dim = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2342			if (OP2_TYPE == IS_CONST) {
2343				variable_ptr = zend_fetch_dimension_address_inner_W_CONST(Z_ARRVAL_P(object_ptr), dim);
2344			} else {
2345				variable_ptr = zend_fetch_dimension_address_inner_W(Z_ARRVAL_P(object_ptr), dim);
2346			}
2347			if (UNEXPECTED(variable_ptr == NULL)) {
2348				ZEND_VM_C_GOTO(assign_dim_error);
2349			}
2350		}
2351		value = GET_OP_DATA_ZVAL_PTR(BP_VAR_R);
2352		value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
2353		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2354			ZVAL_COPY(EX_VAR(opline->result.var), value);
2355		}
2356	} else {
2357		if (EXPECTED(Z_ISREF_P(object_ptr))) {
2358			object_ptr = Z_REFVAL_P(object_ptr);
2359			if (EXPECTED(Z_TYPE_P(object_ptr) == IS_ARRAY)) {
2360				ZEND_VM_C_GOTO(try_assign_dim_array);
2361			}
2362		}
2363		if (EXPECTED(Z_TYPE_P(object_ptr) == IS_OBJECT)) {
2364			dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
2365			value = GET_OP_DATA_ZVAL_PTR(BP_VAR_R);
2366
2367			if (OP_DATA_TYPE == IS_CONST && UNEXPECTED(Z_REFCOUNTED_P(value))) {
2368				Z_ADDREF_P(value);
2369			}
2370
2371			zend_assign_to_object_dim(object_ptr, dim, value);
2372
2373			if (UNEXPECTED(RETURN_VALUE_USED(opline)) && EXPECTED(!EG(exception))) {
2374				ZVAL_COPY(EX_VAR(opline->result.var), value);
2375			}
2376
2377			if (OP_DATA_TYPE == IS_CONST) {
2378				zval_ptr_dtor_nogc(value);
2379			} else {
2380				FREE_OP_DATA();
2381			}
2382		} else if (EXPECTED(Z_TYPE_P(object_ptr) == IS_STRING)) {
2383			if (EXPECTED(Z_STRLEN_P(object_ptr) != 0)) {
2384				if (OP2_TYPE == IS_UNUSED) {
2385					zend_throw_error(NULL, "[] operator not supported for strings");
2386					FREE_UNFETCHED_OP_DATA();
2387					FREE_OP1_VAR_PTR();
2388					HANDLE_EXCEPTION();
2389				} else {
2390					dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
2391					value = GET_OP_DATA_ZVAL_PTR_DEREF(BP_VAR_R);
2392					zend_assign_to_string_offset(object_ptr, dim, value, (UNEXPECTED(RETURN_VALUE_USED(opline)) ? EX_VAR(opline->result.var) : NULL));
2393					FREE_OP_DATA();
2394				}
2395			} else {
2396				zval_ptr_dtor_nogc(object_ptr);
2397ZEND_VM_C_LABEL(assign_dim_convert_to_array):
2398				ZVAL_NEW_ARR(object_ptr);
2399				zend_hash_init(Z_ARRVAL_P(object_ptr), 8, NULL, ZVAL_PTR_DTOR, 0);
2400				ZEND_VM_C_GOTO(try_assign_dim_array);
2401			}
2402		} else if (EXPECTED(Z_TYPE_P(object_ptr) <= IS_FALSE)) {
2403			ZEND_VM_C_GOTO(assign_dim_convert_to_array);
2404		} else {
2405			if (OP1_TYPE != IS_VAR || UNEXPECTED(!Z_ISERROR_P(object_ptr))) {
2406				zend_error(E_WARNING, "Cannot use a scalar value as an array");
2407			}
2408			dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
2409ZEND_VM_C_LABEL(assign_dim_error):
2410			FREE_UNFETCHED_OP_DATA();
2411			if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2412				ZVAL_NULL(EX_VAR(opline->result.var));
2413			}
2414		}
2415	}
2416	if (OP2_TYPE != IS_UNUSED) {
2417		FREE_OP2();
2418	}
2419	FREE_OP1_VAR_PTR();
2420	/* assign_dim has two opcodes! */
2421	ZEND_VM_NEXT_OPCODE_EX(1, 2);
2422}
2423
2424ZEND_VM_HANDLER(38, ZEND_ASSIGN, VAR|CV, CONST|TMP|VAR|CV, SPEC(RETVAL))
2425{
2426	USE_OPLINE
2427	zend_free_op free_op1, free_op2;
2428	zval *value;
2429	zval *variable_ptr;
2430
2431	SAVE_OPLINE();
2432	value = GET_OP2_ZVAL_PTR(BP_VAR_R);
2433	variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
2434
2435	if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(variable_ptr))) {
2436		FREE_OP2();
2437		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2438			ZVAL_NULL(EX_VAR(opline->result.var));
2439		}
2440	} else {
2441		value = zend_assign_to_variable(variable_ptr, value, OP2_TYPE);
2442		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2443			ZVAL_COPY(EX_VAR(opline->result.var), value);
2444		}
2445		FREE_OP1_VAR_PTR();
2446		/* zend_assign_to_variable() always takes care of op2, never free it! */
2447	}
2448
2449	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2450}
2451
2452ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV, SRC)
2453{
2454	USE_OPLINE
2455	zend_free_op free_op1, free_op2;
2456	zval *variable_ptr;
2457	zval *value_ptr;
2458
2459	SAVE_OPLINE();
2460	value_ptr = GET_OP2_ZVAL_PTR_PTR(BP_VAR_W);
2461	variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
2462
2463	if (OP1_TYPE == IS_VAR &&
2464	    UNEXPECTED(Z_TYPE_P(EX_VAR(opline->op1.var)) != IS_INDIRECT) &&
2465	    UNEXPECTED(!Z_ISREF_P(EX_VAR(opline->op1.var))) &&
2466	    UNEXPECTED(!Z_ISERROR_P(EX_VAR(opline->op1.var)))) {
2467
2468		zend_throw_error(NULL, "Cannot assign by reference to overloaded object");
2469		FREE_OP2_VAR_PTR();
2470		HANDLE_EXCEPTION();
2471
2472	} else if (OP2_TYPE == IS_VAR &&
2473	           opline->extended_value == ZEND_RETURNS_FUNCTION &&
2474			   UNEXPECTED(!Z_ISREF_P(value_ptr))) {
2475		zend_error(E_NOTICE, "Only variables should be assigned by reference");
2476		if (UNEXPECTED(EG(exception) != NULL)) {
2477			FREE_OP2_VAR_PTR();
2478			HANDLE_EXCEPTION();
2479		}
2480
2481		value_ptr = zend_assign_to_variable(variable_ptr, value_ptr, OP2_TYPE);
2482		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2483			ZVAL_COPY(EX_VAR(opline->result.var), value_ptr);
2484		}
2485		/* zend_assign_to_variable() always takes care of op2, never free it! */
2486
2487	} else {
2488
2489		if ((OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(variable_ptr))) ||
2490		    (OP2_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(value_ptr)))) {
2491			variable_ptr = &EG(uninitialized_zval);
2492		} else {
2493			zend_assign_to_variable_reference(variable_ptr, value_ptr);
2494		}
2495
2496		if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
2497			ZVAL_COPY(EX_VAR(opline->result.var), variable_ptr);
2498		}
2499
2500		FREE_OP2_VAR_PTR();
2501	}
2502
2503	FREE_OP1_VAR_PTR();
2504	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2505}
2506
2507ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
2508{
2509	zend_execute_data *old_execute_data;
2510	uint32_t call_info = EX_CALL_INFO();
2511
2512	if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) {
2513		i_free_compiled_variables(execute_data);
2514		if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED))) {
2515			if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
2516				zend_clean_and_cache_symbol_table(EX(symbol_table));
2517			}
2518			EG(current_execute_data) = EX(prev_execute_data);
2519			if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
2520				zend_object *object = Z_OBJ(execute_data->This);
2521#if 0
2522				if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
2523#else
2524				if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) {
2525#endif
2526					GC_REFCOUNT(object)--;
2527					if (GC_REFCOUNT(object) == 1) {
2528						zend_object_store_ctor_failed(object);
2529					}
2530				}
2531				OBJ_RELEASE(object);
2532			} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2533				OBJ_RELEASE((zend_object*)execute_data->func->op_array.prototype);
2534			}
2535
2536			zend_vm_stack_free_extra_args_ex(call_info, execute_data);
2537			old_execute_data = execute_data;
2538			execute_data = EX(prev_execute_data);
2539			zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
2540		} else {
2541			EG(current_execute_data) = EX(prev_execute_data);
2542			if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
2543				zend_object *object = Z_OBJ(execute_data->This);
2544#if 0
2545				if (UNEXPECTED(EG(exception) != NULL) && (EX(opline)->op1.num & ZEND_CALL_CTOR)) {
2546#else
2547				if (UNEXPECTED(EG(exception) != NULL) && (call_info & ZEND_CALL_CTOR)) {
2548#endif
2549					GC_REFCOUNT(object)--;
2550					if (GC_REFCOUNT(object) == 1) {
2551						zend_object_store_ctor_failed(object);
2552					}
2553				}
2554				OBJ_RELEASE(object);
2555			} else if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2556				OBJ_RELEASE((zend_object*)execute_data->func->op_array.prototype);
2557			}
2558			EG(vm_stack_top) = (zval*)execute_data;
2559			execute_data = EX(prev_execute_data);
2560		}
2561
2562		if (UNEXPECTED(EG(exception) != NULL)) {
2563			const zend_op *old_opline = EX(opline);
2564			zend_throw_exception_internal(NULL);
2565			if (RETURN_VALUE_USED(old_opline)) {
2566				zval_ptr_dtor(EX_VAR(old_opline->result.var));
2567			}
2568			HANDLE_EXCEPTION_LEAVE();
2569		}
2570
2571		LOAD_NEXT_OPLINE();
2572		ZEND_VM_LEAVE();
2573	} else if (EXPECTED((call_info & ZEND_CALL_TOP) == 0)) {
2574		zend_detach_symbol_table(execute_data);
2575		destroy_op_array(&EX(func)->op_array);
2576		efree_size(EX(func), sizeof(zend_op_array));
2577		old_execute_data = execute_data;
2578		execute_data = EG(current_execute_data) = EX(prev_execute_data);
2579		zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
2580
2581		zend_attach_symbol_table(execute_data);
2582		if (UNEXPECTED(EG(exception) != NULL)) {
2583			zend_throw_exception_internal(NULL);
2584			HANDLE_EXCEPTION_LEAVE();
2585		}
2586
2587		LOAD_NEXT_OPLINE();
2588		ZEND_VM_LEAVE();
2589	} else {
2590		if (EXPECTED((call_info & ZEND_CALL_CODE) == 0)) {
2591			i_free_compiled_variables(execute_data);
2592			if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS))) {
2593				if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
2594					zend_clean_and_cache_symbol_table(EX(symbol_table));
2595				}
2596				zend_vm_stack_free_extra_args_ex(call_info, execute_data);
2597			}
2598			EG(current_execute_data) = EX(prev_execute_data);
2599			if (UNEXPECTED(call_info & ZEND_CALL_CLOSURE)) {
2600				OBJ_RELEASE((zend_object*)EX(func)->op_array.prototype);
2601			}
2602			ZEND_VM_RETURN();
2603		} else /* if (call_kind == ZEND_CALL_TOP_CODE) */ {
2604			zend_array *symbol_table = EX(symbol_table);
2605
2606			zend_detach_symbol_table(execute_data);
2607			old_execute_data = EX(prev_execute_data);
2608			while (old_execute_data) {
2609				if (old_execute_data->func && (ZEND_CALL_INFO(old_execute_data) & ZEND_CALL_HAS_SYMBOL_TABLE)) {
2610					if (old_execute_data->symbol_table == symbol_table) {
2611						zend_attach_symbol_table(old_execute_data);
2612					}
2613					break;
2614				}
2615				old_execute_data = old_execute_data->prev_execute_data;
2616			}
2617			EG(current_execute_data) = EX(prev_execute_data);
2618			ZEND_VM_RETURN();
2619		}
2620	}
2621}
2622
2623ZEND_VM_HANDLER(42, ZEND_JMP, JMP_ADDR, ANY)
2624{
2625	USE_OPLINE
2626
2627	ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op1));
2628	ZEND_VM_CONTINUE();
2629}
2630
2631ZEND_VM_HANDLER(43, ZEND_JMPZ, CONST|TMPVAR|CV, JMP_ADDR)
2632{
2633	USE_OPLINE
2634	zend_free_op free_op1;
2635	zval *val;
2636
2637	val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2638
2639	if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2640		ZEND_VM_SET_NEXT_OPCODE(opline + 1);
2641		ZEND_VM_CONTINUE();
2642	} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2643		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2644			SAVE_OPLINE();
2645			GET_OP1_UNDEF_CV(val, BP_VAR_R);
2646			ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2647		} else {
2648			ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2649			ZEND_VM_CONTINUE();
2650		}
2651	}
2652
2653	SAVE_OPLINE();
2654	if (i_zend_is_true(val)) {
2655		opline++;
2656	} else {
2657		opline = OP_JMP_ADDR(opline, opline->op2);
2658	}
2659	FREE_OP1();
2660	if (UNEXPECTED(EG(exception) != NULL)) {
2661		HANDLE_EXCEPTION();
2662	}
2663	ZEND_VM_JMP(opline);
2664}
2665
2666ZEND_VM_HANDLER(44, ZEND_JMPNZ, CONST|TMPVAR|CV, JMP_ADDR)
2667{
2668	USE_OPLINE
2669	zend_free_op free_op1;
2670	zval *val;
2671
2672	val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2673
2674	if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2675		ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2676		ZEND_VM_CONTINUE();
2677	} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2678		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2679			SAVE_OPLINE();
2680			GET_OP1_UNDEF_CV(val, BP_VAR_R);
2681			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2682		} else {
2683			ZEND_VM_NEXT_OPCODE();
2684		}
2685	}
2686
2687	SAVE_OPLINE();
2688	if (i_zend_is_true(val)) {
2689		opline = OP_JMP_ADDR(opline, opline->op2);
2690	} else {
2691		opline++;
2692	}
2693	FREE_OP1();
2694	if (UNEXPECTED(EG(exception) != NULL)) {
2695		HANDLE_EXCEPTION();
2696	}
2697	ZEND_VM_JMP(opline);
2698}
2699
2700ZEND_VM_HANDLER(45, ZEND_JMPZNZ, CONST|TMPVAR|CV, JMP_ADDR, JMP_ADDR)
2701{
2702	USE_OPLINE
2703	zend_free_op free_op1;
2704	zval *val;
2705
2706	val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2707
2708	if (EXPECTED(Z_TYPE_INFO_P(val) == IS_TRUE)) {
2709		ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
2710		ZEND_VM_CONTINUE();
2711	} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2712		if (OP1_TYPE == IS_CV) {
2713			if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2714				SAVE_OPLINE();
2715				GET_OP1_UNDEF_CV(val, BP_VAR_R);
2716			}
2717			ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2718		} else {
2719			ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2720			ZEND_VM_CONTINUE();
2721		}
2722	}
2723
2724	SAVE_OPLINE();
2725	if (i_zend_is_true(val)) {
2726		opline = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value);
2727	} else {
2728		opline = OP_JMP_ADDR(opline, opline->op2);
2729	}
2730	FREE_OP1();
2731	if (UNEXPECTED(EG(exception) != NULL)) {
2732		HANDLE_EXCEPTION();
2733	}
2734	ZEND_VM_JMP(opline);
2735}
2736
2737ZEND_VM_HANDLER(46, ZEND_JMPZ_EX, CONST|TMPVAR|CV, JMP_ADDR)
2738{
2739	USE_OPLINE
2740	zend_free_op free_op1;
2741	zval *val;
2742	int ret;
2743
2744	val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2745
2746	if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2747		ZVAL_TRUE(EX_VAR(opline->result.var));
2748		ZEND_VM_SET_NEXT_OPCODE(opline + 1);
2749		ZEND_VM_CONTINUE();
2750	} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2751		ZVAL_FALSE(EX_VAR(opline->result.var));
2752		if (OP1_TYPE == IS_CV) {
2753			if (UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2754				SAVE_OPLINE();
2755				GET_OP1_UNDEF_CV(val, BP_VAR_R);
2756			}
2757			ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
2758		} else {
2759			ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2760			ZEND_VM_CONTINUE();
2761		}
2762	}
2763
2764	SAVE_OPLINE();
2765	ret = i_zend_is_true(val);
2766	FREE_OP1();
2767	if (ret) {
2768		ZVAL_TRUE(EX_VAR(opline->result.var));
2769		opline++;
2770	} else {
2771		ZVAL_FALSE(EX_VAR(opline->result.var));
2772		opline = OP_JMP_ADDR(opline, opline->op2);
2773	}
2774	if (UNEXPECTED(EG(exception) != NULL)) {
2775		HANDLE_EXCEPTION();
2776	}
2777	ZEND_VM_JMP(opline);
2778}
2779
2780ZEND_VM_HANDLER(47, ZEND_JMPNZ_EX, CONST|TMPVAR|CV, JMP_ADDR)
2781{
2782	USE_OPLINE
2783	zend_free_op free_op1;
2784	zval *val;
2785	int ret;
2786
2787	val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2788
2789	if (Z_TYPE_INFO_P(val) == IS_TRUE) {
2790		ZVAL_TRUE(EX_VAR(opline->result.var));
2791		ZEND_VM_SET_OPCODE(OP_JMP_ADDR(opline, opline->op2));
2792		ZEND_VM_CONTINUE();
2793	} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
2794		ZVAL_FALSE(EX_VAR(opline->result.var));
2795		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
2796			SAVE_OPLINE();
2797			GET_OP1_UNDEF_CV(val, BP_VAR_R);
2798			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2799		} else {
2800			ZEND_VM_NEXT_OPCODE();
2801		}
2802	}
2803
2804	SAVE_OPLINE();
2805	ret = i_zend_is_true(val);
2806	FREE_OP1();
2807	if (ret) {
2808		ZVAL_TRUE(EX_VAR(opline->result.var));
2809		opline = OP_JMP_ADDR(opline, opline->op2);
2810	} else {
2811		ZVAL_FALSE(EX_VAR(opline->result.var));
2812		opline++;
2813	}
2814	if (UNEXPECTED(EG(exception) != NULL)) {
2815		HANDLE_EXCEPTION();
2816	}
2817	ZEND_VM_JMP(opline);
2818}
2819
2820ZEND_VM_HANDLER(70, ZEND_FREE, TMPVAR, LIVE_RANGE)
2821{
2822	USE_OPLINE
2823
2824	SAVE_OPLINE();
2825	zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
2826	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2827}
2828
2829ZEND_VM_HANDLER(127, ZEND_FE_FREE, TMPVAR, LIVE_RANGE)
2830{
2831	zval *var;
2832	USE_OPLINE
2833
2834	SAVE_OPLINE();
2835	var = EX_VAR(opline->op1.var);
2836	if (Z_TYPE_P(var) != IS_ARRAY && Z_FE_ITER_P(var) != (uint32_t)-1) {
2837		zend_hash_iterator_del(Z_FE_ITER_P(var));
2838	}
2839	zval_ptr_dtor_nogc(var);
2840	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2841}
2842
2843ZEND_VM_HANDLER(53, ZEND_FAST_CONCAT, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
2844{
2845	USE_OPLINE
2846	zend_free_op free_op1, free_op2;
2847	zval *op1, *op2;
2848	zend_string *op1_str, *op2_str, *str;
2849
2850	SAVE_OPLINE();
2851	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
2852	if (OP1_TYPE == IS_CONST) {
2853		op1_str = Z_STR_P(op1);
2854	} else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
2855		op1_str = zend_string_copy(Z_STR_P(op1));
2856	} else {
2857		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
2858			GET_OP1_UNDEF_CV(op1, BP_VAR_R);
2859		}
2860		op1_str = _zval_get_string_func(op1);
2861	}
2862	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2863	if (OP2_TYPE == IS_CONST) {
2864		op2_str = Z_STR_P(op2);
2865	} else if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
2866		op2_str = zend_string_copy(Z_STR_P(op2));
2867	} else {
2868		if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
2869			GET_OP2_UNDEF_CV(op2, BP_VAR_R);
2870		}
2871		op2_str = _zval_get_string_func(op2);
2872	}
2873	do {
2874		if (OP1_TYPE != IS_CONST) {
2875			if (UNEXPECTED(ZSTR_LEN(op1_str) == 0)) {
2876				if (OP2_TYPE == IS_CONST) {
2877					zend_string_addref(op2_str);
2878				}
2879				ZVAL_STR(EX_VAR(opline->result.var), op2_str);
2880				zend_string_release(op1_str);
2881				break;
2882			}
2883		}
2884		if (OP2_TYPE != IS_CONST) {
2885			if (UNEXPECTED(ZSTR_LEN(op2_str) == 0)) {
2886				if (OP1_TYPE == IS_CONST) {
2887					zend_string_addref(op1_str);
2888				}
2889				ZVAL_STR(EX_VAR(opline->result.var), op1_str);
2890				zend_string_release(op2_str);
2891				break;
2892			}
2893		}
2894		str = zend_string_alloc(ZSTR_LEN(op1_str) + ZSTR_LEN(op2_str), 0);
2895		memcpy(ZSTR_VAL(str), ZSTR_VAL(op1_str), ZSTR_LEN(op1_str));
2896		memcpy(ZSTR_VAL(str) + ZSTR_LEN(op1_str), ZSTR_VAL(op2_str), ZSTR_LEN(op2_str)+1);
2897		ZVAL_NEW_STR(EX_VAR(opline->result.var), str);
2898		if (OP1_TYPE != IS_CONST) {
2899			zend_string_release(op1_str);
2900		}
2901		if (OP2_TYPE != IS_CONST) {
2902			zend_string_release(op2_str);
2903		}
2904	} while (0);
2905	FREE_OP1();
2906	FREE_OP2();
2907	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2908}
2909
2910ZEND_VM_HANDLER(54, ZEND_ROPE_INIT, UNUSED, CONST|TMPVAR|CV, NUM)
2911{
2912	USE_OPLINE
2913	zend_free_op free_op2;
2914	zend_string **rope;
2915	zval *var;
2916
2917	/* Compiler allocates the necessary number of zval slots to keep the rope */
2918	rope = (zend_string**)EX_VAR(opline->result.var);
2919	if (OP2_TYPE == IS_CONST) {
2920		var = GET_OP2_ZVAL_PTR(BP_VAR_R);
2921		rope[0] = zend_string_copy(Z_STR_P(var));
2922	} else {
2923		var = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2924		if (EXPECTED(Z_TYPE_P(var) == IS_STRING)) {
2925			if (OP2_TYPE == IS_CV) {
2926				rope[0] = zend_string_copy(Z_STR_P(var));
2927			} else {
2928				rope[0] = Z_STR_P(var);
2929			}
2930		} else {
2931			SAVE_OPLINE();
2932			if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var) == IS_UNDEF)) {
2933				GET_OP2_UNDEF_CV(var, BP_VAR_R);
2934			}
2935			rope[0] = _zval_get_string_func(var);
2936			FREE_OP2();
2937			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2938		}
2939	}
2940	ZEND_VM_NEXT_OPCODE();
2941}
2942
2943ZEND_VM_HANDLER(55, ZEND_ROPE_ADD, TMP, CONST|TMPVAR|CV, NUM)
2944{
2945	USE_OPLINE
2946	zend_free_op free_op2;
2947	zend_string **rope;
2948	zval *var;
2949
2950	/* op1 and result are the same */
2951	rope = (zend_string**)EX_VAR(opline->op1.var);
2952	if (OP2_TYPE == IS_CONST) {
2953		var = GET_OP2_ZVAL_PTR(BP_VAR_R);
2954		rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2955	} else {
2956		var = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2957		if (EXPECTED(Z_TYPE_P(var) == IS_STRING)) {
2958			if (OP2_TYPE == IS_CV) {
2959				rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2960			} else {
2961				rope[opline->extended_value] = Z_STR_P(var);
2962			}
2963		} else {
2964			SAVE_OPLINE();
2965			if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var) == IS_UNDEF)) {
2966				GET_OP2_UNDEF_CV(var, BP_VAR_R);
2967			}
2968			rope[opline->extended_value] = _zval_get_string_func(var);
2969			FREE_OP2();
2970			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
2971		}
2972	}
2973	ZEND_VM_NEXT_OPCODE();
2974}
2975
2976ZEND_VM_HANDLER(56, ZEND_ROPE_END, TMP, CONST|TMPVAR|CV, NUM)
2977{
2978	USE_OPLINE
2979	zend_free_op free_op2;
2980	zend_string **rope;
2981	zval *var, *ret;
2982	uint32_t i;
2983	size_t len = 0;
2984	char *target;
2985
2986	rope = (zend_string**)EX_VAR(opline->op1.var);
2987	if (OP2_TYPE == IS_CONST) {
2988		var = GET_OP2_ZVAL_PTR(BP_VAR_R);
2989		rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2990	} else {
2991		var = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
2992		if (EXPECTED(Z_TYPE_P(var) == IS_STRING)) {
2993			if (OP2_TYPE == IS_CV) {
2994				rope[opline->extended_value] = zend_string_copy(Z_STR_P(var));
2995			} else {
2996				rope[opline->extended_value] = Z_STR_P(var);
2997			}
2998		} else {
2999			SAVE_OPLINE();
3000			if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var) == IS_UNDEF)) {
3001				GET_OP2_UNDEF_CV(var, BP_VAR_R);
3002			}
3003			rope[opline->extended_value] = _zval_get_string_func(var);
3004			FREE_OP2();
3005			if (UNEXPECTED(EG(exception))) {
3006				for (i = 0; i <= opline->extended_value; i++) {
3007					zend_string_release(rope[i]);
3008				}
3009				HANDLE_EXCEPTION();
3010			}
3011		}
3012	}
3013	for (i = 0; i <= opline->extended_value; i++) {
3014		len += ZSTR_LEN(rope[i]);
3015	}
3016	ret = EX_VAR(opline->result.var);
3017	ZVAL_STR(ret, zend_string_alloc(len, 0));
3018	target = Z_STRVAL_P(ret);
3019	for (i = 0; i <= opline->extended_value; i++) {
3020		memcpy(target, ZSTR_VAL(rope[i]), ZSTR_LEN(rope[i]));
3021		target += ZSTR_LEN(rope[i]);
3022		zend_string_release(rope[i]);
3023	}
3024	*target = '\0';
3025
3026	ZEND_VM_NEXT_OPCODE();
3027}
3028
3029ZEND_VM_HANDLER(109, ZEND_FETCH_CLASS, ANY, CONST|TMPVAR|UNUSED|CV, CLASS_FETCH)
3030{
3031	USE_OPLINE
3032
3033	SAVE_OPLINE();
3034	if (OP2_TYPE == IS_UNUSED) {
3035		Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(NULL, opline->extended_value);
3036		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3037	} else {
3038		zend_free_op free_op2;
3039		zval *class_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
3040
3041ZEND_VM_C_LABEL(try_class_name):
3042		if (OP2_TYPE == IS_CONST) {
3043			zend_class_entry *ce = CACHED_PTR(Z_CACHE_SLOT_P(class_name));
3044
3045			if (UNEXPECTED(ce == NULL)) {
3046				ce = zend_fetch_class_by_name(Z_STR_P(class_name), EX_CONSTANT(opline->op2) + 1, opline->extended_value);
3047				CACHE_PTR(Z_CACHE_SLOT_P(class_name), ce);
3048			}
3049			Z_CE_P(EX_VAR(opline->result.var)) = ce;
3050		} else if (Z_TYPE_P(class_name) == IS_OBJECT) {
3051			Z_CE_P(EX_VAR(opline->result.var)) = Z_OBJCE_P(class_name);
3052		} else if (Z_TYPE_P(class_name) == IS_STRING) {
3053			Z_CE_P(EX_VAR(opline->result.var)) = zend_fetch_class(Z_STR_P(class_name), opline->extended_value);
3054		} else if ((OP2_TYPE & (IS_VAR|IS_CV)) && Z_TYPE_P(class_name) == IS_REFERENCE) {
3055			class_name = Z_REFVAL_P(class_name);
3056			ZEND_VM_C_GOTO(try_class_name);
3057		} else {
3058			if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(class_name) == IS_UNDEF)) {
3059				GET_OP2_UNDEF_CV(class_name, BP_VAR_R);
3060				if (UNEXPECTED(EG(exception) != NULL)) {
3061					HANDLE_EXCEPTION();
3062				}
3063			}
3064			zend_throw_error(NULL, "Class name must be a valid object or a string");
3065		}
3066
3067		FREE_OP2();
3068		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3069	}
3070}
3071
3072ZEND_VM_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, NUM)
3073{
3074	USE_OPLINE
3075	zval *function_name;
3076	zend_free_op free_op1, free_op2;
3077	zval *object;
3078	zend_function *fbc;
3079	zend_class_entry *called_scope;
3080	zend_object *obj;
3081	zend_execute_data *call;
3082	uint32_t call_info;
3083
3084	SAVE_OPLINE();
3085
3086	function_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
3087
3088	if (OP2_TYPE != IS_CONST &&
3089	    UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
3090		do {
3091			if ((OP2_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(function_name)) {
3092				function_name = Z_REFVAL_P(function_name);
3093				if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
3094					break;
3095				}
3096			} else if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
3097				GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
3098				if (UNEXPECTED(EG(exception) != NULL)) {
3099					HANDLE_EXCEPTION();
3100				}
3101			}
3102			zend_throw_error(NULL, "Method name must be a string");
3103			FREE_OP2();
3104			FREE_UNFETCHED_OP1();
3105			HANDLE_EXCEPTION();
3106		} while (0);
3107	}
3108
3109	object = GET_OP1_OBJ_ZVAL_PTR_UNDEF(BP_VAR_R);
3110
3111	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(object) == IS_UNDEF)) {
3112		zend_throw_error(NULL, "Using $this when not in object context");
3113		FREE_OP2();
3114		HANDLE_EXCEPTION();
3115	}
3116
3117	if (OP1_TYPE != IS_UNUSED) {
3118		do {
3119			if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(object) != IS_OBJECT)) {
3120				if ((OP1_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(object))) {
3121					object = Z_REFVAL_P(object);
3122					if (EXPECTED(Z_TYPE_P(object) == IS_OBJECT)) {
3123						break;
3124					}
3125				}
3126				if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(object) == IS_UNDEF)) {
3127					object = GET_OP1_UNDEF_CV(object, BP_VAR_R);
3128					if (UNEXPECTED(EG(exception) != NULL)) {
3129						FREE_OP2();
3130						HANDLE_EXCEPTION();
3131					}
3132				}
3133				zend_throw_error(NULL, "Call to a member function %s() on %s", Z_STRVAL_P(function_name), zend_get_type_by_const(Z_TYPE_P(object)));
3134				FREE_OP2();
3135				FREE_OP1();
3136				HANDLE_EXCEPTION();
3137			}
3138		} while (0);
3139	}
3140
3141	obj = Z_OBJ_P(object);
3142	called_scope = obj->ce;
3143
3144	if (OP2_TYPE != IS_CONST ||
3145	    UNEXPECTED((fbc = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), called_scope)) == NULL)) {
3146	    zend_object *orig_obj = obj;
3147
3148		if (UNEXPECTED(obj->handlers->get_method == NULL)) {
3149			zend_throw_error(NULL, "Object does not support method calls");
3150			FREE_OP2();
3151			FREE_OP1();
3152			HANDLE_EXCEPTION();
3153		}
3154
3155		/* First, locate the function. */
3156		fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (EX_CONSTANT(opline->op2) + 1) : NULL));
3157		if (UNEXPECTED(fbc == NULL)) {
3158			if (EXPECTED(!EG(exception))) {
3159				zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(obj->ce->name), Z_STRVAL_P(function_name));
3160			}
3161			FREE_OP2();
3162			FREE_OP1();
3163			HANDLE_EXCEPTION();
3164		}
3165		if (OP2_TYPE == IS_CONST &&
3166		    EXPECTED(fbc->type <= ZEND_USER_FUNCTION) &&
3167		    EXPECTED(!(fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE|ZEND_ACC_NEVER_CACHE))) &&
3168		    EXPECTED(obj == orig_obj)) {
3169			CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), called_scope, fbc);
3170		}
3171		if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
3172			init_func_run_time_cache(&fbc->op_array);
3173		}
3174	}
3175
3176	call_info = ZEND_CALL_NESTED_FUNCTION;
3177	if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_STATIC) != 0)) {
3178		obj = NULL;
3179	} else if (OP1_TYPE & (IS_VAR|IS_TMP_VAR|IS_CV)) {
3180		/* CV may be changed indirectly (e.g. when it's a reference) */
3181		call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_RELEASE_THIS;
3182		GC_REFCOUNT(obj)++; /* For $this pointer */
3183	}
3184
3185	call = zend_vm_stack_push_call_frame(call_info,
3186		fbc, opline->extended_value, called_scope, obj);
3187	call->prev_execute_data = EX(call);
3188	EX(call) = call;
3189
3190	FREE_OP2();
3191	FREE_OP1();
3192
3193	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3194}
3195
3196ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, UNUSED|CLASS_FETCH|CONST|VAR, CONST|TMPVAR|UNUSED|CONSTRUCTOR|CV, NUM)
3197{
3198	USE_OPLINE
3199	zval *function_name;
3200	zend_class_entry *ce;
3201	zend_object *object;
3202	zend_function *fbc;
3203	zend_execute_data *call;
3204
3205	SAVE_OPLINE();
3206
3207	if (OP1_TYPE == IS_CONST) {
3208		/* no function found. try a static method in class */
3209		ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
3210		if (UNEXPECTED(ce == NULL)) {
3211			ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op1)), EX_CONSTANT(opline->op1) + 1, ZEND_FETCH_CLASS_DEFAULT |  ZEND_FETCH_CLASS_EXCEPTION);
3212			if (UNEXPECTED(ce == NULL)) {
3213				if (UNEXPECTED(EG(exception) != NULL)) {
3214					HANDLE_EXCEPTION();
3215				}
3216				zend_throw_error(NULL, "Class '%s' not found", Z_STRVAL_P(EX_CONSTANT(opline->op1)));
3217				HANDLE_EXCEPTION();
3218			}
3219			CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce);
3220		}
3221	} else if (OP1_TYPE == IS_UNUSED) {
3222		ce = zend_fetch_class(NULL, opline->op1.num);
3223		if (UNEXPECTED(ce == NULL)) {
3224			ZEND_ASSERT(EG(exception));
3225			FREE_UNFETCHED_OP2();
3226			HANDLE_EXCEPTION();
3227		}
3228	} else {
3229		ce = Z_CE_P(EX_VAR(opline->op1.var));
3230	}
3231
3232	if (OP1_TYPE == IS_CONST &&
3233	    OP2_TYPE == IS_CONST &&
3234	    EXPECTED((fbc = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) != NULL)) {
3235		/* nothing to do */
3236	} else if (OP1_TYPE != IS_CONST &&
3237	           OP2_TYPE == IS_CONST &&
3238	           (fbc = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce))) {
3239		/* do nothing */
3240	} else if (OP2_TYPE != IS_UNUSED) {
3241		zend_free_op free_op2;
3242
3243		function_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
3244		if (OP2_TYPE != IS_CONST) {
3245			if (UNEXPECTED(Z_TYPE_P(function_name) != IS_STRING)) {
3246				do {
3247					if (OP2_TYPE & (IS_VAR|IS_CV) && Z_ISREF_P(function_name)) {
3248						function_name = Z_REFVAL_P(function_name);
3249						if (EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
3250							break;
3251						}
3252					} else if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
3253						GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
3254						if (UNEXPECTED(EG(exception) != NULL)) {
3255							HANDLE_EXCEPTION();
3256						}
3257					}
3258					zend_throw_error(NULL, "Function name must be a string");
3259					FREE_OP2();
3260					HANDLE_EXCEPTION();
3261				} while (0);
3262 			}
3263		}
3264
3265		if (ce->get_static_method) {
3266			fbc = ce->get_static_method(ce, Z_STR_P(function_name));
3267		} else {
3268			fbc = zend_std_get_static_method(ce, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (EX_CONSTANT(opline->op2) + 1) : NULL));
3269		}
3270		if (UNEXPECTED(fbc == NULL)) {
3271			if (EXPECTED(!EG(exception))) {
3272				zend_throw_error(NULL, "Call to undefined method %s::%s()", ZSTR_VAL(ce->name), Z_STRVAL_P(function_name));
3273			}
3274			FREE_OP2();
3275			HANDLE_EXCEPTION();
3276		}
3277		if (OP2_TYPE == IS_CONST &&
3278		    EXPECTED(fbc->type <= ZEND_USER_FUNCTION) &&
3279		    EXPECTED(!(fbc->common.fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE|ZEND_ACC_NEVER_CACHE)))) {
3280			if (OP1_TYPE == IS_CONST) {
3281				CACHE_PTR(Z_CACHE_SLOT_P(function_name), fbc);
3282			} else {
3283				CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(function_name), ce, fbc);
3284			}
3285		}
3286		if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
3287			init_func_run_time_cache(&fbc->op_array);
3288		}
3289		if (OP2_TYPE != IS_CONST) {
3290			FREE_OP2();
3291		}
3292	} else {
3293		if (UNEXPECTED(ce->constructor == NULL)) {
3294			zend_throw_error(NULL, "Cannot call constructor");
3295			HANDLE_EXCEPTION();
3296		}
3297		if (Z_TYPE(EX(This)) == IS_OBJECT && Z_OBJ(EX(This))->ce != ce->constructor->common.scope && (ce->constructor->common.fn_flags & ZEND_ACC_PRIVATE)) {
3298			zend_throw_error(NULL, "Cannot call private %s::__construct()", ZSTR_VAL(ce->name));
3299			HANDLE_EXCEPTION();
3300		}
3301		fbc = ce->constructor;
3302		if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
3303			init_func_run_time_cache(&fbc->op_array);
3304		}
3305	}
3306
3307	object = NULL;
3308	if (!(fbc->common.fn_flags & ZEND_ACC_STATIC)) {
3309		if (Z_TYPE(EX(This)) == IS_OBJECT && instanceof_function(Z_OBJCE(EX(This)), ce)) {
3310			object = Z_OBJ(EX(This));
3311			ce = object->ce;
3312		} else {
3313			if (fbc->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {
3314				/* Allowed for PHP 4 compatibility. */
3315				zend_error(
3316					E_DEPRECATED,
3317					"Non-static method %s::%s() should not be called statically",
3318					ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3319				if (UNEXPECTED(EG(exception) != NULL)) {
3320					HANDLE_EXCEPTION();
3321				}
3322			} else {
3323				/* An internal function assumes $this is present and won't check that.
3324				 * So PHP would crash by allowing the call. */
3325				zend_throw_error(
3326					zend_ce_error,
3327					"Non-static method %s::%s() cannot be called statically",
3328					ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3329				HANDLE_EXCEPTION();
3330			}
3331		}
3332	}
3333
3334	if (OP1_TYPE == IS_UNUSED) {
3335		/* previous opcode is ZEND_FETCH_CLASS */
3336		if ((opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_PARENT ||
3337		    (opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF) {
3338			if (Z_TYPE(EX(This)) == IS_OBJECT) {
3339				ce = Z_OBJCE(EX(This));
3340			} else {
3341				ce = Z_CE(EX(This));
3342			}
3343		}
3344	}
3345
3346	call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
3347		fbc, opline->extended_value, ce, object);
3348	call->prev_execute_data = EX(call);
3349	EX(call) = call;
3350
3351	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3352}
3353
3354ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST, NUM)
3355{
3356	USE_OPLINE
3357	zend_function *fbc;
3358	zval *function_name, *func;
3359	zend_execute_data *call;
3360
3361	function_name = (zval*)EX_CONSTANT(opline->op2);
3362	fbc = CACHED_PTR(Z_CACHE_SLOT_P(function_name));
3363	if (UNEXPECTED(fbc == NULL)) {
3364		func = zend_hash_find(EG(function_table), Z_STR_P(function_name+1));
3365		if (UNEXPECTED(func == NULL)) {
3366			SAVE_OPLINE();
3367			zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(function_name));
3368			HANDLE_EXCEPTION();
3369		}
3370		fbc = Z_FUNC_P(func);
3371		if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
3372			init_func_run_time_cache(&fbc->op_array);
3373		}
3374		CACHE_PTR(Z_CACHE_SLOT_P(function_name), fbc);
3375	}
3376	call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
3377		fbc, opline->extended_value, NULL, NULL);
3378	call->prev_execute_data = EX(call);
3379	EX(call) = call;
3380
3381	ZEND_VM_NEXT_OPCODE();
3382}
3383
3384ZEND_VM_HANDLER(128, ZEND_INIT_DYNAMIC_CALL, ANY, CONST|TMPVAR|CV, NUM)
3385{
3386	USE_OPLINE
3387	zend_free_op free_op2;
3388	zval *function_name;
3389	zend_execute_data *call;
3390
3391	SAVE_OPLINE();
3392	function_name = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
3393
3394ZEND_VM_C_LABEL(try_function_name):
3395	if (OP2_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_STRING)) {
3396		call = zend_init_dynamic_call_string(Z_STR_P(function_name), opline->extended_value);
3397	} else if (OP2_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_OBJECT)) {
3398		call = zend_init_dynamic_call_object(function_name, opline->extended_value);
3399	} else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY)) {
3400		call = zend_init_dynamic_call_array(Z_ARRVAL_P(function_name), opline->extended_value);
3401	} else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(function_name) == IS_REFERENCE)) {
3402		function_name = Z_REFVAL_P(function_name);
3403		ZEND_VM_C_GOTO(try_function_name);
3404	} else {
3405		if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(function_name) == IS_UNDEF)) {
3406			GET_OP2_UNDEF_CV(function_name, BP_VAR_R);
3407			if (UNEXPECTED(EG(exception) != NULL)) {
3408				HANDLE_EXCEPTION();
3409			}
3410		}
3411		zend_throw_error(NULL, "Function name must be a string");
3412		call = NULL;
3413	}
3414
3415	FREE_OP2();
3416
3417	if (UNEXPECTED(!call)) {
3418		HANDLE_EXCEPTION();
3419	}
3420
3421	call->prev_execute_data = EX(call);
3422	EX(call) = call;
3423
3424	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3425}
3426
3427ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM)
3428{
3429	USE_OPLINE
3430	zend_free_op free_op2;
3431	zval *function_name;
3432	zend_fcall_info_cache fcc;
3433	char *error = NULL;
3434	zend_function *func;
3435	zend_class_entry *called_scope;
3436	zend_object *object;
3437	zend_execute_data *call;
3438	uint32_t call_info = ZEND_CALL_NESTED_FUNCTION | ZEND_CALL_DYNAMIC;
3439
3440	SAVE_OPLINE();
3441	function_name = GET_OP2_ZVAL_PTR(BP_VAR_R);
3442	if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) {
3443		func = fcc.function_handler;
3444		called_scope = fcc.called_scope;
3445		object = fcc.object;
3446		if (func->common.fn_flags & ZEND_ACC_CLOSURE) {
3447			/* Delay closure destruction until its invocation */
3448			if (OP2_TYPE & (IS_VAR|IS_CV)) {
3449				ZVAL_DEREF(function_name);
3450			}
3451			ZEND_ASSERT(GC_TYPE((zend_object*)func->common.prototype) == IS_OBJECT);
3452			GC_REFCOUNT((zend_object*)func->common.prototype)++;
3453			call_info |= ZEND_CALL_CLOSURE;
3454		} else if (object) {
3455			call_info |= ZEND_CALL_RELEASE_THIS;
3456			GC_REFCOUNT(object)++; /* For $this pointer */
3457		}
3458		if (error) {
3459			efree(error);
3460			/* This is the only soft error is_callable() can generate */
3461			zend_error(E_DEPRECATED,
3462				"Non-static method %s::%s() should not be called statically",
3463				ZSTR_VAL(func->common.scope->name), ZSTR_VAL(func->common.function_name));
3464			if (UNEXPECTED(EG(exception) != NULL)) {
3465				HANDLE_EXCEPTION();
3466			}
3467		}
3468		if (EXPECTED(func->type == ZEND_USER_FUNCTION) && UNEXPECTED(!func->op_array.run_time_cache)) {
3469			init_func_run_time_cache(&func->op_array);
3470		}
3471	} else {
3472		zend_internal_type_error(EX_USES_STRICT_TYPES(), "%s() expects parameter 1 to be a valid callback, %s", Z_STRVAL_P(EX_CONSTANT(opline->op1)), error);
3473		efree(error);
3474		func = (zend_function*)&zend_pass_function;
3475		called_scope = NULL;
3476		object = NULL;
3477	}
3478
3479	call = zend_vm_stack_push_call_frame(call_info,
3480		func, opline->extended_value, called_scope, object);
3481	call->prev_execute_data = EX(call);
3482	EX(call) = call;
3483
3484	FREE_OP2();
3485	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3486}
3487
3488ZEND_VM_HANDLER(69, ZEND_INIT_NS_FCALL_BY_NAME, ANY, CONST, NUM)
3489{
3490	USE_OPLINE
3491	zval *func_name;
3492	zval *func;
3493	zend_function *fbc;
3494	zend_execute_data *call;
3495
3496	func_name = EX_CONSTANT(opline->op2) + 1;
3497	fbc = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
3498	if (UNEXPECTED(fbc == NULL)) {
3499		func = zend_hash_find(EG(function_table), Z_STR_P(func_name));
3500		if (func == NULL) {
3501			func_name++;
3502			func = zend_hash_find(EG(function_table), Z_STR_P(func_name));
3503			if (UNEXPECTED(func == NULL)) {
3504				SAVE_OPLINE();
3505				zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
3506				HANDLE_EXCEPTION();
3507			}
3508		}
3509		fbc = Z_FUNC_P(func);
3510		CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), fbc);
3511		if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
3512			init_func_run_time_cache(&fbc->op_array);
3513		}
3514	}
3515
3516	call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_FUNCTION,
3517		fbc, opline->extended_value, NULL, NULL);
3518	call->prev_execute_data = EX(call);
3519	EX(call) = call;
3520
3521	ZEND_VM_NEXT_OPCODE();
3522}
3523
3524ZEND_VM_HANDLER(61, ZEND_INIT_FCALL, NUM, CONST, NUM)
3525{
3526	USE_OPLINE
3527	zend_free_op free_op2;
3528	zval *fname = GET_OP2_ZVAL_PTR(BP_VAR_R);
3529	zval *func;
3530	zend_function *fbc;
3531	zend_execute_data *call;
3532
3533	fbc = CACHED_PTR(Z_CACHE_SLOT_P(fname));
3534	if (UNEXPECTED(fbc == NULL)) {
3535		func = zend_hash_find(EG(function_table), Z_STR_P(fname));
3536		if (UNEXPECTED(func == NULL)) {
3537		    SAVE_OPLINE();
3538			zend_throw_error(NULL, "Call to undefined function %s()", Z_STRVAL_P(fname));
3539			HANDLE_EXCEPTION();
3540		}
3541		fbc = Z_FUNC_P(func);
3542		CACHE_PTR(Z_CACHE_SLOT_P(fname), fbc);
3543		if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!fbc->op_array.run_time_cache)) {
3544			init_func_run_time_cache(&fbc->op_array);
3545		}
3546	}
3547
3548	call = zend_vm_stack_push_call_frame_ex(
3549		opline->op1.num, ZEND_CALL_NESTED_FUNCTION,
3550		fbc, opline->extended_value, NULL, NULL);
3551	call->prev_execute_data = EX(call);
3552	EX(call) = call;
3553
3554	ZEND_VM_NEXT_OPCODE();
3555}
3556
3557ZEND_VM_HANDLER(129, ZEND_DO_ICALL, ANY, ANY, SPEC(RETVAL))
3558{
3559	USE_OPLINE
3560	zend_execute_data *call = EX(call);
3561	zend_function *fbc = call->func;
3562	zval *ret;
3563	zval retval;
3564
3565	SAVE_OPLINE();
3566	EX(call) = call->prev_execute_data;
3567
3568	call->prev_execute_data = execute_data;
3569	EG(current_execute_data) = call;
3570
3571	ret = RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : &retval;
3572	ZVAL_NULL(ret);
3573
3574	fbc->internal_function.handler(call, ret);
3575
3576#if ZEND_DEBUG
3577	ZEND_ASSERT(
3578		EG(exception) || !call->func ||
3579		!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
3580		zend_verify_internal_return_type(call->func, ret));
3581	ZEND_ASSERT(!Z_ISREF_P(ret));
3582#endif
3583
3584	EG(current_execute_data) = call->prev_execute_data;
3585	zend_vm_stack_free_args(call);
3586	zend_vm_stack_free_call_frame(call);
3587
3588	if (!RETURN_VALUE_USED(opline)) {
3589		zval_ptr_dtor(ret);
3590	}
3591
3592	if (UNEXPECTED(EG(exception) != NULL)) {
3593		zend_throw_exception_internal(NULL);
3594		if (RETURN_VALUE_USED(opline)) {
3595			zval_ptr_dtor(EX_VAR(opline->result.var));
3596		}
3597		HANDLE_EXCEPTION();
3598	}
3599
3600	ZEND_VM_SET_OPCODE(opline + 1);
3601	ZEND_VM_CONTINUE();
3602}
3603
3604ZEND_VM_HANDLER(130, ZEND_DO_UCALL, ANY, ANY, SPEC(RETVAL))
3605{
3606	USE_OPLINE
3607	zend_execute_data *call = EX(call);
3608	zend_function *fbc = call->func;
3609	zval *ret;
3610
3611	SAVE_OPLINE();
3612	EX(call) = call->prev_execute_data;
3613
3614	ret = NULL;
3615	if (RETURN_VALUE_USED(opline)) {
3616		ret = EX_VAR(opline->result.var);
3617		ZVAL_NULL(ret);
3618	}
3619
3620	call->prev_execute_data = execute_data;
3621	i_init_func_execute_data(call, &fbc->op_array, ret, 0);
3622
3623	ZEND_VM_ENTER();
3624}
3625
3626ZEND_VM_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY, SPEC(RETVAL))
3627{
3628	USE_OPLINE
3629	zend_execute_data *call = EX(call);
3630	zend_function *fbc = call->func;
3631	zval *ret;
3632
3633	SAVE_OPLINE();
3634	EX(call) = call->prev_execute_data;
3635
3636	if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
3637		ret = NULL;
3638		if (RETURN_VALUE_USED(opline)) {
3639			ret = EX_VAR(opline->result.var);
3640			ZVAL_NULL(ret);
3641		}
3642
3643		call->prev_execute_data = execute_data;
3644		i_init_func_execute_data(call, &fbc->op_array, ret, 0);
3645
3646		ZEND_VM_ENTER();
3647	} else {
3648		zval retval;
3649		ZEND_ASSERT(fbc->type == ZEND_INTERNAL_FUNCTION);
3650
3651		if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) {
3652			zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
3653				fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
3654				fbc->common.scope ? "::" : "",
3655				ZSTR_VAL(fbc->common.function_name));
3656			if (UNEXPECTED(EG(exception) != NULL)) {
3657				HANDLE_EXCEPTION();
3658			}
3659		}
3660
3661		call->prev_execute_data = execute_data;
3662		EG(current_execute_data) = call;
3663
3664		if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
3665		 && UNEXPECTED(!zend_verify_internal_arg_types(fbc, call))) {
3666			zend_vm_stack_free_call_frame(call);
3667			zend_throw_exception_internal(NULL);
3668			HANDLE_EXCEPTION();
3669		}
3670
3671		ret = RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : &retval;
3672		ZVAL_NULL(ret);
3673
3674		fbc->internal_function.handler(call, ret);
3675
3676#if ZEND_DEBUG
3677		if (!EG(exception) && call->func) {
3678			ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
3679				zend_verify_internal_return_type(call->func, ret));
3680			ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
3681				? Z_ISREF_P(ret) : !Z_ISREF_P(ret));
3682		}
3683#endif
3684
3685		EG(current_execute_data) = call->prev_execute_data;
3686		zend_vm_stack_free_args(call);
3687		zend_vm_stack_free_call_frame(call);
3688
3689		if (!RETURN_VALUE_USED(opline)) {
3690			zval_ptr_dtor(ret);
3691		}
3692	}
3693
3694	if (UNEXPECTED(EG(exception) != NULL)) {
3695		zend_throw_exception_internal(NULL);
3696		if (RETURN_VALUE_USED(opline)) {
3697			zval_ptr_dtor(EX_VAR(opline->result.var));
3698		}
3699		HANDLE_EXCEPTION();
3700	}
3701	ZEND_VM_SET_OPCODE(opline + 1);
3702	ZEND_VM_CONTINUE();
3703}
3704
3705ZEND_VM_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
3706{
3707	USE_OPLINE
3708	zend_execute_data *call = EX(call);
3709	zend_function *fbc = call->func;
3710	zend_object *object;
3711	zval *ret;
3712
3713	SAVE_OPLINE();
3714	EX(call) = call->prev_execute_data;
3715	if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) {
3716		if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) {
3717			zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
3718			HANDLE_EXCEPTION();
3719		}
3720		if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_DEPRECATED) != 0)) {
3721			zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
3722				fbc->common.scope ? ZSTR_VAL(fbc->common.scope->name) : "",
3723				fbc->common.scope ? "::" : "",
3724				ZSTR_VAL(fbc->common.function_name));
3725			if (UNEXPECTED(EG(exception) != NULL)) {
3726				HANDLE_EXCEPTION();
3727			}
3728		}
3729	}
3730
3731	LOAD_OPLINE();
3732
3733	if (EXPECTED(fbc->type == ZEND_USER_FUNCTION)) {
3734		ret = NULL;
3735		if (RETURN_VALUE_USED(opline)) {
3736			ret = EX_VAR(opline->result.var);
3737			ZVAL_NULL(ret);
3738		}
3739
3740		call->prev_execute_data = execute_data;
3741		i_init_func_execute_data(call, &fbc->op_array, ret, 1);
3742
3743		if (EXPECTED(zend_execute_ex == execute_ex)) {
3744			ZEND_VM_ENTER();
3745		} else {
3746			ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
3747			zend_execute_ex(call);
3748		}
3749	} else if (EXPECTED(fbc->type < ZEND_USER_FUNCTION)) {
3750		zval retval;
3751
3752		call->prev_execute_data = execute_data;
3753		EG(current_execute_data) = call;
3754
3755		if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
3756		  && UNEXPECTED(!zend_verify_internal_arg_types(fbc, call))) {
3757			if (RETURN_VALUE_USED(opline)) {
3758				ZVAL_UNDEF(EX_VAR(opline->result.var));
3759			}
3760			ZEND_VM_C_GOTO(fcall_end);
3761		}
3762
3763		ret = RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : &retval;
3764		ZVAL_NULL(ret);
3765
3766		if (!zend_execute_internal) {
3767			/* saves one function call if zend_execute_internal is not used */
3768			fbc->internal_function.handler(call, ret);
3769		} else {
3770			zend_execute_internal(call, ret);
3771		}
3772
3773#if ZEND_DEBUG
3774		if (!EG(exception) && call->func) {
3775			ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
3776				zend_verify_internal_return_type(call->func, ret));
3777			ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
3778				? Z_ISREF_P(ret) : !Z_ISREF_P(ret));
3779		}
3780#endif
3781
3782		EG(current_execute_data) = call->prev_execute_data;
3783		zend_vm_stack_free_args(call);
3784
3785		if (!RETURN_VALUE_USED(opline)) {
3786			zval_ptr_dtor(ret);
3787		}
3788
3789	} else { /* ZEND_OVERLOADED_FUNCTION */
3790		zval retval;
3791
3792		ret = RETURN_VALUE_USED(opline) ? EX_VAR(opline->result.var) : &retval;
3793
3794		call->prev_execute_data = execute_data;
3795
3796		if (UNEXPECTED(!zend_do_fcall_overloaded(fbc, call, ret))) {
3797			HANDLE_EXCEPTION();
3798		}
3799
3800		if (!RETURN_VALUE_USED(opline)) {
3801			zval_ptr_dtor(ret);
3802		}
3803	}
3804
3805ZEND_VM_C_LABEL(fcall_end):
3806	if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS)) {
3807		object = Z_OBJ(call->This);
3808#if 0
3809		if (UNEXPECTED(EG(exception) != NULL) && (opline->op1.num & ZEND_CALL_CTOR)) {
3810#else
3811		if (UNEXPECTED(EG(exception) != NULL) && (ZEND_CALL_INFO(call) & ZEND_CALL_CTOR)) {
3812#endif
3813			GC_REFCOUNT(object)--;
3814			if (GC_REFCOUNT(object) == 1) {
3815				zend_object_store_ctor_failed(object);
3816			}
3817		}
3818		OBJ_RELEASE(object);
3819	}
3820
3821	zend_vm_stack_free_call_frame(call);
3822	if (UNEXPECTED(EG(exception) != NULL)) {
3823		zend_throw_exception_internal(NULL);
3824		if (RETURN_VALUE_USED(opline)) {
3825			zval_ptr_dtor(EX_VAR(opline->result.var));
3826		}
3827		HANDLE_EXCEPTION();
3828	}
3829
3830	ZEND_VM_SET_OPCODE(opline + 1);
3831	ZEND_VM_CONTINUE();
3832}
3833
3834ZEND_VM_HANDLER(124, ZEND_VERIFY_RETURN_TYPE, CONST|TMP|VAR|UNUSED|CV, UNUSED)
3835{
3836	USE_OPLINE
3837
3838	SAVE_OPLINE();
3839	if (OP1_TYPE == IS_UNUSED) {
3840		zend_verify_missing_return_type(EX(func), CACHE_ADDR(opline->op2.num));
3841	} else {
3842/* prevents "undefined variable opline" errors */
3843#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
3844		zval *retval_ref, *retval_ptr;
3845		zend_free_op free_op1;
3846		zend_arg_info *ret_info = EX(func)->common.arg_info - 1;
3847
3848		retval_ref = retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3849
3850		if (OP1_TYPE == IS_CONST) {
3851			ZVAL_COPY(EX_VAR(opline->result.var), retval_ptr);
3852			retval_ref = retval_ptr = EX_VAR(opline->result.var);
3853		} else if (OP1_TYPE == IS_VAR) {
3854			if (UNEXPECTED(Z_TYPE_P(retval_ptr) == IS_INDIRECT)) {
3855				retval_ptr = Z_INDIRECT_P(retval_ptr);
3856			}
3857			ZVAL_DEREF(retval_ptr);
3858		} else if (OP1_TYPE == IS_CV) {
3859			ZVAL_DEREF(retval_ptr);
3860		}
3861
3862		if (UNEXPECTED(!ret_info->class_name
3863			&& ret_info->type_hint != IS_CALLABLE
3864			&& !ZEND_SAME_FAKE_TYPE(ret_info->type_hint, Z_TYPE_P(retval_ptr))
3865			&& !(EX(func)->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE)
3866			&& retval_ref != retval_ptr)
3867		) {
3868			/* A cast might happen - unwrap the reference if this is a by-value return */
3869			if (Z_REFCOUNT_P(retval_ref) == 1) {
3870				ZVAL_UNREF(retval_ref);
3871			} else {
3872				Z_DELREF_P(retval_ref);
3873				ZVAL_COPY(retval_ref, retval_ptr);
3874			}
3875			retval_ptr = retval_ref;
3876		}
3877		zend_verify_return_type(EX(func), retval_ptr, CACHE_ADDR(opline->op2.num));
3878
3879		if (UNEXPECTED(EG(exception) != NULL)) {
3880			if (OP1_TYPE == IS_CONST) {
3881				zval_ptr_dtor_nogc(retval_ptr);
3882			}
3883		}
3884#endif
3885	}
3886	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
3887}
3888
3889ZEND_VM_HANDLER(62, ZEND_RETURN, CONST|TMP|VAR|CV, ANY)
3890{
3891	USE_OPLINE
3892	zval *retval_ptr;
3893	zval *return_value;
3894	zend_free_op free_op1;
3895
3896	retval_ptr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
3897	return_value = EX(return_value);
3898	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(retval_ptr) == IS_UNDEF)) {
3899		SAVE_OPLINE();
3900		retval_ptr = GET_OP1_UNDEF_CV(retval_ptr, BP_VAR_R);
3901		if (return_value) {
3902			ZVAL_NULL(return_value);
3903		}
3904	} else if (!return_value) {
3905		if (OP1_TYPE & (IS_VAR|IS_TMP_VAR)) {
3906			if (Z_REFCOUNTED_P(free_op1) && !Z_DELREF_P(free_op1)) {
3907				SAVE_OPLINE();
3908				zval_dtor_func(Z_COUNTED_P(free_op1));
3909			}
3910		}
3911	} else {
3912		if ((OP1_TYPE & (IS_CONST|IS_TMP_VAR))) {
3913			ZVAL_COPY_VALUE(return_value, retval_ptr);
3914			if (OP1_TYPE == IS_CONST) {
3915				if (UNEXPECTED(Z_OPT_REFCOUNTED_P(return_value))) {
3916					Z_ADDREF_P(return_value);
3917				}
3918			}
3919		} else if (OP1_TYPE == IS_CV) {
3920			if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
3921				if (EXPECTED(!Z_OPT_ISREF_P(retval_ptr))) {
3922					ZVAL_COPY_VALUE(return_value, retval_ptr);
3923					if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) {
3924						ZVAL_NULL(retval_ptr);
3925					} else {
3926						Z_ADDREF_P(return_value);
3927					}
3928				} else {
3929					retval_ptr = Z_REFVAL_P(retval_ptr);
3930					ZVAL_COPY(return_value, retval_ptr);
3931				}
3932			} else {
3933				ZVAL_COPY_VALUE(return_value, retval_ptr);
3934			}
3935		} else /* if (OP1_TYPE == IS_VAR) */ {
3936			if (UNEXPECTED(Z_ISREF_P(retval_ptr))) {
3937				zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
3938
3939				retval_ptr = Z_REFVAL_P(retval_ptr);
3940				ZVAL_COPY_VALUE(return_value, retval_ptr);
3941				if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
3942					efree_size(ref, sizeof(zend_reference));
3943				} else if (Z_OPT_REFCOUNTED_P(retval_ptr)) {
3944					Z_ADDREF_P(retval_ptr);
3945				}
3946			} else {
3947				ZVAL_COPY_VALUE(return_value, retval_ptr);
3948			}
3949		}
3950	}
3951	ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
3952}
3953
3954ZEND_VM_HANDLER(111, ZEND_RETURN_BY_REF, CONST|TMP|VAR|CV, ANY, SRC)
3955{
3956	USE_OPLINE
3957	zval *retval_ptr;
3958	zend_free_op free_op1;
3959
3960	SAVE_OPLINE();
3961
3962	do {
3963		if ((OP1_TYPE & (IS_CONST|IS_TMP_VAR)) ||
3964		    (OP1_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_VALUE)) {
3965			/* Not supposed to happen, but we'll allow it */
3966			zend_error(E_NOTICE, "Only variable references should be returned by reference");
3967
3968			retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
3969			if (!EX(return_value)) {
3970				FREE_OP1();
3971			} else {
3972				if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISREF_P(retval_ptr))) {
3973					ZVAL_COPY_VALUE(EX(return_value), retval_ptr);
3974					break;
3975				}
3976
3977				ZVAL_NEW_REF(EX(return_value), retval_ptr);
3978				if (OP1_TYPE == IS_CONST) {
3979					if (Z_REFCOUNTED_P(retval_ptr)) Z_ADDREF_P(retval_ptr);
3980				}
3981			}
3982			break;
3983		}
3984
3985		retval_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
3986
3987		if (OP1_TYPE == IS_VAR) {
3988			if (retval_ptr == &EG(uninitialized_zval) ||
3989			    (opline->extended_value == ZEND_RETURNS_FUNCTION && !Z_ISREF_P(retval_ptr))) {
3990				zend_error(E_NOTICE, "Only variable references should be returned by reference");
3991				if (EX(return_value)) {
3992					ZVAL_NEW_REF(EX(return_value), retval_ptr);
3993				} else {
3994					FREE_OP1_VAR_PTR();
3995				}
3996				break;
3997			}
3998		}
3999
4000		if (EX(return_value)) {
4001			ZVAL_MAKE_REF(retval_ptr);
4002			Z_ADDREF_P(retval_ptr);
4003			ZVAL_REF(EX(return_value), Z_REF_P(retval_ptr));
4004		}
4005
4006		FREE_OP1_VAR_PTR();
4007	} while (0);
4008
4009	ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
4010}
4011
4012ZEND_VM_HANDLER(41, ZEND_GENERATOR_CREATE, ANY, ANY)
4013{
4014	zval *return_value = EX(return_value);
4015
4016	if (EXPECTED(return_value)) {
4017		USE_OPLINE
4018		zend_generator *generator;
4019		zend_execute_data *gen_execute_data;
4020		uint32_t num_args, used_stack, call_info;
4021
4022		object_init_ex(return_value, zend_ce_generator);
4023
4024		/*
4025		 * Normally the execute_data is allocated on the VM stack (because it does
4026		 * not actually do any allocation and thus is faster). For generators
4027		 * though this behavior would be suboptimal, because the (rather large)
4028		 * structure would have to be copied back and forth every time execution is
4029		 * suspended or resumed. That's why for generators the execution context
4030		 * is allocated on heap.
4031		 */
4032		num_args = EX_NUM_ARGS();
4033		used_stack = (ZEND_CALL_FRAME_SLOT + num_args + EX(func)->op_array.last_var + EX(func)->op_array.T - MIN(EX(func)->op_array.num_args, num_args)) * sizeof(zval);
4034		gen_execute_data = (zend_execute_data*)emalloc(used_stack);
4035		memcpy(gen_execute_data, execute_data, used_stack);
4036
4037		/* Save execution context in generator object. */
4038		generator = (zend_generator *) Z_OBJ_P(EX(return_value));
4039		generator->execute_data = gen_execute_data;
4040		generator->frozen_call_stack = NULL;
4041		memset(&generator->execute_fake, 0, sizeof(zend_execute_data));
4042		ZVAL_OBJ(&generator->execute_fake.This, (zend_object *) generator);
4043
4044		gen_execute_data->opline = opline + 1;
4045		/* EX(return_value) keeps pointer to zend_object (not a real zval) */
4046		gen_execute_data->return_value = (zval*)generator;
4047		call_info = Z_TYPE_INFO(EX(This));
4048		if ((call_info & Z_TYPE_MASK) == IS_OBJECT
4049		 && !(call_info & ((ZEND_CALL_CLOSURE|ZEND_CALL_RELEASE_THIS) << ZEND_CALL_INFO_SHIFT))) {
4050			ZEND_ADD_CALL_FLAG_EX(call_info, ZEND_CALL_RELEASE_THIS);
4051			Z_ADDREF(gen_execute_data->This);
4052		}
4053		ZEND_ADD_CALL_FLAG_EX(call_info, (ZEND_CALL_TOP_FUNCTION | ZEND_CALL_ALLOCATED | ZEND_CALL_GENERATOR));
4054		Z_TYPE_INFO(gen_execute_data->This) = call_info;
4055		gen_execute_data->prev_execute_data = NULL;
4056
4057		call_info = EX_CALL_INFO();
4058		EG(current_execute_data) = EX(prev_execute_data);
4059		if (EXPECTED(!(call_info & (ZEND_CALL_TOP|ZEND_CALL_ALLOCATED)))) {
4060			EG(vm_stack_top) = (zval*)execute_data;
4061			execute_data = EX(prev_execute_data);
4062			LOAD_NEXT_OPLINE();
4063			ZEND_VM_LEAVE();
4064		} else if (EXPECTED(!(call_info & ZEND_CALL_TOP))) {
4065			zend_execute_data *old_execute_data = execute_data;
4066			execute_data = EX(prev_execute_data);
4067			zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
4068			LOAD_NEXT_OPLINE();
4069			ZEND_VM_LEAVE();
4070		} else {
4071			ZEND_VM_RETURN();
4072		}
4073	} else {
4074		ZEND_VM_DISPATCH_TO_HELPER(zend_leave_helper);
4075	}
4076}
4077
4078ZEND_VM_HANDLER(161, ZEND_GENERATOR_RETURN, CONST|TMP|VAR|CV, ANY)
4079{
4080	USE_OPLINE
4081	zval *retval;
4082	zend_free_op free_op1;
4083
4084	zend_generator *generator = zend_get_running_generator(execute_data);
4085
4086	SAVE_OPLINE();
4087	retval = GET_OP1_ZVAL_PTR(BP_VAR_R);
4088
4089	/* Copy return value into generator->retval */
4090	if ((OP1_TYPE & (IS_CONST|IS_TMP_VAR))) {
4091		ZVAL_COPY_VALUE(&generator->retval, retval);
4092		if (OP1_TYPE == IS_CONST) {
4093			if (UNEXPECTED(Z_OPT_REFCOUNTED(generator->retval))) {
4094				Z_ADDREF(generator->retval);
4095			}
4096		}
4097	} else if (OP1_TYPE == IS_CV) {
4098		ZVAL_DEREF(retval);
4099		ZVAL_COPY(&generator->retval, retval);
4100	} else /* if (OP1_TYPE == IS_VAR) */ {
4101		if (UNEXPECTED(Z_ISREF_P(retval))) {
4102			zend_refcounted *ref = Z_COUNTED_P(retval);
4103
4104			retval = Z_REFVAL_P(retval);
4105			ZVAL_COPY_VALUE(&generator->retval, retval);
4106			if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4107				efree_size(ref, sizeof(zend_reference));
4108			} else if (Z_OPT_REFCOUNTED_P(retval)) {
4109				Z_ADDREF_P(retval);
4110			}
4111		} else {
4112			ZVAL_COPY_VALUE(&generator->retval, retval);
4113		}
4114	}
4115
4116	/* Close the generator to free up resources */
4117	zend_generator_close(generator, 1);
4118
4119	/* Pass execution back to handling code */
4120	ZEND_VM_RETURN();
4121}
4122
4123ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY)
4124{
4125	USE_OPLINE
4126	zval *value;
4127	zend_free_op free_op1;
4128
4129	SAVE_OPLINE();
4130	value = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4131
4132	do {
4133		if (OP1_TYPE == IS_CONST || UNEXPECTED(Z_TYPE_P(value) != IS_OBJECT)) {
4134			if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) {
4135				value = Z_REFVAL_P(value);
4136				if (EXPECTED(Z_TYPE_P(value) == IS_OBJECT)) {
4137					break;
4138				}
4139			}
4140			if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
4141				GET_OP1_UNDEF_CV(value, BP_VAR_R);
4142				if (UNEXPECTED(EG(exception) != NULL)) {
4143					HANDLE_EXCEPTION();
4144				}
4145			}
4146			zend_throw_error(NULL, "Can only throw objects");
4147			FREE_OP1();
4148			HANDLE_EXCEPTION();
4149		}
4150	} while (0);
4151
4152	zend_exception_save();
4153	if (OP1_TYPE != IS_TMP_VAR) {
4154		if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
4155	}
4156
4157	zend_throw_exception_object(value);
4158	zend_exception_restore();
4159	FREE_OP1_IF_VAR();
4160	HANDLE_EXCEPTION();
4161}
4162
4163ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV, JMP_ADDR)
4164{
4165	USE_OPLINE
4166	zend_class_entry *ce, *catch_ce;
4167	zend_object *exception;
4168
4169	SAVE_OPLINE();
4170	/* Check whether an exception has been thrown, if not, jump over code */
4171	zend_exception_restore();
4172	if (EG(exception) == NULL) {
4173		ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
4174		ZEND_VM_CONTINUE();
4175	}
4176	catch_ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
4177	if (UNEXPECTED(catch_ce == NULL)) {
4178		catch_ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op1)), EX_CONSTANT(opline->op1) + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD);
4179
4180		CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), catch_ce);
4181	}
4182	ce = EG(exception)->ce;
4183
4184#ifdef HAVE_DTRACE
4185	if (DTRACE_EXCEPTION_CAUGHT_ENABLED()) {
4186		DTRACE_EXCEPTION_CAUGHT((char *)ce->name);
4187	}
4188#endif /* HAVE_DTRACE */
4189
4190	if (ce != catch_ce) {
4191		if (!catch_ce || !instanceof_function(ce, catch_ce)) {
4192			if (opline->result.num) {
4193				zend_throw_exception_internal(NULL);
4194				HANDLE_EXCEPTION();
4195			}
4196			ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
4197			ZEND_VM_CONTINUE();
4198		}
4199	}
4200
4201	exception = EG(exception);
4202	zval_ptr_dtor(EX_VAR(opline->op2.var));
4203	ZVAL_OBJ(EX_VAR(opline->op2.var), EG(exception));
4204	if (UNEXPECTED(EG(exception) != exception)) {
4205		GC_REFCOUNT(EG(exception))++;
4206		HANDLE_EXCEPTION();
4207	} else {
4208		EG(exception) = NULL;
4209		ZEND_VM_NEXT_OPCODE();
4210	}
4211}
4212
4213ZEND_VM_HANDLER(65, ZEND_SEND_VAL, CONST|TMP, NUM)
4214{
4215	USE_OPLINE
4216	zval *value, *arg;
4217	zend_free_op free_op1;
4218
4219	value = GET_OP1_ZVAL_PTR(BP_VAR_R);
4220	arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4221	ZVAL_COPY_VALUE(arg, value);
4222	if (OP1_TYPE == IS_CONST) {
4223		if (UNEXPECTED(Z_OPT_REFCOUNTED_P(arg))) {
4224			Z_ADDREF_P(arg);
4225		}
4226	}
4227	ZEND_VM_NEXT_OPCODE();
4228}
4229
4230ZEND_VM_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, NUM, SPEC(QUICK_ARG))
4231{
4232	USE_OPLINE
4233	zval *value, *arg;
4234	zend_free_op free_op1;
4235	uint32_t arg_num = opline->op2.num;
4236
4237	if (EXPECTED(arg_num <= MAX_ARG_FLAG_NUM)) {
4238		if (QUICK_ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4239			ZEND_VM_C_GOTO(send_val_by_ref);
4240		}
4241	} else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4242ZEND_VM_C_LABEL(send_val_by_ref):
4243		SAVE_OPLINE();
4244		zend_throw_error(NULL, "Cannot pass parameter %d by reference", arg_num);
4245		FREE_UNFETCHED_OP1();
4246		arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4247		ZVAL_UNDEF(arg);
4248		HANDLE_EXCEPTION();
4249	}
4250	value = GET_OP1_ZVAL_PTR(BP_VAR_R);
4251	arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4252	ZVAL_COPY_VALUE(arg, value);
4253	if (OP1_TYPE == IS_CONST) {
4254		if (UNEXPECTED(Z_OPT_REFCOUNTED_P(arg))) {
4255			Z_ADDREF_P(arg);
4256		}
4257	}
4258	ZEND_VM_NEXT_OPCODE();
4259}
4260
4261ZEND_VM_HANDLER(117, ZEND_SEND_VAR, VAR|CV, NUM)
4262{
4263	USE_OPLINE
4264	zval *varptr, *arg;
4265	zend_free_op free_op1;
4266
4267	varptr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4268	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) {
4269		SAVE_OPLINE();
4270		GET_OP1_UNDEF_CV(varptr, BP_VAR_R);
4271		arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4272		ZVAL_NULL(arg);
4273		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4274	}
4275
4276	arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4277
4278	if (OP1_TYPE == IS_CV) {
4279		ZVAL_OPT_DEREF(varptr);
4280		ZVAL_COPY(arg, varptr);
4281	} else /* if (OP1_TYPE == IS_VAR) */ {
4282		if (UNEXPECTED(Z_ISREF_P(varptr))) {
4283			zend_refcounted *ref = Z_COUNTED_P(varptr);
4284
4285			varptr = Z_REFVAL_P(varptr);
4286			ZVAL_COPY_VALUE(arg, varptr);
4287			if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4288				efree_size(ref, sizeof(zend_reference));
4289			} else if (Z_OPT_REFCOUNTED_P(arg)) {
4290				Z_ADDREF_P(arg);
4291			}
4292		} else {
4293			ZVAL_COPY_VALUE(arg, varptr);
4294		}
4295	}
4296
4297	ZEND_VM_NEXT_OPCODE();
4298}
4299
4300ZEND_VM_HANDLER(106, ZEND_SEND_VAR_NO_REF, VAR, NUM, SEND)
4301{
4302	USE_OPLINE
4303	zend_free_op free_op1;
4304	zval *varptr, *arg;
4305
4306	if (!(opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND)) {
4307		if (!ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4308			ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_VAR);
4309		}
4310	}
4311
4312	varptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
4313
4314	if (EXPECTED(Z_ISREF_P(varptr) ||
4315	    ((opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) ?
4316	     ((opline->extended_value & ZEND_ARG_SEND_SILENT) != 0) :
4317	     ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num
4318	    )))) {
4319		arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4320		ZVAL_COPY_VALUE(arg, varptr);
4321
4322		ZEND_VM_NEXT_OPCODE();
4323	}
4324
4325	SAVE_OPLINE();
4326	zend_error(E_NOTICE, "Only variables should be passed by reference");
4327
4328	arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4329	ZVAL_COPY_VALUE(arg, varptr);
4330
4331	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4332}
4333
4334ZEND_VM_HANDLER(67, ZEND_SEND_REF, VAR|CV, NUM)
4335{
4336	USE_OPLINE
4337	zend_free_op free_op1;
4338	zval *varptr, *arg;
4339
4340	SAVE_OPLINE();
4341	varptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
4342
4343	arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4344	if (OP1_TYPE == IS_VAR && UNEXPECTED(Z_ISERROR_P(varptr))) {
4345		ZVAL_NEW_REF(arg, &EG(uninitialized_zval));
4346		ZEND_VM_NEXT_OPCODE();
4347	}
4348
4349	if (Z_ISREF_P(varptr)) {
4350		Z_ADDREF_P(varptr);
4351		ZVAL_COPY_VALUE(arg, varptr);
4352	} else {
4353		ZVAL_NEW_REF(arg, varptr);
4354		Z_ADDREF_P(arg);
4355		ZVAL_REF(varptr, Z_REF_P(arg));
4356	}
4357
4358	FREE_OP1_VAR_PTR();
4359	ZEND_VM_NEXT_OPCODE();
4360}
4361
4362ZEND_VM_HANDLER(66, ZEND_SEND_VAR_EX, VAR|CV, NUM, SPEC(QUICK_ARG))
4363{
4364	USE_OPLINE
4365	zval *varptr, *arg;
4366	zend_free_op free_op1;
4367	uint32_t arg_num = opline->op2.num;
4368
4369	if (EXPECTED(arg_num <= MAX_ARG_FLAG_NUM)) {
4370		if (QUICK_ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4371			ZEND_VM_C_GOTO(send_var_by_ref);
4372		}
4373	} else if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4374ZEND_VM_C_LABEL(send_var_by_ref):
4375		ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF);
4376	}
4377
4378	varptr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4379	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(varptr) == IS_UNDEF)) {
4380		SAVE_OPLINE();
4381		GET_OP1_UNDEF_CV(varptr, BP_VAR_R);
4382		arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4383		ZVAL_NULL(arg);
4384		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4385	}
4386
4387	arg = ZEND_CALL_VAR(EX(call), opline->result.var);
4388
4389	if (OP1_TYPE == IS_CV) {
4390		ZVAL_OPT_DEREF(varptr);
4391		ZVAL_COPY(arg, varptr);
4392	} else /* if (OP1_TYPE == IS_VAR) */ {
4393		if (UNEXPECTED(Z_ISREF_P(varptr))) {
4394			zend_refcounted *ref = Z_COUNTED_P(varptr);
4395
4396			varptr = Z_REFVAL_P(varptr);
4397			ZVAL_COPY_VALUE(arg, varptr);
4398			if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
4399				efree_size(ref, sizeof(zend_reference));
4400			} else if (Z_OPT_REFCOUNTED_P(arg)) {
4401				Z_ADDREF_P(arg);
4402			}
4403		} else {
4404			ZVAL_COPY_VALUE(arg, varptr);
4405		}
4406	}
4407
4408	ZEND_VM_NEXT_OPCODE();
4409}
4410
4411ZEND_VM_HANDLER(165, ZEND_SEND_UNPACK, ANY, ANY)
4412{
4413	USE_OPLINE
4414	zend_free_op free_op1;
4415	zval *args;
4416	int arg_num;
4417
4418	SAVE_OPLINE();
4419	args = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4420	arg_num = ZEND_CALL_NUM_ARGS(EX(call)) + 1;
4421
4422ZEND_VM_C_LABEL(send_again):
4423	if (EXPECTED(Z_TYPE_P(args) == IS_ARRAY)) {
4424		HashTable *ht = Z_ARRVAL_P(args);
4425		zval *arg, *top;
4426		zend_string *name;
4427
4428		zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, zend_hash_num_elements(ht));
4429
4430		if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_REFCOUNT_P(args) > 1) {
4431			uint32_t i;
4432			int separate = 0;
4433
4434			/* check if any of arguments are going to be passed by reference */
4435			for (i = 0; i < zend_hash_num_elements(ht); i++) {
4436				if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + i)) {
4437					separate = 1;
4438					break;
4439				}
4440			}
4441			if (separate) {
4442				SEPARATE_ARRAY(args);
4443				ht = Z_ARRVAL_P(args);
4444			}
4445		}
4446
4447		ZEND_HASH_FOREACH_STR_KEY_VAL(ht, name, arg) {
4448			if (name) {
4449				zend_throw_error(NULL, "Cannot unpack array with string keys");
4450				FREE_OP1();
4451				HANDLE_EXCEPTION();
4452			}
4453
4454			top = ZEND_CALL_ARG(EX(call), arg_num);
4455			if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4456				if (Z_REFCOUNT_P(args) == 1) {
4457					ZVAL_MAKE_REF(arg);
4458					Z_ADDREF_P(arg);
4459					ZVAL_REF(top, Z_REF_P(arg));
4460				} else {
4461					ZVAL_DUP(top, arg);
4462				}
4463			} else if (Z_ISREF_P(arg)) {
4464				ZVAL_COPY(top, Z_REFVAL_P(arg));
4465			} else {
4466				ZVAL_COPY(top, arg);
4467			}
4468
4469			ZEND_CALL_NUM_ARGS(EX(call))++;
4470			arg_num++;
4471		} ZEND_HASH_FOREACH_END();
4472
4473	} else if (EXPECTED(Z_TYPE_P(args) == IS_OBJECT)) {
4474		zend_class_entry *ce = Z_OBJCE_P(args);
4475		zend_object_iterator *iter;
4476
4477		if (!ce || !ce->get_iterator) {
4478			zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
4479		} else {
4480
4481			iter = ce->get_iterator(ce, args, 0);
4482			if (UNEXPECTED(!iter)) {
4483				FREE_OP1();
4484				if (!EG(exception)) {
4485					zend_throw_exception_ex(
4486						NULL, 0, "Object of type %s did not create an Iterator", ZSTR_VAL(ce->name)
4487					);
4488				}
4489				HANDLE_EXCEPTION();
4490			}
4491
4492			if (iter->funcs->rewind) {
4493				iter->funcs->rewind(iter);
4494				if (UNEXPECTED(EG(exception) != NULL)) {
4495					ZEND_VM_C_GOTO(unpack_iter_dtor);
4496				}
4497			}
4498
4499			for (; iter->funcs->valid(iter) == SUCCESS; ++arg_num) {
4500				zval *arg, *top;
4501
4502				if (UNEXPECTED(EG(exception) != NULL)) {
4503					ZEND_VM_C_GOTO(unpack_iter_dtor);
4504				}
4505
4506				arg = iter->funcs->get_current_data(iter);
4507				if (UNEXPECTED(EG(exception) != NULL)) {
4508					ZEND_VM_C_GOTO(unpack_iter_dtor);
4509				}
4510
4511				if (iter->funcs->get_current_key) {
4512					zval key;
4513					iter->funcs->get_current_key(iter, &key);
4514					if (UNEXPECTED(EG(exception) != NULL)) {
4515						ZEND_VM_C_GOTO(unpack_iter_dtor);
4516					}
4517
4518					if (Z_TYPE(key) == IS_STRING) {
4519						zend_throw_error(NULL,
4520							"Cannot unpack Traversable with string keys");
4521						zend_string_release(Z_STR(key));
4522						ZEND_VM_C_GOTO(unpack_iter_dtor);
4523					}
4524
4525					zval_dtor(&key);
4526				}
4527
4528				if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4529					zend_error(
4530						E_WARNING, "Cannot pass by-reference argument %d of %s%s%s()"
4531						" by unpacking a Traversable, passing by-value instead", arg_num,
4532						EX(call)->func->common.scope ? ZSTR_VAL(EX(call)->func->common.scope->name) : "",
4533						EX(call)->func->common.scope ? "::" : "",
4534						ZSTR_VAL(EX(call)->func->common.function_name)
4535					);
4536				}
4537
4538				if (Z_ISREF_P(arg)) {
4539					ZVAL_DUP(arg, Z_REFVAL_P(arg));
4540				} else {
4541					if (Z_REFCOUNTED_P(arg)) Z_ADDREF_P(arg);
4542				}
4543
4544				zend_vm_stack_extend_call_frame(&EX(call), arg_num - 1, 1);
4545				top = ZEND_CALL_ARG(EX(call), arg_num);
4546				ZVAL_COPY_VALUE(top, arg);
4547				ZEND_CALL_NUM_ARGS(EX(call))++;
4548
4549				iter->funcs->move_forward(iter);
4550				if (UNEXPECTED(EG(exception) != NULL)) {
4551					ZEND_VM_C_GOTO(unpack_iter_dtor);
4552				}
4553			}
4554
4555ZEND_VM_C_LABEL(unpack_iter_dtor):
4556			zend_iterator_dtor(iter);
4557		}
4558	} else if (EXPECTED(Z_ISREF_P(args))) {
4559		args = Z_REFVAL_P(args);
4560		ZEND_VM_C_GOTO(send_again);
4561	} else {
4562		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(args) == IS_UNDEF)) {
4563			GET_OP1_UNDEF_CV(args, BP_VAR_R);
4564		}
4565		zend_error(E_WARNING, "Only arrays and Traversables can be unpacked");
4566	}
4567
4568	FREE_OP1();
4569	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4570}
4571
4572ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY)
4573{
4574	USE_OPLINE
4575	zend_free_op free_op1;
4576	zval *args;
4577	SAVE_OPLINE();
4578
4579	SAVE_OPLINE();
4580	args = GET_OP1_ZVAL_PTR(BP_VAR_R);
4581
4582	if (UNEXPECTED(Z_TYPE_P(args) != IS_ARRAY)) {
4583		if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(args)) {
4584			args = Z_REFVAL_P(args);
4585			if (EXPECTED(Z_TYPE_P(args) == IS_ARRAY)) {
4586				ZEND_VM_C_GOTO(send_array);
4587			}
4588		}
4589		zend_internal_type_error(EX_USES_STRICT_TYPES(), "call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
4590		if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
4591			OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
4592		}
4593		if (Z_TYPE(EX(call)->This) == IS_OBJECT) {
4594			OBJ_RELEASE(Z_OBJ(EX(call)->This));
4595		}
4596		EX(call)->func = (zend_function*)&zend_pass_function;
4597		Z_OBJ(EX(call)->This) = NULL;
4598		ZEND_SET_CALL_INFO(EX(call), 0, ZEND_CALL_INFO(EX(call)) & ~ZEND_CALL_RELEASE_THIS);
4599	} else {
4600		uint32_t arg_num;
4601		HashTable *ht;
4602		zval *arg, *param;
4603
4604ZEND_VM_C_LABEL(send_array):
4605		ht = Z_ARRVAL_P(args);
4606		zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht));
4607
4608		arg_num = 1;
4609		param = ZEND_CALL_ARG(EX(call), 1);
4610		ZEND_HASH_FOREACH_VAL(ht, arg) {
4611			if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4612				if (UNEXPECTED(!Z_ISREF_P(arg))) {
4613					if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4614
4615						zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
4616							arg_num,
4617							EX(call)->func->common.scope ? ZSTR_VAL(EX(call)->func->common.scope->name) : "",
4618							EX(call)->func->common.scope ? "::" : "",
4619							ZSTR_VAL(EX(call)->func->common.function_name));
4620
4621						if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
4622							OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
4623						}
4624						if (Z_TYPE(EX(call)->This) == IS_OBJECT) {
4625							OBJ_RELEASE(Z_OBJ(EX(call)->This));
4626						}
4627						EX(call)->func = (zend_function*)&zend_pass_function;
4628						Z_OBJ(EX(call)->This) = NULL;
4629						ZEND_SET_CALL_INFO(EX(call), 0, ZEND_CALL_INFO(EX(call)) & ~ZEND_CALL_RELEASE_THIS);
4630						break;
4631					}
4632				}
4633			} else {
4634				if (Z_ISREF_P(arg) &&
4635				    !(EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
4636					/* don't separate references for __call */
4637					arg = Z_REFVAL_P(arg);
4638				}
4639			}
4640			ZVAL_COPY(param, arg);
4641			ZEND_CALL_NUM_ARGS(EX(call))++;
4642			arg_num++;
4643			param++;
4644		} ZEND_HASH_FOREACH_END();
4645	}
4646	FREE_OP1();
4647	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4648}
4649
4650ZEND_VM_HANDLER(120, ZEND_SEND_USER, VAR|CV, NUM)
4651{
4652	USE_OPLINE
4653	zval *arg, *param;
4654	zend_free_op free_op1;
4655
4656	SAVE_OPLINE();
4657	arg = GET_OP1_ZVAL_PTR(BP_VAR_R);
4658	param = ZEND_CALL_VAR(EX(call), opline->result.var);
4659
4660	if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4661		if (UNEXPECTED(!Z_ISREF_P(arg))) {
4662			if (!ARG_MAY_BE_SENT_BY_REF(EX(call)->func, opline->op2.num)) {
4663
4664				zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
4665					opline->op2.num,
4666					EX(call)->func->common.scope ? ZSTR_VAL(EX(call)->func->common.scope->name) : "",
4667					EX(call)->func->common.scope ? "::" : "",
4668					ZSTR_VAL(EX(call)->func->common.function_name));
4669
4670				if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
4671					OBJ_RELEASE((zend_object*)EX(call)->func->common.prototype);
4672				}
4673				if (Z_TYPE(EX(call)->This) == IS_OBJECT) {
4674					OBJ_RELEASE(Z_OBJ(EX(call)->This));
4675				}
4676				ZVAL_UNDEF(param);
4677				EX(call)->func = (zend_function*)&zend_pass_function;
4678				Z_OBJ(EX(call)->This) = NULL;
4679				ZEND_SET_CALL_INFO(EX(call), 0, ZEND_CALL_INFO(EX(call)) & ~ZEND_CALL_RELEASE_THIS);
4680
4681				FREE_OP1();
4682				ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4683			}
4684		}
4685	} else {
4686		if (Z_ISREF_P(arg) &&
4687		    !(EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
4688			/* don't separate references for __call */
4689			arg = Z_REFVAL_P(arg);
4690		}
4691	}
4692	ZVAL_COPY(param, arg);
4693
4694	FREE_OP1();
4695	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4696}
4697
4698ZEND_VM_HANDLER(63, ZEND_RECV, NUM, ANY)
4699{
4700	USE_OPLINE
4701	uint32_t arg_num = opline->op1.num;
4702
4703	if (UNEXPECTED(arg_num > EX_NUM_ARGS())) {
4704		SAVE_OPLINE();
4705		zend_verify_missing_arg(execute_data, arg_num, CACHE_ADDR(opline->op2.num));
4706		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4707	} else if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
4708		zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
4709
4710		SAVE_OPLINE();
4711		if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num)) || EG(exception))) {
4712			HANDLE_EXCEPTION();
4713		}
4714	}
4715
4716	ZEND_VM_NEXT_OPCODE();
4717}
4718
4719ZEND_VM_HANDLER(64, ZEND_RECV_INIT, NUM, CONST)
4720{
4721	USE_OPLINE
4722	uint32_t arg_num;
4723	zval *param;
4724
4725	ZEND_VM_REPEATABLE_OPCODE
4726
4727	arg_num = opline->op1.num;
4728	param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
4729	if (arg_num > EX_NUM_ARGS()) {
4730		ZVAL_COPY(param, EX_CONSTANT(opline->op2));
4731		if (Z_OPT_CONSTANT_P(param)) {
4732			SAVE_OPLINE();
4733			if (UNEXPECTED(zval_update_constant_ex(param, EX(func)->op_array.scope) != SUCCESS)) {
4734				ZVAL_UNDEF(param);
4735				HANDLE_EXCEPTION();
4736			}
4737		}
4738	}
4739
4740	if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
4741		zval *default_value = EX_CONSTANT(opline->op2);
4742
4743		SAVE_OPLINE();
4744		if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, default_value, CACHE_ADDR(Z_CACHE_SLOT_P(default_value))) || EG(exception))) {
4745			HANDLE_EXCEPTION();
4746		}
4747	}
4748
4749	ZEND_VM_REPEAT_OPCODE(ZEND_RECV_INIT);
4750	ZEND_VM_NEXT_OPCODE();
4751}
4752
4753ZEND_VM_HANDLER(164, ZEND_RECV_VARIADIC, NUM, ANY)
4754{
4755	USE_OPLINE
4756	uint32_t arg_num = opline->op1.num;
4757	uint32_t arg_count = EX_NUM_ARGS();
4758	zval *params;
4759
4760	SAVE_OPLINE();
4761
4762	params = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
4763
4764	if (arg_num <= arg_count) {
4765		zval *param;
4766
4767		array_init_size(params, arg_count - arg_num + 1);
4768		zend_hash_real_init(Z_ARRVAL_P(params), 1);
4769		ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(params)) {
4770			param = EX_VAR_NUM(EX(func)->op_array.last_var + EX(func)->op_array.T);
4771			if (UNEXPECTED((EX(func)->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0)) {
4772				do {
4773					zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num));
4774					if (Z_OPT_REFCOUNTED_P(param)) Z_ADDREF_P(param);
4775					ZEND_HASH_FILL_ADD(param);
4776					param++;
4777				} while (++arg_num <= arg_count);
4778			} else {
4779				do {
4780					if (Z_OPT_REFCOUNTED_P(param)) Z_ADDREF_P(param);
4781					ZEND_HASH_FILL_ADD(param);
4782					param++;
4783				} while (++arg_num <= arg_count);
4784			}
4785		} ZEND_HASH_FILL_END();
4786	} else {
4787		array_init(params);
4788	}
4789
4790	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4791}
4792
4793ZEND_VM_HANDLER(52, ZEND_BOOL, CONST|TMPVAR|CV, ANY)
4794{
4795	USE_OPLINE
4796	zval *val;
4797	zend_free_op free_op1;
4798
4799	val = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4800	if (Z_TYPE_INFO_P(val) == IS_TRUE) {
4801		ZVAL_TRUE(EX_VAR(opline->result.var));
4802	} else if (EXPECTED(Z_TYPE_INFO_P(val) <= IS_TRUE)) {
4803		ZVAL_FALSE(EX_VAR(opline->result.var));
4804		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_INFO_P(val) == IS_UNDEF)) {
4805			SAVE_OPLINE();
4806			GET_OP1_UNDEF_CV(val, BP_VAR_R);
4807			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4808		}
4809	} else {
4810		SAVE_OPLINE();
4811		ZVAL_BOOL(EX_VAR(opline->result.var), i_zend_is_true(val));
4812		FREE_OP1();
4813		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4814	}
4815	ZEND_VM_NEXT_OPCODE();
4816}
4817
4818ZEND_VM_HANDLER(48, ZEND_CASE, CONST|TMPVAR|CV, CONST|TMPVAR|CV)
4819{
4820	USE_OPLINE
4821	zend_free_op free_op1, free_op2;
4822	zval *op1, *op2, *result;
4823
4824	op1 = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
4825	op2 = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
4826	do {
4827		int result;
4828
4829		if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
4830			if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4831				result = (Z_LVAL_P(op1) == Z_LVAL_P(op2));
4832			} else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4833				result = ((double)Z_LVAL_P(op1) == Z_DVAL_P(op2));
4834			} else {
4835				break;
4836			}
4837		} else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
4838			if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
4839				result = (Z_DVAL_P(op1) == Z_DVAL_P(op2));
4840			} else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
4841				result = (Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2)));
4842			} else {
4843				break;
4844			}
4845		} else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
4846			if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
4847				if (Z_STR_P(op1) == Z_STR_P(op2)) {
4848					result = 1;
4849				} else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
4850					if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
4851						result = 0;
4852					} else {
4853						result = (memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0);
4854					}
4855				} else {
4856					result = (zendi_smart_strcmp(Z_STR_P(op1), Z_STR_P(op2)) == 0);
4857				}
4858				FREE_OP2();
4859			} else {
4860				break;
4861			}
4862		} else {
4863			break;
4864		}
4865		ZEND_VM_SMART_BRANCH(result, 0);
4866		ZVAL_BOOL(EX_VAR(opline->result.var), result);
4867		ZEND_VM_NEXT_OPCODE();
4868	} while (0);
4869
4870	SAVE_OPLINE();
4871	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op1) == IS_UNDEF)) {
4872		op1 = GET_OP1_UNDEF_CV(op1, BP_VAR_R);
4873	} else if ((OP1_TYPE & IS_VAR) && UNEXPECTED(Z_ISREF_P(op1))) {
4874		/* Don't keep lock on reference, lock the value instead */
4875		if (UNEXPECTED(Z_REFCOUNT_P(op1) == 1)) {
4876			ZVAL_UNREF(op1);
4877		} else {
4878			Z_DELREF_P(op1);
4879			ZVAL_COPY(op1, Z_REFVAL_P(op1));
4880		}
4881	}
4882	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(op2) == IS_UNDEF)) {
4883		op2 = GET_OP2_UNDEF_CV(op2, BP_VAR_R);
4884	}
4885	result = EX_VAR(opline->result.var);
4886	compare_function(result, op1, op2);
4887	ZVAL_BOOL(result, Z_LVAL_P(result) == 0);
4888	FREE_OP2();
4889	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4890}
4891
4892ZEND_VM_HANDLER(68, ZEND_NEW, UNUSED|CLASS_FETCH|CONST|VAR, ANY, NUM)
4893{
4894	USE_OPLINE
4895	zval *result;
4896	zend_function *constructor;
4897	zend_class_entry *ce;
4898	zend_execute_data *call;
4899
4900	SAVE_OPLINE();
4901	if (OP1_TYPE == IS_CONST) {
4902		ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
4903		if (UNEXPECTED(ce == NULL)) {
4904			ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op1)), EX_CONSTANT(opline->op1) + 1, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
4905			if (UNEXPECTED(ce == NULL)) {
4906				ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4907			}
4908			CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce);
4909		}
4910	} else if (OP1_TYPE == IS_UNUSED) {
4911		ce = zend_fetch_class(NULL, opline->op1.num);
4912		if (UNEXPECTED(ce == NULL)) {
4913			ZEND_ASSERT(EG(exception));
4914			HANDLE_EXCEPTION();
4915		}
4916	} else {
4917		ce = Z_CE_P(EX_VAR(opline->op1.var));
4918	}
4919
4920	result = EX_VAR(opline->result.var);
4921	if (UNEXPECTED(object_init_ex(result, ce) != SUCCESS)) {
4922		HANDLE_EXCEPTION();
4923	}
4924
4925	constructor = Z_OBJ_HT_P(result)->get_constructor(Z_OBJ_P(result));
4926	if (constructor == NULL) {
4927		/* If there are no arguments, skip over the DO_FCALL opcode. We check if the next
4928		 * opcode is DO_FCALL in case EXT instructions are used. */
4929		if (EXPECTED(opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL)) {
4930			ZEND_VM_NEXT_OPCODE_EX(1, 2);
4931		}
4932
4933		/* Perform a dummy function call */
4934		call = zend_vm_stack_push_call_frame(
4935			ZEND_CALL_FUNCTION, (zend_function *) &zend_pass_function,
4936			opline->extended_value, NULL, NULL);
4937	} else {
4938		if (EXPECTED(constructor->type == ZEND_USER_FUNCTION) && UNEXPECTED(!constructor->op_array.run_time_cache)) {
4939			init_func_run_time_cache(&constructor->op_array);
4940		}
4941		/* We are not handling overloaded classes right now */
4942		call = zend_vm_stack_push_call_frame(
4943			ZEND_CALL_FUNCTION | ZEND_CALL_RELEASE_THIS | ZEND_CALL_CTOR,
4944			constructor,
4945			opline->extended_value,
4946			ce,
4947			Z_OBJ_P(result));
4948		Z_ADDREF_P(result);
4949	}
4950
4951	call->prev_execute_data = EX(call);
4952	EX(call) = call;
4953	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
4954}
4955
4956ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMPVAR|UNUSED|THIS|CV, ANY)
4957{
4958	USE_OPLINE
4959	zend_free_op free_op1;
4960	zval *obj;
4961	zend_class_entry *ce, *scope;
4962	zend_function *clone;
4963	zend_object_clone_obj_t clone_call;
4964
4965	SAVE_OPLINE();
4966	obj = GET_OP1_OBJ_ZVAL_PTR_UNDEF(BP_VAR_R);
4967
4968	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) == IS_UNDEF)) {
4969		zend_throw_error(NULL, "Using $this when not in object context");
4970		HANDLE_EXCEPTION();
4971	}
4972
4973	do {
4974		if (OP1_TYPE == IS_CONST ||
4975		    (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(obj) != IS_OBJECT))) {
4976		    if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(obj)) {
4977		    	obj = Z_REFVAL_P(obj);
4978		    	if (EXPECTED(Z_TYPE_P(obj) == IS_OBJECT)) {
4979		    		break;
4980				}
4981			}
4982			if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(obj) == IS_UNDEF)) {
4983				GET_OP1_UNDEF_CV(obj, BP_VAR_R);
4984				if (UNEXPECTED(EG(exception) != NULL)) {
4985					HANDLE_EXCEPTION();
4986				}
4987			}
4988			zend_throw_error(NULL, "__clone method called on non-object");
4989			FREE_OP1();
4990			HANDLE_EXCEPTION();
4991		}
4992	} while (0);
4993
4994	ce = Z_OBJCE_P(obj);
4995	clone = ce->clone;
4996	clone_call = Z_OBJ_HT_P(obj)->clone_obj;
4997	if (UNEXPECTED(clone_call == NULL)) {
4998		zend_throw_error(NULL, "Trying to clone an uncloneable object of class %s", ZSTR_VAL(ce->name));
4999		FREE_OP1();
5000		HANDLE_EXCEPTION();
5001	}
5002
5003	if (clone) {
5004		if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) {
5005			/* Ensure that if we're calling a private function, we're allowed to do so.
5006			 */
5007			scope = EX(func)->op_array.scope;
5008			if (UNEXPECTED(ce != scope)) {
5009				zend_throw_error(NULL, "Call to private %s::__clone() from context '%s'", ZSTR_VAL(ce->name), scope ? ZSTR_VAL(scope->name) : "");
5010				FREE_OP1();
5011				HANDLE_EXCEPTION();
5012			}
5013		} else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
5014			/* Ensure that if we're calling a protected function, we're allowed to do so.
5015			 */
5016			scope = EX(func)->op_array.scope;
5017			if (UNEXPECTED(!zend_check_protected(zend_get_function_root_class(clone), scope))) {
5018				zend_throw_error(NULL, "Call to protected %s::__clone() from context '%s'", ZSTR_VAL(ce->name), scope ? ZSTR_VAL(scope->name) : "");
5019				FREE_OP1();
5020				HANDLE_EXCEPTION();
5021			}
5022		}
5023	}
5024
5025	ZVAL_OBJ(EX_VAR(opline->result.var), clone_call(obj));
5026	if (UNEXPECTED(EG(exception) != NULL)) {
5027		OBJ_RELEASE(Z_OBJ_P(EX_VAR(opline->result.var)));
5028	}
5029
5030	FREE_OP1();
5031	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5032}
5033
5034ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, UNUSED, CONST, CONST_FETCH)
5035{
5036	USE_OPLINE
5037	zend_constant *c;
5038
5039	SAVE_OPLINE();
5040
5041	if (EXPECTED(CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2))))) {
5042		c = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
5043	} else if ((c = zend_quick_get_constant(EX_CONSTANT(opline->op2) + 1, opline->extended_value)) == NULL) {
5044		if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) {
5045			char *actual = (char *)zend_memrchr(Z_STRVAL_P(EX_CONSTANT(opline->op2)), '\\', Z_STRLEN_P(EX_CONSTANT(opline->op2)));
5046			if (!actual) {
5047				ZVAL_STR_COPY(EX_VAR(opline->result.var), Z_STR_P(EX_CONSTANT(opline->op2)));
5048			} else {
5049				actual++;
5050				ZVAL_STRINGL(EX_VAR(opline->result.var),
5051						actual, Z_STRLEN_P(EX_CONSTANT(opline->op2)) - (actual - Z_STRVAL_P(EX_CONSTANT(opline->op2))));
5052			}
5053			/* non-qualified constant - allow text substitution */
5054			zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",
5055					Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var)));
5056			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5057		} else {
5058			zend_throw_error(NULL, "Undefined constant '%s'", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
5059			HANDLE_EXCEPTION();
5060		}
5061	} else {
5062		CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), c);
5063	}
5064
5065#ifdef ZTS
5066	if (c->flags & CONST_PERSISTENT) {
5067		ZVAL_DUP(EX_VAR(opline->result.var), &c->value);
5068	} else {
5069		ZVAL_COPY(EX_VAR(opline->result.var), &c->value);
5070	}
5071#else
5072	ZVAL_COPY(EX_VAR(opline->result.var), &c->value);
5073#endif
5074
5075	ZEND_VM_NEXT_OPCODE();
5076}
5077
5078ZEND_VM_HANDLER(181, ZEND_FETCH_CLASS_CONSTANT, VAR|CONST|UNUSED|CLASS_FETCH, CONST)
5079{
5080	zend_class_entry *ce, *scope;
5081	zend_class_constant *c;
5082	zval *value;
5083	USE_OPLINE
5084
5085	SAVE_OPLINE();
5086
5087	do {
5088		if (OP1_TYPE == IS_CONST) {
5089			if (EXPECTED(CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2))))) {
5090				value = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
5091#ifdef ZTS
5092				ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
5093#endif
5094				break;
5095			} else if (EXPECTED(CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1))))) {
5096				ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)));
5097			} else {
5098				ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op1)), EX_CONSTANT(opline->op1) + 1, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
5099				if (UNEXPECTED(ce == NULL)) {
5100					if (EXPECTED(!EG(exception))) {
5101						zend_throw_error(NULL, "Class '%s' not found", Z_STRVAL_P(EX_CONSTANT(opline->op1)));
5102					}
5103					HANDLE_EXCEPTION();
5104				}
5105				CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce);
5106			}
5107		} else {
5108			if (OP1_TYPE == IS_UNUSED) {
5109				ce = zend_fetch_class(NULL, opline->op1.num);
5110				if (UNEXPECTED(ce == NULL)) {
5111					ZEND_ASSERT(EG(exception));
5112					HANDLE_EXCEPTION();
5113				}
5114			} else {
5115				ce = Z_CE_P(EX_VAR(opline->op1.var));
5116			}
5117			if ((value = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce)) != NULL) {
5118				break;
5119			}
5120		}
5121
5122		if (EXPECTED((c = zend_hash_find_ptr(&ce->constants_table, Z_STR_P(EX_CONSTANT(opline->op2)))) != NULL)) {
5123			scope = EX(func)->op_array.scope;
5124			if (!zend_verify_const_access(c, scope)) {
5125				zend_throw_error(NULL, "Cannot access %s const %s::%s", zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(ce->name), Z_STRVAL_P(EX_CONSTANT(opline->op2)));
5126				HANDLE_EXCEPTION();
5127			}
5128			value = &c->value;
5129			if (Z_CONSTANT_P(value)) {
5130				zval_update_constant_ex(value, ce);
5131				if (UNEXPECTED(EG(exception) != NULL)) {
5132					HANDLE_EXCEPTION();
5133				}
5134			}
5135			if (OP1_TYPE == IS_CONST) {
5136				CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), value);
5137			} else {
5138				CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce, value);
5139			}
5140		} else {
5141			zend_throw_error(NULL, "Undefined class constant '%s'", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
5142			HANDLE_EXCEPTION();
5143		}
5144	} while (0);
5145
5146#ifdef ZTS
5147	if (ce->type == ZEND_INTERNAL_CLASS) {
5148		ZVAL_DUP(EX_VAR(opline->result.var), value);
5149	} else {
5150		ZVAL_COPY(EX_VAR(opline->result.var), value);
5151	}
5152#else
5153	ZVAL_COPY(EX_VAR(opline->result.var), value);
5154#endif
5155
5156	ZEND_VM_NEXT_OPCODE();
5157}
5158
5159ZEND_VM_HANDLER(72, ZEND_ADD_ARRAY_ELEMENT, CONST|TMP|VAR|CV, CONST|TMPVAR|UNUSED|NEXT|CV, REF)
5160{
5161	USE_OPLINE
5162	zend_free_op free_op1;
5163	zval *expr_ptr, new_expr;
5164
5165	SAVE_OPLINE();
5166	if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) &&
5167	    UNEXPECTED(opline->extended_value & ZEND_ARRAY_ELEMENT_REF)) {
5168		expr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W);
5169		ZVAL_MAKE_REF(expr_ptr);
5170		Z_ADDREF_P(expr_ptr);
5171		FREE_OP1_VAR_PTR();
5172	} else {
5173		expr_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
5174		if (OP1_TYPE == IS_TMP_VAR) {
5175			/* pass */
5176		} else if (OP1_TYPE == IS_CONST) {
5177			if (Z_REFCOUNTED_P(expr_ptr)) {
5178				Z_ADDREF_P(expr_ptr);
5179			}
5180		} else if (OP1_TYPE == IS_CV) {
5181			ZVAL_DEREF(expr_ptr);
5182			if (Z_REFCOUNTED_P(expr_ptr)) {
5183				Z_ADDREF_P(expr_ptr);
5184			}
5185		} else /* if (OP1_TYPE == IS_VAR) */ {
5186			if (UNEXPECTED(Z_ISREF_P(expr_ptr))) {
5187				zend_refcounted *ref = Z_COUNTED_P(expr_ptr);
5188
5189				expr_ptr = Z_REFVAL_P(expr_ptr);
5190				if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
5191					ZVAL_COPY_VALUE(&new_expr, expr_ptr);
5192					expr_ptr = &new_expr;
5193					efree_size(ref, sizeof(zend_reference));
5194				} else if (Z_OPT_REFCOUNTED_P(expr_ptr)) {
5195					Z_ADDREF_P(expr_ptr);
5196				}
5197			}
5198		}
5199	}
5200
5201	if (OP2_TYPE != IS_UNUSED) {
5202		zend_free_op free_op2;
5203		zval *offset = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
5204		zend_string *str;
5205		zend_ulong hval;
5206
5207ZEND_VM_C_LABEL(add_again):
5208		if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
5209			str = Z_STR_P(offset);
5210			if (OP2_TYPE != IS_CONST) {
5211				if (ZEND_HANDLE_NUMERIC(str, hval)) {
5212					ZEND_VM_C_GOTO(num_index);
5213				}
5214			}
5215ZEND_VM_C_LABEL(str_index):
5216			zend_hash_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), str, expr_ptr);
5217		} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
5218			hval = Z_LVAL_P(offset);
5219ZEND_VM_C_LABEL(num_index):
5220			zend_hash_index_update(Z_ARRVAL_P(EX_VAR(opline->result.var)), hval, expr_ptr);
5221		} else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
5222			offset = Z_REFVAL_P(offset);
5223			ZEND_VM_C_GOTO(add_again);
5224		} else if (Z_TYPE_P(offset) == IS_NULL) {
5225			str = ZSTR_EMPTY_ALLOC();
5226			ZEND_VM_C_GOTO(str_index);
5227		} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
5228			hval = zend_dval_to_lval(Z_DVAL_P(offset));
5229			ZEND_VM_C_GOTO(num_index);
5230		} else if (Z_TYPE_P(offset) == IS_FALSE) {
5231			hval = 0;
5232			ZEND_VM_C_GOTO(num_index);
5233		} else if (Z_TYPE_P(offset) == IS_TRUE) {
5234			hval = 1;
5235			ZEND_VM_C_GOTO(num_index);
5236		} else if (OP2_TYPE == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
5237			GET_OP2_UNDEF_CV(offset, BP_VAR_R);
5238			str = ZSTR_EMPTY_ALLOC();
5239			ZEND_VM_C_GOTO(str_index);
5240		} else {
5241			zend_error(E_WARNING, "Illegal offset type");
5242			zval_ptr_dtor(expr_ptr);
5243		}
5244		FREE_OP2();
5245	} else {
5246		zend_hash_next_index_insert(Z_ARRVAL_P(EX_VAR(opline->result.var)), expr_ptr);
5247	}
5248	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5249}
5250
5251ZEND_VM_HANDLER(71, ZEND_INIT_ARRAY, CONST|TMP|VAR|UNUSED|CV, CONST|TMPVAR|UNUSED|NEXT|CV, ARRAY_INIT|REF)
5252{
5253	zval *array;
5254	uint32_t size;
5255	USE_OPLINE
5256
5257	array = EX_VAR(opline->result.var);
5258	if (OP1_TYPE != IS_UNUSED) {
5259		size = opline->extended_value >> ZEND_ARRAY_SIZE_SHIFT;
5260	} else {
5261		size = 0;
5262	}
5263	ZVAL_NEW_ARR(array);
5264	zend_hash_init(Z_ARRVAL_P(array), size, NULL, ZVAL_PTR_DTOR, 0);
5265
5266	if (OP1_TYPE != IS_UNUSED) {
5267		/* Explicitly initialize array as not-packed if flag is set */
5268		if (opline->extended_value & ZEND_ARRAY_NOT_PACKED) {
5269			zend_hash_real_init(Z_ARRVAL_P(array), 0);
5270		}
5271	}
5272
5273	if (OP1_TYPE == IS_UNUSED) {
5274		ZEND_VM_NEXT_OPCODE();
5275#if !defined(ZEND_VM_SPEC) || (OP1_TYPE != IS_UNUSED)
5276	} else {
5277		ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ADD_ARRAY_ELEMENT);
5278#endif
5279	}
5280}
5281
5282ZEND_VM_HANDLER(21, ZEND_CAST, CONST|TMP|VAR|CV, ANY, TYPE)
5283{
5284	USE_OPLINE
5285	zend_free_op free_op1;
5286	zval *expr;
5287	zval *result = EX_VAR(opline->result.var);
5288
5289	SAVE_OPLINE();
5290	expr = GET_OP1_ZVAL_PTR(BP_VAR_R);
5291
5292	switch (opline->extended_value) {
5293		case IS_NULL:
5294			/* This code is taken from convert_to_null. However, it does not seems very useful,
5295			 * because a conversion to null always results in the same value. This could only
5296			 * be relevant if a cast_object handler for IS_NULL has some kind of side-effect. */
5297#if 0
5298			if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
5299				ZVAL_DEREF(expr);
5300			}
5301			if (Z_TYPE_P(expr) == IS_OBJECT && Z_OBJ_HT_P(expr)->cast_object) {
5302				if (Z_OBJ_HT_P(expr)->cast_object(expr, result, IS_NULL) == SUCCESS) {
5303					break;
5304				}
5305			}
5306#endif
5307
5308			ZVAL_NULL(result);
5309			break;
5310		case _IS_BOOL:
5311			ZVAL_BOOL(result, zend_is_true(expr));
5312			break;
5313		case IS_LONG:
5314			ZVAL_LONG(result, zval_get_long(expr));
5315			break;
5316		case IS_DOUBLE:
5317			ZVAL_DOUBLE(result, zval_get_double(expr));
5318			break;
5319		case IS_STRING:
5320			ZVAL_STR(result, zval_get_string(expr));
5321			break;
5322		default:
5323			if (OP1_TYPE & (IS_VAR|IS_CV)) {
5324				ZVAL_DEREF(expr);
5325			}
5326			/* If value is already of correct type, return it directly */
5327			if (Z_TYPE_P(expr) == opline->extended_value) {
5328				ZVAL_COPY_VALUE(result, expr);
5329				if (OP1_TYPE == IS_CONST) {
5330					if (UNEXPECTED(Z_OPT_REFCOUNTED_P(result))) Z_ADDREF_P(result);
5331				} else if (OP1_TYPE != IS_TMP_VAR) {
5332					if (Z_OPT_REFCOUNTED_P(result)) Z_ADDREF_P(result);
5333				}
5334
5335				FREE_OP1_IF_VAR();
5336				ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5337			}
5338
5339			if (opline->extended_value == IS_ARRAY) {
5340				if (Z_TYPE_P(expr) != IS_OBJECT) {
5341					ZVAL_NEW_ARR(result);
5342					zend_hash_init(Z_ARRVAL_P(result), 8, NULL, ZVAL_PTR_DTOR, 0);
5343					if (Z_TYPE_P(expr) != IS_NULL) {
5344						expr = zend_hash_index_add_new(Z_ARRVAL_P(result), 0, expr);
5345						if (OP1_TYPE == IS_CONST) {
5346							if (UNEXPECTED(Z_OPT_REFCOUNTED_P(expr))) Z_ADDREF_P(expr);
5347						} else {
5348							if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
5349						}
5350					}
5351				} else {
5352					ZVAL_COPY_VALUE(result, expr);
5353					Z_ADDREF_P(result);
5354					convert_to_array(result);
5355				}
5356			} else {
5357				if (Z_TYPE_P(expr) != IS_ARRAY) {
5358					object_init(result);
5359					if (Z_TYPE_P(expr) != IS_NULL) {
5360						expr = zend_hash_add_new(Z_OBJPROP_P(result), CG(known_strings)[ZEND_STR_SCALAR], expr);
5361						if (OP1_TYPE == IS_CONST) {
5362							if (UNEXPECTED(Z_OPT_REFCOUNTED_P(expr))) Z_ADDREF_P(expr);
5363						} else {
5364							if (Z_OPT_REFCOUNTED_P(expr)) Z_ADDREF_P(expr);
5365						}
5366					}
5367				} else {
5368					ZVAL_COPY(result, expr);
5369					convert_to_object(result);
5370				}
5371			}
5372	}
5373
5374	FREE_OP1();
5375	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5376}
5377
5378ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMPVAR|CV, ANY, EVAL)
5379{
5380	USE_OPLINE
5381	zend_op_array *new_op_array;
5382	zend_free_op free_op1;
5383	zval *inc_filename;
5384
5385	SAVE_OPLINE();
5386	inc_filename = GET_OP1_ZVAL_PTR(BP_VAR_R);
5387	new_op_array = zend_include_or_eval(inc_filename, opline->extended_value);
5388	FREE_OP1();
5389	if (UNEXPECTED(EG(exception) != NULL)) {
5390		HANDLE_EXCEPTION();
5391	} else if (new_op_array == ZEND_FAKE_OP_ARRAY) {
5392		if (RETURN_VALUE_USED(opline)) {
5393			ZVAL_TRUE(EX_VAR(opline->result.var));
5394		}
5395	} else if (EXPECTED(new_op_array != NULL)) {
5396		zval *return_value = NULL;
5397		zend_execute_data *call;
5398
5399		if (RETURN_VALUE_USED(opline)) {
5400			return_value = EX_VAR(opline->result.var);
5401		}
5402
5403		new_op_array->scope = EX(func)->op_array.scope;
5404
5405		call = zend_vm_stack_push_call_frame(ZEND_CALL_NESTED_CODE | ZEND_CALL_HAS_SYMBOL_TABLE,
5406			(zend_function*)new_op_array, 0,
5407			Z_TYPE(EX(This)) != IS_OBJECT ? Z_CE(EX(This)) : NULL,
5408			Z_TYPE(EX(This)) == IS_OBJECT ? Z_OBJ(EX(This)) : NULL);
5409
5410		if (EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE) {
5411			call->symbol_table = EX(symbol_table);
5412		} else {
5413			call->symbol_table = zend_rebuild_symbol_table();
5414		}
5415
5416		call->prev_execute_data = execute_data;
5417		i_init_code_execute_data(call, new_op_array, return_value);
5418		if (EXPECTED(zend_execute_ex == execute_ex)) {
5419			ZEND_VM_ENTER();
5420		} else {
5421			ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
5422			zend_execute_ex(call);
5423			zend_vm_stack_free_call_frame(call);
5424		}
5425
5426		destroy_op_array(new_op_array);
5427		efree_size(new_op_array, sizeof(zend_op_array));
5428		if (UNEXPECTED(EG(exception) != NULL)) {
5429			zend_throw_exception_internal(NULL);
5430			HANDLE_EXCEPTION();
5431		}
5432	} else if (RETURN_VALUE_USED(opline)) {
5433		ZVAL_FALSE(EX_VAR(opline->result.var));
5434	}
5435	ZEND_VM_SET_OPCODE(opline + 1);
5436	ZEND_VM_CONTINUE();
5437}
5438
5439ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH|ISSET)
5440{
5441	USE_OPLINE
5442	zval tmp, *varname;
5443	HashTable *target_symbol_table;
5444	zend_free_op free_op1;
5445
5446	SAVE_OPLINE();
5447	if (OP1_TYPE == IS_CV &&
5448	    (opline->extended_value & ZEND_QUICK_SET)) {
5449		zval *var = EX_VAR(opline->op1.var);
5450
5451		if (Z_REFCOUNTED_P(var)) {
5452			zend_refcounted *garbage = Z_COUNTED_P(var);
5453
5454			if (!--GC_REFCOUNT(garbage)) {
5455				ZVAL_UNDEF(var);
5456				zval_dtor_func(garbage);
5457			} else {
5458				zval *z = var;
5459				ZVAL_DEREF(z);
5460				if (Z_COLLECTABLE_P(z) && UNEXPECTED(!Z_GC_INFO_P(z))) {
5461					ZVAL_UNDEF(var);
5462					gc_possible_root(Z_COUNTED_P(z));
5463				} else {
5464					ZVAL_UNDEF(var);
5465				}
5466			}
5467		} else {
5468			ZVAL_UNDEF(var);
5469		}
5470		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5471	}
5472
5473	varname = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
5474
5475	ZVAL_UNDEF(&tmp);
5476	if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
5477		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
5478			varname = GET_OP1_UNDEF_CV(varname, BP_VAR_R);
5479		}
5480		ZVAL_STR(&tmp, zval_get_string(varname));
5481		varname = &tmp;
5482	}
5483
5484	target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK);
5485	zend_hash_del_ind(target_symbol_table, Z_STR_P(varname));
5486
5487	if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
5488		zend_string_release(Z_STR(tmp));
5489	}
5490	FREE_OP1();
5491	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5492}
5493
5494ZEND_VM_HANDLER(179, ZEND_UNSET_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
5495{
5496	USE_OPLINE
5497	zval tmp, *varname;
5498	zend_class_entry *ce;
5499	zend_free_op free_op1;
5500
5501	SAVE_OPLINE();
5502
5503	varname = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
5504
5505	ZVAL_UNDEF(&tmp);
5506	if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
5507		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
5508			varname = GET_OP1_UNDEF_CV(varname, BP_VAR_R);
5509		}
5510		ZVAL_STR(&tmp, zval_get_string(varname));
5511		varname = &tmp;
5512	}
5513
5514	if (OP2_TYPE == IS_CONST) {
5515		ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
5516		if (UNEXPECTED(ce == NULL)) {
5517			ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op2)), EX_CONSTANT(opline->op2) + 1, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
5518			if (UNEXPECTED(ce == NULL)) {
5519				if (EXPECTED(!EG(exception))) {
5520					zend_throw_error(NULL, "Class '%s' not found", Z_STRVAL_P(EX_CONSTANT(opline->op2)));
5521				}
5522				if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
5523					zend_string_release(Z_STR(tmp));
5524				}
5525				FREE_OP1();
5526				HANDLE_EXCEPTION();
5527			}
5528			CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce);
5529		}
5530	} else if (OP2_TYPE == IS_UNUSED) {
5531		ce = zend_fetch_class(NULL, opline->op2.num);
5532		if (UNEXPECTED(ce == NULL)) {
5533			ZEND_ASSERT(EG(exception));
5534			if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
5535				zend_string_release(Z_STR(tmp));
5536			}
5537			FREE_OP1();
5538			HANDLE_EXCEPTION();
5539		}
5540	} else {
5541		ce = Z_CE_P(EX_VAR(opline->op2.var));
5542	}
5543	zend_std_unset_static_property(ce, Z_STR_P(varname));
5544
5545	if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
5546		zend_string_release(Z_STR(tmp));
5547	}
5548	FREE_OP1();
5549	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5550}
5551
5552ZEND_VM_HANDLER(75, ZEND_UNSET_DIM, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
5553{
5554	USE_OPLINE
5555	zend_free_op free_op1, free_op2;
5556	zval *container;
5557	zval *offset;
5558	zend_ulong hval;
5559	zend_string *key;
5560
5561	SAVE_OPLINE();
5562	container = GET_OP1_OBJ_ZVAL_PTR_PTR_UNDEF(BP_VAR_UNSET);
5563	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
5564		zend_throw_error(NULL, "Using $this when not in object context");
5565		FREE_UNFETCHED_OP2();
5566		HANDLE_EXCEPTION();
5567	}
5568	offset = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
5569
5570	do {
5571		if (OP1_TYPE != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
5572			HashTable *ht;
5573
5574ZEND_VM_C_LABEL(unset_dim_array):
5575			SEPARATE_ARRAY(container);
5576			ht = Z_ARRVAL_P(container);
5577ZEND_VM_C_LABEL(offset_again):
5578			if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
5579				key = Z_STR_P(offset);
5580				if (OP2_TYPE != IS_CONST) {
5581					if (ZEND_HANDLE_NUMERIC(key, hval)) {
5582						ZEND_VM_C_GOTO(num_index_dim);
5583					}
5584				}
5585ZEND_VM_C_LABEL(str_index_dim):
5586				if (ht == &EG(symbol_table)) {
5587					zend_delete_global_variable(key);
5588				} else {
5589					zend_hash_del(ht, key);
5590				}
5591			} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
5592				hval = Z_LVAL_P(offset);
5593ZEND_VM_C_LABEL(num_index_dim):
5594				zend_hash_index_del(ht, hval);
5595			} else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_TYPE_P(offset) == IS_REFERENCE)) {
5596				offset = Z_REFVAL_P(offset);
5597				ZEND_VM_C_GOTO(offset_again);
5598			} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
5599				hval = zend_dval_to_lval(Z_DVAL_P(offset));
5600				ZEND_VM_C_GOTO(num_index_dim);
5601			} else if (Z_TYPE_P(offset) == IS_NULL) {
5602				key = ZSTR_EMPTY_ALLOC();
5603				ZEND_VM_C_GOTO(str_index_dim);
5604			} else if (Z_TYPE_P(offset) == IS_FALSE) {
5605				hval = 0;
5606				ZEND_VM_C_GOTO(num_index_dim);
5607			} else if (Z_TYPE_P(offset) == IS_TRUE) {
5608				hval = 1;
5609				ZEND_VM_C_GOTO(num_index_dim);
5610			} else if (Z_TYPE_P(offset) == IS_RESOURCE) {
5611				hval = Z_RES_HANDLE_P(offset);
5612				ZEND_VM_C_GOTO(num_index_dim);
5613			} else if (OP2_TYPE == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
5614				GET_OP2_UNDEF_CV(offset, BP_VAR_R);
5615				key = ZSTR_EMPTY_ALLOC();
5616				ZEND_VM_C_GOTO(str_index_dim);
5617			} else {
5618				zend_error(E_WARNING, "Illegal offset type in unset");
5619			}
5620			break;
5621		} else if (OP1_TYPE != IS_UNUSED && Z_ISREF_P(container)) {
5622			container = Z_REFVAL_P(container);
5623			if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
5624				ZEND_VM_C_GOTO(unset_dim_array);
5625			}
5626		}
5627		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
5628			container = GET_OP1_UNDEF_CV(container, BP_VAR_R);
5629		}
5630		if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
5631			offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
5632		}
5633		if (OP1_TYPE == IS_UNUSED || EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
5634			if (UNEXPECTED(Z_OBJ_HT_P(container)->unset_dimension == NULL)) {
5635				zend_throw_error(NULL, "Cannot use object as array");
5636			} else {
5637				Z_OBJ_HT_P(container)->unset_dimension(container, offset);
5638			}
5639		} else if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_STRING)) {
5640			zend_throw_error(NULL, "Cannot unset string offsets");
5641		}
5642	} while (0);
5643
5644	FREE_OP2();
5645	FREE_OP1_VAR_PTR();
5646	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5647}
5648
5649ZEND_VM_HANDLER(76, ZEND_UNSET_OBJ, VAR|UNUSED|THIS|CV, CONST|TMPVAR|CV)
5650{
5651	USE_OPLINE
5652	zend_free_op free_op1, free_op2;
5653	zval *container;
5654	zval *offset;
5655
5656	SAVE_OPLINE();
5657	container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_UNSET);
5658	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
5659		zend_throw_error(NULL, "Using $this when not in object context");
5660		FREE_UNFETCHED_OP2();
5661		HANDLE_EXCEPTION();
5662	}
5663	offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
5664
5665	do {
5666		if (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
5667			if (Z_ISREF_P(container)) {
5668				container = Z_REFVAL_P(container);
5669				if (Z_TYPE_P(container) != IS_OBJECT) {
5670					break;
5671				}
5672			} else {
5673				break;
5674			}
5675		}
5676		if (Z_OBJ_HT_P(container)->unset_property) {
5677			Z_OBJ_HT_P(container)->unset_property(container, offset, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(offset)) : NULL));
5678		} else {
5679			zend_error(E_NOTICE, "Trying to unset property of non-object");
5680		}
5681	} while (0);
5682
5683	FREE_OP2();
5684	FREE_OP1_VAR_PTR();
5685	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5686}
5687
5688ZEND_VM_HANDLER(77, ZEND_FE_RESET_R, CONST|TMP|VAR|CV, JMP_ADDR)
5689{
5690	USE_OPLINE
5691	zend_free_op free_op1;
5692	zval *array_ptr, *result;
5693	HashTable *fe_ht;
5694
5695	SAVE_OPLINE();
5696
5697	array_ptr = GET_OP1_ZVAL_PTR_DEREF(BP_VAR_R);
5698	if (EXPECTED(Z_TYPE_P(array_ptr) == IS_ARRAY)) {
5699		result = EX_VAR(opline->result.var);
5700		ZVAL_COPY_VALUE(result, array_ptr);
5701		if (OP1_TYPE != IS_TMP_VAR && Z_OPT_REFCOUNTED_P(result)) {
5702			Z_ADDREF_P(array_ptr);
5703		}
5704		Z_FE_POS_P(result) = 0;
5705
5706		FREE_OP1_IF_VAR();
5707		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5708	} else if (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) {
5709		if (!Z_OBJCE_P(array_ptr)->get_iterator) {
5710			HashPosition pos = 0;
5711			Bucket *p;
5712
5713			result = EX_VAR(opline->result.var);
5714			ZVAL_COPY_VALUE(result, array_ptr);
5715			if (OP1_TYPE != IS_TMP_VAR) {
5716				Z_ADDREF_P(array_ptr);
5717			}
5718			fe_ht = Z_OBJPROP_P(array_ptr);
5719			pos = 0;
5720			p = fe_ht->arData;
5721			while (1) {
5722				if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
5723					FREE_OP1_IF_VAR();
5724					Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
5725					ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
5726				}
5727				if ((EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
5728				     (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
5729				      EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) &&
5730				    (UNEXPECTED(!p->key) ||
5731				     EXPECTED(zend_check_property_access(Z_OBJ_P(array_ptr), p->key) == SUCCESS))) {
5732					break;
5733				}
5734				pos++;
5735				p++;
5736			}
5737			Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(fe_ht, pos);
5738
5739			FREE_OP1_IF_VAR();
5740			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5741		} else {
5742			zend_class_entry *ce = Z_OBJCE_P(array_ptr);
5743			zend_object_iterator *iter = ce->get_iterator(ce, array_ptr, 0);
5744			zend_bool is_empty;
5745
5746			if (UNEXPECTED(!iter) || UNEXPECTED(EG(exception))) {
5747				FREE_OP1();
5748				if (!EG(exception)) {
5749					zend_throw_exception_ex(NULL, 0, "Object of type %s did not create an Iterator", ZSTR_VAL(ce->name));
5750				}
5751				zend_throw_exception_internal(NULL);
5752				HANDLE_EXCEPTION();
5753			}
5754
5755			iter->index = 0;
5756			if (iter->funcs->rewind) {
5757				iter->funcs->rewind(iter);
5758				if (UNEXPECTED(EG(exception) != NULL)) {
5759					OBJ_RELEASE(&iter->std);
5760					FREE_OP1();
5761					HANDLE_EXCEPTION();
5762				}
5763			}
5764
5765			is_empty = iter->funcs->valid(iter) != SUCCESS;
5766
5767			if (UNEXPECTED(EG(exception) != NULL)) {
5768				OBJ_RELEASE(&iter->std);
5769				FREE_OP1();
5770				HANDLE_EXCEPTION();
5771			}
5772			iter->index = -1; /* will be set to 0 before using next handler */
5773
5774			ZVAL_OBJ(EX_VAR(opline->result.var), &iter->std);
5775			Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
5776
5777			FREE_OP1();
5778			if (is_empty) {
5779				ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
5780			} else {
5781				ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5782			}
5783		}
5784	} else {
5785		zend_error(E_WARNING, "Invalid argument supplied for foreach()");
5786		ZVAL_UNDEF(EX_VAR(opline->result.var));
5787		Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
5788		FREE_OP1();
5789		ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
5790	}
5791}
5792
5793ZEND_VM_HANDLER(125, ZEND_FE_RESET_RW, CONST|TMP|VAR|CV, JMP_ADDR)
5794{
5795	USE_OPLINE
5796	zend_free_op free_op1;
5797	zval *array_ptr, *array_ref;
5798	HashTable *fe_ht;
5799	HashPosition pos = 0;
5800	Bucket *p;
5801
5802	SAVE_OPLINE();
5803
5804	if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
5805		array_ref = array_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R);
5806		if (Z_ISREF_P(array_ref)) {
5807			array_ptr = Z_REFVAL_P(array_ref);
5808		}
5809	} else {
5810		array_ref = array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
5811	}
5812
5813	if (EXPECTED(Z_TYPE_P(array_ptr) == IS_ARRAY)) {
5814		if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
5815			if (array_ptr == array_ref) {
5816				ZVAL_NEW_REF(array_ref, array_ref);
5817				array_ptr = Z_REFVAL_P(array_ref);
5818			}
5819			Z_ADDREF_P(array_ref);
5820			ZVAL_COPY_VALUE(EX_VAR(opline->result.var), array_ref);
5821		} else {
5822			array_ref = EX_VAR(opline->result.var);
5823			ZVAL_NEW_REF(array_ref, array_ptr);
5824			array_ptr = Z_REFVAL_P(array_ref);
5825		}
5826		if (OP1_TYPE == IS_CONST) {
5827			zval_copy_ctor_func(array_ptr);
5828		} else {
5829			SEPARATE_ARRAY(array_ptr);
5830		}
5831		fe_ht = Z_ARRVAL_P(array_ptr);
5832		p = fe_ht->arData;
5833		while (1) {
5834			if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
5835				FREE_OP1_VAR_PTR();
5836				Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
5837				ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
5838			}
5839			if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
5840			    (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
5841			     EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) {
5842				break;
5843			}
5844			pos++;
5845			p++;
5846		}
5847		Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(fe_ht, pos);
5848
5849		FREE_OP1_VAR_PTR();
5850		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5851	} else if (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(array_ptr) == IS_OBJECT)) {
5852		if (!Z_OBJCE_P(array_ptr)->get_iterator) {
5853			if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
5854				if (array_ptr == array_ref) {
5855					ZVAL_NEW_REF(array_ref, array_ref);
5856					array_ptr = Z_REFVAL_P(array_ref);
5857				}
5858				Z_ADDREF_P(array_ref);
5859				ZVAL_COPY_VALUE(EX_VAR(opline->result.var), array_ref);
5860			} else {
5861				array_ptr = EX_VAR(opline->result.var);
5862				ZVAL_COPY_VALUE(array_ptr, array_ref);
5863			}
5864			fe_ht = Z_OBJPROP_P(array_ptr);
5865			p = fe_ht->arData;
5866			while (1) {
5867				if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
5868					FREE_OP1_VAR_PTR();
5869					Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
5870					ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
5871				}
5872				if ((EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
5873				     (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
5874				      EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) &&
5875				    (UNEXPECTED(!p->key) ||
5876				     EXPECTED(zend_check_property_access(Z_OBJ_P(array_ptr), p->key) == SUCCESS))) {
5877					break;
5878				}
5879				pos++;
5880				p++;
5881			}
5882			Z_FE_ITER_P(EX_VAR(opline->result.var)) = zend_hash_iterator_add(fe_ht, pos);
5883
5884			FREE_OP1_VAR_PTR();
5885			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5886		} else {
5887			zend_class_entry *ce = Z_OBJCE_P(array_ptr);
5888			zend_object_iterator *iter = ce->get_iterator(ce, array_ptr, 1);
5889			zend_bool is_empty;
5890
5891			if (UNEXPECTED(!iter) || UNEXPECTED(EG(exception))) {
5892				if (OP1_TYPE == IS_VAR) {
5893					FREE_OP1_VAR_PTR();
5894				} else {
5895					FREE_OP1();
5896				}
5897				if (!EG(exception)) {
5898					zend_throw_exception_ex(NULL, 0, "Object of type %s did not create an Iterator", ZSTR_VAL(ce->name));
5899				}
5900				zend_throw_exception_internal(NULL);
5901				HANDLE_EXCEPTION();
5902			}
5903
5904			iter->index = 0;
5905			if (iter->funcs->rewind) {
5906				iter->funcs->rewind(iter);
5907				if (UNEXPECTED(EG(exception) != NULL)) {
5908					OBJ_RELEASE(&iter->std);
5909					if (OP1_TYPE == IS_VAR) {
5910						FREE_OP1_VAR_PTR();
5911					} else {
5912						FREE_OP1();
5913					}
5914					HANDLE_EXCEPTION();
5915				}
5916			}
5917
5918			is_empty = iter->funcs->valid(iter) != SUCCESS;
5919
5920			if (UNEXPECTED(EG(exception) != NULL)) {
5921				OBJ_RELEASE(&iter->std);
5922				if (OP1_TYPE == IS_VAR) {
5923					FREE_OP1_VAR_PTR();
5924				} else {
5925					FREE_OP1();
5926				}
5927				HANDLE_EXCEPTION();
5928			}
5929			iter->index = -1; /* will be set to 0 before using next handler */
5930
5931			ZVAL_OBJ(EX_VAR(opline->result.var), &iter->std);
5932			Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
5933
5934			if (OP1_TYPE == IS_VAR) {
5935				FREE_OP1_VAR_PTR();
5936			} else {
5937				FREE_OP1();
5938			}
5939			if (is_empty) {
5940				ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
5941			} else {
5942				ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
5943			}
5944		}
5945	} else {
5946		zend_error(E_WARNING, "Invalid argument supplied for foreach()");
5947		ZVAL_UNDEF(EX_VAR(opline->result.var));
5948		Z_FE_ITER_P(EX_VAR(opline->result.var)) = (uint32_t)-1;
5949		if (OP1_TYPE == IS_VAR) {
5950			FREE_OP1_VAR_PTR();
5951		} else {
5952			FREE_OP1();
5953		}
5954		ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
5955	}
5956}
5957
5958ZEND_VM_HANDLER(78, ZEND_FE_FETCH_R, VAR, ANY, JMP_ADDR)
5959{
5960	USE_OPLINE
5961	zval *array;
5962	zval *value;
5963	uint32_t value_type;
5964	HashTable *fe_ht;
5965	HashPosition pos;
5966	Bucket *p;
5967
5968	array = EX_VAR(opline->op1.var);
5969	SAVE_OPLINE();
5970	if (EXPECTED(Z_TYPE_P(array) == IS_ARRAY)) {
5971		fe_ht = Z_ARRVAL_P(array);
5972		pos = Z_FE_POS_P(array);
5973		p = fe_ht->arData + pos;
5974		while (1) {
5975			if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
5976				/* reached end of iteration */
5977				ZEND_VM_C_GOTO(fe_fetch_r_exit);
5978			}
5979			value = &p->val;
5980			value_type = Z_TYPE_INFO_P(value);
5981			if (value_type == IS_UNDEF) {
5982				pos++;
5983				p++;
5984				continue;
5985			} else if (UNEXPECTED(value_type == IS_INDIRECT)) {
5986				value = Z_INDIRECT_P(value);
5987				value_type = Z_TYPE_INFO_P(value);
5988				if (UNEXPECTED(value_type == IS_UNDEF)) {
5989					pos++;
5990					p++;
5991					continue;
5992				}
5993			}
5994			break;
5995		}
5996		Z_FE_POS_P(array) = pos + 1;
5997		if (opline->result_type & (IS_TMP_VAR|IS_CV)) {
5998			if (!p->key) {
5999				ZVAL_LONG(EX_VAR(opline->result.var), p->h);
6000			} else {
6001				ZVAL_STR_COPY(EX_VAR(opline->result.var), p->key);
6002			}
6003		}
6004	} else if (EXPECTED(Z_TYPE_P(array) == IS_OBJECT)) {
6005		zend_object_iterator *iter;
6006
6007		if ((iter = zend_iterator_unwrap(array)) == NULL) {
6008			/* plain object */
6009
6010 			fe_ht = Z_OBJPROP_P(array);
6011			pos = zend_hash_iterator_pos(Z_FE_ITER_P(array), fe_ht);
6012			p = fe_ht->arData + pos;
6013			while (1) {
6014				if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
6015					/* reached end of iteration */
6016					ZEND_VM_C_GOTO(fe_fetch_r_exit);
6017				}
6018
6019				value = &p->val;
6020				value_type = Z_TYPE_INFO_P(value);
6021				if (UNEXPECTED(value_type == IS_UNDEF)) {
6022					pos++;
6023					p++;
6024					continue;
6025				} else if (UNEXPECTED(value_type == IS_INDIRECT)) {
6026					value = Z_INDIRECT_P(value);
6027					value_type = Z_TYPE_INFO_P(value);
6028					if (UNEXPECTED(value_type == IS_UNDEF)) {
6029						pos++;
6030						p++;
6031						continue;
6032					}
6033				}
6034				if (UNEXPECTED(!p->key) ||
6035				    EXPECTED(zend_check_property_access(Z_OBJ_P(array), p->key) == SUCCESS)) {
6036					break;
6037				}
6038				pos++;
6039				p++;
6040			}
6041			if (opline->result_type & (IS_TMP_VAR|IS_CV)) {
6042				if (UNEXPECTED(!p->key)) {
6043					ZVAL_LONG(EX_VAR(opline->result.var), p->h);
6044				} else if (ZSTR_VAL(p->key)[0]) {
6045					ZVAL_STR_COPY(EX_VAR(opline->result.var), p->key);
6046				} else {
6047					const char *class_name, *prop_name;
6048					size_t prop_name_len;
6049					zend_unmangle_property_name_ex(
6050						p->key, &class_name, &prop_name, &prop_name_len);
6051					ZVAL_STRINGL(EX_VAR(opline->result.var), prop_name, prop_name_len);
6052				}
6053			}
6054			while (1) {
6055				pos++;
6056				if (pos >= fe_ht->nNumUsed) {
6057					pos = HT_INVALID_IDX;
6058					break;
6059				}
6060				p++;
6061				if ((EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
6062				     (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
6063				      EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) &&
6064				    (UNEXPECTED(!p->key) ||
6065				     EXPECTED(zend_check_property_access(Z_OBJ_P(array), p->key) == SUCCESS))) {
6066					break;
6067				}
6068			}
6069			EG(ht_iterators)[Z_FE_ITER_P(array)].pos = pos;
6070		} else {
6071			if (EXPECTED(++iter->index > 0)) {
6072				/* This could cause an endless loop if index becomes zero again.
6073				 * In case that ever happens we need an additional flag. */
6074				iter->funcs->move_forward(iter);
6075				if (UNEXPECTED(EG(exception) != NULL)) {
6076					HANDLE_EXCEPTION();
6077				}
6078				if (UNEXPECTED(iter->funcs->valid(iter) == FAILURE)) {
6079					/* reached end of iteration */
6080					if (UNEXPECTED(EG(exception) != NULL)) {
6081						HANDLE_EXCEPTION();
6082					}
6083					ZEND_VM_C_GOTO(fe_fetch_r_exit);
6084				}
6085			}
6086			value = iter->funcs->get_current_data(iter);
6087			if (UNEXPECTED(EG(exception) != NULL)) {
6088				HANDLE_EXCEPTION();
6089			}
6090			if (!value) {
6091				/* failure in get_current_data */
6092				ZEND_VM_C_GOTO(fe_fetch_r_exit);
6093			}
6094			if (opline->result_type & (IS_TMP_VAR|IS_CV)) {
6095				if (iter->funcs->get_current_key) {
6096					iter->funcs->get_current_key(iter, EX_VAR(opline->result.var));
6097					if (UNEXPECTED(EG(exception) != NULL)) {
6098						HANDLE_EXCEPTION();
6099					}
6100				} else {
6101					ZVAL_LONG(EX_VAR(opline->result.var), iter->index);
6102				}
6103			}
6104			value_type = Z_TYPE_INFO_P(value);
6105		}
6106	} else {
6107		zend_error(E_WARNING, "Invalid argument supplied for foreach()");
6108		if (UNEXPECTED(EG(exception))) {
6109			HANDLE_EXCEPTION();
6110		}
6111ZEND_VM_C_LABEL(fe_fetch_r_exit):
6112		ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
6113		ZEND_VM_CONTINUE();
6114	}
6115
6116	if (EXPECTED(OP2_TYPE == IS_CV)) {
6117		zval *variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->op2.var);
6118		zend_assign_to_variable(variable_ptr, value, IS_CV);
6119	} else {
6120		zval *res = EX_VAR(opline->op2.var);
6121		zend_refcounted *gc = Z_COUNTED_P(value);
6122
6123		ZVAL_COPY_VALUE_EX(res, value, gc, value_type);
6124		if (EXPECTED((value_type & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)) {
6125			GC_REFCOUNT(gc)++;
6126		}
6127	}
6128	ZEND_VM_NEXT_OPCODE();
6129}
6130
6131ZEND_VM_HANDLER(126, ZEND_FE_FETCH_RW, VAR, ANY, JMP_ADDR)
6132{
6133	USE_OPLINE
6134	zval *array;
6135	zval *value;
6136	uint32_t value_type;
6137	HashTable *fe_ht;
6138	HashPosition pos;
6139	Bucket *p;
6140
6141	array = EX_VAR(opline->op1.var);
6142	SAVE_OPLINE();
6143
6144	ZVAL_DEREF(array);
6145	if (EXPECTED(Z_TYPE_P(array) == IS_ARRAY)) {
6146		pos = zend_hash_iterator_pos_ex(Z_FE_ITER_P(EX_VAR(opline->op1.var)), array);
6147		fe_ht = Z_ARRVAL_P(array);
6148		p = fe_ht->arData + pos;
6149		while (1) {
6150			if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
6151				/* reached end of iteration */
6152				ZEND_VM_C_GOTO(fe_fetch_w_exit);
6153			}
6154			value = &p->val;
6155			value_type = Z_TYPE_INFO_P(value);
6156			if (UNEXPECTED(value_type == IS_UNDEF)) {
6157				pos++;
6158				p++;
6159				continue;
6160			} else if (UNEXPECTED(value_type == IS_INDIRECT)) {
6161				value = Z_INDIRECT_P(value);
6162				value_type = Z_TYPE_INFO_P(value);
6163				if (UNEXPECTED(value_type == IS_UNDEF)) {
6164					pos++;
6165					p++;
6166					continue;
6167				}
6168			}
6169			break;
6170		}
6171		if (opline->result_type & (IS_TMP_VAR|IS_CV)) {
6172			if (!p->key) {
6173				ZVAL_LONG(EX_VAR(opline->result.var), p->h);
6174			} else {
6175				ZVAL_STR_COPY(EX_VAR(opline->result.var), p->key);
6176			}
6177		}
6178		while (1) {
6179			pos++;
6180			if (pos >= fe_ht->nNumUsed) {
6181				pos = HT_INVALID_IDX;
6182				break;
6183			}
6184			p++;
6185			if (EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
6186			    (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
6187			     EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) {
6188				break;
6189			}
6190		}
6191		EG(ht_iterators)[Z_FE_ITER_P(EX_VAR(opline->op1.var))].pos = pos;
6192	} else if (EXPECTED(Z_TYPE_P(array) == IS_OBJECT)) {
6193		zend_object_iterator *iter;
6194
6195		if ((iter = zend_iterator_unwrap(array)) == NULL) {
6196			/* plain object */
6197
6198 			fe_ht = Z_OBJPROP_P(array);
6199			pos = zend_hash_iterator_pos(Z_FE_ITER_P(EX_VAR(opline->op1.var)), fe_ht);
6200			p = fe_ht->arData + pos;
6201			while (1) {
6202				if (UNEXPECTED(pos >= fe_ht->nNumUsed)) {
6203					/* reached end of iteration */
6204					ZEND_VM_C_GOTO(fe_fetch_w_exit);
6205				}
6206
6207				value = &p->val;
6208				value_type = Z_TYPE_INFO_P(value);
6209				if (UNEXPECTED(value_type == IS_UNDEF)) {
6210					pos++;
6211					p++;
6212					continue;
6213				} else if (UNEXPECTED(value_type == IS_INDIRECT)) {
6214					value = Z_INDIRECT_P(value);
6215					value_type = Z_TYPE_INFO_P(value);
6216					if (UNEXPECTED(value_type == IS_UNDEF)) {
6217						pos++;
6218						p++;
6219						continue;
6220					}
6221				}
6222				if (UNEXPECTED(!p->key) ||
6223				    EXPECTED(zend_check_property_access(Z_OBJ_P(array), p->key) == SUCCESS)) {
6224					break;
6225				}
6226				pos++;
6227				p++;
6228			}
6229			if (opline->result_type & (IS_TMP_VAR|IS_CV)) {
6230				if (UNEXPECTED(!p->key)) {
6231					ZVAL_LONG(EX_VAR(opline->result.var), p->h);
6232				} else if (ZSTR_VAL(p->key)[0]) {
6233					ZVAL_STR_COPY(EX_VAR(opline->result.var), p->key);
6234				} else {
6235					const char *class_name, *prop_name;
6236					size_t prop_name_len;
6237					zend_unmangle_property_name_ex(
6238						p->key, &class_name, &prop_name, &prop_name_len);
6239					ZVAL_STRINGL(EX_VAR(opline->result.var), prop_name, prop_name_len);
6240				}
6241			}
6242			while (1) {
6243				pos++;
6244				if (pos >= fe_ht->nNumUsed) {
6245					pos = HT_INVALID_IDX;
6246					break;
6247				}
6248				p++;
6249				if ((EXPECTED(Z_TYPE(p->val) != IS_UNDEF) &&
6250				     (EXPECTED(Z_TYPE(p->val) != IS_INDIRECT) ||
6251				      EXPECTED(Z_TYPE_P(Z_INDIRECT(p->val)) != IS_UNDEF))) &&
6252				    (UNEXPECTED(!p->key) ||
6253				     EXPECTED(zend_check_property_access(Z_OBJ_P(array), p->key) == SUCCESS))) {
6254					break;
6255				}
6256			}
6257			EG(ht_iterators)[Z_FE_ITER_P(EX_VAR(opline->op1.var))].pos = pos;
6258		} else {
6259			if (++iter->index > 0) {
6260				/* This could cause an endless loop if index becomes zero again.
6261				 * In case that ever happens we need an additional flag. */
6262				iter->funcs->move_forward(iter);
6263				if (UNEXPECTED(EG(exception) != NULL)) {
6264					HANDLE_EXCEPTION();
6265				}
6266				if (UNEXPECTED(iter->funcs->valid(iter) == FAILURE)) {
6267					/* reached end of iteration */
6268					if (UNEXPECTED(EG(exception) != NULL)) {
6269						HANDLE_EXCEPTION();
6270					}
6271					ZEND_VM_C_GOTO(fe_fetch_w_exit);
6272				}
6273			}
6274			value = iter->funcs->get_current_data(iter);
6275			if (UNEXPECTED(EG(exception) != NULL)) {
6276				HANDLE_EXCEPTION();
6277			}
6278			if (!value) {
6279				/* failure in get_current_data */
6280				ZEND_VM_C_GOTO(fe_fetch_w_exit);
6281			}
6282			if (opline->result_type & (IS_TMP_VAR|IS_CV)) {
6283				if (iter->funcs->get_current_key) {
6284					iter->funcs->get_current_key(iter, EX_VAR(opline->result.var));
6285					if (UNEXPECTED(EG(exception) != NULL)) {
6286						HANDLE_EXCEPTION();
6287					}
6288				} else {
6289					ZVAL_LONG(EX_VAR(opline->result.var), iter->index);
6290				}
6291			}
6292			value_type = Z_TYPE_INFO_P(value);
6293		}
6294	} else {
6295		zend_error(E_WARNING, "Invalid argument supplied for foreach()");
6296		if (UNEXPECTED(EG(exception))) {
6297			HANDLE_EXCEPTION();
6298		}
6299ZEND_VM_C_LABEL(fe_fetch_w_exit):
6300		ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
6301		ZEND_VM_CONTINUE();
6302	}
6303
6304	if (EXPECTED((value_type & Z_TYPE_MASK) != IS_REFERENCE)) {
6305		zend_refcounted *gc = Z_COUNTED_P(value);
6306		zval *ref;
6307		ZVAL_NEW_EMPTY_REF(value);
6308		ref = Z_REFVAL_P(value);
6309		ZVAL_COPY_VALUE_EX(ref, value, gc, value_type);
6310	}
6311	if (EXPECTED(OP2_TYPE == IS_CV)) {
6312		zval *variable_ptr = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->op2.var);
6313		if (EXPECTED(variable_ptr != value)) {
6314			zend_reference *ref;
6315
6316			ref = Z_REF_P(value);
6317			GC_REFCOUNT(ref)++;
6318			zval_ptr_dtor(variable_ptr);
6319			ZVAL_REF(variable_ptr, ref);
6320		}
6321	} else {
6322		Z_ADDREF_P(value);
6323		ZVAL_REF(EX_VAR(opline->op2.var), Z_REF_P(value));
6324	}
6325	ZEND_VM_NEXT_OPCODE();
6326}
6327
6328ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH|ISSET)
6329{
6330	USE_OPLINE
6331	zval *value;
6332	int result;
6333
6334	if (OP1_TYPE == IS_CV &&
6335	    (opline->extended_value & ZEND_QUICK_SET)) {
6336		value = EX_VAR(opline->op1.var);
6337		if (opline->extended_value & ZEND_ISSET) {
6338			result =
6339				Z_TYPE_P(value) > IS_NULL &&
6340			    (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
6341		} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
6342			SAVE_OPLINE();
6343			result = !i_zend_is_true(value);
6344			if (UNEXPECTED(EG(exception))) {
6345				HANDLE_EXCEPTION();
6346			}
6347		}
6348		ZEND_VM_SMART_BRANCH(result, 0);
6349		ZVAL_BOOL(EX_VAR(opline->result.var), result);
6350		ZEND_VM_SET_NEXT_OPCODE(opline + 1);
6351		ZEND_VM_CONTINUE();
6352	} else {
6353		zend_free_op free_op1;
6354		zval tmp, *varname;
6355		HashTable *target_symbol_table;
6356
6357		SAVE_OPLINE();
6358		varname = GET_OP1_ZVAL_PTR(BP_VAR_IS);
6359		ZVAL_UNDEF(&tmp);
6360		if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
6361			ZVAL_STR(&tmp, zval_get_string(varname));
6362			varname = &tmp;
6363		}
6364
6365		target_symbol_table = zend_get_target_symbol_table(execute_data, opline->extended_value & ZEND_FETCH_TYPE_MASK);
6366		value = zend_hash_find_ind(target_symbol_table, Z_STR_P(varname));
6367
6368		if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
6369			zend_string_release(Z_STR(tmp));
6370		}
6371		FREE_OP1();
6372
6373		if (opline->extended_value & ZEND_ISSET) {
6374			result = value && Z_TYPE_P(value) > IS_NULL &&
6375			    (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
6376		} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
6377			result = !value || !i_zend_is_true(value);
6378		}
6379
6380		ZEND_VM_SMART_BRANCH(result, 1);
6381		ZVAL_BOOL(EX_VAR(opline->result.var), result);
6382		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6383	}
6384}
6385
6386ZEND_VM_HANDLER(180, ZEND_ISSET_ISEMPTY_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR, ISSET)
6387{
6388	USE_OPLINE
6389	zval *value;
6390	int result;
6391	zend_free_op free_op1;
6392	zval tmp, *varname;
6393	zend_class_entry *ce;
6394
6395	SAVE_OPLINE();
6396	varname = GET_OP1_ZVAL_PTR(BP_VAR_IS);
6397	ZVAL_UNDEF(&tmp);
6398	if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
6399		ZVAL_STR(&tmp, zval_get_string(varname));
6400		varname = &tmp;
6401	}
6402
6403	if (OP2_TYPE == IS_CONST) {
6404		if (OP1_TYPE == IS_CONST && EXPECTED((ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)))) != NULL)) {
6405			value = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)) + sizeof(void*));
6406
6407			/* check if static properties were destoyed */
6408			if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
6409				value = NULL;
6410			}
6411
6412			ZEND_VM_C_GOTO(is_static_prop_return);
6413		} else if (UNEXPECTED((ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)))) == NULL)) {
6414			ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op2)), EX_CONSTANT(opline->op2) + 1, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
6415			if (UNEXPECTED(ce == NULL)) {
6416				ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6417			}
6418			CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce);
6419		}
6420	} else {
6421		if (OP2_TYPE == IS_UNUSED) {
6422			ce = zend_fetch_class(NULL, opline->op2.num);
6423			if (UNEXPECTED(ce == NULL)) {
6424				ZEND_ASSERT(EG(exception));
6425				if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
6426					zend_string_release(Z_STR(tmp));
6427				}
6428				FREE_OP1();
6429				HANDLE_EXCEPTION();
6430			}
6431		} else {
6432			ce = Z_CE_P(EX_VAR(opline->op2.var));
6433		}
6434		if (OP1_TYPE == IS_CONST &&
6435		    (value = CACHED_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce)) != NULL) {
6436
6437			/* check if static properties were destoyed */
6438			if (UNEXPECTED(CE_STATIC_MEMBERS(ce) == NULL)) {
6439				value = NULL;
6440			}
6441
6442			ZEND_VM_C_GOTO(is_static_prop_return);
6443		}
6444	}
6445
6446	value = zend_std_get_static_property(ce, Z_STR_P(varname), 1);
6447
6448	if (OP1_TYPE == IS_CONST && value) {
6449		CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op1)), ce, value);
6450	}
6451
6452	if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
6453		zend_string_release(Z_STR(tmp));
6454	}
6455	FREE_OP1();
6456
6457ZEND_VM_C_LABEL(is_static_prop_return):
6458	if (opline->extended_value & ZEND_ISSET) {
6459		result = value && Z_TYPE_P(value) > IS_NULL &&
6460		    (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
6461	} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
6462		result = !value || !i_zend_is_true(value);
6463	}
6464
6465	ZEND_VM_SMART_BRANCH(result, 1);
6466	ZVAL_BOOL(EX_VAR(opline->result.var), result);
6467	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6468}
6469
6470ZEND_VM_HANDLER(115, ZEND_ISSET_ISEMPTY_DIM_OBJ, CONST|TMPVAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, ISSET)
6471{
6472	USE_OPLINE
6473	zend_free_op free_op1, free_op2;
6474	zval *container;
6475	int result;
6476	zend_ulong hval;
6477	zval *offset;
6478
6479	SAVE_OPLINE();
6480	container = GET_OP1_OBJ_ZVAL_PTR_UNDEF(BP_VAR_IS);
6481
6482	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
6483		zend_throw_error(NULL, "Using $this when not in object context");
6484		FREE_UNFETCHED_OP2();
6485		HANDLE_EXCEPTION();
6486	}
6487
6488	offset = GET_OP2_ZVAL_PTR_UNDEF(BP_VAR_R);
6489
6490	if (OP1_TYPE != IS_UNUSED && EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
6491		HashTable *ht;
6492		zval *value;
6493		zend_string *str;
6494
6495ZEND_VM_C_LABEL(isset_dim_obj_array):
6496		ht = Z_ARRVAL_P(container);
6497ZEND_VM_C_LABEL(isset_again):
6498		if (EXPECTED(Z_TYPE_P(offset) == IS_STRING)) {
6499			str = Z_STR_P(offset);
6500			if (OP2_TYPE != IS_CONST) {
6501				if (ZEND_HANDLE_NUMERIC(str, hval)) {
6502					ZEND_VM_C_GOTO(num_index_prop);
6503				}
6504			}
6505ZEND_VM_C_LABEL(str_index_prop):
6506			value = zend_hash_find_ind(ht, str);
6507		} else if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
6508			hval = Z_LVAL_P(offset);
6509ZEND_VM_C_LABEL(num_index_prop):
6510			value = zend_hash_index_find(ht, hval);
6511		} else if ((OP2_TYPE & (IS_VAR|IS_CV)) && EXPECTED(Z_ISREF_P(offset))) {
6512			offset = Z_REFVAL_P(offset);
6513			ZEND_VM_C_GOTO(isset_again);
6514		} else if (Z_TYPE_P(offset) == IS_DOUBLE) {
6515			hval = zend_dval_to_lval(Z_DVAL_P(offset));
6516			ZEND_VM_C_GOTO(num_index_prop);
6517		} else if (Z_TYPE_P(offset) == IS_NULL) {
6518			str = ZSTR_EMPTY_ALLOC();
6519			ZEND_VM_C_GOTO(str_index_prop);
6520		} else if (Z_TYPE_P(offset) == IS_FALSE) {
6521			hval = 0;
6522			ZEND_VM_C_GOTO(num_index_prop);
6523		} else if (Z_TYPE_P(offset) == IS_TRUE) {
6524			hval = 1;
6525			ZEND_VM_C_GOTO(num_index_prop);
6526		} else if (Z_TYPE_P(offset) == IS_RESOURCE) {
6527			hval = Z_RES_HANDLE_P(offset);
6528			ZEND_VM_C_GOTO(num_index_prop);
6529		} else if (OP2_TYPE == IS_CV && Z_TYPE_P(offset) == IS_UNDEF) {
6530			GET_OP2_UNDEF_CV(offset, BP_VAR_R);
6531			str = ZSTR_EMPTY_ALLOC();
6532			ZEND_VM_C_GOTO(str_index_prop);
6533		} else {
6534			zend_error(E_WARNING, "Illegal offset type in isset or empty");
6535			ZEND_VM_C_GOTO(isset_not_found);
6536		}
6537
6538		if (opline->extended_value & ZEND_ISSET) {
6539			/* > IS_NULL means not IS_UNDEF and not IS_NULL */
6540			result = value != NULL && Z_TYPE_P(value) > IS_NULL &&
6541			    (!Z_ISREF_P(value) || Z_TYPE_P(Z_REFVAL_P(value)) != IS_NULL);
6542		} else /* if (opline->extended_value & ZEND_ISEMPTY) */ {
6543			result = (value == NULL || !i_zend_is_true(value));
6544		}
6545		ZEND_VM_C_GOTO(isset_dim_obj_exit);
6546	} else if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(container)) {
6547		container = Z_REFVAL_P(container);
6548		if (EXPECTED(Z_TYPE_P(container) == IS_ARRAY)) {
6549			ZEND_VM_C_GOTO(isset_dim_obj_array);
6550		}
6551	}
6552
6553	if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
6554		offset = GET_OP2_UNDEF_CV(offset, BP_VAR_R);
6555	}
6556
6557	if (OP1_TYPE == IS_UNUSED ||
6558	    (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(container) == IS_OBJECT))) {
6559		if (EXPECTED(Z_OBJ_HT_P(container)->has_dimension)) {
6560			result =
6561				((opline->extended_value & ZEND_ISSET) == 0) ^
6562				Z_OBJ_HT_P(container)->has_dimension(container, offset, (opline->extended_value & ZEND_ISSET) == 0);
6563		} else {
6564			zend_error(E_NOTICE, "Trying to check element of non-array");
6565			ZEND_VM_C_GOTO(isset_not_found);
6566		}
6567	} else if (EXPECTED(Z_TYPE_P(container) == IS_STRING)) { /* string offsets */
6568		zend_long lval;
6569
6570		if (EXPECTED(Z_TYPE_P(offset) == IS_LONG)) {
6571			lval = Z_LVAL_P(offset);
6572ZEND_VM_C_LABEL(isset_str_offset):
6573			if (UNEXPECTED(lval < 0)) { /* Handle negative offset */
6574				lval += (zend_long)Z_STRLEN_P(container);
6575			}
6576			if (EXPECTED(lval >= 0) && (size_t)lval < Z_STRLEN_P(container)) {
6577				if (opline->extended_value & ZEND_ISSET) {
6578					result = 1;
6579				} else {
6580					result = (Z_STRVAL_P(container)[lval] == '0');
6581				}
6582			} else {
6583				ZEND_VM_C_GOTO(isset_not_found);
6584			}
6585		} else {
6586			if (OP2_TYPE & (IS_CV|IS_VAR)) {
6587				ZVAL_DEREF(offset);
6588			}
6589			if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
6590					|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
6591						&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
6592				lval = zval_get_long(offset);
6593				ZEND_VM_C_GOTO(isset_str_offset);
6594			}
6595			ZEND_VM_C_GOTO(isset_not_found);
6596		}
6597	} else {
6598ZEND_VM_C_LABEL(isset_not_found):
6599		result = ((opline->extended_value & ZEND_ISSET) == 0);
6600	}
6601
6602ZEND_VM_C_LABEL(isset_dim_obj_exit):
6603	FREE_OP2();
6604	FREE_OP1();
6605	ZEND_VM_SMART_BRANCH(result, 1);
6606	ZVAL_BOOL(EX_VAR(opline->result.var), result);
6607	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6608}
6609
6610ZEND_VM_HANDLER(148, ZEND_ISSET_ISEMPTY_PROP_OBJ, CONST|TMPVAR|UNUSED|THIS|CV, CONST|TMPVAR|CV, ISSET)
6611{
6612	USE_OPLINE
6613	zend_free_op free_op1, free_op2;
6614	zval *container;
6615	int result;
6616	zval *offset;
6617
6618	SAVE_OPLINE();
6619	container = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_IS);
6620
6621	if (OP1_TYPE == IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) == IS_UNDEF)) {
6622		zend_throw_error(NULL, "Using $this when not in object context");
6623		FREE_UNFETCHED_OP2();
6624		HANDLE_EXCEPTION();
6625	}
6626
6627	offset = GET_OP2_ZVAL_PTR(BP_VAR_R);
6628
6629	if (OP1_TYPE == IS_CONST ||
6630	    (OP1_TYPE != IS_UNUSED && UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT))) {
6631		if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(container)) {
6632			container = Z_REFVAL_P(container);
6633			if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) {
6634				ZEND_VM_C_GOTO(isset_no_object);
6635			}
6636		} else {
6637			ZEND_VM_C_GOTO(isset_no_object);
6638		}
6639	}
6640	if (UNEXPECTED(!Z_OBJ_HT_P(container)->has_property)) {
6641		zend_error(E_NOTICE, "Trying to check property of non-object");
6642ZEND_VM_C_LABEL(isset_no_object):
6643		result = ((opline->extended_value & ZEND_ISSET) == 0);
6644	} else {
6645		result =
6646			((opline->extended_value & ZEND_ISSET) == 0) ^
6647			Z_OBJ_HT_P(container)->has_property(container, offset, (opline->extended_value & ZEND_ISSET) == 0, ((OP2_TYPE == IS_CONST) ? CACHE_ADDR(Z_CACHE_SLOT_P(offset)) : NULL));
6648	}
6649
6650	FREE_OP2();
6651	FREE_OP1();
6652	ZEND_VM_SMART_BRANCH(result, 1);
6653	ZVAL_BOOL(EX_VAR(opline->result.var), result);
6654	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6655}
6656
6657ZEND_VM_HANDLER(79, ZEND_EXIT, CONST|TMPVAR|UNUSED|CV, ANY)
6658{
6659	USE_OPLINE
6660
6661	SAVE_OPLINE();
6662	if (OP1_TYPE != IS_UNUSED) {
6663		zend_free_op free_op1;
6664		zval *ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
6665
6666		do {
6667			if (Z_TYPE_P(ptr) == IS_LONG) {
6668				EG(exit_status) = Z_LVAL_P(ptr);
6669			} else {
6670				if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_ISREF_P(ptr)) {
6671					ptr = Z_REFVAL_P(ptr);
6672					if (Z_TYPE_P(ptr) == IS_LONG) {
6673						EG(exit_status) = Z_LVAL_P(ptr);
6674						break;
6675					}
6676				}
6677				zend_print_variable(ptr);
6678			}
6679		} while (0);
6680		FREE_OP1();
6681	}
6682	zend_bailout();
6683	ZEND_VM_NEXT_OPCODE(); /* Never reached */
6684}
6685
6686ZEND_VM_HANDLER(57, ZEND_BEGIN_SILENCE, ANY, ANY)
6687{
6688	USE_OPLINE
6689
6690	ZVAL_LONG(EX_VAR(opline->result.var), EG(error_reporting));
6691
6692	if (EG(error_reporting)) {
6693		do {
6694			EG(error_reporting) = 0;
6695			if (!EG(error_reporting_ini_entry)) {
6696				zend_ini_entry *p = zend_hash_find_ptr(EG(ini_directives), CG(known_strings)[ZEND_STR_ERROR_REPORTING]);
6697				if (p) {
6698					EG(error_reporting_ini_entry) = p;
6699				} else {
6700					break;
6701				}
6702			}
6703			if (!EG(error_reporting_ini_entry)->modified) {
6704				if (!EG(modified_ini_directives)) {
6705					ALLOC_HASHTABLE(EG(modified_ini_directives));
6706					zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
6707				}
6708				if (EXPECTED(zend_hash_add_ptr(EG(modified_ini_directives), CG(known_strings)[ZEND_STR_ERROR_REPORTING], EG(error_reporting_ini_entry)) != NULL)) {
6709					EG(error_reporting_ini_entry)->orig_value = EG(error_reporting_ini_entry)->value;
6710					EG(error_reporting_ini_entry)->orig_modifiable = EG(error_reporting_ini_entry)->modifiable;
6711					EG(error_reporting_ini_entry)->modified = 1;
6712				}
6713			}
6714		} while (0);
6715	}
6716	ZEND_VM_NEXT_OPCODE();
6717}
6718
6719ZEND_VM_HANDLER(58, ZEND_END_SILENCE, TMP, ANY)
6720{
6721	USE_OPLINE
6722
6723	if (!EG(error_reporting) && Z_LVAL_P(EX_VAR(opline->op1.var)) != 0) {
6724		EG(error_reporting) = Z_LVAL_P(EX_VAR(opline->op1.var));
6725	}
6726	ZEND_VM_NEXT_OPCODE();
6727}
6728
6729ZEND_VM_HANDLER(152, ZEND_JMP_SET, CONST|TMP|VAR|CV, JMP_ADDR)
6730{
6731	USE_OPLINE
6732	zend_free_op free_op1;
6733	zval *value;
6734	zval *ref = NULL;
6735
6736	SAVE_OPLINE();
6737	value = GET_OP1_ZVAL_PTR(BP_VAR_R);
6738
6739	if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && Z_ISREF_P(value)) {
6740		if (OP1_TYPE == IS_VAR) {
6741			ref = value;
6742		}
6743		value = Z_REFVAL_P(value);
6744	}
6745	if (i_zend_is_true(value)) {
6746		zval *result = EX_VAR(opline->result.var);
6747
6748		ZVAL_COPY_VALUE(result, value);
6749		if (OP1_TYPE == IS_CONST) {
6750			if (UNEXPECTED(Z_OPT_REFCOUNTED_P(result))) Z_ADDREF_P(result);
6751		} else if (OP1_TYPE == IS_CV) {
6752			if (Z_OPT_REFCOUNTED_P(result)) Z_ADDREF_P(result);
6753		} else if (OP1_TYPE == IS_VAR && ref) {
6754			zend_reference *r = Z_REF_P(ref);
6755
6756			if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
6757				efree_size(r, sizeof(zend_reference));
6758			} else if (Z_OPT_REFCOUNTED_P(result)) {
6759				Z_ADDREF_P(result);
6760			}
6761		}
6762		ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
6763	}
6764
6765	FREE_OP1();
6766	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6767}
6768
6769ZEND_VM_HANDLER(169, ZEND_COALESCE, CONST|TMP|VAR|CV, JMP_ADDR)
6770{
6771	USE_OPLINE
6772	zend_free_op free_op1;
6773	zval *value;
6774	zval *ref = NULL;
6775
6776	SAVE_OPLINE();
6777	value = GET_OP1_ZVAL_PTR(BP_VAR_IS);
6778
6779	if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && Z_ISREF_P(value)) {
6780		if (OP1_TYPE == IS_VAR) {
6781			ref = value;
6782		}
6783		value = Z_REFVAL_P(value);
6784	}
6785
6786	if (Z_TYPE_P(value) > IS_NULL) {
6787		zval *result = EX_VAR(opline->result.var);
6788		ZVAL_COPY_VALUE(result, value);
6789		if (OP1_TYPE == IS_CONST) {
6790			if (UNEXPECTED(Z_OPT_REFCOUNTED_P(result))) Z_ADDREF_P(result);
6791		} else if (OP1_TYPE == IS_CV) {
6792			if (Z_OPT_REFCOUNTED_P(result)) Z_ADDREF_P(result);
6793		} else if (OP1_TYPE == IS_VAR && ref) {
6794			zend_reference *r = Z_REF_P(ref);
6795
6796			if (UNEXPECTED(--GC_REFCOUNT(r) == 0)) {
6797				efree_size(r, sizeof(zend_reference));
6798			} else if (Z_OPT_REFCOUNTED_P(result)) {
6799				Z_ADDREF_P(result);
6800			}
6801		}
6802		ZEND_VM_JMP(OP_JMP_ADDR(opline, opline->op2));
6803	}
6804
6805	FREE_OP1();
6806	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6807}
6808
6809ZEND_VM_HANDLER(22, ZEND_QM_ASSIGN, CONST|TMP|VAR|CV, ANY)
6810{
6811	USE_OPLINE
6812	zend_free_op free_op1;
6813	zval *value;
6814	zval *result = EX_VAR(opline->result.var);
6815
6816	value = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
6817	if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) {
6818		SAVE_OPLINE();
6819		GET_OP1_UNDEF_CV(value, BP_VAR_R);
6820		ZVAL_NULL(result);
6821		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6822	}
6823
6824	if (OP1_TYPE == IS_CV) {
6825		ZVAL_DEREF(value);
6826		ZVAL_COPY(result, value);
6827	} else if (OP1_TYPE == IS_VAR) {
6828		if (UNEXPECTED(Z_ISREF_P(value))) {
6829			ZVAL_COPY_VALUE(result, Z_REFVAL_P(value));
6830			if (UNEXPECTED(Z_DELREF_P(value) == 0)) {
6831				efree_size(Z_REF_P(value), sizeof(zend_reference));
6832			} else if (Z_OPT_REFCOUNTED_P(result)) {
6833				Z_ADDREF_P(result);
6834			}
6835		} else {
6836			ZVAL_COPY_VALUE(result, value);
6837		}
6838	} else {
6839		ZVAL_COPY_VALUE(result, value);
6840		if (OP1_TYPE == IS_CONST) {
6841			if (UNEXPECTED(Z_OPT_REFCOUNTED_P(result))) {
6842				Z_ADDREF_P(result);
6843			}
6844		}
6845	}
6846	ZEND_VM_NEXT_OPCODE();
6847}
6848
6849ZEND_VM_HANDLER(101, ZEND_EXT_STMT, ANY, ANY)
6850{
6851	USE_OPLINE
6852
6853	if (!EG(no_extensions)) {
6854		SAVE_OPLINE();
6855		zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_statement_handler, execute_data);
6856		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6857	}
6858	ZEND_VM_NEXT_OPCODE();
6859}
6860
6861ZEND_VM_HANDLER(102, ZEND_EXT_FCALL_BEGIN, ANY, ANY)
6862{
6863	USE_OPLINE
6864
6865	if (!EG(no_extensions)) {
6866		SAVE_OPLINE();
6867		zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_begin_handler, execute_data);
6868		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6869	}
6870	ZEND_VM_NEXT_OPCODE();
6871}
6872
6873ZEND_VM_HANDLER(103, ZEND_EXT_FCALL_END, ANY, ANY)
6874{
6875	USE_OPLINE
6876
6877	if (!EG(no_extensions)) {
6878		SAVE_OPLINE();
6879		zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_end_handler, execute_data);
6880		ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6881	}
6882	ZEND_VM_NEXT_OPCODE();
6883}
6884
6885ZEND_VM_HANDLER(139, ZEND_DECLARE_CLASS, ANY, ANY)
6886{
6887	USE_OPLINE
6888
6889	SAVE_OPLINE();
6890	Z_CE_P(EX_VAR(opline->result.var)) = do_bind_class(&EX(func)->op_array, opline, EG(class_table), 0);
6891	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6892}
6893
6894ZEND_VM_HANDLER(140, ZEND_DECLARE_INHERITED_CLASS, ANY, VAR)
6895{
6896	USE_OPLINE
6897
6898	SAVE_OPLINE();
6899	Z_CE_P(EX_VAR(opline->result.var)) = do_bind_inherited_class(&EX(func)->op_array, opline, EG(class_table), Z_CE_P(EX_VAR(opline->op2.var)), 0);
6900	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6901}
6902
6903ZEND_VM_HANDLER(145, ZEND_DECLARE_INHERITED_CLASS_DELAYED, ANY, VAR)
6904{
6905	USE_OPLINE
6906	zval *zce, *orig_zce;
6907
6908	SAVE_OPLINE();
6909	if ((zce = zend_hash_find(EG(class_table), Z_STR_P(EX_CONSTANT(opline->op1)))) == NULL ||
6910	    ((orig_zce = zend_hash_find(EG(class_table), Z_STR_P(EX_CONSTANT(opline->op1)+1))) != NULL &&
6911	     Z_CE_P(zce) != Z_CE_P(orig_zce))) {
6912		do_bind_inherited_class(&EX(func)->op_array, opline, EG(class_table), Z_CE_P(EX_VAR(opline->op2.var)), 0);
6913	}
6914	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6915}
6916
6917ZEND_VM_HANDLER(171, ZEND_DECLARE_ANON_CLASS, ANY, ANY, JMP_ADDR)
6918{
6919	zend_class_entry *ce;
6920	USE_OPLINE
6921
6922	SAVE_OPLINE();
6923	ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(EX_CONSTANT(opline->op1)));
6924	Z_CE_P(EX_VAR(opline->result.var)) = ce;
6925	ZEND_ASSERT(ce != NULL);
6926
6927	if (ce->ce_flags & ZEND_ACC_ANON_BOUND) {
6928		ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
6929		ZEND_VM_CONTINUE();
6930	}
6931
6932	if (!(ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLEMENT_INTERFACES|ZEND_ACC_IMPLEMENT_TRAITS))) {
6933		zend_verify_abstract_class(ce);
6934	}
6935	ce->ce_flags |= ZEND_ACC_ANON_BOUND;
6936	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6937}
6938
6939ZEND_VM_HANDLER(172, ZEND_DECLARE_ANON_INHERITED_CLASS, ANY, VAR, JMP_ADDR)
6940{
6941	zend_class_entry *ce;
6942	USE_OPLINE
6943
6944	SAVE_OPLINE();
6945	ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(EX_CONSTANT(opline->op1)));
6946	Z_CE_P(EX_VAR(opline->result.var)) = ce;
6947	ZEND_ASSERT(ce != NULL);
6948
6949	if (ce->ce_flags & ZEND_ACC_ANON_BOUND) {
6950		ZEND_VM_SET_RELATIVE_OPCODE(opline, opline->extended_value);
6951		ZEND_VM_CONTINUE();
6952	}
6953
6954	zend_do_inheritance(ce, Z_CE_P(EX_VAR(opline->op2.var)));
6955	ce->ce_flags |= ZEND_ACC_ANON_BOUND;
6956	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6957}
6958
6959ZEND_VM_HANDLER(141, ZEND_DECLARE_FUNCTION, ANY, ANY)
6960{
6961	USE_OPLINE
6962
6963	SAVE_OPLINE();
6964	do_bind_function(&EX(func)->op_array, opline, EG(function_table), 0);
6965	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6966}
6967
6968ZEND_VM_HANDLER(105, ZEND_TICKS, ANY, ANY, NUM)
6969{
6970	USE_OPLINE
6971
6972	if ((uint32_t)++EG(ticks_count) >= opline->extended_value) {
6973		EG(ticks_count) = 0;
6974		if (zend_ticks_function) {
6975			SAVE_OPLINE();
6976			zend_ticks_function(opline->extended_value);
6977			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
6978		}
6979	}
6980	ZEND_VM_NEXT_OPCODE();
6981}
6982
6983ZEND_VM_HANDLER(138, ZEND_INSTANCEOF, TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
6984{
6985	USE_OPLINE
6986	zend_free_op free_op1;
6987	zval *expr;
6988	zend_bool result;
6989
6990	SAVE_OPLINE();
6991	expr = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
6992
6993ZEND_VM_C_LABEL(try_instanceof):
6994	if (Z_TYPE_P(expr) == IS_OBJECT) {
6995		zend_class_entry *ce;
6996
6997		if (OP2_TYPE == IS_CONST) {
6998			ce = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
6999			if (UNEXPECTED(ce == NULL)) {
7000				ce = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op2)), EX_CONSTANT(opline->op2) + 1, ZEND_FETCH_CLASS_NO_AUTOLOAD);
7001				if (UNEXPECTED(ce == NULL)) {
7002					ZVAL_FALSE(EX_VAR(opline->result.var));
7003					FREE_OP1();
7004					ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
7005				}
7006				CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), ce);
7007			}
7008		} else if (OP2_TYPE == IS_UNUSED) {
7009			ce = zend_fetch_class(NULL, opline->op2.num);
7010			if (UNEXPECTED(ce == NULL)) {
7011				ZEND_ASSERT(EG(exception));
7012				FREE_OP1();
7013				HANDLE_EXCEPTION();
7014			}
7015		} else {
7016			ce = Z_CE_P(EX_VAR(opline->op2.var));
7017		}
7018		result = ce && instanceof_function(Z_OBJCE_P(expr), ce);
7019	} else if ((OP1_TYPE & (IS_VAR|IS_CV)) && Z_TYPE_P(expr) == IS_REFERENCE) {
7020		expr = Z_REFVAL_P(expr);
7021		ZEND_VM_C_GOTO(try_instanceof);
7022	} else {
7023		if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(expr) == IS_UNDEF)) {
7024			GET_OP1_UNDEF_CV(expr, BP_VAR_R);
7025		}
7026		result = 0;
7027	}
7028	FREE_OP1();
7029	ZEND_VM_SMART_BRANCH(result, 1);
7030	ZVAL_BOOL(EX_VAR(opline->result.var), result);
7031	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
7032}
7033
7034ZEND_VM_HANDLER(104, ZEND_EXT_NOP, ANY, ANY)
7035{
7036	USE_OPLINE
7037
7038	ZEND_VM_NEXT_OPCODE();
7039}
7040
7041ZEND_VM_HANDLER(0, ZEND_NOP, ANY, ANY)
7042{
7043	USE_OPLINE
7044
7045	ZEND_VM_NEXT_OPCODE();
7046}
7047
7048ZEND_VM_HANDLER(144, ZEND_ADD_INTERFACE, ANY, CONST)
7049{
7050	USE_OPLINE
7051	zend_class_entry *ce = Z_CE_P(EX_VAR(opline->op1.var));
7052	zend_class_entry *iface;
7053
7054	SAVE_OPLINE();
7055	iface = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
7056	if (UNEXPECTED(iface == NULL)) {
7057		iface = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op2)), EX_CONSTANT(opline->op2) + 1, ZEND_FETCH_CLASS_INTERFACE);
7058		if (UNEXPECTED(iface == NULL)) {
7059			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
7060		}
7061		CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), iface);
7062	}
7063
7064	if (UNEXPECTED((iface->ce_flags & ZEND_ACC_INTERFACE) == 0)) {
7065		zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ZSTR_VAL(ce->name), ZSTR_VAL(iface->name));
7066	}
7067	zend_do_implement_interface(ce, iface);
7068
7069	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
7070}
7071
7072ZEND_VM_HANDLER(154, ZEND_ADD_TRAIT, ANY, ANY)
7073{
7074	USE_OPLINE
7075	zend_class_entry *ce = Z_CE_P(EX_VAR(opline->op1.var));
7076	zend_class_entry *trait;
7077
7078	SAVE_OPLINE();
7079	trait = CACHED_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)));
7080	if (UNEXPECTED(trait == NULL)) {
7081		trait = zend_fetch_class_by_name(Z_STR_P(EX_CONSTANT(opline->op2)),
7082		                                 EX_CONSTANT(opline->op2) + 1,
7083		                                 ZEND_FETCH_CLASS_TRAIT);
7084		if (UNEXPECTED(trait == NULL)) {
7085			ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
7086		}
7087		if (!(trait->ce_flags & ZEND_ACC_TRAIT)) {
7088			zend_error_noreturn(E_ERROR, "%s cannot use %s - it is not a trait", ZSTR_VAL(ce->name), ZSTR_VAL(trait->name));
7089		}
7090		CACHE_PTR(Z_CACHE_SLOT_P(EX_CONSTANT(opline->op2)), trait);
7091	}
7092
7093	zend_do_implement_trait(ce, trait);
7094
7095	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
7096}
7097
7098ZEND_VM_HANDLER(155, ZEND_BIND_TRAITS, ANY, ANY)
7099{
7100	USE_OPLINE
7101	zend_class_entry *ce = Z_CE_P(EX_VAR(opline->op1.var));
7102
7103	SAVE_OPLINE();
7104	zend_do_bind_traits(ce);
7105	ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
7106}
7107
7108ZEND_VM_HELPER(zend_dispatch_try_catch_finally_helper, ANY, ANY, uint32_t try_catch_offset, uint32_t op_num)
7109{
7110	zend_object *ex = EG(exception);
7111
7112	/* Walk try/catch/finally structures upwards, performing the necessary actions */
7113	while (try_catch_offset != (uint32_t) -1) {
7114		zend_try_catch_element *try_catch =
7115			&EX(func)->op_array.try_catch_array[try_catch_offset];
7116
7117		if (op_num < try_catch->catch_op) {
7118			/* Go to catch block */
7119			cleanup_live_vars(execute_data, op_num, try_catch->catch_op);
7120			ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[try_catch->catch_op]);
7121			ZEND_VM_CONTINUE();
7122
7123		} else if (op_num < try_catch->finally_op) {
7124			/* Go to finally block */
7125			zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[try_catch->finally_end].op1.var);
7126			cleanup_live_vars(execute_data, op_num, try_catch->finally_op);
7127			Z_OBJ_P(fast_call) = EG(exception);
7128			EG(exception) = NULL;
7129			fast_call->u2.lineno = (uint32_t)-1;
7130			ZEND_VM_SET_OPCODE(&EX(func)->op_array.opcodes[try_catch->finally_op]);
7131			ZEND_VM_CONTINUE();
7132
7133		} else if (op_num < try_catch->finally_end) {
7134			/* Chain potential exception from wrapping finally block */
7135			zval *fast_call = EX_VAR(EX(func)->op_array.opcodes[try_catch->finally_end].op1.var);
7136			if (Z_OBJ_P(fast_call)) {
7137				zend_exception_set_previous(ex, Z_OBJ_P(fast_call));
7138				ex = Z_OBJ_P(fast_call);
7139			}
7140		}
7141
7142		try_catch_offset--;
7143	}
7144
7145	/* Uncaught exception */
7146	cleanup_live_vars(execute_data, op_num, 0);
7147	if (UNEXPECTED((EX_CALL_INFO() & ZEND_CALL_GENERATOR) != 0)) {
7148		zend_generator *