Skip to content

Commit e5830c4

Browse files
committed
Eliminate dead type stores
1 parent 8efcc28 commit e5830c4

File tree

4 files changed

+116
-73
lines changed

4 files changed

+116
-73
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
22462246
} else if (ival->flags & ZREG_STORE) {
22472247
ZEND_ASSERT(ival->reg != ZREG_NONE);
22482248

2249-
if (!zend_jit_store_var(&dasm_state, ssa->var_info[phi->ssa_var].type, ssa->vars[phi->ssa_var].var, ival->reg)) {
2249+
if (!zend_jit_store_var(&dasm_state, ssa->var_info[phi->ssa_var].type, ssa->vars[phi->ssa_var].var, ival->reg, 1)) {
22502250
goto jit_failure;
22512251
}
22522252
}
@@ -2699,7 +2699,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
26992699
}
27002700
if (!zend_jit_qm_assign(&dasm_state, opline,
27012701
OP1_INFO(), op1_addr, op1_def_addr,
2702-
RES_INFO(), RES_REG_ADDR())) {
2702+
-1, RES_INFO(), RES_REG_ADDR())) {
27032703
goto jit_failure;
27042704
}
27052705
goto done;

ext/opcache/jit/zend_jit_internal.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,10 @@ typedef union _zend_jit_trace_stack {
317317
int32_t ssa_var;
318318
uint32_t info;
319319
struct {
320-
uint8_t type;
321-
int8_t reg;
322-
uint16_t flags;
320+
uint8_t type; /* variable type (for type inference) */
321+
uint8_t mem_type; /* stack slot type (for eliminate dead type store) */
322+
int8_t reg;
323+
uint8_t flags;
323324
};
324325
} zend_jit_trace_stack;
325326

@@ -329,6 +330,8 @@ typedef union _zend_jit_trace_stack {
329330
(_stack)[_slot].info
330331
#define STACK_TYPE(_stack, _slot) \
331332
(_stack)[_slot].type
333+
#define STACK_MEM_TYPE(_stack, _slot) \
334+
(_stack)[_slot].mem_type
332335
#define STACK_REG(_stack, _slot) \
333336
(_stack)[_slot].reg
334337
#define SET_STACK_VAR(_stack, _slot, _ssa_var) do { \
@@ -337,8 +340,12 @@ typedef union _zend_jit_trace_stack {
337340
#define SET_STACK_INFO(_stack, _slot, _info) do { \
338341
(_stack)[_slot].info = _info; \
339342
} while (0)
340-
#define SET_STACK_TYPE(_stack, _slot, _type) do { \
341-
(_stack)[_slot].type = _type; \
343+
#define SET_STACK_TYPE(_stack, _slot, _type, _set_mem_type) do { \
344+
uint8_t __type = (_type); \
345+
(_stack)[_slot].type = __type; \
346+
if (_set_mem_type) { \
347+
(_stack)[_slot].mem_type = __type; \
348+
} \
342349
(_stack)[_slot].reg = ZREG_NONE; \
343350
(_stack)[_slot].flags = 0; \
344351
} while (0)

0 commit comments

Comments
 (0)