Skip to content

Commit 4163923

Browse files
committed
More agressive "packed array" guards insertion
1 parent 53a8754 commit 4163923

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,16 +1524,11 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
15241524
&& (info->type & MAY_BE_ARRAY_HASH)
15251525
&& orig_op1_type != IS_UNKNOWN
15261526
&& !(orig_op1_type & IS_TRACE_REFERENCE)) {
1527-
/* setup "packed" guards only for loop invariant or reused variables */
1528-
if ((trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP
1529-
&& tssa->ops[idx].op1_use < trace_buffer->op_array->last_var)
1530-
|| tssa->ops[idx].op1_use_chain >= 0) {
1531-
info->type |= MAY_BE_PACKED_GUARD;
1532-
if (orig_op1_type & IS_TRACE_PACKED) {
1533-
info->type &= ~MAY_BE_ARRAY_HASH;
1534-
} else {
1535-
info->type &= ~MAY_BE_ARRAY_PACKED;
1536-
}
1527+
info->type |= MAY_BE_PACKED_GUARD;
1528+
if (orig_op1_type & IS_TRACE_PACKED) {
1529+
info->type &= ~MAY_BE_ARRAY_HASH;
1530+
} else {
1531+
info->type &= ~MAY_BE_ARRAY_PACKED;
15371532
}
15381533
}
15391534
}
@@ -4229,6 +4224,17 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42294224
ssa->var_info[ssa_op->op1_use].avoid_refcounting;
42304225
if (op1_info & MAY_BE_PACKED_GUARD) {
42314226
ssa->var_info[ssa_op->op1_use].type &= ~MAY_BE_PACKED_GUARD;
4227+
} else if ((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG
4228+
&& (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY
4229+
&& (op1_info & MAY_BE_ARRAY_PACKED)
4230+
&& (op1_info & MAY_BE_ARRAY_HASH)
4231+
&& orig_op1_type != IS_UNKNOWN) {
4232+
op1_info |= MAY_BE_PACKED_GUARD;
4233+
if (orig_op1_type & IS_TRACE_PACKED) {
4234+
op1_info &= ~MAY_BE_ARRAY_HASH;
4235+
} else {
4236+
op1_info &= ~MAY_BE_ARRAY_PACKED;
4237+
}
42324238
}
42334239
if (!zend_jit_fetch_dim_read(&dasm_state, opline, ssa, ssa_op,
42344240
op1_info, op1_addr, avoid_refcounting,
@@ -4304,6 +4310,17 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
43044310
ssa->var_info[ssa_op->op1_use].avoid_refcounting;
43054311
if (op1_info & MAY_BE_PACKED_GUARD) {
43064312
ssa->var_info[ssa_op->op1_use].type &= ~MAY_BE_PACKED_GUARD;
4313+
} else if ((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG
4314+
&& (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY
4315+
&& (op1_info & MAY_BE_ARRAY_PACKED)
4316+
&& (op1_info & MAY_BE_ARRAY_HASH)
4317+
&& orig_op1_type != IS_UNKNOWN) {
4318+
op1_info |= MAY_BE_PACKED_GUARD;
4319+
if (orig_op1_type & IS_TRACE_PACKED) {
4320+
op1_info &= ~MAY_BE_ARRAY_HASH;
4321+
} else {
4322+
op1_info &= ~MAY_BE_ARRAY_PACKED;
4323+
}
43074324
}
43084325
if (!zend_jit_isset_isempty_dim(&dasm_state, opline,
43094326
op1_info, op1_addr, avoid_refcounting,

0 commit comments

Comments
 (0)