zend_execute.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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. | Dmitry Stogov <dmitry@php.net> |
  18. +----------------------------------------------------------------------+
  19. */
  20. #ifndef ZEND_EXECUTE_H
  21. #define ZEND_EXECUTE_H
  22. #include "zend_compile.h"
  23. #include "zend_hash.h"
  24. #include "zend_operators.h"
  25. #include "zend_variables.h"
  26. BEGIN_EXTERN_C()
  27. struct _zend_fcall_info;
  28. ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data);
  29. ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data, zval *return_value);
  30. /* The lc_name may be stack allocated! */
  31. ZEND_API extern zend_class_entry *(*zend_autoload)(zend_string *name, zend_string *lc_name);
  32. void init_executor(void);
  33. void shutdown_executor(void);
  34. void shutdown_destructors(void);
  35. ZEND_API void zend_shutdown_executor_values(bool fast_shutdown);
  36. ZEND_API void zend_init_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
  37. ZEND_API void zend_init_func_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
  38. ZEND_API void zend_init_code_execute_data(zend_execute_data *execute_data, zend_op_array *op_array, zval *return_value);
  39. ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value);
  40. ZEND_API void execute_ex(zend_execute_data *execute_data);
  41. ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value);
  42. ZEND_API bool zend_is_valid_class_name(zend_string *name);
  43. ZEND_API zend_class_entry *zend_lookup_class(zend_string *name);
  44. ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags);
  45. ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex);
  46. ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex);
  47. ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name);
  48. ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name);
  49. ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions);
  50. ZEND_API zend_result zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, bool handle_exceptions);
  51. /* export zend_pass_function to allow comparisons against it */
  52. extern ZEND_API const zend_internal_function zend_pass_function;
  53. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_missing_arg_error(zend_execute_data *execute_data);
  54. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc);
  55. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_false_to_array_deprecated(void);
  56. ZEND_COLD void ZEND_FASTCALL zend_param_must_be_ref(const zend_function *func, uint32_t arg_num);
  57. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_use_resource_as_offset(const zval *dim);
  58. ZEND_API bool ZEND_FASTCALL zend_verify_ref_assignable_zval(zend_reference *ref, zval *zv, bool strict);
  59. ZEND_API bool ZEND_FASTCALL zend_verify_prop_assignable_by_ref(zend_property_info *prop_info, zval *orig_val, bool strict);
  60. ZEND_API ZEND_COLD void zend_throw_ref_type_error_zval(zend_property_info *prop, zval *zv);
  61. ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1, zend_property_info *prop2, zval *zv);
  62. ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval);
  63. ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset);
  64. ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void);
  65. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error(zend_property_info *info);
  66. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_indirect_modification_error(zend_property_info *info);
  67. ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg);
  68. ZEND_API ZEND_COLD void zend_verify_arg_error(
  69. const zend_function *zf, const zend_arg_info *arg_info, uint32_t arg_num, zval *value);
  70. ZEND_API ZEND_COLD void zend_verify_return_error(
  71. const zend_function *zf, zval *value);
  72. ZEND_API ZEND_COLD void zend_verify_never_error(
  73. const zend_function *zf);
  74. ZEND_API bool zend_verify_ref_array_assignable(zend_reference *ref);
  75. ZEND_API bool zend_check_user_type_slow(
  76. zend_type *type, zval *arg, zend_reference *ref, void **cache_slot, bool is_return_type);
  77. #if ZEND_DEBUG
  78. ZEND_API bool zend_internal_call_should_throw(zend_function *fbc, zend_execute_data *call);
  79. ZEND_API ZEND_COLD void zend_internal_call_arginfo_violation(zend_function *fbc);
  80. ZEND_API bool zend_verify_internal_return_type(zend_function *zf, zval *ret);
  81. #endif
  82. #define ZEND_REF_TYPE_SOURCES(ref) \
  83. (ref)->sources
  84. #define ZEND_REF_HAS_TYPE_SOURCES(ref) \
  85. (ZEND_REF_TYPE_SOURCES(ref).ptr != NULL)
  86. #define ZEND_REF_FIRST_SOURCE(ref) \
  87. (ZEND_PROPERTY_INFO_SOURCE_IS_LIST((ref)->sources.list) \
  88. ? ZEND_PROPERTY_INFO_SOURCE_TO_LIST((ref)->sources.list)->ptr[0] \
  89. : (ref)->sources.ptr)
  90. ZEND_API void ZEND_FASTCALL zend_ref_add_type_source(zend_property_info_source_list *source_list, zend_property_info *prop);
  91. ZEND_API void ZEND_FASTCALL zend_ref_del_type_source(zend_property_info_source_list *source_list, zend_property_info *prop);
  92. ZEND_API zval* zend_assign_to_typed_ref(zval *variable_ptr, zval *value, zend_uchar value_type, bool strict);
  93. static zend_always_inline void zend_copy_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type)
  94. {
  95. zend_refcounted *ref = NULL;
  96. if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
  97. ref = Z_COUNTED_P(value);
  98. value = Z_REFVAL_P(value);
  99. }
  100. ZVAL_COPY_VALUE(variable_ptr, value);
  101. if (ZEND_CONST_COND(value_type == IS_CONST, 0)) {
  102. if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
  103. Z_ADDREF_P(variable_ptr);
  104. }
  105. } else if (value_type & (IS_CONST|IS_CV)) {
  106. if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
  107. Z_ADDREF_P(variable_ptr);
  108. }
  109. } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
  110. if (UNEXPECTED(GC_DELREF(ref) == 0)) {
  111. efree_size(ref, sizeof(zend_reference));
  112. } else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
  113. Z_ADDREF_P(variable_ptr);
  114. }
  115. }
  116. }
  117. static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval *value, zend_uchar value_type, bool strict)
  118. {
  119. do {
  120. if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr))) {
  121. zend_refcounted *garbage;
  122. if (Z_ISREF_P(variable_ptr)) {
  123. if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(Z_REF_P(variable_ptr)))) {
  124. return zend_assign_to_typed_ref(variable_ptr, value, value_type, strict);
  125. }
  126. variable_ptr = Z_REFVAL_P(variable_ptr);
  127. if (EXPECTED(!Z_REFCOUNTED_P(variable_ptr))) {
  128. break;
  129. }
  130. }
  131. garbage = Z_COUNTED_P(variable_ptr);
  132. zend_copy_to_variable(variable_ptr, value, value_type);
  133. if (GC_DELREF(garbage) == 0) {
  134. rc_dtor_func(garbage);
  135. } else { /* we need to split */
  136. /* optimized version of GC_ZVAL_CHECK_POSSIBLE_ROOT(variable_ptr) */
  137. if (UNEXPECTED(GC_MAY_LEAK(garbage))) {
  138. gc_possible_root(garbage);
  139. }
  140. }
  141. return variable_ptr;
  142. }
  143. } while (0);
  144. zend_copy_to_variable(variable_ptr, value, value_type);
  145. return variable_ptr;
  146. }
  147. ZEND_API zend_result ZEND_FASTCALL zval_update_constant(zval *pp);
  148. ZEND_API zend_result ZEND_FASTCALL zval_update_constant_ex(zval *pp, zend_class_entry *scope);
  149. /* dedicated Zend executor functions - do not use! */
  150. struct _zend_vm_stack {
  151. zval *top;
  152. zval *end;
  153. zend_vm_stack prev;
  154. };
  155. #define ZEND_VM_STACK_HEADER_SLOTS \
  156. ((ZEND_MM_ALIGNED_SIZE(sizeof(struct _zend_vm_stack)) + ZEND_MM_ALIGNED_SIZE(sizeof(zval)) - 1) / ZEND_MM_ALIGNED_SIZE(sizeof(zval)))
  157. #define ZEND_VM_STACK_ELEMENTS(stack) \
  158. (((zval*)(stack)) + ZEND_VM_STACK_HEADER_SLOTS)
  159. /*
  160. * In general in RELEASE build ZEND_ASSERT() must be zero-cost, but for some
  161. * reason, GCC generated worse code, performing CSE on assertion code and the
  162. * following "slow path" and moving memory read operations from slow path into
  163. * common header. This made a degradation for the fast path.
  164. * The following "#if ZEND_DEBUG" eliminates it.
  165. */
  166. #if ZEND_DEBUG
  167. # define ZEND_ASSERT_VM_STACK(stack) ZEND_ASSERT(stack->top > (zval *) stack && stack->end > (zval *) stack && stack->top <= stack->end)
  168. # define ZEND_ASSERT_VM_STACK_GLOBAL ZEND_ASSERT(EG(vm_stack_top) > (zval *) EG(vm_stack) && EG(vm_stack_end) > (zval *) EG(vm_stack) && EG(vm_stack_top) <= EG(vm_stack_end))
  169. #else
  170. # define ZEND_ASSERT_VM_STACK(stack)
  171. # define ZEND_ASSERT_VM_STACK_GLOBAL
  172. #endif
  173. ZEND_API void zend_vm_stack_init(void);
  174. ZEND_API void zend_vm_stack_init_ex(size_t page_size);
  175. ZEND_API void zend_vm_stack_destroy(void);
  176. ZEND_API void* zend_vm_stack_extend(size_t size);
  177. static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend_vm_stack prev) {
  178. zend_vm_stack page = (zend_vm_stack)emalloc(size);
  179. page->top = ZEND_VM_STACK_ELEMENTS(page);
  180. page->end = (zval*)((char*)page + size);
  181. page->prev = prev;
  182. return page;
  183. }
  184. static zend_always_inline void zend_vm_init_call_frame(zend_execute_data *call, uint32_t call_info, zend_function *func, uint32_t num_args, void *object_or_called_scope)
  185. {
  186. ZEND_ASSERT(!func->common.scope || object_or_called_scope);
  187. call->func = func;
  188. Z_PTR(call->This) = object_or_called_scope;
  189. ZEND_CALL_INFO(call) = call_info;
  190. ZEND_CALL_NUM_ARGS(call) = num_args;
  191. }
  192. static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame_ex(uint32_t used_stack, uint32_t call_info, zend_function *func, uint32_t num_args, void *object_or_called_scope)
  193. {
  194. zend_execute_data *call = (zend_execute_data*)EG(vm_stack_top);
  195. ZEND_ASSERT_VM_STACK_GLOBAL;
  196. if (UNEXPECTED(used_stack > (size_t)(((char*)EG(vm_stack_end)) - (char*)call))) {
  197. call = (zend_execute_data*)zend_vm_stack_extend(used_stack);
  198. ZEND_ASSERT_VM_STACK_GLOBAL;
  199. zend_vm_init_call_frame(call, call_info | ZEND_CALL_ALLOCATED, func, num_args, object_or_called_scope);
  200. return call;
  201. } else {
  202. EG(vm_stack_top) = (zval*)((char*)call + used_stack);
  203. zend_vm_init_call_frame(call, call_info, func, num_args, object_or_called_scope);
  204. return call;
  205. }
  206. }
  207. static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, zend_function *func)
  208. {
  209. uint32_t used_stack = ZEND_CALL_FRAME_SLOT + num_args;
  210. if (EXPECTED(ZEND_USER_CODE(func->type))) {
  211. used_stack += func->op_array.last_var + func->op_array.T - MIN(func->op_array.num_args, num_args);
  212. }
  213. return used_stack * sizeof(zval);
  214. }
  215. static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint32_t call_info, zend_function *func, uint32_t num_args, void *object_or_called_scope)
  216. {
  217. uint32_t used_stack = zend_vm_calc_used_stack(num_args, func);
  218. return zend_vm_stack_push_call_frame_ex(used_stack, call_info,
  219. func, num_args, object_or_called_scope);
  220. }
  221. static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_info, zend_execute_data *call)
  222. {
  223. if (UNEXPECTED(call_info & ZEND_CALL_FREE_EXTRA_ARGS)) {
  224. uint32_t count = ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args;
  225. zval *p = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var + call->func->op_array.T);
  226. do {
  227. i_zval_ptr_dtor(p);
  228. p++;
  229. } while (--count);
  230. }
  231. }
  232. static zend_always_inline void zend_vm_stack_free_extra_args(zend_execute_data *call)
  233. {
  234. zend_vm_stack_free_extra_args_ex(ZEND_CALL_INFO(call), call);
  235. }
  236. static zend_always_inline void zend_vm_stack_free_args(zend_execute_data *call)
  237. {
  238. uint32_t num_args = ZEND_CALL_NUM_ARGS(call);
  239. if (EXPECTED(num_args > 0)) {
  240. zval *p = ZEND_CALL_ARG(call, 1);
  241. do {
  242. zval_ptr_dtor_nogc(p);
  243. p++;
  244. } while (--num_args);
  245. }
  246. }
  247. static zend_always_inline void zend_vm_stack_free_call_frame_ex(uint32_t call_info, zend_execute_data *call)
  248. {
  249. ZEND_ASSERT_VM_STACK_GLOBAL;
  250. if (UNEXPECTED(call_info & ZEND_CALL_ALLOCATED)) {
  251. zend_vm_stack p = EG(vm_stack);
  252. zend_vm_stack prev = p->prev;
  253. ZEND_ASSERT(call == (zend_execute_data*)ZEND_VM_STACK_ELEMENTS(EG(vm_stack)));
  254. EG(vm_stack_top) = prev->top;
  255. EG(vm_stack_end) = prev->end;
  256. EG(vm_stack) = prev;
  257. efree(p);
  258. } else {
  259. EG(vm_stack_top) = (zval*)call;
  260. }
  261. ZEND_ASSERT_VM_STACK_GLOBAL;
  262. }
  263. static zend_always_inline void zend_vm_stack_free_call_frame(zend_execute_data *call)
  264. {
  265. zend_vm_stack_free_call_frame_ex(ZEND_CALL_INFO(call), call);
  266. }
  267. zend_execute_data *zend_vm_stack_copy_call_frame(
  268. zend_execute_data *call, uint32_t passed_args, uint32_t additional_args);
  269. static zend_always_inline void zend_vm_stack_extend_call_frame(
  270. zend_execute_data **call, uint32_t passed_args, uint32_t additional_args)
  271. {
  272. if (EXPECTED((uint32_t)(EG(vm_stack_end) - EG(vm_stack_top)) > additional_args)) {
  273. EG(vm_stack_top) += additional_args;
  274. } else {
  275. *call = zend_vm_stack_copy_call_frame(*call, passed_args, additional_args);
  276. }
  277. }
  278. ZEND_API void ZEND_FASTCALL zend_free_extra_named_params(zend_array *extra_named_params);
  279. /* services */
  280. ZEND_API const char *get_active_class_name(const char **space);
  281. ZEND_API const char *get_active_function_name(void);
  282. ZEND_API const char *get_active_function_arg_name(uint32_t arg_num);
  283. ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t arg_num);
  284. ZEND_API zend_string *get_active_function_or_method_name(void);
  285. ZEND_API zend_string *get_function_or_method_name(const zend_function *func);
  286. ZEND_API const char *zend_get_executed_filename(void);
  287. ZEND_API zend_string *zend_get_executed_filename_ex(void);
  288. ZEND_API uint32_t zend_get_executed_lineno(void);
  289. ZEND_API zend_class_entry *zend_get_executed_scope(void);
  290. ZEND_API bool zend_is_executing(void);
  291. ZEND_API ZEND_COLD void ZEND_FASTCALL zend_cannot_pass_by_reference(uint32_t arg_num);
  292. ZEND_API void zend_set_timeout(zend_long seconds, bool reset_signals);
  293. ZEND_API void zend_unset_timeout(void);
  294. ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void);
  295. ZEND_API zend_class_entry *zend_fetch_class(zend_string *class_name, int fetch_type);
  296. ZEND_API zend_class_entry *zend_fetch_class_with_scope(zend_string *class_name, int fetch_type, zend_class_entry *scope);
  297. ZEND_API zend_class_entry *zend_fetch_class_by_name(zend_string *class_name, zend_string *lcname, int fetch_type);
  298. ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function(zend_string *name);
  299. ZEND_API zend_function * ZEND_FASTCALL zend_fetch_function_str(const char *name, size_t len);
  300. ZEND_API void ZEND_FASTCALL zend_init_func_run_time_cache(zend_op_array *op_array);
  301. ZEND_API void zend_fetch_dimension_const(zval *result, zval *container, zval *dim, int type);
  302. ZEND_API zval* zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, uint32_t var);
  303. #define ZEND_USER_OPCODE_CONTINUE 0 /* execute next opcode */
  304. #define ZEND_USER_OPCODE_RETURN 1 /* exit from executor (return from function) */
  305. #define ZEND_USER_OPCODE_DISPATCH 2 /* call original opcode handler */
  306. #define ZEND_USER_OPCODE_ENTER 3 /* enter into new op_array without recursion */
  307. #define ZEND_USER_OPCODE_LEAVE 4 /* return to calling op_array within the same executor */
  308. #define ZEND_USER_OPCODE_DISPATCH_TO 0x100 /* call original handler of returned opcode */
  309. ZEND_API int zend_set_user_opcode_handler(zend_uchar opcode, user_opcode_handler_t handler);
  310. ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode);
  311. ZEND_API zval *zend_get_zval_ptr(const zend_op *opline, int op_type, const znode_op *node, const zend_execute_data *execute_data);
  312. ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table);
  313. ZEND_API void ZEND_FASTCALL zend_free_compiled_variables(zend_execute_data *execute_data);
  314. ZEND_API void zend_cleanup_unfinished_execution(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num);
  315. zval * ZEND_FASTCALL zend_handle_named_arg(
  316. zend_execute_data **call_ptr, zend_string *arg_name,
  317. uint32_t *arg_num_ptr, void **cache_slot);
  318. ZEND_API int ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *call);
  319. #define CACHE_ADDR(num) \
  320. ((void**)((char*)EX(run_time_cache) + (num)))
  321. #define CACHED_PTR(num) \
  322. ((void**)((char*)EX(run_time_cache) + (num)))[0]
  323. #define CACHE_PTR(num, ptr) do { \
  324. ((void**)((char*)EX(run_time_cache) + (num)))[0] = (ptr); \
  325. } while (0)
  326. #define CACHED_POLYMORPHIC_PTR(num, ce) \
  327. (EXPECTED(((void**)((char*)EX(run_time_cache) + (num)))[0] == (void*)(ce)) ? \
  328. ((void**)((char*)EX(run_time_cache) + (num)))[1] : \
  329. NULL)
  330. #define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \
  331. void **slot = (void**)((char*)EX(run_time_cache) + (num)); \
  332. slot[0] = (ce); \
  333. slot[1] = (ptr); \
  334. } while (0)
  335. #define CACHED_PTR_EX(slot) \
  336. (slot)[0]
  337. #define CACHE_PTR_EX(slot, ptr) do { \
  338. (slot)[0] = (ptr); \
  339. } while (0)
  340. #define CACHED_POLYMORPHIC_PTR_EX(slot, ce) \
  341. (EXPECTED((slot)[0] == (ce)) ? (slot)[1] : NULL)
  342. #define CACHE_POLYMORPHIC_PTR_EX(slot, ce, ptr) do { \
  343. (slot)[0] = (ce); \
  344. (slot)[1] = (ptr); \
  345. } while (0)
  346. #define CACHE_SPECIAL (1<<0)
  347. #define IS_SPECIAL_CACHE_VAL(ptr) \
  348. (((uintptr_t)(ptr)) & CACHE_SPECIAL)
  349. #define ENCODE_SPECIAL_CACHE_NUM(num) \
  350. ((void*)((((uintptr_t)(num)) << 1) | CACHE_SPECIAL))
  351. #define DECODE_SPECIAL_CACHE_NUM(ptr) \
  352. (((uintptr_t)(ptr)) >> 1)
  353. #define ENCODE_SPECIAL_CACHE_PTR(ptr) \
  354. ((void*)(((uintptr_t)(ptr)) | CACHE_SPECIAL))
  355. #define DECODE_SPECIAL_CACHE_PTR(ptr) \
  356. ((void*)(((uintptr_t)(ptr)) & ~CACHE_SPECIAL))
  357. #define SKIP_EXT_OPLINE(opline) do { \
  358. while (UNEXPECTED((opline)->opcode >= ZEND_EXT_STMT \
  359. && (opline)->opcode <= ZEND_TICKS)) { \
  360. (opline)--; \
  361. } \
  362. } while (0)
  363. #define ZEND_CLASS_HAS_TYPE_HINTS(ce) ((ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS) == ZEND_ACC_HAS_TYPE_HINTS)
  364. ZEND_API bool zend_verify_property_type(zend_property_info *info, zval *property, bool strict);
  365. ZEND_COLD void zend_verify_property_type_error(zend_property_info *info, zval *property);
  366. #define ZEND_REF_ADD_TYPE_SOURCE(ref, source) \
  367. zend_ref_add_type_source(&ZEND_REF_TYPE_SOURCES(ref), source)
  368. #define ZEND_REF_DEL_TYPE_SOURCE(ref, source) \
  369. zend_ref_del_type_source(&ZEND_REF_TYPE_SOURCES(ref), source)
  370. #define ZEND_REF_FOREACH_TYPE_SOURCES(ref, prop) do { \
  371. zend_property_info_source_list *_source_list = &ZEND_REF_TYPE_SOURCES(ref); \
  372. zend_property_info **_prop, **_end; \
  373. zend_property_info_list *_list; \
  374. if (_source_list->ptr) { \
  375. if (ZEND_PROPERTY_INFO_SOURCE_IS_LIST(_source_list->list)) { \
  376. _list = ZEND_PROPERTY_INFO_SOURCE_TO_LIST(_source_list->list); \
  377. _prop = _list->ptr; \
  378. _end = _list->ptr + _list->num; \
  379. } else { \
  380. _prop = &_source_list->ptr; \
  381. _end = _prop + 1; \
  382. } \
  383. for (; _prop < _end; _prop++) { \
  384. prop = *_prop; \
  385. #define ZEND_REF_FOREACH_TYPE_SOURCES_END() \
  386. } \
  387. } \
  388. } while (0)
  389. ZEND_COLD void zend_match_unhandled_error(zval *value);
  390. END_EXTERN_C()
  391. #endif /* ZEND_EXECUTE_H */