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

kernel/fcall.c optimizations #954

Merged
merged 6 commits into from Jul 30, 2013
Merged

kernel/fcall.c optimizations #954

merged 6 commits into from Jul 30, 2013

Conversation

ghost
Copy link

@ghost ghost commented Jul 30, 2013

  • renamed all macros to follow the same style: phalcon_call_WHAT_pX(_noret)
  • fixed inconsistencies in restoring memory frame on failure in phalcon_create_instance(_params)
  • use variadic arguments instead of arrays in phalcon_call_WHAT_params()
  • added phalcon_has_constructor_ce() which reuses the existing class entry (calls to Z_OBJCE_P() are expensive)
  • removed a lot of functions from kernel/fcall.h — now that we don't need array to pass the parameters, we can use variadic macros instead
  • use do_alloca()/free_alloca() macros from Zend instead of emalloc()/efree(): if the block to be allocated is not large, alloca() will be used (much faster than emalloc()); otherwise, emalloc() will be used as a fallback
  • introduced optimized macros PHALCON_CALL_FUNCTION, PHALCON_CALL_METHOD, PHALCON_CALL_PARENT, PHALCON_CALL_SELF, PHALCON_CALL_STATIC: they wrap phalcon_call_XXX_params() functions and restore memory frame on failures. If the compiler is GCC, these macros expand to pretty optimized calls: when the method or function name is a known compile time constant, its hash can also be computed at compile time. If the name is not a literal (say, a variable), then instead of sizeof() we use strlen() to make sure that the length will be correct.

PS: I will address failed Mongo tests in my next PR as they are not related to fcall.

@ghost
Copy link
Author

ghost commented Jul 30, 2013

Just added:

  • when method hash is not supplied, check if the method name is an interned string and if so, use the precomputed hash

phalcon pushed a commit that referenced this pull request Jul 30, 2013
kernel/fcall.c optimizations
@phalcon phalcon merged commit 3369218 into phalcon:1.3.0 Jul 30, 2013
@ghost ghost deleted the fcall branch July 30, 2013 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants