Skip to content
8 changes: 4 additions & 4 deletions Zend/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,14 +1671,14 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
}

for (i = 0; i < call->num_args; i++) {
zend_op *opline = call->arg_info[i].opline;
if (opline->opcode != ZEND_SEND_VAL && opline->opcode != ZEND_SEND_VAR) {
zend_op *arg_info_opline = call->arg_info[i].opline;
if (arg_info_opline->opcode != ZEND_SEND_VAL && arg_info_opline->opcode != ZEND_SEND_VAR) {
SET_RESULT_BOT(result);
return;
}

args[i] = get_op1_value(ctx, opline,
&ctx->scdf.ssa->ops[opline - ctx->scdf.op_array->opcodes]);
args[i] = get_op1_value(ctx, arg_info_opline,
&ctx->scdf.ssa->ops[arg_info_opline - ctx->scdf.op_array->opcodes]);
if (args[i]) {
if (IS_BOT(args[i]) || IS_PARTIAL_ARRAY(args[i])) {
SET_RESULT_BOT(result);
Expand Down
22 changes: 11 additions & 11 deletions Zend/Optimizer/zend_call_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32
case ZEND_FRAMELESS_ICALL_2:
case ZEND_FRAMELESS_ICALL_3: {
func = ZEND_FLF_FUNC(opline);
zend_call_info *call_info = zend_arena_calloc(arena, 1, sizeof(zend_call_info));
call_info->caller_op_array = op_array;
call_info->caller_init_opline = opline;
call_info->caller_call_opline = NULL;
call_info->callee_func = func;
call_info->num_args = ZEND_FLF_NUM_ARGS(opline->opcode);
call_info->next_callee = func_info->callee_info;
call_info->is_prototype = false;
call_info->is_frameless = true;
call_info->next_caller = NULL;
func_info->callee_info = call_info;
zend_call_info *frameless_call_info = zend_arena_calloc(arena, 1, sizeof(zend_call_info));
frameless_call_info->caller_op_array = op_array;
frameless_call_info->caller_init_opline = opline;
frameless_call_info->caller_call_opline = NULL;
frameless_call_info->callee_func = func;
frameless_call_info->num_args = ZEND_FLF_NUM_ARGS(opline->opcode);
frameless_call_info->next_callee = func_info->callee_info;
frameless_call_info->is_prototype = false;
frameless_call_info->is_frameless = true;
frameless_call_info->next_caller = NULL;
func_info->callee_info = frameless_call_info;
break;
}
case ZEND_DO_FCALL:
Expand Down
4 changes: 2 additions & 2 deletions Zend/Optimizer/zend_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ ZEND_API void zend_cfg_compute_dominators_tree(const zend_op_array *op_array, ze
{
zend_basic_block *blocks = cfg->blocks;
int blocks_count = cfg->blocks_count;
int j, k, changed;
int j, changed;

if (cfg->blocks_count == 1) {
blocks[0].level = 0;
Expand All @@ -697,7 +697,7 @@ ZEND_API void zend_cfg_compute_dominators_tree(const zend_op_array *op_array, ze
if ((blocks[j].flags & ZEND_BB_REACHABLE) == 0) {
continue;
}
for (k = 0; k < blocks[j].predecessors_count; k++) {
for (int k = 0; k < blocks[j].predecessors_count; k++) {
int pred = cfg->predecessors[blocks[j].predecessor_offset + k];

if (blocks[pred].idom >= 0) {
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ typedef size_t (*zend_write_func_t)(const char *str, size_t str_length);

#define zend_try \
{ \
ZEND_DIAGNOSTIC_IGNORED_START("-Wshadow") \
JMP_BUF *__orig_bailout = EG(bailout); \
JMP_BUF __bailout; \
ZEND_DIAGNOSTIC_IGNORED_END \
\
EG(bailout) = &__bailout; \
if (SETJMP(__bailout)==0) {
Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -3808,14 +3808,14 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc
ret = 1;
}
} else if ((ce = zend_lookup_class(name)) != NULL) {
zend_class_entry *scope = get_scope(frame);
const zend_class_entry *frame_scope = get_scope(frame);
fcc->calling_scope = ce;
if (scope && !fcc->object) {
if (frame_scope && !fcc->object) {
zend_object *object = zend_get_this_object(frame);

if (object &&
instanceof_function(object->ce, scope) &&
instanceof_function(scope, ce)) {
instanceof_function(object->ce, frame_scope) &&
instanceof_function(frame_scope, ce)) {
fcc->object = object;
fcc->called_scope = object->ce;
} else {
Expand Down
40 changes: 20 additions & 20 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,9 @@ static void *zend_mm_alloc_pages(zend_mm_heap *heap, uint32_t pages_count ZEND_F
}
#if ZEND_MM_STAT
do {
size_t size = heap->real_size + ZEND_MM_CHUNK_SIZE;
size_t peak = MAX(heap->real_peak, size);
heap->real_size = size;
size_t new_real_size = heap->real_size + ZEND_MM_CHUNK_SIZE;
size_t peak = MAX(heap->real_peak, new_real_size);
heap->real_size = new_real_size;
heap->real_peak = peak;
} while (0);
#elif ZEND_MM_LIMIT
Expand Down Expand Up @@ -1130,9 +1130,9 @@ static zend_always_inline void *zend_mm_alloc_large_ex(zend_mm_heap *heap, size_
#endif
#if ZEND_MM_STAT
do {
size_t size = heap->size + pages_count * ZEND_MM_PAGE_SIZE;
size_t peak = MAX(heap->peak, size);
heap->size = size;
size_t mem_size = heap->size + pages_count * ZEND_MM_PAGE_SIZE;
size_t peak = MAX(heap->peak, mem_size);
heap->size = mem_size;
heap->peak = peak;
} while (0);
#endif
Expand Down Expand Up @@ -1799,9 +1799,9 @@ static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *p
zend_mm_bitset_is_free_range(chunk->free_map, page_num + old_pages_count, new_pages_count - old_pages_count)) {
#if ZEND_MM_STAT
do {
size_t size = heap->size + (new_size - old_size);
size_t peak = MAX(heap->peak, size);
heap->size = size;
size_t new_real_size = heap->size + (new_size - old_size);
size_t peak = MAX(heap->peak, new_real_size);
heap->size = new_real_size;
heap->peak = peak;
} while (0);
#endif
Expand Down Expand Up @@ -1970,15 +1970,15 @@ static void *zend_mm_alloc_huge(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_D
#endif
#if ZEND_MM_STAT
do {
size_t size = heap->real_size + new_size;
size_t peak = MAX(heap->real_peak, size);
heap->real_size = size;
size_t new_real_size = heap->real_size + new_size;
size_t peak = MAX(heap->real_peak, new_real_size);
heap->real_size = new_real_size;
heap->real_peak = peak;
} while (0);
do {
size_t size = heap->size + new_size;
size_t peak = MAX(heap->peak, size);
heap->size = size;
size_t new_heap_size = heap->size + new_size;
size_t peak = MAX(heap->peak, new_heap_size);
heap->size = new_heap_size;
heap->peak = peak;
} while (0);
#elif ZEND_MM_LIMIT
Expand Down Expand Up @@ -3021,15 +3021,15 @@ static void tracked_free_all(zend_mm_heap *heap) {
}
#endif

static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
static void alloc_globals_ctor(zend_alloc_globals *alloc_globals_ptr)
{
char *tmp;

#if ZEND_MM_CUSTOM
tmp = getenv("USE_ZEND_ALLOC");
if (tmp && !ZEND_ATOL(tmp)) {
bool tracked = (tmp = getenv("USE_TRACKED_ALLOC")) && ZEND_ATOL(tmp);
zend_mm_heap *mm_heap = alloc_globals->mm_heap = malloc(sizeof(zend_mm_heap));
zend_mm_heap *mm_heap = alloc_globals_ptr->mm_heap = malloc(sizeof(zend_mm_heap));
memset(mm_heap, 0, sizeof(zend_mm_heap));
mm_heap->use_custom_heap = ZEND_MM_CUSTOM_HEAP_STD;
mm_heap->limit = (size_t)Z_L(-1) >> 1;
Expand All @@ -3056,13 +3056,13 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
if (tmp && ZEND_ATOL(tmp)) {
zend_mm_use_huge_pages = true;
}
alloc_globals->mm_heap = zend_mm_init();
alloc_globals_ptr->mm_heap = zend_mm_init();
}

#ifdef ZTS
static void alloc_globals_dtor(zend_alloc_globals *alloc_globals)
static void alloc_globals_dtor(zend_alloc_globals *alloc_globals_ptr)
{
zend_mm_shutdown(alloc_globals->mm_heap, 1, 1);
zend_mm_shutdown(alloc_globals_ptr->mm_heap, 1, 1);
}
#endif

Expand Down
8 changes: 4 additions & 4 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2253,9 +2253,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
case ZEND_AST_NEW:
smart_str_appends(str, "new ");
if (ast->child[0]->kind == ZEND_AST_CLASS) {
zend_ast_decl *decl = (zend_ast_decl *) ast->child[0];
if (decl->child[3]) {
zend_ast_export_attributes(str, decl->child[3], indent, 0);
zend_ast_decl *class_decl = (zend_ast_decl *) ast->child[0];
if (class_decl->child[3]) {
zend_ast_export_attributes(str, class_decl->child[3], indent, 0);
}
smart_str_appends(str, "class");
if (!zend_ast_is_list(ast->child[1])
Expand All @@ -2264,7 +2264,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
zend_ast_export_ex(str, ast->child[1], 0, indent);
smart_str_appendc(str, ')');
}
zend_ast_export_class_no_header(str, decl, indent);
zend_ast_export_class_no_header(str, class_decl, indent);
} else {
zend_ast_export_ns_name(str, ast->child[0], 0, indent);
smart_str_appendc(str, '(');
Expand Down
11 changes: 4 additions & 7 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2012,24 +2012,21 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
zend_execute_data *prev_call = prev;

while (prev_call) {
zend_execute_data *prev;

if (prev_call &&
prev_call->func &&
!ZEND_USER_CODE(prev_call->func->common.type) &&
!(prev_call->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
break;
}

prev = prev_call->prev_execute_data;
if (prev && prev->func && ZEND_USER_CODE(prev->func->common.type)) {
ZVAL_STR_COPY(&tmp, prev->func->op_array.filename);
prev_call = prev_call->prev_execute_data;
if (prev_call && prev_call->func && ZEND_USER_CODE(prev_call->func->common.type)) {
ZVAL_STR_COPY(&tmp, prev_call->func->op_array.filename);
_zend_hash_append_ex(stack_frame, ZSTR_KNOWN(ZEND_STR_FILE), &tmp, 1);
ZVAL_LONG(&tmp, prev->opline->lineno);
ZVAL_LONG(&tmp, prev_call->opline->lineno);
_zend_hash_append_ex(stack_frame, ZSTR_KNOWN(ZEND_STR_LINE), &tmp, 1);
break;
}
prev_call = prev;
}
filename = NULL;
}
Expand Down
66 changes: 31 additions & 35 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3161,25 +3161,25 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
if (nullsafe) {
if (obj_node.op_type == IS_TMP_VAR) {
/* Flush delayed oplines */
zend_op *opline = NULL, *oplines = zend_stack_base(&CG(delayed_oplines_stack));
zend_op *delayed_opline = NULL, *delayed_oplines = zend_stack_base(&CG(delayed_oplines_stack));
uint32_t var = obj_node.u.op.var;
uint32_t count = zend_stack_count(&CG(delayed_oplines_stack));
uint32_t i = count;

while (i > 0 && oplines[i-1].result_type == IS_TMP_VAR && oplines[i-1].result.var == var) {
while (i > 0 && delayed_oplines[i-1].result_type == IS_TMP_VAR && delayed_oplines[i-1].result.var == var) {
i--;
if (oplines[i].op1_type == IS_TMP_VAR) {
var = oplines[i].op1.var;
if (delayed_oplines[i].op1_type == IS_TMP_VAR) {
var = delayed_oplines[i].op1.var;
} else {
break;
}
}
for (; i < count; ++i) {
if (oplines[i].opcode != ZEND_NOP) {
opline = get_next_op();
memcpy(opline, &oplines[i], sizeof(zend_op));
oplines[i].opcode = ZEND_NOP;
oplines[i].extended_value = opline - CG(active_op_array)->opcodes;
if (delayed_oplines[i].opcode != ZEND_NOP) {
delayed_opline = get_next_op();
memcpy(delayed_opline, &delayed_oplines[i], sizeof(zend_op));
delayed_oplines[i].opcode = ZEND_NOP;
delayed_oplines[i].extended_value = delayed_opline - CG(active_op_array)->opcodes;
}
}
}
Expand Down Expand Up @@ -4280,7 +4280,6 @@ static void zend_compile_init_user_func(zend_ast *name_ast, uint32_t num_args, z
static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */
{
znode arg_node;
zend_op *opline;

if (args->children != 2) {
return FAILURE;
Expand Down Expand Up @@ -4322,7 +4321,8 @@ static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, ze
zend_compile_expr(&arg_node, args->child[1]);
zend_emit_op(NULL, ZEND_SEND_ARRAY, &arg_node, NULL);
zend_emit_op(NULL, ZEND_CHECK_UNDEF_ARGS, NULL, NULL);
opline = zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL);

zend_op *opline = zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL);
opline->extended_value = ZEND_FCALL_MAY_HAVE_EXTRA_NAMED_PARAMS;

return SUCCESS;
Expand Down Expand Up @@ -4384,9 +4384,9 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string
if (args->child[0]->kind == ZEND_AST_NAMED_ARG) {
/* If the original argument was named, add the new argument as named as well,
* as mixing named and positional is not allowed. */
zend_ast *name = zend_ast_create_zval_from_str(
zend_ast *name_arg = zend_ast_create_zval_from_str(
ZSTR_INIT_LITERAL("description", 0));
arg = zend_ast_create(ZEND_AST_NAMED_ARG, name, arg);
arg = zend_ast_create(ZEND_AST_NAMED_ARG, name_arg, arg);
}
zend_ast_list_add((zend_ast *) args, arg);
}
Expand Down Expand Up @@ -7146,13 +7146,13 @@ static zend_type zend_compile_typename_ex(
type_list->types[type_list->num_types++] = single_type;

/* Check for trivially redundant class types */
for (size_t i = 0; i < type_list->num_types - 1; i++) {
if (ZEND_TYPE_IS_INTERSECTION(type_list->types[i])) {
zend_are_intersection_types_redundant(single_type, type_list->types[i]);
for (size_t type_index = 0; type_index < type_list->num_types - 1; type_index++) {
if (ZEND_TYPE_IS_INTERSECTION(type_list->types[type_index])) {
zend_are_intersection_types_redundant(single_type, type_list->types[type_index]);
continue;
}
/* Type from type list is a simple type */
zend_is_intersection_type_redundant_by_single_type(single_type, type_list->types[i]);
zend_is_intersection_type_redundant_by_single_type(single_type, type_list->types[type_index]);
}
continue;
}
Expand Down Expand Up @@ -7206,10 +7206,10 @@ static zend_type zend_compile_typename_ex(
}

if (type_list->num_types) {
zend_type_list *list = zend_arena_alloc(
zend_type_list *type_list_arena = zend_arena_alloc(
&CG(arena), ZEND_TYPE_LIST_SIZE(type_list->num_types));
memcpy(list, type_list, ZEND_TYPE_LIST_SIZE(type_list->num_types));
ZEND_TYPE_SET_LIST(type, list);
memcpy(type_list_arena, type_list, ZEND_TYPE_LIST_SIZE(type_list->num_types));
ZEND_TYPE_SET_LIST(type, type_list_arena);
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_ARENA_BIT;
/* Inform that the type list is a union type */
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_UNION_BIT;
Expand Down Expand Up @@ -7733,16 +7733,16 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32
}

if (is_promoted) {
zend_op_array *op_array = CG(active_op_array);
zend_class_entry *scope = op_array->scope;
zend_op_array *promoted_prop_op_array = CG(active_op_array);
zend_class_entry *scope = promoted_prop_op_array->scope;

bool is_ctor =
scope && zend_is_constructor(op_array->function_name);
scope && zend_is_constructor(promoted_prop_op_array->function_name);
if (!is_ctor) {
zend_error_noreturn(E_COMPILE_ERROR,
"Cannot declare promoted property outside a constructor");
}
if ((op_array->fn_flags & ZEND_ACC_ABSTRACT)
if ((promoted_prop_op_array->fn_flags & ZEND_ACC_ABSTRACT)
|| (scope->ce_flags & ZEND_ACC_INTERFACE)) {
zend_error_noreturn(E_COMPILE_ERROR,
"Cannot declare promoted property in an abstract constructor");
Expand Down Expand Up @@ -7991,24 +7991,20 @@ static void compile_implicit_lexical_binds(

static void zend_compile_closure_uses(zend_ast *ast) /* {{{ */
{
zend_op_array *op_array = CG(active_op_array);
zend_ast_list *list = zend_ast_get_list(ast);
uint32_t i;
const zend_op_array *op_array = CG(active_op_array);
const zend_ast_list *list = zend_ast_get_list(ast);

for (i = 0; i < list->children; ++i) {
for (uint32_t i = 0; i < list->children; ++i) {
uint32_t mode = ZEND_BIND_EXPLICIT;
zend_ast *var_ast = list->child[i];
zend_string *var_name = zend_ast_get_str(var_ast);
zval zv;
ZVAL_NULL(&zv);

{
int i;
for (i = 0; i < op_array->last_var; i++) {
if (zend_string_equals(op_array->vars[i], var_name)) {
zend_error_noreturn_unchecked(E_COMPILE_ERROR,
"Cannot use lexical variable $%S as a parameter name", var_name);
}
for (int var_index = 0; var_index < op_array->last_var; var_index++) {
if (zend_string_equals(op_array->vars[var_index], var_name)) {
zend_error_noreturn_unchecked(E_COMPILE_ERROR,
"Cannot use lexical variable $%S as a parameter name", var_name);
}
}

Expand Down
Loading