@@ -1607,20 +1607,27 @@ static zend_always_inline void _object_properties_init(zend_object *object, zend
1607
1607
if (class_type -> default_properties_count ) {
1608
1608
zval * src = CE_DEFAULT_PROPERTIES_TABLE (class_type );
1609
1609
zval * dst = object -> properties_table ;
1610
- zval * end = src + class_type -> default_properties_count ;
1611
1610
1612
- if (UNEXPECTED (class_type -> type == ZEND_INTERNAL_CLASS )) {
1613
- do {
1614
- ZVAL_COPY_OR_DUP_PROP (dst , src );
1615
- src ++ ;
1616
- dst ++ ;
1617
- } while (src != end );
1611
+ if (!(class_type -> ce_flags & ZEND_ACC_HAS_RC_PROPS )) {
1612
+ // printf("fast path %s\n", class_type->name->val);
1613
+ memcpy (dst , src , sizeof (zval ) * class_type -> default_properties_count );
1618
1614
} else {
1619
- do {
1620
- ZVAL_COPY_PROP (dst , src );
1621
- src ++ ;
1622
- dst ++ ;
1623
- } while (src != end );
1615
+ // printf("slow path %s\n", class_type->name->val);
1616
+ zval * end = src + class_type -> default_properties_count ;
1617
+
1618
+ if (UNEXPECTED (class_type -> type == ZEND_INTERNAL_CLASS )) {
1619
+ do {
1620
+ ZVAL_COPY_OR_DUP_PROP (dst , src );
1621
+ src ++ ;
1622
+ dst ++ ;
1623
+ } while (src != end );
1624
+ } else {
1625
+ do {
1626
+ ZVAL_COPY_PROP (dst , src );
1627
+ src ++ ;
1628
+ dst ++ ;
1629
+ } while (src != end );
1630
+ }
1624
1631
}
1625
1632
}
1626
1633
}
@@ -4303,6 +4310,7 @@ static zend_always_inline bool is_persistent_class(zend_class_entry *ce) {
4303
4310
ZEND_API zend_property_info * zend_declare_typed_property (zend_class_entry * ce , zend_string * name , zval * property , int access_type , zend_string * doc_comment , zend_type type ) /* {{{ */
4304
4311
{
4305
4312
zend_property_info * property_info , * property_info_ptr ;
4313
+ // printf("decl prop %s\n", name->val);
4306
4314
4307
4315
if (ZEND_TYPE_IS_SET (type )) {
4308
4316
ce -> ce_flags |= ZEND_ACC_HAS_TYPE_HINTS ;
@@ -4378,6 +4386,11 @@ ZEND_API zend_property_info *zend_declare_typed_property(zend_class_entry *ce, z
4378
4386
ce -> properties_info_table [ce -> default_properties_count - 1 ] = property_info ;
4379
4387
}
4380
4388
}
4389
+ // printf("%s %s\n", ce->name->val, name->val);
4390
+ if (Z_REFCOUNTED_P (property )) {
4391
+ // printf("refcounted\n");
4392
+ ce -> ce_flags |= ZEND_ACC_HAS_RC_PROPS ;
4393
+ }
4381
4394
property_default_ptr = & ce -> default_properties_table [OBJ_PROP_TO_NUM (property_info -> offset )];
4382
4395
ZVAL_COPY_VALUE (property_default_ptr , property );
4383
4396
Z_PROP_FLAG_P (property_default_ptr ) = Z_ISUNDEF_P (property ) ? IS_PROP_UNINIT : 0 ;
0 commit comments