-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Use zend_std_build_properties() to access zend_object.properties #14996
Conversation
5342ffa
to
909fd8e
Compare
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.
ACK for SPL and PDO.
This also makes the API simpler and clearer, which is good IMHO
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.
LGTM ext-random!
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 looked at everything except zend_vm. Looks good :)
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.
We've talked about this before. Thank you, this LGTM.
One question though: I suggested moving zend_std_get_properties()
into the header and making it static inline
, because the implementation is trivial. This would require making rebuild_object_properties
non-static again. Do you still intend to do that?
Zend/zend_object_handlers.c
Outdated
@@ -62,7 +62,7 @@ | |||
called, we cal __call handler. | |||
*/ | |||
|
|||
ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ | |||
static void rebuild_object_properties(zend_object *zobj) /* {{{ */ |
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.
since something no-longer is ZEND_API
which was before, does this need to be noted in some changelog/releasenotes ?
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.
Agreed. I usually update the UPGRADING files separately, as our merge strategy for those tends to lose the changes.
I forgot about this part of your suggestion. I've now inlined the An alternative would have been to introduce a non-handler function with a name like |
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.
LGTM, maybe add a short note to UPGRADING.INTERNALS.
25e5404
to
50c2e67
Compare
The zend_object.properties HashTable needs to be built just in time by calling rebuild_object_properties() on the object before accessing it. Normally this is done automatically in zend_std_get_properties(), but we do it manually in a few places. In this change I introduce an inline variant of zend_std_build_properties(), and refactor these places to use it instead of calling rebuild_object_properties() manually. rebuild_object_properties() is made static to enforce usage of zend_std_get_properties() or zend_std_build_properties_ex().
50c2e67
to
6e216aa
Compare
I figured that calling rebuild_object_properties(), which is un-exported by this change, from an inline function may be problematic. So I've re-exported it, and renamed it to force external code to notice the change. |
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.
Still LGTM
*/ | ||
|
||
ZEND_API void rebuild_object_properties(zend_object *zobj) /* {{{ */ | ||
ZEND_API void rebuild_object_properties_internal(zend_object *zobj) /* {{{ */ |
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.
As the API is changed anyway, it makes sense to return HashTable
and avoid extra load of zobj->properties
in zend_std_get_properties[_ex]
.
/* Use zend_std_get_properties_ex() */ | ||
ZEND_API void rebuild_object_properties_internal(zend_object *zobj); | ||
|
||
static inline HashTable *zend_std_get_properties_ex(zend_object *object) |
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.
It's better to use zend_always_inline
The
zend_object.properties
HashTable needs to be built just in time by callingrebuild_object_properties()
on the object before accessing it. Normally this is done automatically inzend_std_get_properties()
, but we do it manually in a few places, like this:php-src/Zend/zend_API.c
Lines 1782 to 1785 in 7d99a9c
In this PR I refactor these places to use
zend_std_get_properties()
instead. I also makerebuild_object_properties()
static to enforce usage ofzend_std_get_properties()
.This refactoring will be useful in the context of the lazy objects RFC, as the
zend_std_get_properties()
function becomes a single entry point forzend_object.properties
where we can initialize a lazy object.cc @TimWolla