-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Handle trampolines correctly in new FCC API + usages #9877
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
Conversation
eecde4c
to
14ba20f
Compare
My understanding is that SPL copies |
Ah, so I suppose it's a wise idea to free this when doing the copy. :) |
c322a0f
to
1699bd7
Compare
Zend/zend_API.h
Outdated
memcpy(copy, fcc->function_handler, sizeof(zend_function)); | ||
fcc->function_handler->common.function_name = NULL; | ||
fcc->function_handler = copy; | ||
memset(&EG(trampoline), 0, sizeof(zend_function)); |
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.
This is redundant with the fcc->function_handler->common.function_name = NULL
above.
It may be enough to just set EG(trampoline).common.function_name
to NULL
(this is what zend_free_trampoline
does, and EG(trampoline).common.function_name
only looks at EG(trampoline).common.function_name
to check that the slot is free).
As the trampoline will refer to a zend_function* defined on the closure CE
1699bd7
to
d369627
Compare
So I finally understand what php-src calls trampolines, and they are extremely annoying to deal with.
I've taken the code to handle them from the SPL class autoloading mechanism, however I haven't yet figured out why SPL copies the function handler when
fcc->function_handler == &EG(trampoline)
.This makes me wonder if this is the reason why no FCC API was introduced previously as you would need to carry the zval callable around which would would recreate the trampoline each time.
Moreover, the refetching of the trampoline which is freed by ZPP should probably be part of some explicit API that we provide if in the end we thing providing an FCC API is sensible.