php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
zend_compile.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Zend Engine |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 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@php.net> |
16 | Zeev Suraski <zeev@php.net> |
17 +----------------------------------------------------------------------+
18*/
19
20#ifndef ZEND_COMPILE_H
21#define ZEND_COMPILE_H
22
23#include "zend_ast.h"
24#include "zend_types.h"
25#include "zend_map_ptr.h"
26#include "zend_alloc.h"
27
28#include <stdarg.h>
29#include <stdint.h>
30
31#include "zend_llist.h"
33#include "zend_property_hooks.h"
34
35#define SET_UNUSED(op) do { \
36 op ## _type = IS_UNUSED; \
37 op.num = (uint32_t) -1; \
38} while (0)
39
40#define MAKE_NOP(opline) do { \
41 (opline)->opcode = ZEND_NOP; \
42 SET_UNUSED((opline)->op1); \
43 SET_UNUSED((opline)->op2); \
44 SET_UNUSED((opline)->result); \
45} while (0)
46
47#define RESET_DOC_COMMENT() do { \
48 if (CG(doc_comment)) { \
49 zend_string_release_ex(CG(doc_comment), 0); \
50 CG(doc_comment) = NULL; \
51 } \
52} while (0)
53
55typedef struct _zend_op zend_op;
56
57/* On 64-bit systems less optimal, but more compact VM code leads to better
58 * performance. So on 32-bit systems we use absolute addresses for jump
59 * targets and constants, but on 64-bit systems relative 32-bit offsets */
60#if SIZEOF_SIZE_T == 4
61# define ZEND_USE_ABS_JMP_ADDR 1
62# define ZEND_USE_ABS_CONST_ADDR 1
63#else
64# define ZEND_USE_ABS_JMP_ADDR 0
65# define ZEND_USE_ABS_CONST_ADDR 0
66#endif
67
68typedef union _znode_op {
69 uint32_t constant;
70 uint32_t var;
71 uint32_t num;
72 uint32_t opline_num; /* Needs to be signed */
73#if ZEND_USE_ABS_JMP_ADDR
74 zend_op *jmp_addr;
75#else
76 uint32_t jmp_offset;
77#endif
78#if ZEND_USE_ABS_CONST_ADDR
79 zval *zv;
80#endif
82
83typedef struct _znode { /* used only during compilation */
84 uint8_t op_type;
85 uint8_t flag;
86 union {
88 zval constant; /* replaced by literal/zv */
89 } u;
91
98
100
101static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) {
102 return &((zend_ast_znode *) ast)->node;
103}
104
108
109/* Compilation context that is different for each file, but shared between op arrays. */
123
131
133void zend_const_expr_to_zval(zval *result, zend_ast **ast_ptr, bool allow_dynamic);
134
136
137struct _zend_op {
138 const void *handler;
143 uint32_t lineno;
144 uint8_t opcode; /* Opcodes defined in Zend/zend_vm_opcodes.h */
145 uint8_t op1_type; /* IS_UNUSED, IS_CONST, IS_TMP_VAR, IS_VAR, IS_CV */
146 uint8_t op2_type; /* IS_UNUSED, IS_CONST, IS_TMP_VAR, IS_VAR, IS_CV */
147 uint8_t result_type; /* IS_UNUSED, IS_CONST, IS_TMP_VAR, IS_VAR, IS_CV */
148#ifdef ZEND_VERIFY_TYPE_INFERENCE
149 uint32_t op1_use_type;
150 uint32_t op2_use_type;
151 uint32_t result_use_type;
152 uint32_t op1_def_type;
153 uint32_t op2_def_type;
154 uint32_t result_def_type;
155#endif
156};
157
158
166
167typedef struct _zend_label {
169 uint32_t opline_num;
171
173 uint32_t try_op;
174 uint32_t catch_op; /* ketchup! */
175 uint32_t finally_op;
176 uint32_t finally_end;
178
179#define ZEND_LIVE_TMPVAR 0
180#define ZEND_LIVE_LOOP 1
181#define ZEND_LIVE_SILENCE 2
182#define ZEND_LIVE_ROPE 3
183#define ZEND_LIVE_NEW 4
184#define ZEND_LIVE_MASK 7
185
186typedef struct _zend_live_range {
187 uint32_t var; /* low bits are used for variable type (ZEND_LIVE_* macros) */
188 uint32_t start;
189 uint32_t end;
191
193
194/* Compilation context that is different for each op array. */
211
212/* Class, property and method flags class|meth.|prop.|const*/
213/* | | | */
214/* Common flags | | | */
215/* ============ | | | */
216/* | | | */
217/* Visibility flags (public < protected < private) | | | */
218#define ZEND_ACC_PUBLIC (1 << 0) /* | X | X | X */
219#define ZEND_ACC_PROTECTED (1 << 1) /* | X | X | X */
220#define ZEND_ACC_PRIVATE (1 << 2) /* | X | X | X */
221/* | | | */
222/* Property or method overrides private one | | | */
223#define ZEND_ACC_CHANGED (1 << 3) /* | X | X | */
224/* | | | */
225/* Static method or property | | | */
226#define ZEND_ACC_STATIC (1 << 4) /* | X | X | */
227/* | | | */
228/* Final class or method | | | */
229#define ZEND_ACC_FINAL (1 << 5) /* X | X | X | X */
230/* | | | */
231/* Abstract method | | | */
232#define ZEND_ACC_ABSTRACT (1 << 6) /* X | X | X | */
233#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS (1 << 6) /* X | | | */
234/* | | | */
235/* Readonly property | | | */
236#define ZEND_ACC_READONLY (1 << 7) /* | | X | */
237/* | | | */
238/* Immutable op_array and class_entries | | | */
239/* (implemented only for lazy loading of op_arrays) | | | */
240#define ZEND_ACC_IMMUTABLE (1 << 7) /* X | X | | */
241/* | | | */
242/* Function has typed arguments / class has typed props | | | */
243#define ZEND_ACC_HAS_TYPE_HINTS (1 << 8) /* X | X | | */
244/* | | | */
245/* Top-level class or function declaration | | | */
246#define ZEND_ACC_TOP_LEVEL (1 << 9) /* X | X | | */
247/* | | | */
248/* op_array or class is preloaded | | | */
249#define ZEND_ACC_PRELOADED (1 << 10) /* X | X | | */
250/* | | | */
251/* Flag to differentiate cases from constants. | | | */
252/* Must not conflict with ZEND_ACC_ visibility flags | | | */
253/* or IS_CONSTANT_VISITED_MARK | | | */
254#define ZEND_CLASS_CONST_IS_CASE (1 << 6) /* | | | X */
255/* | | | */
256/* Property Flags (unused: 13...) | | | */
257/* =========== | | | */
258/* | | | */
259/* Promoted property / parameter | | | */
260#define ZEND_ACC_PROMOTED (1 << 8) /* | | X | */
261/* | | | */
262/* Virtual property without backing storage | | | */
263#define ZEND_ACC_VIRTUAL (1 << 9) /* | | X | */
264/* | | | */
265/* Asymmetric visibility | | | */
266#define ZEND_ACC_PUBLIC_SET (1 << 10) /* | | X | */
267#define ZEND_ACC_PROTECTED_SET (1 << 11) /* | | X | */
268#define ZEND_ACC_PRIVATE_SET (1 << 12) /* | | X | */
269/* | | | */
270/* Class Flags (unused: 30,31) | | | */
271/* =========== | | | */
272/* | | | */
273/* Special class types | | | */
274#define ZEND_ACC_INTERFACE (1 << 0) /* X | | | */
275#define ZEND_ACC_TRAIT (1 << 1) /* X | | | */
276#define ZEND_ACC_ANON_CLASS (1 << 2) /* X | | | */
277#define ZEND_ACC_ENUM (1 << 28) /* X | | | */
278/* | | | */
279/* Class linked with parent, interfaces and traits | | | */
280#define ZEND_ACC_LINKED (1 << 3) /* X | | | */
281/* | | | */
282/* Class is abstract, since it is set by any | | | */
283/* abstract method | | | */
284#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS (1 << 4) /* X | | | */
285/* | | | */
286/* Class has magic methods __get/__set/__unset/ | | | */
287/* __isset that use guards | | | */
288#define ZEND_ACC_USE_GUARDS (1 << 11) /* X | | | */
289/* | | | */
290/* Class constants updated | | | */
291#define ZEND_ACC_CONSTANTS_UPDATED (1 << 12) /* X | | | */
292/* | | | */
293/* Objects of this class may not have dynamic properties | | | */
294#define ZEND_ACC_NO_DYNAMIC_PROPERTIES (1 << 13) /* X | | | */
295/* | | | */
296/* User class has methods with static variables | | | */
297#define ZEND_HAS_STATIC_IN_METHODS (1 << 14) /* X | | | */
298/* | | | */
299/* Objects of this class may have dynamic properties | | | */
300/* without triggering a deprecation warning | | | */
301#define ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES (1 << 15) /* X | | | */
302/* | | | */
303/* Readonly class | | | */
304#define ZEND_ACC_READONLY_CLASS (1 << 16) /* X | | | */
305/* | | | */
306/* Parent class is resolved (CE). | | | */
307#define ZEND_ACC_RESOLVED_PARENT (1 << 17) /* X | | | */
308/* | | | */
309/* Interfaces are resolved (CEs). | | | */
310#define ZEND_ACC_RESOLVED_INTERFACES (1 << 18) /* X | | | */
311/* | | | */
312/* Class has unresolved variance obligations. | | | */
313#define ZEND_ACC_UNRESOLVED_VARIANCE (1 << 19) /* X | | | */
314/* | | | */
315/* Class is linked apart from variance obligations. | | | */
316#define ZEND_ACC_NEARLY_LINKED (1 << 20) /* X | | | */
317/* Class has readonly props | | | */
318#define ZEND_ACC_HAS_READONLY_PROPS (1 << 21) /* X | | | */
319/* | | | */
320/* stored in opcache (may be partially) | | | */
321#define ZEND_ACC_CACHED (1 << 22) /* X | | | */
322/* | | | */
323/* temporary flag used during delayed variance checks | | | */
324#define ZEND_ACC_CACHEABLE (1 << 23) /* X | | | */
325/* | | | */
326#define ZEND_ACC_HAS_AST_CONSTANTS (1 << 24) /* X | | | */
327#define ZEND_ACC_HAS_AST_PROPERTIES (1 << 25) /* X | | | */
328#define ZEND_ACC_HAS_AST_STATICS (1 << 26) /* X | | | */
329/* | | | */
330/* loaded from file cache to process memory | | | */
331#define ZEND_ACC_FILE_CACHED (1 << 27) /* X | | | */
332/* | | | */
333/* Class cannot be serialized or unserialized | | | */
334#define ZEND_ACC_NOT_SERIALIZABLE (1 << 29) /* X | | | */
335/* | | | */
336/* Function Flags (unused: 29-30) | | | */
337/* ============== | | | */
338/* | | | */
339/* deprecation flag | | | */
340#define ZEND_ACC_DEPRECATED (1 << 11) /* | X | | X */
341/* | | | */
342/* Function returning by reference | | | */
343#define ZEND_ACC_RETURN_REFERENCE (1 << 12) /* | X | | */
344/* | | | */
345/* Function has a return type | | | */
346#define ZEND_ACC_HAS_RETURN_TYPE (1 << 13) /* | X | | */
347/* | | | */
348/* Function with variable number of arguments | | | */
349#define ZEND_ACC_VARIADIC (1 << 14) /* | X | | */
350/* | | | */
351/* op_array has finally blocks (user only) | | | */
352#define ZEND_ACC_HAS_FINALLY_BLOCK (1 << 15) /* | X | | */
353/* | | | */
354/* "main" op_array with | | | */
355/* ZEND_DECLARE_CLASS_DELAYED opcodes | | | */
356#define ZEND_ACC_EARLY_BINDING (1 << 16) /* | X | | */
357/* | | | */
358/* closure uses $this | | | */
359#define ZEND_ACC_USES_THIS (1 << 17) /* | X | | */
360/* | | | */
361/* call through user function trampoline. e.g. | | | */
362/* __call, __callstatic | | | */
363#define ZEND_ACC_CALL_VIA_TRAMPOLINE (1 << 18) /* | X | | */
364/* | | | */
365/* disable inline caching | | | */
366#define ZEND_ACC_NEVER_CACHE (1 << 19) /* | X | | */
367/* | | | */
368/* op_array is a clone of trait method | | | */
369#define ZEND_ACC_TRAIT_CLONE (1 << 20) /* | X | | */
370/* | | | */
371/* functions is a constructor | | | */
372#define ZEND_ACC_CTOR (1 << 21) /* | X | | */
373/* | | | */
374/* Closure related | | | */
375#define ZEND_ACC_CLOSURE (1 << 22) /* | X | | */
376#define ZEND_ACC_FAKE_CLOSURE (1 << 23) /* | X | | */ /* Same as ZEND_CALL_FAKE_CLOSURE */
377/* | | | */
378#define ZEND_ACC_GENERATOR (1 << 24) /* | X | | */
379/* | | | */
380/* function was processed by pass two (user only) | | | */
381#define ZEND_ACC_DONE_PASS_TWO (1 << 25) /* | X | | */
382/* | | | */
383/* internal function is allocated at arena (int only) | | | */
384#define ZEND_ACC_ARENA_ALLOCATED (1 << 25) /* | X | | */
385/* | | | */
386/* run_time_cache allocated on heap (user only) | | | */
387#define ZEND_ACC_HEAP_RT_CACHE (1 << 26) /* | X | | */
388/* | | | */
389/* method flag used by Closure::__invoke() (int only) | | | */
390#define ZEND_ACC_USER_ARG_INFO (1 << 26) /* | X | | */
391/* | | | */
392/* supports opcache compile-time evaluation (funcs) | | | */
393#define ZEND_ACC_COMPILE_TIME_EVAL (1 << 27) /* | X | | */
394/* | | | */
395/* has #[\Override] attribute | | | */
396#define ZEND_ACC_OVERRIDE (1 << 28) /* | X | | */
397/* | | | */
398/* op_array uses strict mode types | | | */
399#define ZEND_ACC_STRICT_TYPES (1U << 31) /* | X | | */
400
401#define ZEND_ACC_PPP_MASK (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE)
402#define ZEND_ACC_PPP_SET_MASK (ZEND_ACC_PUBLIC_SET | ZEND_ACC_PROTECTED_SET | ZEND_ACC_PRIVATE_SET)
403
404static zend_always_inline uint32_t zend_visibility_to_set_visibility(uint32_t visibility)
405{
406 switch (visibility) {
407 case ZEND_ACC_PUBLIC:
408 return ZEND_ACC_PUBLIC_SET;
411 case ZEND_ACC_PRIVATE:
414 }
415}
416
417/* call through internal function handler. e.g. Closure::invoke() */
418#define ZEND_ACC_CALL_VIA_HANDLER ZEND_ACC_CALL_VIA_TRAMPOLINE
419
420#define ZEND_ACC_UNINSTANTIABLE ( \
421 ZEND_ACC_INTERFACE | \
422 ZEND_ACC_TRAIT | \
423 ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | \
424 ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | \
425 ZEND_ACC_ENUM \
426)
427
428#define ZEND_SHORT_CIRCUITING_CHAIN_MASK 0x3
429#define ZEND_SHORT_CIRCUITING_CHAIN_EXPR 0
430#define ZEND_SHORT_CIRCUITING_CHAIN_ISSET 1
431#define ZEND_SHORT_CIRCUITING_CHAIN_EMPTY 2
432
433// Must not clash with ZEND_SHORT_CIRCUITING_CHAIN_MASK
434#define ZEND_JMP_NULL_BP_VAR_IS 4
435
436char *zend_visibility_string(uint32_t fn_flags);
437
438#define ZEND_PROPERTY_HOOK_COUNT 2
439#define ZEND_PROPERTY_HOOK_STRUCT_SIZE (sizeof(zend_function*) * ZEND_PROPERTY_HOOK_COUNT)
440
441/* Stored in zend_property_info.offset, not returned by zend_get_property_offset(). */
442#define ZEND_VIRTUAL_PROPERTY_OFFSET ((uint32_t)-1)
443
445
446typedef struct _zend_property_info {
447 uint32_t offset; /* property offset for object properties or
448 property index for static properties */
449 uint32_t flags;
458
459#define OBJ_PROP(obj, offset) \
460 ((zval*)((char*)(obj) + offset))
461#define OBJ_PROP_NUM(obj, num) \
462 (&(obj)->properties_table[(num)])
463#define OBJ_PROP_TO_OFFSET(num) \
464 ((uint32_t)(XtOffsetOf(zend_object, properties_table) + sizeof(zval) * (num)))
465#define OBJ_PROP_TO_NUM(offset) \
466 (((offset) - OBJ_PROP_TO_OFFSET(0)) / sizeof(zval))
467#define OBJ_PROP_SLOT_TO_OFFSET(obj, slot) \
468 ((uintptr_t)(slot) - (uintptr_t)(obj))
469
477
478#define ZEND_CLASS_CONST_FLAGS(c) Z_CONSTANT_FLAGS((c)->value)
479
480/* arg_info for internal functions */
486
487/* arg_info for user functions */
493
494/* the following structure repeats the layout of zend_internal_arg_info,
495 * but its fields have different meaning. It's used as the first element of
496 * arg_info array to define properties of internal functions.
497 * It's also used for the return type.
498 */
504
506 /* Common elements */
507 uint8_t type;
508 uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */
509 uint32_t fn_flags;
513 uint32_t num_args;
517 ZEND_MAP_PTR_DEF(void **, run_time_cache);
519 uint32_t T; /* number of temporary variables */
520 const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */
521 /* END of common elements */
522
523 int cache_size; /* number of run_time_cache_slots * sizeof(void*) */
524 int last_var; /* number of CV variables */
525 uint32_t last; /* number of opcodes */
526
528 ZEND_MAP_PTR_DEF(HashTable *, static_variables_ptr);
530 zend_string **vars; /* names of CV variables */
531
532 uint32_t *refcount;
533
538
540 uint32_t line_start;
541 uint32_t line_end;
542
546
547 /* Functions that are declared dynamically are stored here and
548 * referenced by index from opcodes. */
550
552};
553
554
555#define ZEND_RETURN_VALUE 0
556#define ZEND_RETURN_REFERENCE 1
557
558#define INTERNAL_FUNCTION_PARAMETERS zend_execute_data *execute_data, zval *return_value
559#define INTERNAL_FUNCTION_PARAM_PASSTHRU execute_data, return_value
560
561/* zend_internal_function_handler */
563
565 /* Common elements */
566 uint8_t type;
567 uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */
568 uint32_t fn_flags;
572 uint32_t num_args;
576 ZEND_MAP_PTR_DEF(void **, run_time_cache);
578 uint32_t T; /* number of temporary variables */
579 const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */
580 /* END of common elements */
581
587
588#define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ? ZSTR_VAL((function)->common.scope->name) : "")
589
591 uint8_t type; /* MUST be the first element of this struct! */
593
594 struct {
595 uint8_t type; /* never used */
596 uint8_t arg_flags[3]; /* bitset of arg_info.pass_by_reference */
597 uint32_t fn_flags;
601 uint32_t num_args;
603 zend_arg_info *arg_info; /* index -1 represents the return value info, if any */
605 ZEND_MAP_PTR_DEF(void **, run_time_cache);
607 uint32_t T; /* number of temporary variables */
608 const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */
610
613};
614
616 const zend_op *opline; /* executed opline */
617 zend_execute_data *call; /* current call */
619 zend_function *func; /* executed function */
620 zval This; /* this + call_info + num_args */
623 void **run_time_cache; /* cache op_array->run_time_cache */
625};
626
627#define ZEND_CALL_HAS_THIS IS_OBJECT_EX
628
629/* Top 16 bits of Z_TYPE_INFO(EX(This)) are used as call_info flags */
630#define ZEND_CALL_FUNCTION (0 << 16)
631#define ZEND_CALL_CODE (1 << 16)
632#define ZEND_CALL_NESTED (0 << 17)
633#define ZEND_CALL_TOP (1 << 17)
634#define ZEND_CALL_ALLOCATED (1 << 18)
635#define ZEND_CALL_FREE_EXTRA_ARGS (1 << 19)
636#define ZEND_CALL_HAS_SYMBOL_TABLE (1 << 20)
637#define ZEND_CALL_RELEASE_THIS (1 << 21)
638#define ZEND_CALL_CLOSURE (1 << 22)
639#define ZEND_CALL_FAKE_CLOSURE (1 << 23) /* Same as ZEND_ACC_FAKE_CLOSURE */
640#define ZEND_CALL_GENERATOR (1 << 24)
641#define ZEND_CALL_DYNAMIC (1 << 25)
642#define ZEND_CALL_MAY_HAVE_UNDEF (1 << 26)
643#define ZEND_CALL_HAS_EXTRA_NAMED_PARAMS (1 << 27)
644#define ZEND_CALL_OBSERVED (1 << 28) /* "fcall_begin" observer handler may set this flag */
645 /* to prevent optimization in RETURN handler and */
646 /* keep all local variables for "fcall_end" handler */
647#define ZEND_CALL_JIT_RESERVED (1 << 29) /* reserved for tracing JIT */
648#define ZEND_CALL_NEEDS_REATTACH (1 << 30)
649#define ZEND_CALL_SEND_ARG_BY_REF (1u << 31)
650
651#define ZEND_CALL_NESTED_FUNCTION (ZEND_CALL_FUNCTION | ZEND_CALL_NESTED)
652#define ZEND_CALL_NESTED_CODE (ZEND_CALL_CODE | ZEND_CALL_NESTED)
653#define ZEND_CALL_TOP_FUNCTION (ZEND_CALL_TOP | ZEND_CALL_FUNCTION)
654#define ZEND_CALL_TOP_CODE (ZEND_CALL_CODE | ZEND_CALL_TOP)
655
656#define ZEND_CALL_INFO(call) \
657 Z_TYPE_INFO((call)->This)
658
659#define ZEND_CALL_KIND_EX(call_info) \
660 (call_info & (ZEND_CALL_CODE | ZEND_CALL_TOP))
661
662#define ZEND_CALL_KIND(call) \
663 ZEND_CALL_KIND_EX(ZEND_CALL_INFO(call))
664
665#define ZEND_ADD_CALL_FLAG_EX(call_info, flag) do { \
666 call_info |= (flag); \
667 } while (0)
668
669#define ZEND_DEL_CALL_FLAG_EX(call_info, flag) do { \
670 call_info &= ~(flag); \
671 } while (0)
672
673#define ZEND_ADD_CALL_FLAG(call, flag) do { \
674 ZEND_ADD_CALL_FLAG_EX(Z_TYPE_INFO((call)->This), flag); \
675 } while (0)
676
677#define ZEND_DEL_CALL_FLAG(call, flag) do { \
678 ZEND_DEL_CALL_FLAG_EX(Z_TYPE_INFO((call)->This), flag); \
679 } while (0)
680
681#define ZEND_CALL_NUM_ARGS(call) \
682 (call)->This.u2.num_args
683
684/* Ensure the correct alignment before slots calculation */
686 "zval must be aligned by ZEND_MM_ALIGNMENT");
687/* A number of call frame slots (zvals) reserved for zend_execute_data. */
688#define ZEND_CALL_FRAME_SLOT \
689 ((int)((sizeof(zend_execute_data) + sizeof(zval) - 1) / sizeof(zval)))
690
691#define ZEND_CALL_VAR(call, n) \
692 ((zval*)(((char*)(call)) + ((int)(n))))
693
694#define ZEND_CALL_VAR_NUM(call, n) \
695 (((zval*)(call)) + (ZEND_CALL_FRAME_SLOT + ((int)(n))))
696
697#define ZEND_CALL_ARG(call, n) \
698 ZEND_CALL_VAR_NUM(call, ((int)(n)) - 1)
699
700#define EX(element) ((execute_data)->element)
701
702#define EX_CALL_INFO() ZEND_CALL_INFO(execute_data)
703#define EX_CALL_KIND() ZEND_CALL_KIND(execute_data)
704#define EX_NUM_ARGS() ZEND_CALL_NUM_ARGS(execute_data)
705
706#define ZEND_CALL_USES_STRICT_TYPES(call) \
707 (((call)->func->common.fn_flags & ZEND_ACC_STRICT_TYPES) != 0)
708
709#define EX_USES_STRICT_TYPES() \
710 ZEND_CALL_USES_STRICT_TYPES(execute_data)
711
712#define ZEND_ARG_USES_STRICT_TYPES() \
713 (EG(current_execute_data)->prev_execute_data && \
714 EG(current_execute_data)->prev_execute_data->func && \
715 ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data)->prev_execute_data))
716
717#define ZEND_FLF_ARG_USES_STRICT_TYPES() \
718 (EG(current_execute_data) && \
719 EG(current_execute_data)->func && \
720 ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data)))
721
722#define ZEND_RET_USES_STRICT_TYPES() \
723 ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))
724
725#define EX_VAR(n) ZEND_CALL_VAR(execute_data, n)
726#define EX_VAR_NUM(n) ZEND_CALL_VAR_NUM(execute_data, n)
727
728#define EX_VAR_TO_NUM(n) ((uint32_t)((n) / sizeof(zval) - ZEND_CALL_FRAME_SLOT))
729#define EX_NUM_TO_VAR(n) ((uint32_t)(((n) + ZEND_CALL_FRAME_SLOT) * sizeof(zval)))
730
731#define ZEND_OPLINE_TO_OFFSET(opline, target) \
732 ((char*)(target) - (char*)(opline))
733
734#define ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline_num) \
735 ((char*)&(op_array)->opcodes[opline_num] - (char*)(opline))
736
737#define ZEND_OFFSET_TO_OPLINE(base, offset) \
738 ((zend_op*)(((char*)(base)) + (int)offset))
739
740#define ZEND_OFFSET_TO_OPLINE_NUM(op_array, base, offset) \
741 (ZEND_OFFSET_TO_OPLINE(base, offset) - op_array->opcodes)
742
743#if ZEND_USE_ABS_JMP_ADDR
744
745/* run-time jump target */
746# define OP_JMP_ADDR(opline, node) \
747 (node).jmp_addr
748
749# define ZEND_SET_OP_JMP_ADDR(opline, node, val) do { \
750 (node).jmp_addr = (val); \
751 } while (0)
752
753/* convert jump target from compile-time to run-time */
754# define ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, node) do { \
755 (node).jmp_addr = (op_array)->opcodes + (node).opline_num; \
756 } while (0)
757
758/* convert jump target back from run-time to compile-time */
759# define ZEND_PASS_TWO_UNDO_JMP_TARGET(op_array, opline, node) do { \
760 (node).opline_num = (node).jmp_addr - (op_array)->opcodes; \
761 } while (0)
762
763#else
764
765/* run-time jump target */
766# define OP_JMP_ADDR(opline, node) \
767 ZEND_OFFSET_TO_OPLINE(opline, (node).jmp_offset)
768
769# define ZEND_SET_OP_JMP_ADDR(opline, node, val) do { \
770 (node).jmp_offset = ZEND_OPLINE_TO_OFFSET(opline, val); \
771 } while (0)
772
773/* convert jump target from compile-time to run-time */
774# define ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, node) do { \
775 (node).jmp_offset = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, (node).opline_num); \
776 } while (0)
777
778/* convert jump target back from run-time to compile-time */
779# define ZEND_PASS_TWO_UNDO_JMP_TARGET(op_array, opline, node) do { \
780 (node).opline_num = ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, (node).jmp_offset); \
781 } while (0)
782
783#endif
784
785/* constant-time constant */
786# define CT_CONSTANT_EX(op_array, num) \
787 ((op_array)->literals + (num))
788
789# define CT_CONSTANT(node) \
790 CT_CONSTANT_EX(CG(active_op_array), (node).constant)
791
792#if ZEND_USE_ABS_CONST_ADDR
793
794/* run-time constant */
795# define RT_CONSTANT(opline, node) \
796 (node).zv
797
798/* convert constant from compile-time to run-time */
799# define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, node) do { \
800 (node).zv = CT_CONSTANT_EX(op_array, (node).constant); \
801 } while (0)
802
803#else
804
805/* At run-time, constants are allocated together with op_array->opcodes
806 * and addressed relatively to current opline.
807 */
808
809/* run-time constant */
810# define RT_CONSTANT(opline, node) \
811 ((zval*)(((char*)(opline)) + (int32_t)(node).constant))
812
813/* convert constant from compile-time to run-time */
814# define ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, node) do { \
815 (node).constant = \
816 (((char*)CT_CONSTANT_EX(op_array, (node).constant)) - \
817 ((char*)opline)); \
818 } while (0)
819
820#endif
821
822/* convert constant back from run-time to compile-time */
823#define ZEND_PASS_TWO_UNDO_CONSTANT(op_array, opline, node) do { \
824 (node).constant = RT_CONSTANT(opline, node) - (op_array)->literals; \
825 } while (0)
826
827#define RUN_TIME_CACHE(op_array) \
828 ZEND_MAP_PTR_GET((op_array)->run_time_cache)
829
830#define ZEND_OP_ARRAY_EXTENSION(op_array, handle) \
831 ((void**)RUN_TIME_CACHE(op_array))[handle]
832
833#define IS_UNUSED 0 /* Unused operand */
834#define IS_CONST (1<<0)
835#define IS_TMP_VAR (1<<1)
836#define IS_VAR (1<<2)
837#define IS_CV (1<<3) /* Compiled variable */
838
839/* Used for result.type of smart branch instructions */
840#define IS_SMART_BRANCH_JMPZ (1<<4)
841#define IS_SMART_BRANCH_JMPNZ (1<<5)
842
843#define ZEND_EXTRA_VALUE 1
844
845#include "zend_globals.h"
846
852
854
855void init_compiler(void);
856void shutdown_compiler(void);
858
862void zend_file_context_end(zend_file_context *prev_context);
863
864extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
865extern ZEND_API zend_op_array *(*zend_compile_string)(zend_string *source_string, const char *filename, zend_compile_position position);
866
870
872ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename);
876
878
879#ifdef ZTS
880const char *zend_get_zendtext(void);
881int zend_get_zendleng(void);
882#endif
883
886
889
890void zend_stop_lexing(void);
891void zend_emit_final_return(bool return_one);
892
900
901/* Used during AST construction */
904uint32_t zend_add_class_modifier(uint32_t flags, uint32_t new_flag);
905uint32_t zend_add_anonymous_class_modifier(uint32_t flags, uint32_t new_flag);
906uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag, zend_modifier_target target);
907
910
912
914 zval *class_table_slot, zval *lcname, zend_string *lc_parent_name);
917
918void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline);
919
922
923#define INITIAL_OP_ARRAY_SIZE 64
924
925
926/* helper functions in zend_language_scanner.l */
927struct _zend_arena;
928
930ZEND_API zend_op_array *compile_string(zend_string *source_string, const char *filename, zend_compile_position position);
933 zend_string *code, struct _zend_arena **ast_arena, zend_string *filename);
934ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count, ...);
937ZEND_API void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size);
945
946
948
949#define zend_try_exception_handler() do { \
950 if (UNEXPECTED(EG(exception))) { \
951 if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) { \
952 zend_user_exception_handler(); \
953 } \
954 } \
955 } while (0)
956
962
963ZEND_API zend_string *zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal);
964#define zend_unmangle_property_name(mangled_property, class_name, prop_name) \
965 zend_unmangle_property_name_ex(mangled_property, class_name, prop_name, NULL)
966ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len);
967
968static zend_always_inline const char *zend_get_unmangled_property_name(const zend_string *mangled_prop) {
969 const char *class_name, *prop_name;
970 zend_unmangle_property_name(mangled_prop, &class_name, &prop_name);
971 return prop_name;
972}
973
974#define ZEND_FUNCTION_DTOR zend_function_dtor
975#define ZEND_CLASS_DTOR destroy_zend_class
976
977typedef bool (*zend_needs_live_range_cb)(zend_op_array *op_array, zend_op *opline);
979 zend_op_array *op_array, zend_needs_live_range_cb needs_live_range);
980
981ZEND_API void pass_two(zend_op_array *op_array);
982ZEND_API bool zend_is_compiling(void);
984ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_handlers);
986ZEND_API uint8_t zend_get_call_op(const zend_op *init_op, zend_function *fbc);
987ZEND_API bool zend_is_smart_branch(const zend_op *opline);
988
996
1000ZEND_API bool zend_is_auto_global_str(const char *name, size_t len);
1001ZEND_API size_t zend_dirname(char *path, size_t len);
1003
1005
1006void zend_assert_valid_class_name(const zend_string *const_name, const char *type);
1007
1010
1011/* BEGIN: OPCODES */
1012
1013#include "zend_vm_opcodes.h"
1014
1015/* END: OPCODES */
1016
1017/* class fetches */
1018#define ZEND_FETCH_CLASS_DEFAULT 0
1019#define ZEND_FETCH_CLASS_SELF 1
1020#define ZEND_FETCH_CLASS_PARENT 2
1021#define ZEND_FETCH_CLASS_STATIC 3
1022#define ZEND_FETCH_CLASS_AUTO 4
1023#define ZEND_FETCH_CLASS_INTERFACE 5
1024#define ZEND_FETCH_CLASS_TRAIT 6
1025#define ZEND_FETCH_CLASS_MASK 0x0f
1026#define ZEND_FETCH_CLASS_NO_AUTOLOAD 0x80
1027#define ZEND_FETCH_CLASS_SILENT 0x0100
1028#define ZEND_FETCH_CLASS_EXCEPTION 0x0200
1029#define ZEND_FETCH_CLASS_ALLOW_UNLINKED 0x0400
1030#define ZEND_FETCH_CLASS_ALLOW_NEARLY_LINKED 0x0800
1031
1032/* These should not clash with ZEND_ACC_PPP_MASK and ZEND_ACC_PPP_SET_MASK */
1033#define ZEND_PARAM_REF (1<<3)
1034#define ZEND_PARAM_VARIADIC (1<<4)
1035
1036#define ZEND_NAME_FQ 0
1037#define ZEND_NAME_NOT_FQ 1
1038#define ZEND_NAME_RELATIVE 2
1039
1040/* ZEND_FETCH_ flags in class name AST of new const expression must not clash with ZEND_NAME_ flags */
1041#define ZEND_CONST_EXPR_NEW_FETCH_TYPE_SHIFT 2
1042
1043#define ZEND_TYPE_NULLABLE (1<<8)
1044
1045#define ZEND_ARRAY_SYNTAX_LIST 1 /* list() */
1046#define ZEND_ARRAY_SYNTAX_LONG 2 /* array() */
1047#define ZEND_ARRAY_SYNTAX_SHORT 3 /* [] */
1048
1049/* var status for backpatching */
1050#define BP_VAR_R 0
1051#define BP_VAR_W 1
1052#define BP_VAR_RW 2
1053#define BP_VAR_IS 3
1054#define BP_VAR_FUNC_ARG 4
1055#define BP_VAR_UNSET 5
1056
1057#define ZEND_INTERNAL_FUNCTION 1
1058#define ZEND_USER_FUNCTION 2
1059#define ZEND_EVAL_CODE 4
1060
1061#define ZEND_USER_CODE(type) ((type) != ZEND_INTERNAL_FUNCTION)
1062
1063#define ZEND_INTERNAL_CLASS 1
1064#define ZEND_USER_CLASS 2
1065
1066#define ZEND_EVAL (1<<0)
1067#define ZEND_INCLUDE (1<<1)
1068#define ZEND_INCLUDE_ONCE (1<<2)
1069#define ZEND_REQUIRE (1<<3)
1070#define ZEND_REQUIRE_ONCE (1<<4)
1071
1072/* global/local fetches */
1073#define ZEND_FETCH_GLOBAL (1<<1)
1074#define ZEND_FETCH_LOCAL (1<<2)
1075#define ZEND_FETCH_GLOBAL_LOCK (1<<3)
1076
1077#define ZEND_FETCH_TYPE_MASK 0xe
1078
1079/* Only one of these can ever be in use */
1080#define ZEND_FETCH_REF 1
1081#define ZEND_FETCH_DIM_WRITE 2
1082#define ZEND_FETCH_OBJ_FLAGS 3
1083
1084/* Used to mark what kind of operation a writing FETCH_DIM is used in,
1085 * to produce a more precise error on incorrect string offset use. */
1086#define ZEND_FETCH_DIM_REF 1
1087#define ZEND_FETCH_DIM_DIM 2
1088#define ZEND_FETCH_DIM_OBJ 3
1089#define ZEND_FETCH_DIM_INCDEC 4
1090
1091#define ZEND_ISEMPTY (1<<0)
1092
1093#define ZEND_LAST_CATCH (1<<0)
1094
1095#define ZEND_FREE_ON_RETURN (1<<0)
1096#define ZEND_FREE_SWITCH (1<<1)
1097
1098#define ZEND_SEND_BY_VAL 0u
1099#define ZEND_SEND_BY_REF 1u
1100#define ZEND_SEND_PREFER_REF 2u
1101
1102#define ZEND_THROW_IS_EXPR 1u
1103
1104#define ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS 1
1105
1106/* The send mode, the is_variadic, the is_promoted, and the is_tentative flags are stored as part of zend_type */
1107#define _ZEND_SEND_MODE_SHIFT _ZEND_TYPE_EXTRA_FLAGS_SHIFT
1108#define _ZEND_IS_VARIADIC_BIT (1 << (_ZEND_TYPE_EXTRA_FLAGS_SHIFT + 2))
1109#define _ZEND_IS_PROMOTED_BIT (1 << (_ZEND_TYPE_EXTRA_FLAGS_SHIFT + 3))
1110#define _ZEND_IS_TENTATIVE_BIT (1 << (_ZEND_TYPE_EXTRA_FLAGS_SHIFT + 4))
1111#define ZEND_ARG_SEND_MODE(arg_info) \
1112 ((ZEND_TYPE_FULL_MASK((arg_info)->type) >> _ZEND_SEND_MODE_SHIFT) & 3)
1113#define ZEND_ARG_IS_VARIADIC(arg_info) \
1114 ((ZEND_TYPE_FULL_MASK((arg_info)->type) & _ZEND_IS_VARIADIC_BIT) != 0)
1115#define ZEND_ARG_IS_PROMOTED(arg_info) \
1116 ((ZEND_TYPE_FULL_MASK((arg_info)->type) & _ZEND_IS_PROMOTED_BIT) != 0)
1117#define ZEND_ARG_TYPE_IS_TENTATIVE(arg_info) \
1118 ((ZEND_TYPE_FULL_MASK((arg_info)->type) & _ZEND_IS_TENTATIVE_BIT) != 0)
1119
1120#define ZEND_DIM_IS (1 << 0) /* isset fetch needed for null coalesce. Set in zend_compile.c for ZEND_AST_DIM nested within ZEND_AST_COALESCE. */
1121
1122/* Attributes for ${} encaps var in strings (ZEND_AST_DIM or ZEND_AST_VAR node) */
1123/* ZEND_AST_VAR nodes can have any of the ZEND_ENCAPS_VAR_* flags */
1124/* ZEND_AST_DIM flags can have ZEND_ENCAPS_VAR_DOLLAR_CURLY during the parse phase. */
1125#define ZEND_ENCAPS_VAR_DOLLAR_CURLY (1 << 0)
1126#define ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR (1 << 1)
1127
1128/* Make sure these don't clash with ZEND_FETCH_CLASS_* flags. */
1129#define IS_CONSTANT_CLASS 0x400 /* __CLASS__ in trait */
1130#define IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE 0x800
1131
1132static zend_always_inline bool zend_check_arg_send_type(const zend_function *zf, uint32_t arg_num, uint32_t mask)
1133{
1134 arg_num--;
1135 if (UNEXPECTED(arg_num >= zf->common.num_args)) {
1136 if (EXPECTED((zf->common.fn_flags & ZEND_ACC_VARIADIC) == 0)) {
1137 return 0;
1138 }
1139 arg_num = zf->common.num_args;
1140 }
1141 return UNEXPECTED((ZEND_ARG_SEND_MODE(&zf->common.arg_info[arg_num]) & mask) != 0);
1142}
1143
1144#define ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
1145 zend_check_arg_send_type(zf, arg_num, ZEND_SEND_BY_REF)
1146
1147#define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
1148 zend_check_arg_send_type(zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF)
1149
1150#define ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
1151 zend_check_arg_send_type(zf, arg_num, ZEND_SEND_PREFER_REF)
1152
1153/* Quick API to check first 12 arguments */
1154#define MAX_ARG_FLAG_NUM 12
1155
1156#ifdef WORDS_BIGENDIAN
1157# define ZEND_SET_ARG_FLAG(zf, arg_num, mask) do { \
1158 (zf)->quick_arg_flags |= ((mask) << ((arg_num) - 1) * 2); \
1159 } while (0)
1160# define ZEND_CHECK_ARG_FLAG(zf, arg_num, mask) \
1161 (((zf)->quick_arg_flags >> (((arg_num) - 1) * 2)) & (mask))
1162#else
1163# define ZEND_SET_ARG_FLAG(zf, arg_num, mask) do { \
1164 (zf)->quick_arg_flags |= (((mask) << 6) << (arg_num) * 2); \
1165 } while (0)
1166# define ZEND_CHECK_ARG_FLAG(zf, arg_num, mask) \
1167 (((zf)->quick_arg_flags >> (((arg_num) + 3) * 2)) & (mask))
1168#endif
1169
1170#define QUICK_ARG_MUST_BE_SENT_BY_REF(zf, arg_num) \
1171 ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_BY_REF)
1172
1173#define QUICK_ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \
1174 ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_BY_REF|ZEND_SEND_PREFER_REF)
1175
1176#define QUICK_ARG_MAY_BE_SENT_BY_REF(zf, arg_num) \
1177 ZEND_CHECK_ARG_FLAG(zf, arg_num, ZEND_SEND_PREFER_REF)
1178
1179#define ZEND_RETURN_VAL 0
1180#define ZEND_RETURN_REF 1
1181
1182#define ZEND_BIND_VAL 0
1183#define ZEND_BIND_REF 1
1184#define ZEND_BIND_IMPLICIT 2
1185#define ZEND_BIND_EXPLICIT 4
1186
1187#define ZEND_RETURNS_FUNCTION (1<<0)
1188#define ZEND_RETURNS_VALUE (1<<1)
1189
1190#define ZEND_ARRAY_ELEMENT_REF (1<<0)
1191#define ZEND_ARRAY_NOT_PACKED (1<<1)
1192#define ZEND_ARRAY_SIZE_SHIFT 2
1193
1194/* Attribute for ternary inside parentheses */
1195#define ZEND_PARENTHESIZED_CONDITIONAL 1
1196
1197/* Used to distinguish (parent::$prop)::get() from parent hook call. */
1198#define ZEND_PARENTHESIZED_STATIC_PROP 1
1199
1200/* For "use" AST nodes and the seen symbol table */
1201#define ZEND_SYMBOL_CLASS (1<<0)
1202#define ZEND_SYMBOL_FUNCTION (1<<1)
1203#define ZEND_SYMBOL_CONST (1<<2)
1204
1205/* All increment opcodes are even (decrement are odd) */
1206#define ZEND_IS_INCREMENT(opcode) (((opcode) & 1) == 0)
1207
1208#define ZEND_IS_BINARY_ASSIGN_OP_OPCODE(opcode) \
1209 (((opcode) >= ZEND_ADD) && ((opcode) <= ZEND_POW))
1210
1211/* Pseudo-opcodes that are used only temporarily during compilation */
1212#define ZEND_GOTO 253
1213#define ZEND_BRK 254
1214#define ZEND_CONT 255
1215
1216
1218
1219#define ZEND_CLONE_FUNC_NAME "__clone"
1220#define ZEND_CONSTRUCTOR_FUNC_NAME "__construct"
1221#define ZEND_DESTRUCTOR_FUNC_NAME "__destruct"
1222#define ZEND_GET_FUNC_NAME "__get"
1223#define ZEND_SET_FUNC_NAME "__set"
1224#define ZEND_UNSET_FUNC_NAME "__unset"
1225#define ZEND_ISSET_FUNC_NAME "__isset"
1226#define ZEND_CALL_FUNC_NAME "__call"
1227#define ZEND_CALLSTATIC_FUNC_NAME "__callstatic"
1228#define ZEND_TOSTRING_FUNC_NAME "__tostring"
1229#define ZEND_INVOKE_FUNC_NAME "__invoke"
1230#define ZEND_DEBUGINFO_FUNC_NAME "__debuginfo"
1231
1232/* The following constants may be combined in CG(compiler_options)
1233 * to change the default compiler behavior */
1234
1235/* generate extended debug information */
1236#define ZEND_COMPILE_EXTENDED_STMT (1<<0)
1237#define ZEND_COMPILE_EXTENDED_FCALL (1<<1)
1238#define ZEND_COMPILE_EXTENDED_INFO (ZEND_COMPILE_EXTENDED_STMT|ZEND_COMPILE_EXTENDED_FCALL)
1239
1240/* call op_array handler of extensions */
1241#define ZEND_COMPILE_HANDLE_OP_ARRAY (1<<2)
1242
1243/* generate ZEND_INIT_FCALL_BY_NAME for internal functions instead of ZEND_INIT_FCALL */
1244#define ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS (1<<3)
1245
1246/* don't perform early binding for classes inherited form internal ones;
1247 * in namespaces assume that internal class that doesn't exist at compile-time
1248 * may appear in run-time */
1249#define ZEND_COMPILE_IGNORE_INTERNAL_CLASSES (1<<4)
1250
1251/* generate ZEND_DECLARE_CLASS_DELAYED opcode to delay early binding */
1252#define ZEND_COMPILE_DELAYED_BINDING (1<<5)
1253
1254/* disable constant substitution at compile-time */
1255#define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION (1<<6)
1256
1257/* disable substitution of persistent constants at compile-time */
1258#define ZEND_COMPILE_NO_PERSISTENT_CONSTANT_SUBSTITUTION (1<<8)
1259
1260/* generate ZEND_INIT_FCALL_BY_NAME for userland functions instead of ZEND_INIT_FCALL */
1261#define ZEND_COMPILE_IGNORE_USER_FUNCTIONS (1<<9)
1262
1263/* force ZEND_ACC_USE_GUARDS for all classes */
1264#define ZEND_COMPILE_GUARDS (1<<10)
1265
1266/* disable builtin special case function calls */
1267#define ZEND_COMPILE_NO_BUILTINS (1<<11)
1268
1269/* result of compilation may be stored in file cache */
1270#define ZEND_COMPILE_WITH_FILE_CACHE (1<<12)
1271
1272/* ignore functions and classes declared in other files */
1273#define ZEND_COMPILE_IGNORE_OTHER_FILES (1<<13)
1274
1275/* this flag is set when compiler invoked by opcache_compile_file() */
1276#define ZEND_COMPILE_WITHOUT_EXECUTION (1<<14)
1277
1278/* this flag is set when compiler invoked during preloading */
1279#define ZEND_COMPILE_PRELOAD (1<<15)
1280
1281/* disable jumptable optimization for switch statements */
1282#define ZEND_COMPILE_NO_JUMPTABLES (1<<16)
1283
1284/* this flag is set when compiler invoked during preloading in separate process */
1285#define ZEND_COMPILE_PRELOAD_IN_CHILD (1<<17)
1286
1287/* ignore observer notifications, e.g. to manually notify afterwards in a post-processing step after compilation */
1288#define ZEND_COMPILE_IGNORE_OBSERVER (1<<18)
1289
1290/* The default value for CG(compiler_options) */
1291#define ZEND_COMPILE_DEFAULT ZEND_COMPILE_HANDLE_OP_ARRAY
1292
1293/* The default value for CG(compiler_options) during eval() */
1294#define ZEND_COMPILE_DEFAULT_FOR_EVAL 0
1295
1297ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, const zval *op1, const zval *op2);
1298ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, const zval *op);
1299
1300#endif /* ZEND_COMPILE_H */
size_t len
Definition apprentice.c:174
uint32_t u
Definition cdf.c:78
zend_ffi_type * type
Definition ffi.c:3812
zval * zv
Definition ffi.c:3975
ffi persistent
Definition ffi.c:3633
lu_byte right
Definition minilua.c:4267
lu_byte left
Definition minilua.c:4266
#define zendlex
Definition php.h:337
zend_op_array *(* compile_string)(zend_string *source_string, const char *filename, zend_compile_position position)
Definition phpdbg.h:274
zend_op_array *(* compile_file)(zend_file_handle *file_handle, int type)
Definition phpdbg.h:272
zend_string * lcname
zend_string * default_value
zend_string * name
zend_ast_kind kind
zend_ast_attr attr
zend_auto_global_callback auto_global_callback
zend_string * name
zend_class_entry * ce
zend_string * doc_comment
zend_array * extra_named_params
zend_execute_data * prev_execute_data
zend_execute_data * call
zend_array * symbol_table
zend_function * func
const zend_op * opline
zend_declarables declarables
HashTable * imports_const
HashTable * imports_function
HashTable * imports
zend_string * current_namespace
const zend_property_info * prop_info
zend_class_entry * scope
zend_string * function_name
zend_function * prototype
ZEND_MAP_PTR_DEF(void **, run_time_cache)
struct _zend_module_entry * module
const zend_frameless_function_info * frameless_function_infos
void * reserved[ZEND_MAX_RESERVED_RESOURCES]
zend_internal_arg_info * arg_info
zend_string * doc_comment
uint32_t opline_num
ZEND_MAP_PTR_DEF(HashTable *, static_variables_ptr)
uint32_t * refcount
zend_function * prototype
HashTable * attributes
HashTable * static_variables
zend_op_array ** dynamic_func_defs
const zend_property_info * prop_info
zend_string * filename
zend_string * doc_comment
uint32_t required_num_args
uint32_t line_start
zend_class_entry * scope
uint8_t arg_flags[3]
zend_arg_info * arg_info
uint32_t num_args
zend_try_catch_element * try_catch_array
zend_string ** vars
zend_op * opcodes
zend_live_range * live_range
uint32_t line_end
void * reserved[ZEND_MAX_RESERVED_RESOURCES]
zend_string * function_name
uint32_t fn_flags
uint32_t num_dynamic_func_defs
ZEND_MAP_PTR_DEF(void **, run_time_cache)
znode_op op1
uint8_t result_type
znode_op op2
znode_op result
uint8_t opcode
uint8_t op1_type
uint32_t extended_value
uint32_t lineno
const void * handler
uint8_t op2_type
zend_property_hook_kind active_property_hook_kind
struct _zend_oparray_context * prev
const zend_property_info * active_property_info
zend_op_array * op_array
zend_brk_cont_element * brk_cont_array
const zend_property_info * prototype
zend_string * doc_comment
zend_function ** hooks
zend_string * name
HashTable * attributes
zend_class_entry * ce
zval constant
znode_op op
uint8_t flag
uint8_t op_type
uint32_t quick_arg_flags
zend_arg_info * arg_info
uint8_t arg_flags[3]
zend_function * prototype
zend_string * doc_comment
uint32_t required_num_args
zend_class_entry * scope
zend_op_array op_array
const zend_property_info * prop_info
zend_string * function_name
struct _zend_function::@236135173067030250234125302313220025134003177336 common
HashTable * attributes
uint32_t fn_flags
zend_internal_function internal_function
uint32_t num_args
unsigned char * ident
uint32_t opline_num
uint32_t var
uint32_t constant
uint32_t jmp_offset
uint32_t num
#define INTERNAL_FUNCTION_PARAMETERS
Definition zend.h:49
#define ZEND_MM_ALIGNED_SIZE(size)
Definition zend_alloc.h:35
uint16_t zend_ast_kind
Definition zend_ast.h:183
uint16_t zend_ast_attr
Definition zend_ast.h:184
struct _zval_struct zval
execute_data func
ZEND_API zend_string * zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var)
ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename)
ZEND_API zend_string * zend_set_compiled_filename(zend_string *new_compiled_filename)
void zend_oparray_context_end(zend_oparray_context *prev_context)
void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_array *op_array)
void zend_file_context_begin(zend_file_context *prev_context)
ZEND_API zend_op_array *(* zend_compile_file)(zend_file_handle *file_handle, int type)
ZEND_API zend_op_array *(* zend_compile_string)(zend_string *source_string, const char *filename, zend_compile_position position)
ZEND_API int zend_get_compiled_lineno(void)
void zend_init_compiler_data_structures(void)
void init_compiler(void)
ZEND_API zend_string * zend_get_compiled_filename(void)
void shutdown_compiler(void)
void zend_file_context_end(zend_file_context *prev_context)
ZEND_API zend_result zend_register_auto_global(zend_string *name, bool jit, zend_auto_global_callback auto_global_callback)
ZEND_API bool zend_unary_op_produces_error(uint32_t opcode, const zval *op)
zend_result(ZEND_FASTCALL * binary_op_type)(zval *, zval *, zval *)
ZEND_API zend_result zend_execute_script(int type, zval *retval, zend_file_handle *file_handle)
Definition zend.c:1925
ZEND_API bool zend_is_smart_branch(const zend_op *opline)
struct _zend_oparray_context zend_oparray_context
struct _zend_brk_cont_element zend_brk_cont_element
void startup_scanner(void)
ZEND_API zend_op_array * compile_filename(int type, zend_string *filename)
void zend_emit_final_return(bool return_one)
ZEND_API bool zend_is_op_long_compatible(const zval *op)
ZEND_API char * zend_make_compiled_string_description(const char *name)
Definition zend.c:1980
struct _zend_op zend_op
ZEND_API void zend_activate_auto_globals(void)
void zend_const_expr_to_zval(zval *result, zend_ast **ast_ptr, bool allow_dynamic)
ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count,...)
Definition zend.c:1954
uint32_t zend_modifier_list_to_flags(zend_modifier_target target, zend_ast *modifiers)
ZEND_API zend_ast * zend_compile_string_to_ast(zend_string *code, struct _zend_arena **ast_arena, zend_string *filename)
ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_handlers)
ZEND_API void destroy_op_array(zend_op_array *op_array)
ZEND_API void zend_function_dtor(zval *zv)
ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, const zval *op1, const zval *op2)
uint32_t zend_get_class_fetch_type(const zend_string *name)
struct _zend_label zend_label
ZEND_API void pass_two(zend_op_array *op_array)
struct _zend_internal_function_info zend_internal_function_info
void zend_assert_valid_class_name(const zend_string *const_name, const char *type)
ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name)
struct _zend_declarables zend_declarables
bool(* zend_needs_live_range_cb)(zend_op_array *op_array, zend_op *opline)
ZEND_API bool zend_is_compiling(void)
zend_ast * zend_ast_append_str(zend_ast *left, zend_ast *right)
ZEND_API zend_ast *ZEND_FASTCALL zend_ast_create_znode(znode *node)
Definition zend_ast.c:45
enum _zend_compile_position zend_compile_position
#define ZEND_ACC_PROTECTED_SET
uint32_t zend_add_anonymous_class_modifier(uint32_t flags, uint32_t new_flag)
ZEND_API void destroy_zend_function(zend_function *function)
#define ZEND_ARG_SEND_MODE(arg_info)
#define zend_unmangle_property_name(mangled_property, class_name, prop_name)
uint32_t zend_add_class_modifier(uint32_t flags, uint32_t new_flag)
ZEND_API bool zend_is_auto_global_str(const char *name, size_t len)
ZEND_API size_t zend_dirname(char *path, size_t len)
ZEND_API uint8_t zend_get_call_op(const zend_op *init_op, zend_function *fbc)
ZEND_API binary_op_type get_binary_op(int opcode)
ZEND_API void zend_set_function_arg_flags(zend_function *func)
union _zend_parser_stack_elem zend_parser_stack_elem
ZEND_API int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem)
struct _zend_file_context zend_file_context
int(* user_opcode_handler_t)(zend_execute_data *execute_data)
ZEND_API zend_string * zend_type_to_string(zend_type type)
#define ZEND_ACC_PRIVATE_SET
void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline)
struct _zend_op_array zend_op_array
struct _zend_ast_znode zend_ast_znode
union _znode_op znode_op
ZEND_API zend_class_entry * zend_bind_class_in_slot(zval *class_table_slot, zval *lcname, zend_string *lc_parent_name)
ZEND_API void destroy_zend_class(zval *zv)
struct _zend_class_constant zend_class_constant
struct _zend_property_info zend_property_info
struct _znode znode
ZEND_API unary_op_type get_unary_op(int opcode)
ZEND_API void zend_destroy_static_vars(zend_op_array *op_array)
void zend_compile_top_stmt(zend_ast *ast)
#define ZEND_ACC_PRIVATE
zend_string * zval_make_interned_string(zval *zv)
ZEND_API void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size)
Definition zend_opcode.c:48
struct _zend_internal_arg_info zend_internal_arg_info
ZEND_API zend_string * zend_mangle_property_name(const char *src1, size_t src1_length, const char *src2, size_t src2_length, bool internal)
bool(* zend_auto_global_callback)(zend_string *name)
void shutdown_scanner(void)
ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle)
#define ZEND_ACC_PUBLIC
struct _zend_arg_info zend_arg_info
_zend_compile_position
@ ZEND_COMPILE_POSITION_AFTER_OPEN_TAG
@ ZEND_COMPILE_POSITION_AT_SHEBANG
@ ZEND_COMPILE_POSITION_AT_OPEN_TAG
#define ZEND_ACC_PUBLIC_SET
zend_property_hook_kind zend_get_property_hook_kind_from_name(zend_string *name)
ZEND_API void zend_type_release(zend_type type, bool persistent)
ZEND_API size_t zend_get_scanned_file_offset(void)
ZEND_API zend_string * zend_create_member_string(zend_string *class_name, zend_string *member_name)
ZEND_API bool zend_is_auto_global(zend_string *name)
void zend_class_add_ref(zval *zv)
zend_ast * zend_negate_num_string(zend_ast *ast)
#define ZEND_ACC_VARIADIC
zend_modifier_target
@ ZEND_MODIFIER_TARGET_CONSTANT
@ ZEND_MODIFIER_TARGET_PROPERTY
@ ZEND_MODIFIER_TARGET_PROPERTY_HOOK
@ ZEND_MODIFIER_TARGET_METHOD
@ ZEND_MODIFIER_TARGET_CPP
ZEND_API zend_result do_bind_function(zend_function *func, zval *lcname)
zend_string * zend_type_to_string_resolved(zend_type type, zend_class_entry *scope)
ZEND_API ZEND_COLD void zend_user_exception_handler(void)
Definition zend.c:1887
uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag, zend_modifier_target target)
void zend_free_internal_arg_info(zend_internal_function *function)
ZEND_API void zend_cleanup_mutable_class_data(zend_class_entry *ce)
ZEND_API void function_add_ref(zend_function *function)
ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce)
struct _zend_auto_global zend_auto_global
ZEND_API void zend_recalc_live_ranges(zend_op_array *op_array, zend_needs_live_range_cb needs_live_range)
struct _zend_try_catch_element zend_try_catch_element
struct _zend_live_range zend_live_range
struct _zend_internal_function zend_internal_function
zend_result(ZEND_FASTCALL * unary_op_type)(zval *, zval *)
ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len)
void(ZEND_FASTCALL * zif_handler)(INTERNAL_FUNCTION_PARAMETERS)
char * zend_visibility_string(uint32_t fn_flags)
void zend_stop_lexing(void)
#define ZEND_ACC_PROTECTED
bool zend_handle_encoding_declaration(zend_ast *ast)
uint32_t zend_modifier_token_to_flag(zend_modifier_target target, uint32_t flags)
ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle)
#define ZEND_API
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
union _zend_function zend_function
struct _zend_file_handle zend_file_handle
int32_t zend_long
Definition zend_long.h:42
uint32_t zend_ulong
Definition zend_long.h:43
struct _zend_string zend_string
#define ZEND_MAP_PTR_DEF(type, name)
#define END_EXTERN_C()
#define EXPECTED(condition)
#define zend_always_inline
#define ZEND_FASTCALL
#define ZEND_STATIC_ASSERT(c, m)
#define ZEND_MAX_RESERVED_RESOURCES
#define ZEND_COLD
#define EMPTY_SWITCH_DEFAULT_CASE()
#define UNEXPECTED(condition)
#define BEGIN_EXTERN_C()
struct _zend_array zend_array
zend_property_hook_kind
struct _zend_class_entry zend_class_entry
struct _zend_array HashTable
Definition zend_types.h:386
ZEND_RESULT_CODE zend_result
Definition zend_types.h:64
struct _zend_ast zend_ast
Definition zend_types.h:102
struct _zend_execute_data zend_execute_data
Definition zend_types.h:91
zval retval
uint32_t arg_num
zend_string * name
zend_function * fbc
bool result
op2
function(EX_VAR(opline->result.var))
op1
execute_data
new_op_array scope