Lines Matching refs:op_array
34 static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array) in zend_extension_op_array_ctor_handler() argument
37 extension->op_array_ctor(op_array); in zend_extension_op_array_ctor_handler()
41 static void zend_extension_op_array_dtor_handler(zend_extension *extension, zend_op_array *op_array) in zend_extension_op_array_dtor_handler() argument
44 extension->op_array_dtor(op_array); in zend_extension_op_array_dtor_handler()
48 void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size) in init_op_array() argument
50 op_array->type = type; in init_op_array()
51 op_array->arg_flags[0] = 0; in init_op_array()
52 op_array->arg_flags[1] = 0; in init_op_array()
53 op_array->arg_flags[2] = 0; in init_op_array()
55 op_array->refcount = (uint32_t *) emalloc(sizeof(uint32_t)); in init_op_array()
56 *op_array->refcount = 1; in init_op_array()
57 op_array->last = 0; in init_op_array()
58 op_array->opcodes = emalloc(initial_ops_size * sizeof(zend_op)); in init_op_array()
60 op_array->last_var = 0; in init_op_array()
61 op_array->vars = NULL; in init_op_array()
63 op_array->T = 0; in init_op_array()
65 op_array->function_name = NULL; in init_op_array()
66 op_array->filename = zend_string_copy(zend_get_compiled_filename()); in init_op_array()
67 op_array->doc_comment = NULL; in init_op_array()
68 op_array->attributes = NULL; in init_op_array()
70 op_array->arg_info = NULL; in init_op_array()
71 op_array->num_args = 0; in init_op_array()
72 op_array->required_num_args = 0; in init_op_array()
74 op_array->scope = NULL; in init_op_array()
75 op_array->prototype = NULL; in init_op_array()
76 op_array->prop_info = NULL; in init_op_array()
78 op_array->live_range = NULL; in init_op_array()
79 op_array->try_catch_array = NULL; in init_op_array()
80 op_array->last_live_range = 0; in init_op_array()
82 op_array->static_variables = NULL; in init_op_array()
83 ZEND_MAP_PTR_INIT(op_array->static_variables_ptr, NULL); in init_op_array()
84 op_array->last_try_catch = 0; in init_op_array()
86 op_array->fn_flags = 0; in init_op_array()
88 op_array->last_literal = 0; in init_op_array()
89 op_array->literals = NULL; in init_op_array()
91 op_array->num_dynamic_func_defs = 0; in init_op_array()
92 op_array->dynamic_func_defs = NULL; in init_op_array()
94 ZEND_MAP_PTR_INIT(op_array->run_time_cache, NULL); in init_op_array()
95 op_array->cache_size = zend_op_array_extension_handles * sizeof(void*); in init_op_array()
97 memset(op_array->reserved, 0, ZEND_MAX_RESERVED_RESOURCES * sizeof(void*)); in init_op_array()
100 …nt(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_ctor_handler, op_array); in init_op_array()
150 destroy_op_array(&function->op_array); in zend_function_dtor()
403 destroy_op_array(&prop_info->hooks[i]->op_array); in destroy_zend_class()
544 ZEND_API void zend_destroy_static_vars(zend_op_array *op_array) in zend_destroy_static_vars() argument
546 if (ZEND_MAP_PTR(op_array->static_variables_ptr)) { in zend_destroy_static_vars()
547 HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr); in zend_destroy_static_vars()
550 ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL); in zend_destroy_static_vars()
555 ZEND_API void destroy_op_array(zend_op_array *op_array) in destroy_op_array() argument
559 if ((op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE) in destroy_op_array()
560 && ZEND_MAP_PTR(op_array->run_time_cache)) { in destroy_op_array()
561 efree(ZEND_MAP_PTR(op_array->run_time_cache)); in destroy_op_array()
564 if (op_array->function_name) { in destroy_op_array()
565 zend_string_release_ex(op_array->function_name, 0); in destroy_op_array()
568 if (!op_array->refcount || --(*op_array->refcount) > 0) { in destroy_op_array()
572 efree_size(op_array->refcount, sizeof(*(op_array->refcount))); in destroy_op_array()
574 if (op_array->vars) { in destroy_op_array()
575 i = op_array->last_var; in destroy_op_array()
578 zend_string_release_ex(op_array->vars[i], 0); in destroy_op_array()
580 efree(op_array->vars); in destroy_op_array()
583 if (op_array->literals) { in destroy_op_array()
584 zval *literal = op_array->literals; in destroy_op_array()
585 zval *end = literal + op_array->last_literal; in destroy_op_array()
591 || !(op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO)) { in destroy_op_array()
592 efree(op_array->literals); in destroy_op_array()
595 efree(op_array->opcodes); in destroy_op_array()
597 zend_string_release_ex(op_array->filename, 0); in destroy_op_array()
598 if (op_array->doc_comment) { in destroy_op_array()
599 zend_string_release_ex(op_array->doc_comment, 0); in destroy_op_array()
601 if (op_array->attributes) { in destroy_op_array()
602 zend_hash_release(op_array->attributes); in destroy_op_array()
604 if (op_array->live_range) { in destroy_op_array()
605 efree(op_array->live_range); in destroy_op_array()
607 if (op_array->try_catch_array) { in destroy_op_array()
608 efree(op_array->try_catch_array); in destroy_op_array()
611 if (op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) { in destroy_op_array()
612 …nt(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_dtor_handler, op_array); in destroy_op_array()
615 if (op_array->arg_info) { in destroy_op_array()
616 uint32_t num_args = op_array->num_args; in destroy_op_array()
617 zend_arg_info *arg_info = op_array->arg_info; in destroy_op_array()
619 if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { in destroy_op_array()
623 if (op_array->fn_flags & ZEND_ACC_VARIADIC) { in destroy_op_array()
634 if (op_array->static_variables) { in destroy_op_array()
635 zend_array_destroy(op_array->static_variables); in destroy_op_array()
637 if (op_array->num_dynamic_func_defs) { in destroy_op_array()
638 for (i = 0; i < op_array->num_dynamic_func_defs; i++) { in destroy_op_array()
641 if (op_array->dynamic_func_defs[i]->static_variables in destroy_op_array()
642 && (op_array->dynamic_func_defs[i]->fn_flags & ZEND_ACC_CLOSURE)) { in destroy_op_array()
643 zend_array_destroy(op_array->dynamic_func_defs[i]->static_variables); in destroy_op_array()
644 op_array->dynamic_func_defs[i]->static_variables = NULL; in destroy_op_array()
646 destroy_op_array(op_array->dynamic_func_defs[i]); in destroy_op_array()
648 efree(op_array->dynamic_func_defs); in destroy_op_array()
652 static void zend_update_extended_stmts(zend_op_array *op_array) in zend_update_extended_stmts() argument
654 zend_op *opline = op_array->opcodes, *end=opline+op_array->last; in zend_update_extended_stmts()
675 static void zend_extension_op_array_handler(zend_extension *extension, zend_op_array *op_array) in zend_extension_op_array_handler() argument
678 extension->op_array_handler(op_array); in zend_extension_op_array_handler()
682 static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num) in zend_check_finally_breakout() argument
686 for (i = 0; i < op_array->last_try_catch; i++) { in zend_check_finally_breakout()
687 if ((op_num < op_array->try_catch_array[i].finally_op || in zend_check_finally_breakout()
688 op_num >= op_array->try_catch_array[i].finally_end) in zend_check_finally_breakout()
689 && (dst_num >= op_array->try_catch_array[i].finally_op && in zend_check_finally_breakout()
690 dst_num <= op_array->try_catch_array[i].finally_end)) { in zend_check_finally_breakout()
692 CG(active_op_array) = op_array; in zend_check_finally_breakout()
693 CG(zend_lineno) = op_array->opcodes[op_num].lineno; in zend_check_finally_breakout()
695 } else if ((op_num >= op_array->try_catch_array[i].finally_op in zend_check_finally_breakout()
696 && op_num <= op_array->try_catch_array[i].finally_end) in zend_check_finally_breakout()
697 && (dst_num > op_array->try_catch_array[i].finally_end in zend_check_finally_breakout()
698 || dst_num < op_array->try_catch_array[i].finally_op)) { in zend_check_finally_breakout()
700 CG(active_op_array) = op_array; in zend_check_finally_breakout()
701 CG(zend_lineno) = op_array->opcodes[op_num].lineno; in zend_check_finally_breakout()
707 static uint32_t zend_get_brk_cont_target(const zend_op_array *op_array, const zend_op *opline) { in zend_get_brk_cont_target() argument
722 zend_op_array *op_array, uint32_t var_num, uint32_t kind, uint32_t start, uint32_t end) { in emit_live_range_raw() argument
725 op_array->last_live_range++; in emit_live_range_raw()
726 op_array->live_range = erealloc(op_array->live_range, in emit_live_range_raw()
727 sizeof(zend_live_range) * op_array->last_live_range); in emit_live_range_raw()
730 range = &op_array->live_range[op_array->last_live_range - 1]; in emit_live_range_raw()
731 range->var = EX_NUM_TO_VAR(op_array->last_var + var_num); in emit_live_range_raw()
738 zend_op_array *op_array, uint32_t var_num, uint32_t start, uint32_t end, in emit_live_range() argument
740 zend_op *def_opline = &op_array->opcodes[start], *orig_def_opline = def_opline; in emit_live_range()
741 zend_op *use_opline = &op_array->opcodes[end]; in emit_live_range()
813 emit_live_range_raw(op_array, var_num, ZEND_LIVE_NEW, orig_start + 1, start + 1); in emit_live_range()
826 if (needs_live_range && !needs_live_range(op_array, orig_def_opline)) { in emit_live_range()
835 uint32_t rt_var_num = EX_NUM_TO_VAR(op_array->last_var + var_num); in emit_live_range()
836 if (needs_live_range && !needs_live_range(op_array, orig_def_opline)) { in emit_live_range()
853 start = block_start_op - op_array->opcodes; in emit_live_range()
855 emit_live_range_raw(op_array, var_num, kind, start, end); in emit_live_range()
864 start = def_opline + 1 - op_array->opcodes; in emit_live_range()
865 emit_live_range_raw(op_array, var_num, kind, start, end); in emit_live_range()
873 start = def_opline + 1 - op_array->opcodes; in emit_live_range()
874 end = use_opline - op_array->opcodes; in emit_live_range()
875 emit_live_range_raw(op_array, var_num, kind, start, end); in emit_live_range()
880 emit_live_range_raw(op_array, var_num, kind, start, end); in emit_live_range()
929 zend_op_array *op_array, zend_needs_live_range_cb needs_live_range) { in zend_calc_live_ranges() argument
930 uint32_t opnum = op_array->last; in zend_calc_live_ranges()
931 zend_op *opline = &op_array->opcodes[opnum]; in zend_calc_live_ranges()
933 uint32_t var_offset = op_array->last_var; in zend_calc_live_ranges()
934 uint32_t *last_use = do_alloca(sizeof(uint32_t) * op_array->T, use_heap); in zend_calc_live_ranges()
935 memset(last_use, -1, sizeof(uint32_t) * op_array->T); in zend_calc_live_ranges()
937 ZEND_ASSERT(!op_array->live_range); in zend_calc_live_ranges()
962 emit_live_range(op_array, var_num, num, last_use[var_num], needs_live_range); in zend_calc_live_ranges()
985 op_array, var_num, opnum, last_use[var_num], needs_live_range); in zend_calc_live_ranges()
1002 if (op_array->last_live_range > 1) { in zend_calc_live_ranges()
1003 zend_live_range *r1 = op_array->live_range; in zend_calc_live_ranges()
1004 zend_live_range *r2 = r1 + op_array->last_live_range - 1; in zend_calc_live_ranges()
1013 r1 = op_array->live_range; in zend_calc_live_ranges()
1014 r2 = r1 + op_array->last_live_range - 1; in zend_calc_live_ranges()
1029 zend_op_array *op_array, zend_needs_live_range_cb needs_live_range) { in zend_recalc_live_ranges() argument
1031 ZEND_ASSERT(op_array->live_range); in zend_recalc_live_ranges()
1032 efree(op_array->live_range); in zend_recalc_live_ranges()
1033 op_array->live_range = NULL; in zend_recalc_live_ranges()
1034 op_array->last_live_range = 0; in zend_recalc_live_ranges()
1035 zend_calc_live_ranges(op_array, needs_live_range); in zend_recalc_live_ranges()
1038 ZEND_API void pass_two(zend_op_array *op_array) in pass_two() argument
1042 if (!ZEND_USER_CODE(op_array->type)) { in pass_two()
1046 zend_update_extended_stmts(op_array); in pass_two()
1050 …rgument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array); in pass_two()
1054 if (CG(context).vars_size != op_array->last_var) { in pass_two()
1055 …op_array->vars = (zend_string**) erealloc(op_array->vars, sizeof(zend_string*)*op_array->last_var); in pass_two()
1056 CG(context).vars_size = op_array->last_var; in pass_two()
1060 if (CG(context).opcodes_size != op_array->last) { in pass_two()
1061 op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last); in pass_two()
1062 CG(context).opcodes_size = op_array->last; in pass_two()
1064 if (CG(context).literals_size != op_array->last_literal) { in pass_two()
1065 op_array->literals = (zval*)erealloc(op_array->literals, sizeof(zval) * op_array->last_literal); in pass_two()
1066 CG(context).literals_size = op_array->last_literal; in pass_two()
1069 op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, in pass_two()
1070 ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op) * op_array->last, 16) + in pass_two()
1071 sizeof(zval) * op_array->last_literal); in pass_two()
1072 if (op_array->literals) { in pass_two()
1073 memcpy(((char*)op_array->opcodes) + ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op) * op_array->last, 16), in pass_two()
1074 op_array->literals, sizeof(zval) * op_array->last_literal); in pass_two()
1075 efree(op_array->literals); in pass_two()
1076 …op_array->literals = (zval*)(((char*)op_array->opcodes) + ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op) … in pass_two()
1078 CG(context).opcodes_size = op_array->last; in pass_two()
1079 CG(context).literals_size = op_array->last_literal; in pass_two()
1082 op_array->T += ZEND_OBSERVER_ENABLED; // reserve last temporary for observers if enabled in pass_two()
1086 op_array->fn_flags |= ZEND_ACC_DONE_PASS_TWO; in pass_two()
1088 opline = op_array->opcodes; in pass_two()
1089 end = opline + op_array->last; in pass_two()
1096 uint32_t slot = ZEND_MM_ALIGNED_SIZE_EX(op_array->cache_size, 8); in pass_two()
1098 op_array->cache_size += sizeof(zval); in pass_two()
1103 opline->op1.opline_num = op_array->try_catch_array[opline->op1.num].finally_op; in pass_two()
1104 ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1); in pass_two()
1109 uint32_t jmp_target = zend_get_brk_cont_target(op_array, opline); in pass_two()
1111 if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) { in pass_two()
1112 zend_check_finally_breakout(op_array, opline - op_array->opcodes, jmp_target); in pass_two()
1117 ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1); in pass_two()
1121 zend_resolve_goto_label(op_array, opline); in pass_two()
1122 if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) { in pass_two()
1123 zend_check_finally_breakout(op_array, opline - op_array->opcodes, opline->op1.opline_num); in pass_two()
1127 ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op1); in pass_two()
1140 ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2); in pass_two()
1145 zend_op *call = &op_array->opcodes[opline->op2.opline_num - 1]; in pass_two()
1152 ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2); in pass_two()
1158 opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value); in pass_two()
1162 ZEND_PASS_TWO_UPDATE_JMP_TARGET(op_array, opline, opline->op2); in pass_two()
1167 if (op_array->fn_flags & ZEND_ACC_GENERATOR) { in pass_two()
1179 Z_LVAL_P(zv) = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, Z_LVAL_P(zv)); in pass_two()
1182 opline->extended_value = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, opline->extended_value); in pass_two()
1187 ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op1); in pass_two()
1189 opline->op1.var = EX_NUM_TO_VAR(op_array->last_var + opline->op1.var); in pass_two()
1192 ZEND_PASS_TWO_UPDATE_CONSTANT(op_array, opline, opline->op2); in pass_two()
1194 opline->op2.var = EX_NUM_TO_VAR(op_array->last_var + opline->op2.var); in pass_two()
1197 opline->result.var = EX_NUM_TO_VAR(op_array->last_var + opline->result.var); in pass_two()
1203 zend_calc_live_ranges(op_array, NULL); in pass_two()