Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jan 3, 2025

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.

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.
Copy link
Contributor

@DanielEScherzer DanielEScherzer left a 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

Comment on lines 87 to -90
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);
Copy link
Member

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.

Comment on lines 93 to -96
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);
Copy link
Member

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.

Comment on lines 128 to +130
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);
Copy link
Member

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?

@nielsdos nielsdos closed this in 82d71a8 Jan 17, 2025
@nielsdos
Copy link
Member Author

Accidentally messed up the PR id... Sorry

@nielsdos nielsdos reopened this Jan 17, 2025
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.

5 participants