Skip to content

Commit 819a872

Browse files
committed
Avoid more null arithmetic
1 parent 5a90392 commit 819a872

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Zend/zend_compile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
31923192
zend_compile_expr(&arg_node, arg->child[0]);
31933193
opline = zend_emit_op(NULL, ZEND_SEND_UNPACK, &arg_node, NULL);
31943194
opline->op2.num = arg_count;
3195-
opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_ARG(NULL, arg_count);
3195+
opline->result.var = EX_NUM_TO_VAR(arg_count - 1);
31963196
continue;
31973197
}
31983198

@@ -3286,7 +3286,7 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
32863286

32873287
opline = zend_emit_op(NULL, opcode, &arg_node, NULL);
32883288
opline->op2.opline_num = arg_num;
3289-
opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_ARG(NULL, arg_num);
3289+
opline->result.var = EX_NUM_TO_VAR(arg_num - 1);
32903290
}
32913291

32923292
return arg_count;
@@ -3680,7 +3680,7 @@ int zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcnam
36803680

36813681
opline = zend_emit_op(NULL, ZEND_SEND_USER, &arg_node, NULL);
36823682
opline->op2.num = i;
3683-
opline->result.var = (uint32_t)(zend_intptr_t)ZEND_CALL_ARG(NULL, i);
3683+
opline->result.var = EX_NUM_TO_VAR(i - 1);
36843684
}
36853685
zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL);
36863686

Zend/zend_compile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ struct _zend_execute_data {
578578
#define EX_VAR_NUM(n) ZEND_CALL_VAR_NUM(execute_data, n)
579579

580580
#define EX_VAR_TO_NUM(n) ((uint32_t)((n) / sizeof(zval) - ZEND_CALL_FRAME_SLOT))
581-
#define EX_NUM_TO_VAR(n) ((uint32_t)((n + ZEND_CALL_FRAME_SLOT) * sizeof(zval)))
581+
#define EX_NUM_TO_VAR(n) ((uint32_t)(((n) + ZEND_CALL_FRAME_SLOT) * sizeof(zval)))
582582

583583
#define ZEND_OPLINE_TO_OFFSET(opline, target) \
584584
((char*)(target) - (char*)(opline))

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2726,7 +2726,7 @@ static int zend_jit_store_var(dasm_State **Dst, uint32_t info, int var, zend_reg
27262726
static int zend_jit_store_var_if_necessary(dasm_State **Dst, int var, zend_jit_addr src, uint32_t info)
27272727
{
27282728
if (Z_MODE(src) == IS_REG && Z_STORE(src)) {
2729-
zend_jit_addr dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, (uint32_t)(uintptr_t)ZEND_CALL_VAR(NULL, var));
2729+
zend_jit_addr dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var);
27302730
return zend_jit_spill_store(Dst, src, dst, info, 1);
27312731
}
27322732
return 1;
@@ -2735,7 +2735,7 @@ static int zend_jit_store_var_if_necessary(dasm_State **Dst, int var, zend_jit_a
27352735
static int zend_jit_store_var_if_necessary_ex(dasm_State **Dst, int var, zend_jit_addr src, uint32_t info, zend_jit_addr old, uint32_t old_info)
27362736
{
27372737
if (Z_MODE(src) == IS_REG && Z_STORE(src)) {
2738-
zend_jit_addr dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, (uint32_t)(uintptr_t)ZEND_CALL_VAR(NULL, var));
2738+
zend_jit_addr dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var);
27392739
zend_bool set_type = 1;
27402740

27412741
if ((info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) ==

0 commit comments

Comments
 (0)