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 allocating temporaries on the call frame for property hook trampolines #16287

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

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Oct 7, 2024

As pointed out in #16252 (comment)

@nielsdos nielsdos marked this pull request as ready for review October 7, 2024 19:43
@nielsdos nielsdos requested a review from dstogov as a code owner October 7, 2024 19:43
@@ -1707,6 +1707,9 @@ ZEND_API zend_function *zend_get_property_hook_trampoline(
func = (zend_function *)(uintptr_t)ecalloc(1, sizeof(zend_internal_function));
}
func->type = ZEND_INTERNAL_FUNCTION;
/* This trampoline does not use the call_trampoline_op, so it won't reuse the call frame,
* which means we don't even need to reserve a temporary for observers. */
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused by this comment. Won't this simply not use observers because of ZEND_ACC_CALL_VIA_TRAMPOLINE? See zend_observer_handler_is_unobserved().

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but see #16252 to know why this isn't always a safe assumption.

Copy link
Member Author

Choose a reason for hiding this comment

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

To clarify, it's not because a function isn't observed that the call frame won't be reused by a function that becomes observed. The reuse happens when dealing with call_trampoline_op. This doesn't happen here so we don't have to account for the extra observer temporary.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. This goes over my head at this time of day ^^ I will have a closer look tomorrow.

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.

2 participants