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.

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