XCache is a fast, stable PHP opcode cacher that has been proven and is now running on production servers under high load. https://xcache.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.1 KiB

  1. /* {{{ xc_get_class_num
  2. * return class_index + 1
  3. */
  4. static zend_ulong xc_get_class_num(xc_processor_t *processor, zend_class_entry *ce) {
  5. zend_uint i;
  6. const xc_entry_data_php_t *php = processor->php_src;
  7. zend_class_entry *ceptr;
  8. if (processor->cache_ce == ce) {
  9. return processor->cache_class_index + 1;
  10. }
  11. for (i = 0; i < php->classinfo_cnt; i ++) {
  12. ceptr = CestToCePtr(php->classinfos[i].cest);
  13. if (ZCEP_REFCOUNT_PTR(ceptr) == ZCEP_REFCOUNT_PTR(ce)) {
  14. processor->cache_ce = ceptr;
  15. processor->cache_class_index = i;
  16. assert(i <= processor->active_class_index);
  17. return i + 1;
  18. }
  19. }
  20. assert(0);
  21. return (zend_ulong) -1;
  22. }
  23. define(`xc_get_class_num', `IFSTORE(``xc_get_class_num'($@)',``xc_get_class_num' can be use in store only')')
  24. /* }}} */
  25. #ifdef ZEND_ENGINE_2
  26. static zend_class_entry *xc_get_class(xc_processor_t *processor, zend_ulong class_num) { /* {{{ */
  27. /* must be parent or currrent class */
  28. assert(class_num > 0);
  29. assert(class_num <= processor->active_class_index + 1);
  30. return CestToCePtr(processor->php_dst->classinfos[class_num - 1].cest);
  31. }
  32. define(`xc_get_class', `IFRESTORE(``xc_get_class'($@)',``xc_get_class' can be use in restore only')')
  33. /* }}} */
  34. #endif
  35. #ifdef ZEND_ENGINE_2
  36. /* fix method on store */
  37. static void xc_fix_method(xc_processor_t *processor, zend_op_array *dst TSRMLS_DC) /* {{{ */
  38. {
  39. zend_function *zf = (zend_function *) dst;
  40. zend_class_entry *ce = processor->active_class_entry_dst;
  41. const zend_class_entry *srcce = processor->active_class_entry_src;
  42. /* Fixing up the default functions for objects here since
  43. * we need to compare with the newly allocated functions
  44. *
  45. * caveat: a sub-class method can have the same name as the
  46. * parent~s constructor and create problems.
  47. */
  48. if (zf->common.fn_flags & ZEND_ACC_CTOR) {
  49. if (!ce->constructor) {
  50. ce->constructor = zf;
  51. }
  52. }
  53. else if (zf->common.fn_flags & ZEND_ACC_DTOR) {
  54. ce->destructor = zf;
  55. }
  56. else if (zf->common.fn_flags & ZEND_ACC_CLONE) {
  57. ce->clone = zf;
  58. }
  59. else {
  60. pushdef(`SET_IF_SAME_NAMEs', `
  61. SET_IF_SAME_NAME(__get);
  62. SET_IF_SAME_NAME(__set);
  63. #ifdef ZEND_ENGINE_2_1
  64. SET_IF_SAME_NAME(__unset);
  65. SET_IF_SAME_NAME(__isset);
  66. #endif
  67. SET_IF_SAME_NAME(__call);
  68. #ifdef ZEND_CALLSTATIC_FUNC_NAME
  69. SET_IF_SAME_NAME(__callstatic);
  70. #endif
  71. #if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6
  72. SET_IF_SAME_NAME(__tostring);
  73. #endif
  74. #if defined(ZEND_ENGINE_2_6)
  75. SET_IF_SAME_NAME(__debugInfo);
  76. #endif
  77. ')
  78. #ifdef IS_UNICODE
  79. if (UG(unicode)) {
  80. #define SET_IF_SAME_NAME(member) \
  81. do { \
  82. if (srcce->member && u_strcmp(ZSTR_U(zf->common.function_name), ZSTR_U(srcce->member->common.function_name)) == 0) { \
  83. ce->member = zf; \
  84. } \
  85. } \
  86. while(0)
  87. SET_IF_SAME_NAMEs()
  88. #undef SET_IF_SAME_NAME
  89. }
  90. else
  91. #endif
  92. do {
  93. #define SET_IF_SAME_NAME(member) \
  94. do { \
  95. if (srcce->member && strcmp(ZSTR_S(zf->common.function_name), ZSTR_S(srcce->member->common.function_name)) == 0) { \
  96. ce->member = zf; \
  97. } \
  98. } \
  99. while(0)
  100. SET_IF_SAME_NAMEs()
  101. #undef SET_IF_SAME_NAME
  102. } while (0);
  103. popdef(`SET_IF_SAME_NAMEs')
  104. }
  105. }
  106. /* }}} */
  107. #endif
  108. define(`xc_lookup_class', `IFRESTORE(``xc_lookup_class'($@)',``xc_lookup_class' can be use in restore only')')