xref: /PHP-7.2/Zend/zend_vm_opcodes.c (revision 7a7ec01a)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1998-2018 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 #include <stdio.h>
22 #include <zend.h>
23 
24 static const char *zend_vm_opcodes_names[198] = {
25 	"ZEND_NOP",
26 	"ZEND_ADD",
27 	"ZEND_SUB",
28 	"ZEND_MUL",
29 	"ZEND_DIV",
30 	"ZEND_MOD",
31 	"ZEND_SL",
32 	"ZEND_SR",
33 	"ZEND_CONCAT",
34 	"ZEND_BW_OR",
35 	"ZEND_BW_AND",
36 	"ZEND_BW_XOR",
37 	"ZEND_BW_NOT",
38 	"ZEND_BOOL_NOT",
39 	"ZEND_BOOL_XOR",
40 	"ZEND_IS_IDENTICAL",
41 	"ZEND_IS_NOT_IDENTICAL",
42 	"ZEND_IS_EQUAL",
43 	"ZEND_IS_NOT_EQUAL",
44 	"ZEND_IS_SMALLER",
45 	"ZEND_IS_SMALLER_OR_EQUAL",
46 	"ZEND_CAST",
47 	"ZEND_QM_ASSIGN",
48 	"ZEND_ASSIGN_ADD",
49 	"ZEND_ASSIGN_SUB",
50 	"ZEND_ASSIGN_MUL",
51 	"ZEND_ASSIGN_DIV",
52 	"ZEND_ASSIGN_MOD",
53 	"ZEND_ASSIGN_SL",
54 	"ZEND_ASSIGN_SR",
55 	"ZEND_ASSIGN_CONCAT",
56 	"ZEND_ASSIGN_BW_OR",
57 	"ZEND_ASSIGN_BW_AND",
58 	"ZEND_ASSIGN_BW_XOR",
59 	"ZEND_PRE_INC",
60 	"ZEND_PRE_DEC",
61 	"ZEND_POST_INC",
62 	"ZEND_POST_DEC",
63 	"ZEND_ASSIGN",
64 	"ZEND_ASSIGN_REF",
65 	"ZEND_ECHO",
66 	"ZEND_GENERATOR_CREATE",
67 	"ZEND_JMP",
68 	"ZEND_JMPZ",
69 	"ZEND_JMPNZ",
70 	"ZEND_JMPZNZ",
71 	"ZEND_JMPZ_EX",
72 	"ZEND_JMPNZ_EX",
73 	"ZEND_CASE",
74 	"ZEND_CHECK_VAR",
75 	"ZEND_SEND_VAR_NO_REF_EX",
76 	"ZEND_MAKE_REF",
77 	"ZEND_BOOL",
78 	"ZEND_FAST_CONCAT",
79 	"ZEND_ROPE_INIT",
80 	"ZEND_ROPE_ADD",
81 	"ZEND_ROPE_END",
82 	"ZEND_BEGIN_SILENCE",
83 	"ZEND_END_SILENCE",
84 	"ZEND_INIT_FCALL_BY_NAME",
85 	"ZEND_DO_FCALL",
86 	"ZEND_INIT_FCALL",
87 	"ZEND_RETURN",
88 	"ZEND_RECV",
89 	"ZEND_RECV_INIT",
90 	"ZEND_SEND_VAL",
91 	"ZEND_SEND_VAR_EX",
92 	"ZEND_SEND_REF",
93 	"ZEND_NEW",
94 	"ZEND_INIT_NS_FCALL_BY_NAME",
95 	"ZEND_FREE",
96 	"ZEND_INIT_ARRAY",
97 	"ZEND_ADD_ARRAY_ELEMENT",
98 	"ZEND_INCLUDE_OR_EVAL",
99 	"ZEND_UNSET_VAR",
100 	"ZEND_UNSET_DIM",
101 	"ZEND_UNSET_OBJ",
102 	"ZEND_FE_RESET_R",
103 	"ZEND_FE_FETCH_R",
104 	"ZEND_EXIT",
105 	"ZEND_FETCH_R",
106 	"ZEND_FETCH_DIM_R",
107 	"ZEND_FETCH_OBJ_R",
108 	"ZEND_FETCH_W",
109 	"ZEND_FETCH_DIM_W",
110 	"ZEND_FETCH_OBJ_W",
111 	"ZEND_FETCH_RW",
112 	"ZEND_FETCH_DIM_RW",
113 	"ZEND_FETCH_OBJ_RW",
114 	"ZEND_FETCH_IS",
115 	"ZEND_FETCH_DIM_IS",
116 	"ZEND_FETCH_OBJ_IS",
117 	"ZEND_FETCH_FUNC_ARG",
118 	"ZEND_FETCH_DIM_FUNC_ARG",
119 	"ZEND_FETCH_OBJ_FUNC_ARG",
120 	"ZEND_FETCH_UNSET",
121 	"ZEND_FETCH_DIM_UNSET",
122 	"ZEND_FETCH_OBJ_UNSET",
123 	"ZEND_FETCH_LIST",
124 	"ZEND_FETCH_CONSTANT",
125 	NULL,
126 	"ZEND_EXT_STMT",
127 	"ZEND_EXT_FCALL_BEGIN",
128 	"ZEND_EXT_FCALL_END",
129 	"ZEND_EXT_NOP",
130 	"ZEND_TICKS",
131 	"ZEND_SEND_VAR_NO_REF",
132 	"ZEND_CATCH",
133 	"ZEND_THROW",
134 	"ZEND_FETCH_CLASS",
135 	"ZEND_CLONE",
136 	"ZEND_RETURN_BY_REF",
137 	"ZEND_INIT_METHOD_CALL",
138 	"ZEND_INIT_STATIC_METHOD_CALL",
139 	"ZEND_ISSET_ISEMPTY_VAR",
140 	"ZEND_ISSET_ISEMPTY_DIM_OBJ",
141 	"ZEND_SEND_VAL_EX",
142 	"ZEND_SEND_VAR",
143 	"ZEND_INIT_USER_CALL",
144 	"ZEND_SEND_ARRAY",
145 	"ZEND_SEND_USER",
146 	"ZEND_STRLEN",
147 	"ZEND_DEFINED",
148 	"ZEND_TYPE_CHECK",
149 	"ZEND_VERIFY_RETURN_TYPE",
150 	"ZEND_FE_RESET_RW",
151 	"ZEND_FE_FETCH_RW",
152 	"ZEND_FE_FREE",
153 	"ZEND_INIT_DYNAMIC_CALL",
154 	"ZEND_DO_ICALL",
155 	"ZEND_DO_UCALL",
156 	"ZEND_DO_FCALL_BY_NAME",
157 	"ZEND_PRE_INC_OBJ",
158 	"ZEND_PRE_DEC_OBJ",
159 	"ZEND_POST_INC_OBJ",
160 	"ZEND_POST_DEC_OBJ",
161 	"ZEND_ASSIGN_OBJ",
162 	"ZEND_OP_DATA",
163 	"ZEND_INSTANCEOF",
164 	"ZEND_DECLARE_CLASS",
165 	"ZEND_DECLARE_INHERITED_CLASS",
166 	"ZEND_DECLARE_FUNCTION",
167 	"ZEND_YIELD_FROM",
168 	"ZEND_DECLARE_CONST",
169 	"ZEND_ADD_INTERFACE",
170 	"ZEND_DECLARE_INHERITED_CLASS_DELAYED",
171 	"ZEND_VERIFY_ABSTRACT_CLASS",
172 	"ZEND_ASSIGN_DIM",
173 	"ZEND_ISSET_ISEMPTY_PROP_OBJ",
174 	"ZEND_HANDLE_EXCEPTION",
175 	"ZEND_USER_OPCODE",
176 	"ZEND_ASSERT_CHECK",
177 	"ZEND_JMP_SET",
178 	"ZEND_DECLARE_LAMBDA_FUNCTION",
179 	"ZEND_ADD_TRAIT",
180 	"ZEND_BIND_TRAITS",
181 	"ZEND_SEPARATE",
182 	"ZEND_FETCH_CLASS_NAME",
183 	"ZEND_CALL_TRAMPOLINE",
184 	"ZEND_DISCARD_EXCEPTION",
185 	"ZEND_YIELD",
186 	"ZEND_GENERATOR_RETURN",
187 	"ZEND_FAST_CALL",
188 	"ZEND_FAST_RET",
189 	"ZEND_RECV_VARIADIC",
190 	"ZEND_SEND_UNPACK",
191 	"ZEND_POW",
192 	"ZEND_ASSIGN_POW",
193 	"ZEND_BIND_GLOBAL",
194 	"ZEND_COALESCE",
195 	"ZEND_SPACESHIP",
196 	"ZEND_DECLARE_ANON_CLASS",
197 	"ZEND_DECLARE_ANON_INHERITED_CLASS",
198 	"ZEND_FETCH_STATIC_PROP_R",
199 	"ZEND_FETCH_STATIC_PROP_W",
200 	"ZEND_FETCH_STATIC_PROP_RW",
201 	"ZEND_FETCH_STATIC_PROP_IS",
202 	"ZEND_FETCH_STATIC_PROP_FUNC_ARG",
203 	"ZEND_FETCH_STATIC_PROP_UNSET",
204 	"ZEND_UNSET_STATIC_PROP",
205 	"ZEND_ISSET_ISEMPTY_STATIC_PROP",
206 	"ZEND_FETCH_CLASS_CONSTANT",
207 	"ZEND_BIND_LEXICAL",
208 	"ZEND_BIND_STATIC",
209 	"ZEND_FETCH_THIS",
210 	NULL,
211 	"ZEND_ISSET_ISEMPTY_THIS",
212 	"ZEND_SWITCH_LONG",
213 	"ZEND_SWITCH_STRING",
214 	"ZEND_IN_ARRAY",
215 	"ZEND_COUNT",
216 	"ZEND_GET_CLASS",
217 	"ZEND_GET_CALLED_CLASS",
218 	"ZEND_GET_TYPE",
219 	"ZEND_FUNC_NUM_ARGS",
220 	"ZEND_FUNC_GET_ARGS",
221 	"ZEND_UNSET_CV",
222 	"ZEND_ISSET_ISEMPTY_CV",
223 };
224 
225 static uint32_t zend_vm_opcodes_flags[198] = {
226 	0x00000000,
227 	0x00000707,
228 	0x00000707,
229 	0x00000707,
230 	0x00000707,
231 	0x00000707,
232 	0x00000707,
233 	0x00000707,
234 	0x00000707,
235 	0x00000707,
236 	0x00000707,
237 	0x00000707,
238 	0x00000007,
239 	0x00000007,
240 	0x00000707,
241 	0x00000303,
242 	0x00000303,
243 	0x00000707,
244 	0x00000707,
245 	0x00000707,
246 	0x00000707,
247 	0x07000003,
248 	0x00000003,
249 	0x04006751,
250 	0x04006751,
251 	0x04006751,
252 	0x04006751,
253 	0x04006751,
254 	0x04006751,
255 	0x04006751,
256 	0x04006751,
257 	0x04006751,
258 	0x04006751,
259 	0x04006751,
260 	0x00000001,
261 	0x00000001,
262 	0x00000001,
263 	0x00000001,
264 	0x00000301,
265 	0x0b000101,
266 	0x00000007,
267 	0x00000000,
268 	0x00000020,
269 	0x00002007,
270 	0x00002007,
271 	0x03002007,
272 	0x00002007,
273 	0x00002007,
274 	0x00000707,
275 	0x00000101,
276 	0x00001001,
277 	0x00000101,
278 	0x00000007,
279 	0x00000707,
280 	0x01000701,
281 	0x01000701,
282 	0x01000701,
283 	0x00000000,
284 	0x00000001,
285 	0x01000300,
286 	0x00000000,
287 	0x01000310,
288 	0x00000003,
289 	0x00000010,
290 	0x00000310,
291 	0x00001007,
292 	0x00001001,
293 	0x00001001,
294 	0x01000073,
295 	0x01000300,
296 	0x00004005,
297 	0x00186703,
298 	0x00106703,
299 	0x08000007,
300 	0x00010107,
301 	0x00000701,
302 	0x00000751,
303 	0x00002003,
304 	0x03000001,
305 	0x00000007,
306 	0x00010107,
307 	0x00000707,
308 	0x00000753,
309 	0x00010107,
310 	0x00006701,
311 	0x00000751,
312 	0x00010107,
313 	0x00006701,
314 	0x00000751,
315 	0x00010107,
316 	0x00000707,
317 	0x00000757,
318 	0x00050107,
319 	0x01006703,
320 	0x01000753,
321 	0x00010107,
322 	0x00000701,
323 	0x00000751,
324 	0x00000707,
325 	0x06000301,
326 	0x00000000,
327 	0x00000000,
328 	0x00000000,
329 	0x00000000,
330 	0x00000000,
331 	0x01000000,
332 	0x00001001,
333 	0x03000103,
334 	0x00000003,
335 	0x05000700,
336 	0x00000057,
337 	0x0b000003,
338 	0x01000757,
339 	0x01008773,
340 	0x00030107,
341 	0x00020707,
342 	0x00001003,
343 	0x00001001,
344 	0x01000703,
345 	0x01000000,
346 	0x00001003,
347 	0x00000007,
348 	0x00000003,
349 	0x07000003,
350 	0x00000103,
351 	0x00002003,
352 	0x03000001,
353 	0x00004005,
354 	0x01000700,
355 	0x00000000,
356 	0x00000000,
357 	0x00000000,
358 	0x00000751,
359 	0x00000751,
360 	0x00000751,
361 	0x00000751,
362 	0x00000751,
363 	0x00000000,
364 	0x00007305,
365 	0x00000000,
366 	0x00000100,
367 	0x00000000,
368 	0x00000003,
369 	0x00000303,
370 	0x00000300,
371 	0x00000100,
372 	0x00000000,
373 	0x00006701,
374 	0x00020757,
375 	0x00000000,
376 	0x00000000,
377 	0x00002000,
378 	0x00002003,
379 	0x00000103,
380 	0x00000000,
381 	0x00000000,
382 	0x00000101,
383 	0x05000000,
384 	0x00000000,
385 	0x00000000,
386 	0x0b000303,
387 	0x00000003,
388 	0x00000020,
389 	0x00003000,
390 	0x00000010,
391 	0x00000000,
392 	0x00000707,
393 	0x04006751,
394 	0x00000301,
395 	0x00002003,
396 	0x00000707,
397 	0x03000000,
398 	0x03000100,
399 	0x00007307,
400 	0x00007307,
401 	0x00007307,
402 	0x00007307,
403 	0x01007307,
404 	0x00007307,
405 	0x00007307,
406 	0x00027307,
407 	0x00000373,
408 	0x00100101,
409 	0x00100301,
410 	0x00000101,
411 	0x00000000,
412 	0x00000101,
413 	0x03000307,
414 	0x03000307,
415 	0x01000303,
416 	0x00000103,
417 	0x00000103,
418 	0x00000101,
419 	0x00000103,
420 	0x00000101,
421 	0x00000103,
422 	0x00000101,
423 	0x00020101,
424 };
425 
zend_get_opcode_name(zend_uchar opcode)426 ZEND_API const char* zend_get_opcode_name(zend_uchar opcode) {
427 	return zend_vm_opcodes_names[opcode];
428 }
zend_get_opcode_flags(zend_uchar opcode)429 ZEND_API uint32_t zend_get_opcode_flags(zend_uchar opcode) {
430 	return zend_vm_opcodes_flags[opcode];
431 }
432