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.
 
 
 
 
 
 

149 lines
4.8 KiB

  1. define(`PROCESS_SCALAR', `dnl {{{ (1:elm, 2:format=%d, 3:type=)
  2. IFNOTMEMCPY(`IFCOPY(`DST(`$1') = SRC(`$1');')')
  3. IFDPRINT(`
  4. INDENT()
  5. fprintf(stderr, "$3:$1:\t%ifelse(`$2',`',`d',`$2')\n", SRC(`$1'));
  6. ')
  7. IFDASM(`
  8. ifelse(
  9. `$3', `zend_bool', `add_assoc_bool_ex(dst, XCACHE_STRS("$1"), SRC(`$1') ? 1 : 0);'
  10. , `$3', `double', `add_assoc_double_ex(dst, XCACHE_STRS("$1"), SRC(`$1'));'
  11. , `', `', `add_assoc_long_ex(dst, XCACHE_STRS("$1"), SRC(`$1'));'
  12. )
  13. ')
  14. DONE(`$1')
  15. ')
  16. dnl }}}
  17. dnl {{{ PROCESS_CTEXTPOINTER
  18. define(`PROCESS_CTEXTPOINTER', `COPY(`$1')')
  19. dnl }}}
  20. define(`PROCESS_xc_ztstring', `dnl {{{ (1:elm)
  21. pushdef(`REALPTRTYPE', `zend_class_entry')
  22. PROC_STRING(`$1')
  23. popdef(`REALPTRTYPE')
  24. ')
  25. dnl }}}
  26. define(`PROCESS_xc_zval_type_t', `dnl {{{ (1:elm)
  27. IFDPRINT(`
  28. INDENT()
  29. fprintf(stderr, ":$1:\t%d %s\n", SRC(`$1'), xc_get_data_type(SRC(`$1')));
  30. DONE(`$1')
  31. ', `PROCESS_SCALAR(`$1')')
  32. ')
  33. dnl }}}
  34. define(`PROCESS_xc_op_type', `dnl {{{ (1:elm)
  35. IFDPRINT(`
  36. INDENT()
  37. fprintf(stderr, ":$1:\t%d %s\n", SRC(`$1'), xc_get_op_type(SRC(`$1')));
  38. DONE(`$1')
  39. ', `PROCESS_SCALAR(`$1')')
  40. ')
  41. dnl }}}
  42. define(`PROCESS_xc_opcode', `dnl {{{ (1:elm)
  43. IFDPRINT(`
  44. INDENT()
  45. fprintf(stderr, ":$1:\t%u %s\n", SRC(`$1'), xc_get_opcode(SRC(`$1')));
  46. DONE(`$1')
  47. ', `PROCESS_SCALAR(`$1')')
  48. ')
  49. dnl }}}
  50. define(`PROCESS', `dnl PROCESS(1:type, 2:elm)
  51. DBG(`$0($*)')
  52. assert(sizeof($1) == sizeof(SRC(`$2')));
  53. ifelse(
  54. `$1', `zend_bool', `PROCESS_SCALAR(`$2', `u', `$1')'
  55. , `$1', `zend_uchar', `PROCESS_SCALAR(`$2', `u', `$1')'
  56. , `$1', `char', `PROCESS_SCALAR(`$2', `d', `$1')'
  57. , `$1', `int32_t', `PROCESS_SCALAR(`$2', `d', `$1')'
  58. , `$1', `unsigned char', `PROCESS_SCALAR(`$2', `u', `$1')'
  59. , `$1', `zend_uint', `PROCESS_SCALAR(`$2', `u', `$1')'
  60. , `$1', `uint', `PROCESS_SCALAR(`$2', `u', `$1')'
  61. , `$1', `unsigned int', `PROCESS_SCALAR(`$2', `u', `$1')'
  62. , `$1', `zend_ulong', `PROCESS_SCALAR(`$2', `lu', `$1')'
  63. , `$1', `ulong', `PROCESS_SCALAR(`$2', `lu', `$1')'
  64. , `$1', `size_t', `PROCESS_SCALAR(`$2', `lu', `$1')'
  65. , `$1', `long', `PROCESS_SCALAR(`$2', `ld', `$1')'
  66. , `$1', `time_t', `PROCESS_SCALAR(`$2', `ld', `$1')'
  67. , `$1', `zend_ushort', `PROCESS_SCALAR(`$2', `hu', `$1')'
  68. , `$1', `int', `PROCESS_SCALAR(`$2', `d', `$1')'
  69. , `$1', `double', `PROCESS_SCALAR(`$2', `f', `$1')'
  70. , `$1', `xc_entry_type_t', `PROCESS_SCALAR(`$2', `d', `$1')'
  71. , `$1', `xc_hash_value_t', `PROCESS_SCALAR(`$2', `lu', `$1')'
  72. , `$1', `last_brk_cont_t', `PROCESS_SCALAR(`$2', `d', `$1')'
  73. , `$1', `zend_object_handle',`PROCESS_SCALAR(`$2', `d', `$1')'
  74. , `$1', `xc_ztstring', `PROCESS_xc_ztstring(`$2')'
  75. , `$1', `xc_zval_type_t', `PROCESS_xc_zval_type_t(`$2')'
  76. , `$1', `xc_op_type', `PROCESS_xc_op_type(`$2')'
  77. , `$1', `xc_opcode', `PROCESS_xc_opcode(`$2')'
  78. , `$1', `opcode_handler_t', `/* is copying enough? */PROCESS_CTEXTPOINTER(`$2')'
  79. , `$1', `xc_md5sum_t', `COPY(`$2')'
  80. , `', `', `m4_errprint(`AUTOCHECK ERROR: Unknown type "$1"')define(`EXIT_PENDING', 1)'
  81. )
  82. ')
  83. define(`PROCESS_ARRAY', `dnl {{{ (1:count, 2:type, 3:elm, [4:real_type])
  84. if (SRC(`$3')) {
  85. int LOOPCOUNTER;
  86. IFDASM(`
  87. zval *arr;
  88. ALLOC_INIT_ZVAL(arr);
  89. array_init(arr);
  90. for (LOOPCOUNTER = 0;
  91. ifelse(`$1', `', `SRC(`$3[LOOPCOUNTER]')',
  92. `', `', `LOOPCOUNTER < SRC(`$1')');
  93. ++LOOPCOUNTER) {
  94. pushdef(`dst', `arr')
  95. pushdef(`SRC', `ifelse(`$4', `', `', `($2)')' defn(`SRC') `[LOOPCOUNTER]')
  96. pushdef(`add_assoc_bool_ex', `add_next_index_bool($1, $3)')
  97. pushdef(`add_assoc_string_ex', `add_next_index_string($1, $3)')
  98. pushdef(`add_assoc_long_ex', `add_next_index_long($1, $3)')
  99. pushdef(`add_assoc_zval_ex', `add_next_index_zval($1, $3)')
  100. DISABLECHECK(`
  101. PROCESS(`$2', `$3')
  102. ')
  103. popdef(`add_assoc_zval_ex')
  104. popdef(`add_assoc_long_ex')
  105. popdef(`add_assoc_string_ex')
  106. popdef(`add_assoc_bool_ex')
  107. popdef(`SRC')
  108. popdef(`dst')
  109. }
  110. add_assoc_zval_ex(dst, XCACHE_STRS("$3"), arr);
  111. ', `
  112. dnl find count with NULL
  113. ifelse(`$1', `', `
  114. size_t count = 0;
  115. while (SRC(`$3[count]')) {
  116. ++count;
  117. }
  118. ++count;
  119. pushdef(`STRUCT_COUNT', `count')
  120. ',
  121. `', `', `pushdef(`STRUCT_COUNT', `SRC(`$1')')')
  122. ALLOC(`DST(`$3')', `$2', `STRUCT_COUNT', , `$4')
  123. popdef(`STRUCT_COUNT')
  124. for (LOOPCOUNTER = 0;
  125. ifelse(`$1', `', `SRC(`$3[LOOPCOUNTER]')',
  126. `', `', `LOOPCOUNTER < SRC(`$1')');
  127. ++LOOPCOUNTER) {
  128. DISABLECHECK(`
  129. pushdef(`DST', defn(`DST') `[LOOPCOUNTER]')
  130. pushdef(`SRC', `ifelse(`$4', `', `', `', `', `($2)')' defn(`SRC') `[LOOPCOUNTER]')
  131. PROCESS(`$2', `$3')
  132. popdef(`SRC')
  133. popdef(`DST')
  134. ')
  135. }
  136. dnl the end marker
  137. ifelse(`$1', `', `IFCOPY(`DST(`$3[LOOPCOUNTER]') = NULL;')')
  138. ')dnl IFDASM
  139. DONE(`$3')
  140. }
  141. else {
  142. COPYNULL(`$3')
  143. }
  144. ')
  145. dnl }}}