Skip to content

Commit 120ae17

Browse files
authored
Add typed specialization for ZEND_COUNT (#11825)
1 parent a33dfd2 commit 120ae17

File tree

3 files changed

+619
-548
lines changed

3 files changed

+619
-548
lines changed

Zend/zend_vm_def.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9344,6 +9344,21 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
93449344
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
93459345
}
93469346

9347+
ZEND_VM_TYPE_SPEC_HANDLER(ZEND_COUNT, (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF)) == MAY_BE_ARRAY, ZEND_COUNT_ARRAY, CV|TMPVAR, UNUSED)
9348+
{
9349+
USE_OPLINE
9350+
zend_array *ht = Z_ARRVAL_P(GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R));
9351+
ZVAL_LONG(EX_VAR(opline->result.var), zend_hash_num_elements(ht));
9352+
if (OP1_TYPE & (IS_TMP_VAR|IS_VAR) && !(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && !GC_DELREF(ht)) {
9353+
SAVE_OPLINE();
9354+
zend_array_destroy(ht);
9355+
if (EG(exception)) {
9356+
HANDLE_EXCEPTION();
9357+
}
9358+
}
9359+
ZEND_VM_NEXT_OPCODE();
9360+
}
9361+
93479362
ZEND_VM_COLD_CONST_HANDLER(191, ZEND_GET_CLASS, UNUSED|CONST|TMPVAR|CV, UNUSED)
93489363
{
93499364
USE_OPLINE

0 commit comments

Comments
 (0)