Skip to content

php_reflection.c: make a bunch of pointers const #15927

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

Merged
merged 3 commits into from
Sep 17, 2024

Conversation

DanielEScherzer
Copy link
Member

No description provided.

@DanielEScherzer
Copy link
Member Author

Failures appear to be from things timing out, should be unrelated

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise.

static void _extension_string(smart_str *str, zend_module_entry *module, char *indent);
static void _zend_extension_string(smart_str *str, zend_extension *extension, char *indent);
static void _const_string(smart_str *str, const char *name, zval *value, const char *indent);
static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, const char* indent);
Copy link
Member

@iluuu1994 iluuu1994 Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more question: Based on what rules did you add const? It seems a bit arbitrary to add it for zend_extension, but not zend_function, zval, etc. I don't object about these changes in general, but I'm not sure it makes sense to touch all functions just to add them, at least not unless we can show that there's some code-generation benefit from it. In this isolated context, the changes look fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added as many as I could

E.g. for _const_string, the zval *value gets passed to zval_get_tmp_string() which requires a non-const zval, since (digging deeper into the call stack) for IS_STRING values the reference count is increased, which needs non-constant inputs

For _function_string, the function pointer is passed to _function_parameter_string() and from there to _parameter_string() which needs to cast it to (zend_op_array*), so a non-constant input is needed

If this (and a few other smaller test patches I was going to send, the next being for zend_enum.c) were accepted, I would then file a task/start a discussion for doing this all over the place. E.g., if zend_string_dup() gets changed to get a constant pointer, then anything that calls (and doesn't need a non-constant pointer for anything else), and so on, bubbling up.

@iluuu1994 iluuu1994 merged commit 71edc05 into php:master Sep 17, 2024
9 of 10 checks passed
@iluuu1994
Copy link
Member

Thank you @DanielEScherzer!

@DanielEScherzer DanielEScherzer deleted the patch-3 branch September 17, 2024 01:21
@DanielEScherzer
Copy link
Member Author

Thank you @DanielEScherzer!

Thanks for the review - I sent the zend_enum.c patch as #15932

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