Skip to content

Conversation

@ndossche
Copy link
Member

This currently uses ZVAL_COPY_OR_DUP, which copies the value and handles refcounting. However, internal classes cannot have refcounted default properties because of constraints imposed by
zend_declare_typed_property(). So copying the value is sufficient.

While this doesn't really improve the performance for our benchmarks, it improves performance for cases where a lot of temporary internal objects are instantiated. For example, when instantiating DOM classes: DOM objects are transient, so lots of temporary objects are created.

I have a variant on my fork that adds a CE flag to extend this to user classes too (ndossche#55). But the performance win is so small that I'm not convinced that's useful.

This currently uses ZVAL_COPY_OR_DUP, which copies the value and handles
refcounting. However, internal classes cannot have refcounted default
properties because of constraints imposed by
zend_declare_typed_property(). So copying the value is sufficient.

While this doesn't really improve the performance for our benchmarks, it
improves performance for cases where a lot of temporary internal objects
are instantiated. For example, when instantiating DOM classes: DOM
objects are transient, so lots of temporary objects are created.
@iluuu1994
Copy link
Member

There's similar code in zend_do_inheritance_ex, where ZVAL_COPY_OR_DUP_PROP is used. It doesn't matter much there since it's only done once per class, but to avoid confusion the same changes should probably be made there.

@ndossche ndossche merged commit cdfa016 into php:master Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants