Skip to content

Commit e86b5c8

Browse files
committed
Record information about packed arrays
1 parent ea87d04 commit e86b5c8

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

ext/opcache/jit/zend_jit_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ typedef enum _zend_jit_trace_op {
245245
} zend_jit_trace_op;
246246

247247
#define IS_UNKNOWN 255 /* may be used for zend_jit_trace_rec.op?_type */
248+
#define IS_TRACE_PACKED (1<<4)
248249
#define IS_TRACE_REFERENCE (1<<5)
249250
#define IS_TRACE_INDIRECT (1<<6)
250251

ext/opcache/jit/zend_jit_trace.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,9 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin
13681368
if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) {
13691369
op1_type = IS_UNKNOWN;
13701370
}
1371+
if (op1_type != IS_UNKNOWN) {
1372+
op1_type &= ~IS_TRACE_PACKED;
1373+
}
13711374
if (op2_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) {
13721375
op2_type = IS_UNKNOWN;
13731376
}
@@ -3122,6 +3125,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
31223125
if (op1_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) {
31233126
op1_type = IS_UNKNOWN;
31243127
}
3128+
if (op1_type != IS_UNKNOWN) {
3129+
op1_type &= ~IS_TRACE_PACKED;
3130+
}
31253131
if (op2_type & (IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) {
31263132
op2_type = IS_UNKNOWN;
31273133
}
@@ -5134,8 +5140,8 @@ static void zend_jit_dump_trace(zend_jit_trace_rec *trace_buffer, zend_ssa *tssa
51345140
fprintf(stderr, " op1(%sobject of class %s)", ref,
51355141
ZSTR_VAL(p->ce->name));
51365142
} else {
5137-
const char *type = (op1_type == 0) ? "undef" : zend_get_type_by_const(op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT));
5138-
fprintf(stderr, " op1(%s%s)", ref, type);
5143+
const char *type = (op1_type == 0) ? "undef" : zend_get_type_by_const(op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED));
5144+
fprintf(stderr, " op1(%s%s%s)", ref, (op1_type & IS_TRACE_PACKED) ? "packed " : "", type);
51395145
}
51405146
}
51415147
if (op2_type != IS_UNKNOWN) {

ext/opcache/jit/zend_jit_vm_helpers.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,14 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
659659
op1_type = Z_TYPE_P(zv);
660660
flags |= IS_TRACE_REFERENCE;
661661
}
662-
op1_type |= flags;
663662
if (Z_TYPE_P(zv) == IS_OBJECT) {
664663
ce1 = Z_OBJCE_P(zv);
664+
} else if (Z_TYPE_P(zv) == IS_ARRAY) {
665+
if (HT_IS_PACKED(Z_ARRVAL_P(zv))) {
666+
flags |= IS_TRACE_PACKED;
667+
}
665668
}
669+
op1_type |= flags;
666670
}
667671
if (opline->op2_type & (IS_TMP_VAR|IS_VAR|IS_CV)
668672
&& opline->opcode != ZEND_INSTANCEOF
@@ -684,10 +688,10 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
684688
op2_type = Z_TYPE_P(zv);
685689
flags |= IS_TRACE_REFERENCE;
686690
}
687-
op2_type |= flags;
688691
if (Z_TYPE_P(zv) == IS_OBJECT) {
689692
ce2 = Z_OBJCE_P(zv);
690693
}
694+
op2_type |= flags;
691695
}
692696
if (opline->opcode == ZEND_ASSIGN_DIM ||
693697
opline->opcode == ZEND_ASSIGN_OBJ ||

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12354,7 +12354,9 @@ static zend_bool zend_jit_fetch_reference(dasm_State **Dst, const zend_op *oplin
1235412354
var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, offsetof(zend_reference, val));
1235512355
*var_addr_ptr = var_addr;
1235612356

12357-
var_type &= ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT);
12357+
if (var_type != IS_UNKNOWN) {
12358+
var_type &= ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED);
12359+
}
1235812360
if (add_type_guard
1235912361
&& var_type != IS_UNKNOWN
1236012362
&& (var_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << var_type)) {
@@ -12394,7 +12396,9 @@ static zend_bool zend_jit_fetch_indirect_var(dasm_State **Dst, const zend_op *op
1239412396
var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);
1239512397
*var_addr_ptr = var_addr;
1239612398

12397-
var_type &= ~IS_TRACE_INDIRECT;
12399+
if (var_type != IS_UNKNOWN) {
12400+
var_type &= ~(IS_TRACE_INDIRECT|IS_TRACE_PACKED);
12401+
}
1239812402
if (!(var_type & IS_TRACE_REFERENCE)
1239912403
&& var_type != IS_UNKNOWN
1240012404
&& (var_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1 << var_type)) {
@@ -12514,7 +12518,7 @@ static zend_bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zen
1251412518
op2_info = OP2_INFO();
1251512519
if (trace
1251612520
&& trace->op1_type != IS_UNKNOWN
12517-
&& (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT)) == IS_ARRAY) {
12521+
&& (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)) == IS_ARRAY) {
1251812522
op1_info &= ~((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY);
1251912523
}
1252012524
return ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) &&

0 commit comments

Comments
 (0)