-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid useless string releases in arginfo.h files #17344
base: master
Are you sure you want to change the base?
Conversation
These just contribute to code bloat. For the interned strings we don't need to release them and for the non-interned ones we can use the _ex variant to avoid generating the branching code. Reduces the size of the text section of the CLI binary by 0.166% on a default build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to send a patch to do the same thing in the next few days, don't have approval rights but makes sense to me
ZVAL_LONG(&const_TARGET_CLASS_value, ZEND_ATTRIBUTE_TARGET_CLASS); | ||
zend_string *const_TARGET_CLASS_name = zend_string_init_interned("TARGET_CLASS", sizeof("TARGET_CLASS") - 1, 1); | ||
zend_declare_typed_class_constant(class_entry, const_TARGET_CLASS_name, &const_TARGET_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); | ||
zend_string_release(const_TARGET_CLASS_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think about specialized functions that accept char*
and size_t```. Also may be add specialization by type. Actually, we already have
zend_declare_class_constant_long()`` that we used before...
Probably API should be adjusted according to the new requirements.
zend_string *const_TARGET_FUNCTION_name = zend_string_init_interned("TARGET_FUNCTION", sizeof("TARGET_FUNCTION") - 1, 1); | ||
zend_declare_typed_class_constant(class_entry, const_TARGET_FUNCTION_name, &const_TARGET_FUNCTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); | ||
zend_string_release(const_TARGET_FUNCTION_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have assumption, that in some edge case zend_string_init_interned()
may return a non-interned string.
e.g. when DSO extension is loaded at run-time and opcache is active, or when opcache.interned_strings_buffer
is insufficient.
Can you please check this.
zend_string *property_flags_name = zend_string_init("flags", sizeof("flags") - 1, 1); | ||
zend_declare_typed_property(class_entry, property_flags_name, &property_flags_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); | ||
zend_string_release(property_flags_name); | ||
zend_string_release_ex(property_flags_name, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use zend_string_init
here?
Accidentally messed up the PR id... Sorry |
These just contribute to code bloat. For the interned strings we don't need to release them and for the non-interned ones we can use the _ex variant to avoid generating the branching code.
Reduces the size of the text section of the CLI binary by 0.166% on a default build.