-
Notifications
You must be signed in to change notification settings - Fork 0
Implement single "last matched CE" cache slot for RECV and VERIFY_RETURN_TYPE #123
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
base: master
Are you sure you want to change the base?
Conversation
return true; | ||
} | ||
} | ||
}; |
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.
TODO: remove this accident
Thank you for trying this! I get -0.14% wall time on symfony demo:
(Average of 5 runs We may avoid allocating a cache slot for simple types, as we use it only for complex ones. |
Good point.
For me it's a bit of a hit or miss on my older CPU. I can try again on some more recent machine a bit later. I also see only now that Ilija also tried something like this (before I removed the original cache slot implementation): iluuu1994#155 |
I just committed this to run in CI and get a CI Valgrind bench going: diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 7d2e4112797..563e12d3af2 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1145,9 +1145,9 @@ static zend_always_inline bool zend_check_type_slow(
bool is_return_type, bool is_internal)
{
if (ZEND_TYPE_IS_COMPLEX(*type) && EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
- if (*cache_slot == Z_OBJCE_P(arg)) {
- return true;
- }
+ // if (*cache_slot == Z_OBJCE_P(arg)) {
+ // return true;
+ // }
zend_class_entry *ce;
if (UNEXPECTED(ZEND_TYPE_HAS_LIST(*type))) {
if (ZEND_TYPE_IS_INTERSECTION(*type)) {
@@ -1242,6 +1242,10 @@ static zend_always_inline bool zend_verify_recv_arg_type(const zend_function *zf
ZEND_ASSERT(arg_num <= zf->common.num_args);
cur_arg_info = &zf->common.arg_info[arg_num-1];
+ if (Z_TYPE_P(arg) == IS_OBJECT && *cache_slot == Z_OBJCE_P(arg)) {
+ return 1;
+ }
+
if (ZEND_TYPE_IS_SET(cur_arg_info->type)
&& UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) {
zend_verify_arg_error(zf, cur_arg_info, arg_num, arg); I'm afraid this may degrade scalar checks though. |
No description provided.