├── .gitignore ├── .vimrc ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.frag ├── Makefile.frag.deps ├── NEWS ├── README ├── THANKS ├── bin └── phpdc.phpr ├── config.m4 ├── config.w32 ├── devel ├── exportfunctions.php ├── gen_const_string_opcodes.awk ├── gen_xc_opcode_spec.awk ├── graph │ └── cached_compile.dot ├── include.php ├── include_once.php ├── lsnewini ├── make ├── po2php.awk ├── prepare.cfg.example ├── prepare.mak ├── require.php ├── require_once.php ├── run ├── sample.cpp.php └── test.mak ├── gen_structinfo.awk ├── htdocs ├── cacher │ ├── cacher.css │ ├── common.php │ ├── config.default.php │ ├── config.example.php │ ├── edit.php │ ├── edit.tpl.php │ ├── index.php │ ├── lang │ │ ├── en.php │ │ ├── en.po │ │ ├── zh-simplified.php │ │ ├── zh-simplified.po │ │ ├── zh-traditional.php │ │ └── zh-traditional.po │ ├── listentries.tpl.php │ ├── mkpassword.php │ ├── sub │ │ ├── entrylist.tpl.php │ │ ├── moduleinfo.tpl.php │ │ ├── summary.tpl.php │ │ └── testcoredump.tpl.php │ └── summary.tpl.php ├── common │ ├── common.css │ ├── common.php │ ├── footer.tpl.php │ ├── header.tpl.php │ ├── lang │ │ ├── en.php │ │ ├── en.po │ │ ├── zh-simplified.php │ │ ├── zh-simplified.po │ │ ├── zh-traditional.php │ │ └── zh-traditional.po │ ├── tablesort.js │ └── xcache.png ├── config.default.php ├── config.example.php ├── coverager │ ├── common.php │ ├── config.default.php │ ├── config.example.php │ ├── coverager.css │ ├── coverager.tpl.php │ ├── index.php │ └── lang │ │ ├── en.php │ │ ├── en.po │ │ ├── zh-simplified.php │ │ ├── zh-simplified.po │ │ ├── zh-traditional.php │ │ └── zh-traditional.po ├── diagnosis │ ├── diagnosis.css │ ├── diagnosis.tpl.php │ ├── index.php │ └── lang │ │ ├── en.php │ │ ├── en.po │ │ ├── zh-simplified.php │ │ ├── zh-simplified.po │ │ ├── zh-traditional.php │ │ ├── zh-traditional.po │ │ └── zh-tranditional.php └── index.php ├── includes.c ├── lib └── Decompiler.class.php ├── mod_assembler └── xc_assembler.c ├── mod_cacher ├── xc_cache.h ├── xc_cacher.c └── xc_cacher.h ├── mod_coverager ├── xc_coverager.c └── xc_coverager.h ├── mod_decoder └── xc_decoder.c ├── mod_disassembler ├── xc_disassembler.c └── xc_disassembler.h ├── mod_encoder └── xc_encoder.c ├── mod_optimizer ├── xc_optimizer.c └── xc_optimizer.h ├── processor ├── class-helper.m4 ├── debug.h ├── foot.m4 ├── hashtable.m4 ├── head.m4 ├── main.m4 ├── process.m4 ├── processor-t.h ├── processor.m4 ├── string-helper-t.h ├── string-helper.h ├── string-helper.m4 ├── string.m4 ├── struct.m4 ├── types.h ├── types.m4 ├── var-helper-t.h ├── var-helper.h └── var-helper.m4 ├── run-xcachetest ├── tests ├── include-skipif.inc ├── skipif.inc ├── sub-a.inc ├── sub-b.inc ├── xcache_deep_copy_arg_info.phpt ├── xcache_deep_copy_opcodes_for_const.phpt ├── xcache_deep_copy_static_variables.phpt ├── xcache_include_absolute.phpt ├── xcache_include_relative_cwd.phpt ├── xcache_include_relative_file.phpt ├── xcache_is_autoglobal.phpt ├── xcache_shallow_copy_check_early_binding.phpt ├── xcache_var.phpt ├── xcache_var_object.phpt ├── xcache_var_object_5.1.phpt ├── xcache_var_reference.phpt ├── xcache_var_reference_4.phpt └── xcache_var_reference_5.1.phpt ├── util ├── README ├── xc_align.h ├── xc_foreachcoresig.h ├── xc_trace.c ├── xc_trace.h ├── xc_util.h ├── xc_vector.h └── xc_vector_test.c ├── xcache-test.ini ├── xcache-zh-gb2312.ini ├── xcache.c ├── xcache.h ├── xcache.ini ├── xcache ├── README ├── xc_allocator.c ├── xc_allocator.h ├── xc_allocator_bestfit.c ├── xc_compatibility.c ├── xc_compatibility.h ├── xc_const_string.c ├── xc_const_string.h ├── xc_const_string_opcodes_php4.x.h ├── xc_const_string_opcodes_php5.0.h ├── xc_const_string_opcodes_php5.1.h ├── xc_const_string_opcodes_php5.2.h ├── xc_const_string_opcodes_php5.3.h ├── xc_const_string_opcodes_php5.4.h ├── xc_const_string_opcodes_php5.5.h ├── xc_const_string_opcodes_php5.6.h ├── xc_const_string_opcodes_php6.x.h ├── xc_extension.c ├── xc_extension.h ├── xc_ini.c ├── xc_ini.h ├── xc_malloc.c ├── xc_mutex.c ├── xc_mutex.h ├── xc_opcode_spec.c ├── xc_opcode_spec.h ├── xc_opcode_spec_def.h ├── xc_processor.c ├── xc_sandbox.c ├── xc_sandbox.h ├── xc_shm.c ├── xc_shm.h ├── xc_shm_mmap.c ├── xc_utils.c └── xc_utils.h └── xcache_globals.h /.gitignore: -------------------------------------------------------------------------------- 1 | acinclude.m4 2 | aclocal.m4 3 | allocator_test 4 | autom4te.cache 5 | build 6 | config.cache 7 | config.guess 8 | config.h 9 | config.h.in 10 | config.log 11 | config.nice 12 | config.status 13 | config.sub 14 | configure 15 | configure.in 16 | conftest 17 | conftest.c 18 | .deps 19 | devel.fpm 20 | devel.ini 21 | devel.php 22 | devel.pid 23 | .exvim.* 24 | .gdb_history 25 | htdocs/*/lang/*-merged 26 | htdocs/*/lang/*.pot 27 | include 28 | includes.i 29 | install-sh 30 | libtool 31 | ltmain.sh 32 | make 33 | Makefile 34 | Makefile.fragments 35 | Makefile.global 36 | Makefile.objects 37 | missing 38 | mkinstalldirs 39 | modules 40 | output.php 41 | prepare.cfg 42 | prepare.devel.inc 43 | run 44 | run.cfg 45 | run-tests.php 46 | structinfo.m4 47 | .svnignore 48 | tags 49 | xcache.exvim 50 | xc_processor.c 51 | xc_processor.h 52 | xc_processor.out.c 53 | -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | set noexpandtab 2 | au FileType m4 setlocal ts=2 sw=2 fdm=marker noexpandtab 3 | au FileType c setlocal ts=4 sw=4 fdm=marker noexpandtab 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | mOo 2 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (c) 2005-2014, mOo, phpxcache@gmail.com, XCache 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | - Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | - Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | - Neither the name of the 'XCache' nor the names of its contributors may 17 | be used to endorse or promote products derived from this software without 18 | specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 | THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | # vim:ts=4:sw=4 2 | Installtion: 3 | 4 | $ phpize --clean && phpize 5 | $ ./configure --help 6 | $ CFLAGS='your cflags' ./configure --enable-xcache --enable... 7 | $ make 8 | $ su 9 | # make install 10 | (update php.ini, restart php) 11 | 12 | Reinstall: 13 | 14 | $ mv config.nice conf 15 | $ make distclean && phpize --clean && phpize 16 | $ mv conf config.nice 17 | $ ./config.nice 18 | $ make 19 | $ su 20 | # make install 21 | (update php.ini, restart php) 22 | 23 | Update php.ini: 24 | $ su 25 | # cat xcache.ini >> /etc/php.ini 26 | # $EDITOR /etc/php.ini 27 | -------------------------------------------------------------------------------- /Makefile.frag: -------------------------------------------------------------------------------- 1 | XCACHE_PROC_SRC=$(srcdir)/processor/main.m4 2 | XCACHE_PROC_OUT=$(builddir)/processor.out.c 3 | XCACHE_PROC_C=$(builddir)/xc_processor.c.h 4 | XCACHE_PROC_H=$(builddir)/xc_processor.h 5 | XCACHE_INCLUDES_SRC=$(srcdir)/includes.c 6 | XCACHE_INCLUDES_I=$(builddir)/includes.i 7 | XCACHE_STRUCTINFO_OUT=$(builddir)/structinfo.m4 8 | 9 | $(XCACHE_INCLUDES_I): 10 | $(CC) -I. -I$(srcdir) $(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) -E $(XCACHE_INCLUDES_SRC) -o $(XCACHE_INCLUDES_I) 11 | 12 | $(XCACHE_STRUCTINFO_OUT): $(XCACHE_INCLUDES_I) $(srcdir)/gen_structinfo.awk 13 | @echo $(XCACHE_STRUCTINFO_OUT) is optional if XCache test is not enabled, feel free if it awk failed to produce it 14 | $(XCACHE_AWK) -f $(srcdir)/gen_structinfo.awk < $(XCACHE_INCLUDES_I) > $(XCACHE_STRUCTINFO_OUT).tmp || echo > $(XCACHE_STRUCTINFO_OUT) 15 | mv $(XCACHE_STRUCTINFO_OUT).tmp $(XCACHE_STRUCTINFO_OUT) 16 | 17 | $(XCACHE_PROC_OUT): $(XCACHE_PROC_SRC) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SOURCES) 18 | $(M4) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp 19 | mv $(XCACHE_PROC_OUT).tmp $(XCACHE_PROC_OUT) 20 | 21 | $(XCACHE_PROC_H): $(XCACHE_PROC_OUT) 22 | $(GREP) "export: " $(XCACHE_PROC_OUT) | $(SED) "s/.*export:\(.*\):export.*/\1/g" > $(XCACHE_PROC_H) 23 | -$(XCACHE_INDENT) < $(XCACHE_PROC_H) > $(XCACHE_PROC_H).tmp && mv $(XCACHE_PROC_H).tmp $(XCACHE_PROC_H) 24 | 25 | $(XCACHE_PROC_C): $(XCACHE_PROC_OUT) $(XCACHE_PROC_H) 26 | cp $(XCACHE_PROC_OUT) $(XCACHE_PROC_C) 27 | -$(XCACHE_INDENT) < $(XCACHE_PROC_OUT) > $(XCACHE_PROC_C).tmp && mv $(XCACHE_PROC_C).tmp $(XCACHE_PROC_C) 28 | 29 | xcachevcsclean: clean 30 | cat .gitignore | grep -v devel | grep -v gitignore | grep -v ^Makefile | grep -v ^config.nice | xargs rm -rf 31 | 32 | xcachetest: all 33 | $(SED) "s#\\./\\.libs/#$(top_builddir)/\\.libs/#" < $(srcdir)/xcache-test.ini > $(top_builddir)/tmp-php.ini 34 | if test -z "$(TESTS)"; then \ 35 | TEST_INI=$(top_builddir)/tmp-php.ini TEST_PHP_USER=tests TEST_PHP_SRCDIR=$(srcdir) $(srcdir)/run-xcachetest $(TEST_ARGS); \ 36 | fi 37 | TEST_INI=$(top_builddir)/tmp-php.ini $(srcdir)/run-xcachetest $(TESTS) $(TEST_ARGS) 38 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 4.0.0 2014-??-?? 2 | ======== 3 | * api updates 4 | * cache defragment, cache to disk 5 | * added class const support for __FILE__ __DIR__ 6 | * adds support for object caching 7 | * updated disassembler decompiler support 8 | 9 | 3.2.0 2014-09-18 10 | ======== 11 | * PHP_5_6 support 12 | * reduce memory usage for small or empty files 13 | * aware of Zend OPcache 14 | 15 | 3.1.2 2014-09-18 16 | ======== 17 | * repackage of 3.1.1 to fix sub directory name in source package 18 | 19 | 3.1.1 2014-09-02 20 | ======== 21 | * compatible with bcompiler 22 | * fix 24h counter in admin page 23 | 24 | 3.1.0 2013-10-10 25 | ======== 26 | * adds support for PHP_5_5 27 | * compatible with pcntl_fork() 28 | * fixes support for __FILE__ __DIR__ on moved/hardlinked files 29 | * disassembler now working again (fail since 3.0), supports PHP 4.x ~ PHP 5.5.x 30 | 31 | 3.0.4 2013-10-10 32 | ======== 33 | * improve stability under massive concurrent 34 | * refix locking impl for threaded env 35 | * fix out of source building 36 | 37 | 3.0.3 2013-06-18 38 | ======== 39 | * clean files in release (fix htdocs config) 40 | 41 | 3.0.2 2013-06-10 42 | ======== 43 | * (PHP5.4+ only bug) random "cannot redeclare class" errors is now gone. Can also be avoid by using readonly_protection (unavailable with /dev/zero). 44 | * fixes SEGV with Zend Debugger 45 | * more bug fixes 46 | 47 | 3.0.1 2013-01-11 48 | ======== 49 | * bug fixes 50 | * improve compatibility with "the ionCube PHP Loader", Zend Optimizer 51 | * improve stability 52 | * improve support for PHP_5_4 53 | * improve stability on threaded env 54 | 55 | 3.0.0 2012-10-29 56 | ======== 57 | * lots of improvements 58 | * bug fixes 59 | * updates api, adds a few ini 60 | * uses extension= to load XCache. loading via zend_extension= is unsupported 61 | * updates XCache admin page 62 | * namespace support 63 | * professional helpers 64 | * adds an diagnosis module to give advise @ htdocs 65 | * auto disable caching on crash @ runtime 66 | 67 | 2.0.1 2012-07-14 68 | ======== 69 | * improve stability 70 | * admin/ config changed. please update accordingly 71 | * PHP 5.3.14 is unstable. Please upgrade to new version. You have been warned 72 | * fixed __FILE__ __DIR__ handling for moved/hardlinked files (set "xcache.experimental = on" to eanble this fix) 73 | 74 | 2.0.0 2012-04-20 75 | ======== 76 | * support for PHP_5_4 77 | * reduce memory usage by caching 1 for multiple same content files 78 | * correct __FILE__ __DIR__ supported for hardlinked files 79 | 80 | 1.3.2 2011-06-04 81 | ======== 82 | * admin page security fix 83 | * adds 30 seconds timeout to "compiling" flag 84 | * improves decompiling 85 | * memory leak on recompile 86 | * disassembler fixes and updates for new PHP 87 | * win32 build fix 88 | * improve compatibility with ionCube Loader 89 | 90 | 1.3.1 2010-11-27 91 | ======== 92 | * 2G/4G limitation on 64bit arch 93 | * xcache_unset matching e.g. prefixed_ values 94 | 95 | 1.3.0 2009-08-04 96 | ======== 97 | * PHP 5.3 support 98 | * many cacher/coverager bug fixes 99 | * improved admin pages 100 | * admin page is now magic quote gpc aware 101 | 102 | 1.2.2 2007-12-29 103 | ======== 104 | * live with wrong system time: allow caching files with mtime in further 105 | * bug fix for compatibility with Zend Optimizer and other non-cachable 106 | * a rare segv bug with token_get_all 107 | * minor bug fixes 108 | 109 | 1.2.1 2007-07-01 110 | ======== 111 | * compatibility fix for apache 1.x, which init XCache module correctly 112 | * full Zend Optimizer compatibility 113 | * ini settings changed 114 | * other bug fixes 115 | 116 | 1.2.0 2006-12-10 117 | ======== 118 | * full 5.2 support 119 | * minor admin/coverage-viewer page improves 120 | * compatible with suhosin/ZendOptimizer 121 | * xcache_get reference handling 122 | * new apis for coverager 123 | * some ini settings changed 124 | 125 | 1.1.0 2006-11-11 126 | ======== 127 | * fix xcache_get issue on ttl 0 data 128 | * avoid crash when php failed to compile file when coverager enabled 129 | * gc expired items, new ini 130 | * Partial php 5.2 support 131 | * "Cannot redeclare ()" bug 132 | * bug fixes 133 | * Chinese Simplified/Traditional translations 134 | * admin page fixes and applied phpinfo style 135 | * coverage viewer page use phpinfo style 136 | * fix build on rare arch and Mac OS X 137 | * zts build 138 | * includes all fixes from <=1.0.2 139 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load. 2 | It is tested (on linux) and supported on all of the latest version of PHP popular release branches. 3 | ThreadSafe/Windows is also perfectly supported. 4 | 5 | Please check http://xcache.lighttpd.net/ and https://groups.google.com/group/xcache for help 6 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | 2 | Jan , host XCache website 3 | Alex , redist to FreeBSD 4 | darix , redist to openSUSE 5 | judas_iscariote , redist/test with openSUSE 6 | Finjon Kiang , Chinese Traditional translation 7 | 8 | There is also many ppl on IRC or forum helped me a lot testing XCache. 9 | Without them, XCache may not even be released. 10 | -------------------------------------------------------------------------------- /bin/phpdc.phpr: -------------------------------------------------------------------------------- 1 | #! /usr/bin/php -dopen_basedir= 2 | decompileString($phpcode) === false) { 71 | exit(2); 72 | } 73 | $dc->output(); 74 | } 75 | else { 76 | foreach ($files as $file) { 77 | $dc = new Decompiler($outputTypes); 78 | switch ($inputType) { 79 | case 'opcode': 80 | eval('$opcode = ' . file_get_contents($file) . ';'); 81 | if ($dc->decompileDasm($opcode) === false) { 82 | exit(2); 83 | } 84 | break; 85 | 86 | case 'php'; 87 | if ($dc->decompileFile($file) === false) { 88 | exit(2); 89 | } 90 | break; 91 | } 92 | $dc->output(); 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl vim:ts=2:sw=2:expandtab 2 | 3 | AC_DEFUN([XCACHE_MODULE], [ 4 | PHP_ARG_ENABLE(xcache-$1, for XCache $1, 5 | [ --enable-xcache-$2 XCache: $4], no, no) 6 | if test "$PHP_$3" != "no"; then 7 | xcache_sources="$xcache_sources mod_$1/xc_$1.c" 8 | XCACHE_MODULES="$XCACHE_MODULES $1" 9 | HAVE_$3=1 10 | AC_DEFINE([HAVE_$3], 1, [Define for XCache: $4]) 11 | else 12 | HAVE_$3= 13 | fi 14 | ])dnl 15 | 16 | PHP_ARG_ENABLE(xcache, for XCache support, 17 | [ --enable-xcache XCache Extension.]) 18 | 19 | if test "$PHP_XCACHE" != "no"; then 20 | PHP_ARG_ENABLE(xcache-constant, for XCache handle of compile time constant, 21 | [ --enable-xcache-constant XCache: Handle new constants made by php compiler (e.g.: for __halt_compiler)], yes, no) 22 | if test "$PHP_XCACHE_CONSTANT" != "no"; then 23 | AC_DEFINE([HAVE_XCACHE_CONSTANT], 1, [Define to enable XCache handling of compile time constants]) 24 | fi 25 | 26 | xcache_sources="xcache.c" 27 | for i in \ 28 | xc_trace.c \ 29 | ; do 30 | xcache_sources="$xcache_sources util/$i" 31 | done 32 | for i in \ 33 | xc_allocator.c \ 34 | xc_allocator_bestfit.c \ 35 | xc_compatibility.c \ 36 | xc_const_string.c \ 37 | xc_extension.c \ 38 | xc_ini.c \ 39 | xc_mutex.c \ 40 | xc_opcode_spec.c \ 41 | xc_processor.c \ 42 | xc_sandbox.c \ 43 | xc_shm.c \ 44 | xc_shm_mmap.c \ 45 | xc_utils.c \ 46 | ; do 47 | xcache_sources="$xcache_sources xcache/$i" 48 | done 49 | for i in \ 50 | xc_cacher.c \ 51 | ; do 52 | xcache_sources="$xcache_sources mod_cacher/$i" 53 | done 54 | XCACHE_MODULES="cacher" 55 | AC_DEFINE([HAVE_XCACHE_CACHER], 1, [Define to enable XCache cacher]) 56 | XCACHE_MODULE([optimizer], [optimizer ], [XCACHE_OPTIMIZER], [(N/A)]) 57 | XCACHE_MODULE([coverager], [coverager ], [XCACHE_COVERAGER], [Enable code coverage dumper, useful for testing php scripts]) 58 | XCACHE_MODULE([assembler], [assembler ], [XCACHE_ASSEMBLER], [(N/A)]) 59 | XCACHE_MODULE([disassembler], [disassembler], [XCACHE_DISASSEMBLER], [Enable opcode to php variable dumper, not for server usage]) 60 | XCACHE_MODULE([encoder], [encoder ], [XCACHE_ENCODER], [(N/A)]) 61 | XCACHE_MODULE([decoder], [decoder ], [XCACHE_DECODER], [(N/A)]) 62 | AC_DEFINE_UNQUOTED([XCACHE_MODULES], "$XCACHE_MODULES", [Define what modules is built with XCache]) 63 | 64 | PHP_ARG_ENABLE(xcache-test, for XCache self test, 65 | [ --enable-xcache-test XCache: Enable self test - FOR DEVELOPERS ONLY!!], no, no) 66 | if test "$PHP_XCACHE_TEST" != "no"; then 67 | XCACHE_ENABLE_TEST=-DXCACHE_ENABLE_TEST 68 | xcache_sources="$xcache_sources xcache/xc_malloc.c" 69 | AC_DEFINE([HAVE_XCACHE_TEST], 1, [Define to enable XCache self test]) 70 | else 71 | XCACHE_ENABLE_TEST= 72 | fi 73 | PHP_SUBST([XCACHE_ENABLE_TEST]) 74 | 75 | PHP_ARG_ENABLE(xcache-dprint, for XCache self test, 76 | [ --enable-xcache-dprint XCache: Enable debug print functions - FOR DEVELOPERS ONLY!!], no, no) 77 | if test "$PHP_XCACHE_DPRINT" != "no"; then 78 | AC_DEFINE([HAVE_XCACHE_DPRINT], 1, [Define to enable XCache debug print functions]) 79 | fi 80 | 81 | PHP_NEW_EXTENSION(xcache, $xcache_sources, $ext_shared) 82 | for module in $XCACHE_MODULES; do 83 | PHP_ADD_BUILD_DIR($ext_builddir/mod_$module) 84 | done 85 | PHP_ADD_BUILD_DIR($ext_builddir/util) 86 | PHP_ADD_BUILD_DIR($ext_builddir/xcache) 87 | PHP_ADD_MAKEFILE_FRAGMENT() 88 | PHP_ADD_MAKEFILE_FRAGMENT($ext_srcdir/Makefile.frag.deps) 89 | 90 | AC_PATH_PROGS([XCACHE_AWK], [gawk awk]) 91 | dnl clean locale for gawk 3.1.5 assertion bug 92 | if echo | LANG=C "$XCACHE_AWK" -- '' > /dev/null 2>&1 ; then 93 | XCACHE_AWK="LANG=C $XCACHE_AWK" 94 | else 95 | if echo | /usr/bin/env - "$XCACHE_AWK" -- '' > /dev/null 2>&1 ; then 96 | XCACHE_AWK="/usr/bin/env - $XCACHE_AWK" 97 | fi 98 | fi 99 | PHP_SUBST([XCACHE_AWK]) 100 | AC_PATH_PROGS([M4], [m4]) 101 | if test "$PHP_XCACHE_TEST" != "no"; then 102 | if echo | "$M4" -E > /dev/null 2>&1 ; then 103 | M4="$M4 -E" 104 | fi 105 | fi 106 | dnl fix for solaris m4: size of the push-back and argument 107 | if echo | "$M4" -B 102400 > /dev/null 2>&1 ; then 108 | M4="$M4 -B 102400" 109 | fi 110 | PHP_SUBST([M4]) 111 | AC_PATH_PROGS([GREP], [grep]) 112 | PHP_SUBST([GREP]) 113 | AC_PATH_PROGS([SED], [sed]) 114 | PHP_SUBST([SED]) 115 | 116 | AC_PATH_PROGS([INDENT], [indent cat]) 117 | XCACHE_INDENT=cat 118 | case $INDENT in 119 | */indent[)] 120 | XCACHE_INDENT="$INDENT" 121 | opts="-kr --use-tabs --tab-size 4" 122 | if echo | $INDENT $opts > /dev/null 2>&1 ; then 123 | XCACHE_INDENT="$XCACHE_INDENT $opts" 124 | fi 125 | opts="-sob -nce" 126 | if echo | $INDENT $opts > /dev/null 2>&1 ; then 127 | XCACHE_INDENT="$XCACHE_INDENT $opts" 128 | fi 129 | opts="-l 160" 130 | if echo | $INDENT $opts > /dev/null 2>&1 ; then 131 | XCACHE_INDENT="$XCACHE_INDENT $opts" 132 | fi 133 | ;; 134 | esac 135 | PHP_SUBST([XCACHE_INDENT]) 136 | 137 | dnl $ac_srcdir etc require PHP_NEW_EXTENSION 138 | XCACHE_PROC_SOURCES=`ls $ac_srcdir/processor/*.m4 $ac_srcdir/processor/*.h` 139 | PHP_SUBST([XCACHE_PROC_SOURCES]) 140 | fi 141 | -------------------------------------------------------------------------------- /devel/exportfunctions.php: -------------------------------------------------------------------------------- 1 | origin_compile [label="compiling", color=red]; 12 | 13 | begin -> entry_init_key -> entry_lookup; 14 | edge [label=hit, color=blue] 15 | entry_lookup -> restore; 16 | php_lookup -> entry_store; 17 | edge [label=miss, color=green] 18 | entry_lookup -> md5_init; 19 | md5_init -> php_lookup; 20 | php_lookup -> php_compile; 21 | 22 | edge [label="", color=""] 23 | php_lookup -> origin_compile [label="miss but compiling", color=red]; 24 | php_compile -> php_store -> entry_store -> restore; 25 | 26 | edge [color=red]; 27 | md5_init -> error; 28 | php_compile -> error; 29 | php_store -> error; 30 | entry_store -> error; 31 | } 32 | -------------------------------------------------------------------------------- /devel/include.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lighttpd/xcache/6f52434277cd3b8134e899af9b99959f6a99dfff/devel/include.php -------------------------------------------------------------------------------- /devel/include_once.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lighttpd/xcache/6f52434277cd3b8134e899af9b99959f6a99dfff/devel/include_once.php -------------------------------------------------------------------------------- /devel/lsnewini: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | tmp1=`mktemp` 4 | tmp2=`mktemp` 5 | grep -F '=' xcache.ini |grep -v '^;' | sed -r -e 's# *=.*##' | sort > $tmp2 6 | grep 'PHP_INI.*("' *.c | sed -r -e 's#^[^"]*"([^"]*)".*#\1#' | sort > $tmp1 7 | diff -iu $tmp2 $tmp1 |grep '^[-+]' 8 | rm -f $tmp1 $tmp2 9 | -------------------------------------------------------------------------------- /devel/make: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec ./run make "$@" 3 | -------------------------------------------------------------------------------- /devel/po2php.awk: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | BEGIN { 3 | print " \""msgstr"\","; 18 | } 19 | } 20 | else { 21 | print "unexpected section " section; 22 | exit 1; 23 | } 24 | section = null; 25 | } 26 | } 27 | 28 | /^msgid ".*"$/ { 29 | $0 = gensub(/^msgid "(.*)"$/, "\\1", $0); 30 | 31 | section = "msgid"; 32 | msgid = $0; 33 | next; 34 | } 35 | /^msgstr ".*"$/ { 36 | $0 = gensub(/^msgstr "(.*)"$/, "\\1", $0); 37 | 38 | section = "msgstr"; 39 | msgstr = $0; 40 | next; 41 | } 42 | /^".*"$/ { 43 | $0 = gensub(/^"(.*)"$/, "\\1", $0); 44 | if (section == "msgid") { 45 | msgid = msgid $0; 46 | } 47 | else { 48 | msgstr = msgstr $0; 49 | } 50 | next; 51 | } 52 | /^$/ { 53 | flushOut(); 54 | next; 55 | } 56 | /^#/ { 57 | next; 58 | } 59 | /./ { 60 | print "error", $0; 61 | exit 1; 62 | } 63 | END { 64 | flushOut(); 65 | print "\t\t);"; 66 | print ""; 67 | } 68 | -------------------------------------------------------------------------------- /devel/prepare.cfg.example: -------------------------------------------------------------------------------- 1 | # copy this file as prepare.cfg before modifying 2 | PHP4_x_DIR= 3 | PHP5_0_DIR= 4 | PHP5_1_DIR= 5 | PHP5_3_DIR= 6 | PHP5_4_DIR= 7 | PHP5_5_DIR= 8 | PHP5_6_DIR= 9 | PHP6_x_DIR= 10 | 11 | PHP_DEVEL_DIR=$(PHP5_6_DIR) 12 | 13 | # path to eaccelerator source dir 14 | EA_DIR= 15 | -------------------------------------------------------------------------------- /devel/prepare.mak: -------------------------------------------------------------------------------- 1 | CTAGS=$(shell which ctags 2>/dev/null || which exuberant-ctags 2>/dev/null) 2 | AWK=$(shell which gawk 2>/dev/null || which awk 2>/dev/null) 3 | 4 | include devel/prepare.cfg 5 | 6 | .PHONY: dummy 7 | .PHONY: all 8 | all: xcache/xc_opcode_spec_def.h xc_const_string tags po 9 | 10 | .PHONY: clean 11 | clean: clean_xc_const_string clean_po 12 | rm -f tags xcache/xc_opcode_spec_def.h 13 | 14 | .PHONY: clean_xc_const_string 15 | clean_xc_const_string: 16 | rm -f xcache/xc_const_string_opcodes_php*.h 17 | 18 | .PHONY: xc_const_string 19 | xc_const_string: \ 20 | xcache/xc_const_string_opcodes_php4.x.h \ 21 | xcache/xc_const_string_opcodes_php5.0.h \ 22 | xcache/xc_const_string_opcodes_php5.1.h \ 23 | xcache/xc_const_string_opcodes_php5.2.h \ 24 | xcache/xc_const_string_opcodes_php5.3.h \ 25 | xcache/xc_const_string_opcodes_php5.4.h \ 26 | xcache/xc_const_string_opcodes_php5.5.h \ 27 | xcache/xc_const_string_opcodes_php5.6.h \ 28 | xcache/xc_const_string_opcodes_php6.x.h 29 | 30 | ifeq (${EA_DIR},) 31 | xcache/xc_opcode_spec_def.h: dummy 32 | @echo "Skipped $@: EA_DIR not set" 33 | else 34 | xcache/xc_opcode_spec_def.h: ${EA_DIR}/opcodes.c 35 | $(AWK) -f ./devel/gen_xc_opcode_spec.awk < "$<" > "$@".tmp 36 | mv "$@".tmp "$@" 37 | endif 38 | 39 | ifeq (${PHP4_x_DIR},) 40 | xcache/xc_const_string_opcodes_php4.x.h: dummy 41 | @echo "Skipped $@: PHP_4_x_DIR not set" 42 | else 43 | xcache/xc_const_string_opcodes_php4.x.h: ${PHP4_x_DIR}/Zend/zend_compile.h 44 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 45 | mv "$@.tmp" "$@" 46 | endif 47 | 48 | ifeq (${PHP5_0_DIR},) 49 | xcache/xc_const_string_opcodes_php5.0.h: dummy 50 | @echo "Skipped $@: PHP_5_0_DIR not set" 51 | else 52 | xcache/xc_const_string_opcodes_php5.0.h: ${PHP5_0_DIR}/Zend/zend_compile.h 53 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 54 | mv "$@.tmp" "$@" 55 | endif 56 | 57 | ifeq (${PHP5_1_DIR},) 58 | xcache/xc_const_string_opcodes_php5.1.h: dummy 59 | @echo "Skipped $@: PHP_5_1_DIR not set" 60 | else 61 | xcache/xc_const_string_opcodes_php5.1.h: ${PHP5_1_DIR}/Zend/zend_vm_def.h 62 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 63 | mv "$@.tmp" "$@" 64 | endif 65 | 66 | ifeq (${PHP5_2_DIR},) 67 | xcache/xc_const_string_opcodes_php5.2.h: dummy 68 | @echo "Skipped $@: PHP_5_2_DIR not set" 69 | else 70 | xcache/xc_const_string_opcodes_php5.2.h: ${PHP5_2_DIR}/Zend/zend_vm_def.h 71 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 72 | mv "$@.tmp" "$@" 73 | endif 74 | 75 | ifeq (${PHP5_3_DIR},) 76 | xcache/xc_const_string_opcodes_php5.3.h: dummy 77 | @echo "Skipped $@: PHP_5_3_DIR not set" 78 | else 79 | xcache/xc_const_string_opcodes_php5.3.h: ${PHP5_3_DIR}/Zend/zend_vm_def.h 80 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 81 | mv "$@.tmp" "$@" 82 | endif 83 | 84 | ifeq (${PHP5_4_DIR},) 85 | xcache/xc_const_string_opcodes_php5.4.h: dummy 86 | @echo "Skipped $@: PHP_5_4_DIR not set" 87 | else 88 | xcache/xc_const_string_opcodes_php5.4.h: ${PHP5_4_DIR}/Zend/zend_vm_def.h 89 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 90 | mv "$@.tmp" "$@" 91 | endif 92 | 93 | ifeq (${PHP5_5_DIR},) 94 | xcache/xc_const_string_opcodes_php5.5.h: dummy 95 | @echo "Skipped $@: PHP_5_5_DIR not set" 96 | else 97 | xcache/xc_const_string_opcodes_php5.5.h: ${PHP5_5_DIR}/Zend/zend_vm_def.h 98 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 99 | mv "$@.tmp" "$@" 100 | endif 101 | 102 | ifeq (${PHP5_6_DIR},) 103 | xcache/xc_const_string_opcodes_php5.6.h: dummy 104 | @echo "Skipped $@: PHP_5_6_DIR not set" 105 | else 106 | xcache/xc_const_string_opcodes_php5.6.h: ${PHP5_6_DIR}/Zend/zend_vm_def.h 107 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 108 | mv "$@.tmp" "$@" 109 | endif 110 | 111 | ifeq (${PHP6_x_DIR},) 112 | xcache/xc_const_string_opcodes_php6.x.h: dummy 113 | @echo "Skipped $@: PHP_6_x_DIR not set" 114 | else 115 | xcache/xc_const_string_opcodes_php6.x.h: ${PHP6_x_DIR}/Zend/zend_vm_def.h 116 | $(AWK) -f ./devel/gen_const_string_opcodes.awk < "$<" > "$@.tmp" 117 | mv "$@.tmp" "$@" 118 | endif 119 | 120 | ifeq (${PHP_DEVEL_DIR},) 121 | tags: 122 | @echo "* Making tags without php source files" 123 | "$(CTAGS)" -R . 124 | else 125 | tags: 126 | @echo "* Making tags with ${PHP_DEVEL_DIR}" 127 | "$(CTAGS)" -R . "${PHP_DEVEL_DIR}/main" "${PHP_DEVEL_DIR}/Zend" "${PHP_DEVEL_DIR}/TSRM" "${PHP_DEVEL_DIR}/ext/standard" 128 | endif 129 | 130 | .PHONY: po 131 | define htdocspo 132 | po: \ 133 | htdocs/$(1)/lang/en.po \ 134 | htdocs/$(1)/lang/en.po-merged \ 135 | htdocs/$(1)/lang/zh-simplified.po-merged \ 136 | htdocs/$(1)/lang/zh-simplified.po \ 137 | htdocs/$(1)/lang/zh-traditional.po \ 138 | htdocs/$(1)/lang/zh-traditional.po-merged 139 | 140 | htdocs/$(1)/lang/%.po-merged: htdocs/$(1)/lang/%.po htdocs/$(1)/lang/$(1).pot 141 | msgmerge -o "$$@".tmp $$^ 142 | mv "$$@".tmp "$$@" 143 | 144 | htdocs/$(1)/lang/%.po: 145 | touch "$$@" 146 | 147 | htdocs/$(1)/lang/$(1).pot: 148 | xgettext --keyword=_T --keyword=N_ --from-code=UTF-8 -F -D htdocs/$(1)/ $$(subst htdocs/$(1)/,,$$^) -o "$$@".tmp 149 | mv "$$@".tmp "$$@" 150 | 151 | htdocs/$(1)/lang/$(1).pot: $(shell find htdocs/$(1) -type f | grep php | grep -v lang | grep -v config | grep -vF .swp) 152 | 153 | endef 154 | 155 | $(eval $(call htdocspo,cacher)) 156 | $(eval $(call htdocspo,common)) 157 | $(eval $(call htdocspo,coverager)) 158 | $(eval $(call htdocspo,diagnosis)) 159 | 160 | .PHONY: clean_po 161 | clean_po: clean_pot 162 | rm -f htdocs/*/lang/*.po-merged 163 | 164 | .PHONY: clean_pot 165 | clean_pot: 166 | rm -f htdocs/*/lang/*.pot 167 | -------------------------------------------------------------------------------- /devel/require.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lighttpd/xcache/6f52434277cd3b8134e899af9b99959f6a99dfff/devel/require.php -------------------------------------------------------------------------------- /devel/require_once.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lighttpd/xcache/6f52434277cd3b8134e899af9b99959f6a99dfff/devel/require_once.php -------------------------------------------------------------------------------- /devel/test.mak: -------------------------------------------------------------------------------- 1 | #! /usr/bin/make -f 2 | 3 | CC=gcc 4 | LDFLAGS= 5 | CFLAGS=-g -O0 -I. -D TEST -D HAVE_XCACHE_TEST -Wall 6 | TEST=valgrind 7 | 8 | all: allocator vector 9 | 10 | allocator_test: xcache/xc_allocator.h xcache/xc_allocator.c xcache/xc_malloc.c xcache/xc_allocator_bestfit.c util/xc_trace.c util/xc_trace.h 11 | $(CC) $(LDFLAGS) $(CFLAGS) -o allocator_test xcache/xc_allocator.c xcache/xc_malloc.c xcache/xc_allocator_bestfit.c util/xc_trace.c 12 | 13 | allocator: allocator_test 14 | $(TEST) ./allocator_test 15 | 16 | vector_test: util/xc_vector_test.c 17 | $(CC) $(LDFLAGS) $(CFLAGS) -o vector_test util/xc_vector_test.c 18 | 19 | vector: vector_test 20 | $(TEST) ./vector_test 21 | 22 | clean: 23 | rm -f allocator_test vector_test 24 | -------------------------------------------------------------------------------- /gen_structinfo.awk: -------------------------------------------------------------------------------- 1 | #! /usr/bin/awk -f 2 | # vim:ts=4:sw=4 3 | BEGIN { 4 | brace = 0; 5 | incomment = 0; 6 | buffer_len = 0; 7 | } 8 | function printstruct(structname) { 9 | printf "define(`ELEMENTSOF_%s', `%s')\n", structname, ELEMENTSOF[structname]; 10 | printf "define(`COUNTOF_%s', `%s')\n", structname, COUNTOF[structname]; 11 | printf "define(`SIZEOF_%s', `( %s )')\n", structname, SIZEOF[structname]; 12 | } 13 | function countBrace(text, len, i, char, braceCount) { 14 | len = length(text); 15 | braceCount = 0; 16 | for (i = 1; i <= len; ++i) { 17 | char = substr(text, i, 1); 18 | if (char == "{") { 19 | braceCount = braceCount + 1; 20 | } 21 | else if (char == "}") { 22 | braceCount = braceCount - 1; 23 | } 24 | } 25 | return braceCount; 26 | } 27 | 28 | # multiline comment handling 29 | { 30 | # removes one line comment 31 | gsub(/\/\*(.+?)\*\//, " "); 32 | } 33 | /\*\// { 34 | if (incomment) { 35 | sub(/.*\*\//, ""); 36 | incomment = 0; 37 | } 38 | } 39 | incomment { 40 | next; 41 | } 42 | /\/\*/ { 43 | sub(/\/\*.*/, ""); 44 | incomment = 1; 45 | # fall through 46 | } 47 | 48 | # skip file/line mark here to be faster 49 | /^#/ { 50 | next; 51 | } 52 | 53 | /^}.*;/ { 54 | if (instruct) { 55 | sub(";", ""); 56 | structname = instruct; 57 | if (structname == 1 && $2) { 58 | structname = $2; 59 | } 60 | if (structname in typedefs) { 61 | structname = typedefs[structname]; 62 | } 63 | sizeinfo = ""; 64 | elms = ""; 65 | for (i = 0; i in buffer; i ++) { 66 | if (i) { 67 | sizeinfo = sizeinfo " + "; 68 | } 69 | sizeinfo = sizeinfo "sizeof(((" structname "*)NULL)->" buffer[i] ")"; 70 | 71 | if (i == 0) { 72 | elms = "\"" buffer[i] "\""; 73 | } 74 | else { 75 | elms = elms "," "\"" buffer[i] "\""; 76 | } 77 | } 78 | ELEMENTSOF[structname] = elms; 79 | COUNTOF[structname] = i; 80 | SIZEOF[structname] = sizeinfo; 81 | printstruct(structname); 82 | print "\n"; 83 | for (i in buffer) { 84 | delete buffer[i]; 85 | } 86 | buffer_len = 0; 87 | instruct = 0; 88 | } 89 | next; 90 | } 91 | 92 | /.[{}]/ { 93 | brace += countBrace($0); 94 | } 95 | 96 | { 97 | if (brace == 1 && instruct) { 98 | gsub(/(^[\t ]+|[\t ]+$)/, ""); # trim whitespaces 99 | sub(/.*[{}]/, ""); 100 | gsub(/\[[^\]]+\]/, ""); # ignore [...] 101 | gsub(/:[0-9]+/, ""); # ignore struct bit 102 | if (match($0, /^[^(]*\([ ]*\*([^)]+)\)/)) { 103 | sub(/ +/, "") 104 | sub(/^[^(]*\(\*/, ""); 105 | sub(/\).*/, ""); 106 | # function pointer 107 | buffer[buffer_len] = $0; 108 | buffer_len ++; 109 | } 110 | else { 111 | # process normal variables 112 | 113 | # ignore any ()s 114 | while (gsub(/(\([^)]*\))/, "")) { 115 | } 116 | if (match($0, /[()]/)) { 117 | next; 118 | } 119 | # unsigned int *a, b; int c; 120 | gsub(/[*]/, " "); 121 | # unsigned int a, b; int c; 122 | gsub(/ +/, " "); 123 | # unsigned int a, b; int c; 124 | gsub(/ *[,;]/, ";"); 125 | # unsigned int a; b; int c; 126 | if (!match($0, /;/)) { 127 | next; 128 | } 129 | # print "=DEBUG=" $0 "=="; 130 | split($0, chunks, ";"); 131 | # [unsigned int a, b, c] 132 | 133 | for (i = 1; i in chunks; i ++) { 134 | if (chunks[i] == "") { 135 | delete chunks[i]; 136 | continue; 137 | } 138 | split(chunks[i], pieces, " "); 139 | # [unsigned, int, a] 140 | # [b] 141 | # [c] 142 | 143 | last_piece = ""; 144 | for (j = 1; j in pieces; j ++) { 145 | last_piece = pieces[j]; 146 | delete pieces[j]; 147 | } 148 | if (last_piece == "") { 149 | # print "=ERROR=" chunks[i] "=="; 150 | delete chunks[i]; 151 | continue; 152 | } 153 | # a 154 | # b 155 | # c 156 | 157 | buffer[buffer_len] = last_piece; 158 | buffer_len ++; 159 | delete chunks[i] 160 | } 161 | last_piece = ""; 162 | } 163 | next; 164 | } 165 | } 166 | 167 | /^typedef struct [^{]*;/ { 168 | sub(";", ""); 169 | typename=$3; 170 | newtypename=$4; 171 | typedefs[typename] = newtypename; 172 | if (ELEMENTSOF[typename]) { 173 | ELEMENTSOF[newtypename] = ELEMENTSOF[typename]; 174 | COUNTOF[newtypename] = COUNTOF[typename]; 175 | sub(/.*/, SIZEOF[typename]); 176 | gsub(typename, newtypename); 177 | SIZEOF[newtypename] = $0; 178 | printstruct(newtypename); 179 | } 180 | next; 181 | } 182 | /^typedef struct .*\{[^}]*$/ { 183 | brace = countBrace($0); 184 | if (brace > 0) { 185 | instruct = 1; 186 | } 187 | else { 188 | brace = 0; 189 | instruct = 0; 190 | } 191 | 192 | for (i in buffer) { 193 | delete buffer[i]; 194 | } 195 | next; 196 | } 197 | 198 | /^struct .*\{.*/ { 199 | brace = countBrace($0); 200 | if (brace > 0) { 201 | instruct = $2; 202 | } 203 | else { 204 | brace = 0; 205 | instruct = 0; 206 | } 207 | 208 | for (i in buffer) { 209 | delete buffer[i]; 210 | } 211 | next; 212 | } 213 | -------------------------------------------------------------------------------- /htdocs/cacher/cacher.css: -------------------------------------------------------------------------------- 1 | td, th { white-space: pre; } 2 | 3 | .percent { height: 3px; margin-bottom: 1px; border: 1px solid gray; } 4 | .percent div { float: left; height: 100%; } 5 | .pvalue { background: limegreen; } 6 | 7 | .blocksgraph { height: 13px; } 8 | .blocksgraph div { float: left; height: 3px; width: 4px; border: 0 solid gray; border-width: 0 0 1px 0; } 9 | .blocksgraph { border: 1px solid gray; border-bottom: 0; } 10 | .percent *, .blocksgraph *, .hitsgraph * { font-size: 1px; line-height: 1px; } 11 | 12 | .hitsgraph { margin: auto; } 13 | .hitsgraph a { display: block; float: left; border: 0 solid gray; } 14 | .hitsgraph a { width: 2px; height: 20px; border-top-width: 1px; border-bottom-width: 1px; } /* update this along with index.php */ 15 | .hitsgraph a * { display: block; } 16 | .hitsgraph a.active { border-top-color: yellow; } 17 | .hitsgraph a:hover { background: gray; } 18 | 19 | dl { overflow: hidden; } 20 | dt { font-weight: bold; clear: both; float: left; width: 100px; text-align: right; margin: 0; } 21 | dd { margin: 0; } 22 | .blockarea { overflow: hidden; width: 400px; } 23 | .legends { padding-bottom: 8px; } 24 | div.legend { float: left; border: 1px solid gray; font: 12px/12px monospace; } 25 | div.legendtitle { float: left; padding: 2px; padding-right: 10px; font: 12px/12px monospace; } 26 | -------------------------------------------------------------------------------- /htdocs/cacher/common.php: -------------------------------------------------------------------------------- 1 | 47 | -------------------------------------------------------------------------------- /htdocs/cacher/edit.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 6 |
7 |
8 | 9 |
10 | > 11 | 16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /htdocs/cacher/lang/en.php: -------------------------------------------------------------------------------- 1 | "PHP Cached", 6 | "var Cached" 7 | => "Variable Cached", 8 | "php Deleted" 9 | => "PHP Deleted", 10 | "var Deleted" 11 | => "Variable Deleted", 12 | "entry.id" 13 | => "Id|", 14 | "entry.remove" 15 | => "Remove|", 16 | "entry.name" 17 | => "Entry name|The entry name or filename", 18 | "entry.hits" 19 | => "Hits|Hit times of this entry (loaded from this cache)", 20 | "entry.size" 21 | => "Size|Size in bytes of this entry in the cache", 22 | "entry.refcount" 23 | => "Refs|Reference count of this entry is holded by a php request", 24 | "entry.phprefcount" 25 | => "Shares|Count of entry sharing this php data", 26 | "entry.class_cnt" 27 | => "Cls.|Count of classes", 28 | "entry.function_cnt" 29 | => "Funcs|Count of functions", 30 | "entry.file_size" 31 | => "Src Size|Size of the source file", 32 | "entry.file_mtime" 33 | => "Modified|Last modified time of the source file", 34 | "entry.file_device" 35 | => "dev|device number of the source file", 36 | "entry.file_inode" 37 | => "ino|inode number of the source file", 38 | "entry.hash" 39 | => "Hash|Hash value of this entry", 40 | "entry.atime" 41 | => "Access|Last time when this entry is accessed", 42 | "entry.ctime" 43 | => "Create|The time when this entry is stored", 44 | "entry.delete" 45 | => "Delete|The time when this entry is deleted", 46 | "Caches" 47 | => "Caches", 48 | "cache.cache" 49 | => "Cache|", 50 | "cache.slots" 51 | => "Slots|Number of hash slots. the setting from your php.ini", 52 | "cache.size" 53 | => "Size|Cache Size, Size of the cache (or cache chunk), in bytes", 54 | "cache.avail" 55 | => "Avail|Available Memory, free memory in bytes of this cache", 56 | "cache.blocksgraph" 57 | => "Percent Graph|Shows how much memory available in percent, and memory blocks status in graph", 58 | "cache.operations" 59 | => "Operations|Press the clear button to clean this cache", 60 | "cache.status" 61 | => "Status|Compiling flag, \"Compiling\" if the cache is busy compiling php script. \"Disabled\" if cache is disabled", 62 | "cache.hits" 63 | => "Hits|Cache Hits, hit=a var/php is loaded from this cache", 64 | "cache.hits_graph" 65 | => "Hits*24H|Hits graph of last 24 hours", 66 | "cache.hits_avg_h" 67 | => "Hits/H|Average Hits per Hour. Only last 24 hours is logged", 68 | "cache.hits_avg_s" 69 | => "Hits/S|Average Hits per Second. Only last 5 seconds is logged", 70 | "cache.updates" 71 | => "Updates|Cache Updates", 72 | "cache.skips" 73 | => "Skips|Skips. Skip=updates are needed but skipped for some reason. e.g.: other process/thread is busy compiling on this cache", 74 | "cache.ooms" 75 | => "OOMs|Out Of Memory, how many times a new item should be stored but there isn't enough memory in the cache, think of increasing the xcache.size or xcache.var_size", 76 | "cache.errors" 77 | => "Errs|Compiler errors, how many times your script(s) failed to be compiled by PHP. You should really check what is happening if you see this value increase. (See Help for more information)", 78 | "cache.readonly_protected" 79 | => "Protected|Whether readonly_protection is available and enable on this cache (See help for more information)", 80 | "cache.cached" 81 | => "Cached|Number of entries stored in this cache", 82 | "cache.deleted" 83 | => "Deleted|Number of entries is pending in delete list (expired but referenced)", 84 | "cache.gc_timer" 85 | => "GC|Seconds count down of Garbage Collection", 86 | ); 87 | 88 | -------------------------------------------------------------------------------- /htdocs/cacher/lang/zh-simplified.php: -------------------------------------------------------------------------------- 1 | "正在编辑变量 %s", 6 | "Set %s in config to enable" 7 | => "请在配置文件中设置 %s 启用本功能", 8 | "Total" 9 | => "总共", 10 | "Summary" 11 | => "摘要信息", 12 | "List PHP" 13 | => "列出PHP", 14 | "List Var Data" 15 | => "列变量数据", 16 | "php Cached" 17 | => "缓存的 PHP 脚本", 18 | "var Cached" 19 | => "缓存的变量", 20 | "php Deleted" 21 | => "待删 PHP 脚本缓存", 22 | "var Deleted" 23 | => "待删变量缓存", 24 | "entry.id" 25 | => "Id|", 26 | "entry.remove" 27 | => "删除|", 28 | "entry.name" 29 | => "项目名/文件名|项目名或者文件名", 30 | "entry.hits" 31 | => "命中|该项目被命中的次数 (从缓存区载入)", 32 | "entry.size" 33 | => "大小|项目在缓存里占用字节数", 34 | "entry.refcount" 35 | => "引用数|项目依然被其他进程占据的引用次数", 36 | "entry.phprefcount" 37 | => "共享数|与本项目相同 PHP 代码的个数", 38 | "entry.class_cnt" 39 | => "类|类个数", 40 | "entry.function_cnt" 41 | => "函数|函数个数", 42 | "entry.file_size" 43 | => "源大小|源文件大小", 44 | "entry.file_mtime" 45 | => "修改|源文件最后修改时间", 46 | "entry.file_device" 47 | => "dev|源文件所在设备ID", 48 | "entry.file_inode" 49 | => "ino|源文件的 inode", 50 | "entry.hash" 51 | => "哈希|该项目的哈希值", 52 | "entry.atime" 53 | => "访问|最后访问该项目的时间", 54 | "entry.ctime" 55 | => "创建|该项目被创建于缓存区内的时间", 56 | "entry.delete" 57 | => "删除|该项目被决定删除的时间", 58 | "Remove Selected" 59 | => "删除所选", 60 | "Module Info" 61 | => "模块信息", 62 | "Caches" 63 | => "缓存区", 64 | "cache.cache" 65 | => "缓存|", 66 | "cache.slots" 67 | => "槽|Hash 槽个数, 对应 php.ini 里的设置", 68 | "cache.size" 69 | => "大小|共享内存区大小, 单位: 字节", 70 | "cache.avail" 71 | => "剩余|可用内存, 对应缓存区的剩余内存字节数", 72 | "cache.blocksgraph" 73 | => "百分比图|条状显示可用内存的比例, 以及显示分配块状态", 74 | "cache.operations" 75 | => "操作|点击按钮清除对应缓存区的数据", 76 | "cache.status" 77 | => "状态|状态标记. 当缓存区正在编译 PHP 脚本时标记为 \"编译中\". 当缓存区暂停使用时标记为 \"禁用\"", 78 | "cache.hits" 79 | => "命中|缓存命中次数, 命中=从该缓存载入 PHP 或者变量", 80 | "cache.hits_graph" 81 | => "24H 分布|24 小时命中分布图. 图表现是最后 24 小时的命中次数", 82 | "cache.hits_avg_h" 83 | => "命中/H|每小时命中次数. 只统计最后 24 小时", 84 | "cache.hits_avg_s" 85 | => "命中/S|每秒命中次数. 只统计最后 5 秒", 86 | "cache.updates" 87 | => "更新|缓存更新次数", 88 | "cache.skips" 89 | => "跳过|跳过更新次数, 跳过=XCache 自动判断阻塞的缓存区自动跳过阻塞等待, 直接使用编译不缓存方式继续处理请求", 90 | "cache.ooms" 91 | => "内存不足|内存不足次数, 显示需要存储新数据但是缓存区内存不足的次数. 如果出现太频繁请考虑加大配置中的 xcache.size 或者 xcache.var_size", 92 | "cache.errors" 93 | => "错误|编译错误, 显示您的脚本被编译时出错的次数. 如果您发现这个数字不断增长, 您应该检查什么脚本产生错误. 参考 帮助 获取更多信息", 94 | "cache.readonly_protected" 95 | => "保护|显示该 Cache 是否支持并启用 readonly_protection. 参考 帮助 获取更多信息", 96 | "cache.cached" 97 | => "缓存|缓存于该缓存区的项目条数", 98 | "cache.deleted" 99 | => "待删|缓存区内将要删除的项目 (已经删除但是还被某些进程占用)", 100 | "cache.gc_timer" 101 | => "GC|垃圾回收的倒计时", 102 | "Clear" 103 | => "清除", 104 | "Disabled" 105 | => "禁用", 106 | "Disable" 107 | => "禁用", 108 | "Enable" 109 | => "启用", 110 | "Compiling" 111 | => "编译中", 112 | "Normal" 113 | => "正常", 114 | "Sure?" 115 | => "确认?", 116 | "Legends:" 117 | => "图例:", 118 | "% Free" 119 | => "% 剩余", 120 | "% Used" 121 | => "% 已用", 122 | "Free Blocks" 123 | => "未用块", 124 | "Used Blocks" 125 | => "已用块", 126 | "Hits" 127 | => "命中", 128 | ); 129 | 130 | -------------------------------------------------------------------------------- /htdocs/cacher/lang/zh-traditional.php: -------------------------------------------------------------------------------- 1 | "正在编辑变量 %s", 6 | "Set %s in config to enable" 7 | => "請在配置文件中設置 %s 啟用本功能", 8 | "Total" 9 | => "总共", 10 | "Summary" 11 | => "簡要訊息", 12 | "List PHP" 13 | => "列出PHP", 14 | "List Var Data" 15 | => "列變數資料", 16 | "php Cached" 17 | => "快取的 PHP 指令", 18 | "var Cached" 19 | => "快取的變數", 20 | "php Deleted" 21 | => "待刪 PHP 指令快取", 22 | "var Deleted" 23 | => "待刪變數快取", 24 | "entry.id" 25 | => "Id|", 26 | "entry.remove" 27 | => "移除|", 28 | "entry.name" 29 | => "項目名稱/檔案名稱|項目名稱或者檔案名稱", 30 | "entry.hits" 31 | => "命中|該項目被命中的次數 (從共享記憶體區載入)", 32 | "entry.size" 33 | => "大小|項目在共享記憶體裡佔用位元數", 34 | "entry.refcount" 35 | => "引用數|項目依然被其他程序佔用的引用次數", 36 | "entry.phprefcount" 37 | => "共享|與本項目相同 PHP 內容的个數", 38 | "entry.class_cnt" 39 | => "类|类个数", 40 | "entry.function_cnt" 41 | => "函数|函数个数", 42 | "entry.file_size" 43 | => "源大小|原始檔案大小", 44 | "entry.file_mtime" 45 | => "修改|原始檔案最後修改時間", 46 | "entry.file_device" 47 | => "dev|原始檔案所在設備ID", 48 | "entry.file_inode" 49 | => "ino|原始檔案的inode", 50 | "entry.hash" 51 | => "Hash|Hash", 52 | "entry.atime" 53 | => "存取|最後存取該項目的時間", 54 | "entry.ctime" 55 | => "建立|該項目被建立於共享內的時間", 56 | "entry.delete" 57 | => "移除|該項目被移除於共享內的時間", 58 | "Remove Selected" 59 | => "移除所选", 60 | "Module Info" 61 | => "組元訊息", 62 | "Caches" 63 | => "快取", 64 | "cache.cache" 65 | => "快取|", 66 | "cache.slots" 67 | => "槽|Hash 槽個數,對應 php.ini 裡的設置", 68 | "cache.size" 69 | => "大小|共享記憶體區大小,單位:位元", 70 | "cache.avail" 71 | => "剩餘|可用記憶體,對應共享記憶體區的剩餘記憶體位元數", 72 | "cache.blocksgraph" 73 | => "百分比图|條狀顯示可用記憶體的比例", 74 | "cache.operations" 75 | => "操作|點擊按鈕清除對應共享記憶體區的資料", 76 | "cache.status" 77 | => "狀態|狀態標記. 當共享內存區正在編譯 PHP 腳本時標記為 \"編譯中\". 當共享內存區暫停使用時標記為 \"禁用\"", 78 | "cache.hits" 79 | => "命中|共享記憶體命中次數,命中=從該共享記憶體載入 PHP 或者變數", 80 | "cache.hits_graph" 81 | => "24H 分布|24 小时命中分布图. 图表现是最后 24 小时的命中次数", 82 | "cache.hits_avg_h" 83 | => "命中/H|每小时命中次数. 只统计最后 24 小时", 84 | "cache.hits_avg_s" 85 | => "命中/S|每秒命中次数. 只统计最后 5 秒", 86 | "cache.updates" 87 | => "更新|共享記憶更新過次數", 88 | "cache.skips" 89 | => "跳過|跳過更新次數,跳過=XCache 自動判斷阻塞的共享記憶體區自動跳過阻塞等待,直接使用编译不存储方式繼續處理請求", 90 | "cache.ooms" 91 | => "記憶體不足|記憶體不足次數,顯示需要儲存新資料但是共享記憶體區記憶體不足的次數. 如果出現太頻繁請考慮加大配置中的 xcache.size 或者 xcache.var_size", 92 | "cache.errors" 93 | => "错误|编译错误, 显示您的脚本被编译时出错的次数. 如果您发现这个数字不断增长, 您应该检查什么脚本产生错误. 参考 說明 获取更多信息", 94 | "cache.readonly_protected" 95 | => "保护|顯示該 Cache 是否支援並啟用 readonly_protection. 参考 說明", 96 | "cache.cached" 97 | => "快取|共享記憶體於該共享記憶體區的項目個數", 98 | "cache.deleted" 99 | => "待刪|共享記憶體區內將要刪除的項目 (已經刪除但是還被某些程序佔用)", 100 | "cache.gc_timer" 101 | => "GC|垃圾回收的倒數計時", 102 | "Clear" 103 | => "清除", 104 | "Disabled" 105 | => "禁用", 106 | "Disable" 107 | => "禁用", 108 | "Enable" 109 | => "啟用", 110 | "Compiling" 111 | => "編譯中", 112 | "Normal" 113 | => "正常", 114 | "Sure?" 115 | => "確認?", 116 | "Legends:" 117 | => "图例:", 118 | "% Free" 119 | => "% 剩余", 120 | "% Used" 121 | => "% 已用", 122 | "Free Blocks" 123 | => "未用块", 124 | "Used Blocks" 125 | => "已用块", 126 | "Hits" 127 | => "命中", 128 | ); 129 | 130 | -------------------------------------------------------------------------------- /htdocs/cacher/listentries.tpl.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 22 | 23 | -------------------------------------------------------------------------------- /htdocs/cacher/mkpassword.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | Simple MD5 password generator 8 | 11 | 12 | 13 |

Simple MD5 password generator

14 |
15 |
16 | Name:
17 |
18 | Password:
19 |
20 |
21 | The INI settings you need is: 22 | 23 |
$md5_1$md5_2\"\n";
32 | 				}
33 | 				?>
34 |
35 |
36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /htdocs/cacher/sub/entrylist.tpl.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 9 | 10 | TR; 11 | 12 | if ($isphp) { 13 | echo 14 | th(N_("entry.id")) 15 | ; 16 | } 17 | else { 18 | echo 19 | th(N_("entry.remove")) 20 | ; 21 | } 22 | 23 | echo 24 | th(N_("entry.name")) 25 | , th(N_("entry.hits")) 26 | , th(N_("entry.size")) 27 | ; 28 | 29 | if ($isphp) { 30 | echo 31 | th(N_("entry.refcount")) 32 | , th(N_("entry.phprefcount")) 33 | , th(N_("entry.class_cnt")) 34 | , th(N_("entry.function_cnt")) 35 | , th(N_("entry.file_size")) 36 | , th(N_("entry.file_mtime")) 37 | ; 38 | echo 39 | th(N_("entry.file_device")) 40 | , th(N_("entry.file_inode")) 41 | ; 42 | } 43 | echo 44 | th(N_("entry.hash")) 45 | , th(N_("entry.atime")) 46 | , th(N_("entry.ctime")) 47 | ; 48 | 49 | if ($listName == 'Deleted') { 50 | echo 51 | th(N_("entry.delete")) 52 | ; 53 | } 54 | ?> 55 | 56 | $entry) { 58 | $class = $cycleClass->next(); 59 | echo << 61 | 62 | TR; 63 | $hits = number_format($entry['hits']); 64 | $size = size($entry['size']); 65 | if ($isphp) { 66 | $class_cnt = number_format($entry['class_cnt']); 67 | $function_cnt = number_format($entry['function_cnt']); 68 | $phprefcount = number_format($entry['phprefcount']); 69 | $file_size = size($entry['file_size']); 70 | } 71 | 72 | if ($isphp) { 73 | $file_mtime = age($entry['file_mtime']); 74 | } 75 | $ctime = age($entry['ctime']); 76 | $atime = age($entry['atime']); 77 | if ($listName == 'Deleted') { 78 | $dtime = age($entry['dtime']); 79 | } 80 | 81 | if ($isphp) { 82 | $hname = htmlspecialchars($entry['name']); 83 | $namelink = $hname; 84 | echo <<{$entry['cache_name']} {$i} 86 | 87 | ENTRY; 88 | } 89 | else { 90 | $name = $entry['name']; 91 | if (!empty($config['enable_eval'])) { 92 | $name = var_export($name, true); 93 | } 94 | $uname = urlencode($name); 95 | $hname = htmlspecialchars(str_replace("\0", "\\0", $entry['name'])); 96 | echo << 98 | 99 | ENTRY; 100 | $namelink = "$hname"; 101 | } 102 | 103 | echo <<{$namelink} 105 | 106 | 107 | 108 | ENTRY; 109 | if ($isphp) { 110 | $refcount = number_format($entry['refcount']); 111 | echo <<{$entry['refcount']} 113 | 114 | 115 | 116 | 117 | 118 | 119 | ENTRY; 120 | if (isset($entry['file_inode'])) { 121 | echo <<{$entry['file_device']} 123 | 124 | 125 | ENTRY; 126 | } 127 | } 128 | echo <<{$entry['hvalue']} 130 | 131 | 132 | 133 | ENTRY; 134 | if ($listName == 'Deleted') { 135 | echo <<{$dtime} 137 | 138 | ENTRY; 139 | } 140 | 141 | echo << 143 | 144 | TR; 145 | } 146 | ?> 147 |
{$entry['hits']}{$size}{$phprefcount}{$class_cnt}{$function_cnt}{$file_size}{$file_mtime}{$entry['file_inode']}{$atime}{$ctime}
148 | 149 | "> 150 | 151 |
152 | 155 | -------------------------------------------------------------------------------- /htdocs/cacher/sub/moduleinfo.tpl.php: -------------------------------------------------------------------------------- 1 |

2 |
3 | -------------------------------------------------------------------------------- /htdocs/cacher/sub/summary.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 27 | 28 | $ci) { 38 | $class = $cycleClass->next(); 39 | echo << 41 | 42 | TR; 43 | $pvalue = (int) ($ci['avail'] / $ci['size'] * 100); 44 | $pempty = 100 - $pvalue; 45 | if ($config['percent_graph_type'] == 'used') { 46 | // swap 47 | $tmp = $pvalue; 48 | $pvalue = $pempty; 49 | $pempty = $tmp; 50 | } 51 | 52 | $w = $config['percent_graph_width'] + 2; 53 | if (empty($ci['istotal'])) { 54 | $graph = freeblock_to_graph($ci['free_blocks'], $ci['size']); 55 | $blocksgraph = "
{$graph}
"; 56 | } 57 | else { 58 | $blocksgraph = ''; 59 | } 60 | 61 | $ci_slots = size($ci['slots']); 62 | $ci_size = size($ci['size']); 63 | $ci_avail = size($ci['avail']); 64 | $ci = number_formats($ci, $numkeys); 65 | 66 | $hits_avg_h = number_format(array_avg($ci['hits_by_hour']), 2); 67 | $hits_avg_s = number_format(array_avg($ci['hits_by_second']), 2); 68 | $hits_graph_h = get_cache_hits_graph($ci, 'hits_by_hour'); 69 | 70 | if (!empty($ci['istotal'])) { 71 | $ci['status'] = '-'; 72 | $ci['can_readonly'] = '-'; 73 | } 74 | else { 75 | if ($ci['disabled']) { 76 | $ci['status'] = $l_disabled 77 | . sprintf("(%s)", age($ci['disabled'])); 78 | } 79 | else if ($ci['type'] == XC_TYPE_PHP) { 80 | $ci['status'] = $ci['compiling'] 81 | ? $l_compiling . sprintf("(%s)", age($ci['compiling'])) 82 | : $l_normal; 83 | } 84 | else { 85 | $ci['status'] = '-'; 86 | } 87 | $ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no'; 88 | } 89 | $enabledisable = $ci['disabled'] ? 'enable' : 'disable'; 90 | $l_enabledisable = $ci['disabled'] ? $l_enable : $l_disable; 91 | echo <<{$ci['cache_name']} 93 | 94 | 95 | 96 | 102 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | EOS; 127 | ?> 128 | 129 | 130 |
{$ci_slots}{$ci_size}{$ci_avail}
{$blocksgraph}
{$ci['status']}{$ci['hits']}{$hits_graph_h}{$hits_avg_h}{$hits_avg_s}{$ci['updates']}{$ci['skips']}{$ci['ooms']}{$ci['errors']}{$ci['can_readonly']}{$ci['cached']}{$ci['deleted']}{$ci['gc']}
131 |
132 |
133 |
  
134 |
135 |
  
136 |
137 |
  
138 |
139 |
140 | 141 | -------------------------------------------------------------------------------- /htdocs/cacher/sub/testcoredump.tpl.php: -------------------------------------------------------------------------------- 1 |
6 | -------------------------------------------------------------------------------- /htdocs/cacher/summary.tpl.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /htdocs/common/common.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | -moz-box-sizing: border-box; 4 | } 5 | body { 6 | background: white; 7 | color: black; 8 | margin: 0; 9 | padding: 0; 10 | font-family: arial; 11 | font-size: 12pt; 12 | } 13 | form { 14 | margin: 0; 15 | padding: 0; 16 | } 17 | a:link 18 | , a:visited { 19 | color: #0066CC; 20 | } 21 | a:link:hover 22 | , a:visited:hover { 23 | color: #BB0000; 24 | } 25 | a:link:active 26 | , a:visited:active { 27 | color: red; 28 | } 29 | #header { 30 | background: #5084D5; 31 | position: relative; 32 | height: 51px; 33 | color: #d0d0d0; 34 | } 35 | h1, h2, h3, h4, h5, h6 { 36 | margin-bottom: 2px; 37 | } 38 | #header #banner { 39 | font: 32px/51px "arial", serif; 40 | color: white; 41 | } 42 | #header #banner a { 43 | color: white; 44 | } 45 | #header #banner #logo { 46 | border: 0; 47 | display: block; 48 | float: left; 49 | margin-right: 5px; 50 | background: white; 51 | } 52 | #header #mainnav { 53 | top: 3px; 54 | right: 5px; 55 | font-size: 16px; 56 | line-height: 16px; 57 | position: absolute; 58 | } 59 | #header #mainnav a { 60 | font-size: 14px; 61 | } 62 | #header #subnav { 63 | bottom: 0; 64 | right: 5px; 65 | position: absolute; 66 | font-size: 28px; 67 | line-height: 28px; 68 | } 69 | #header #subnav a { 70 | font-size: 24px; 71 | } 72 | #header #nav { 73 | font-family: "arial", serif; 74 | } 75 | #header #mainnav a:link, #header #mainnav a:visited { 76 | color: black; 77 | } 78 | #header #mainnav a:active, #header #mainnav a:hover { 79 | color: red; 80 | } 81 | #header #mainnav a { 82 | padding: 0 8px 0 8px; 83 | } 84 | #headerbase { 85 | background: #1163BC; 86 | border: 1px solid #334C66; 87 | border-width: 1px 0 1px 0; 88 | margin-bottom: 10px; 89 | font: 12px/12px serif; 90 | } 91 | #main table { 92 | font-size: 12px; 93 | border: 1px solid #334C66; 94 | border-top-width: 0; 95 | } 96 | #main table caption { 97 | background: #1163BC; 98 | color: white; 99 | line-height: 20px; 100 | border: 1px solid #334C66; 101 | border-bottom-width: 0; 102 | padding: 0; 103 | } 104 | #main table tfoot { 105 | background: #1163BC; 106 | } 107 | #main table th { 108 | background: #E7E7FF; 109 | color: black; 110 | } 111 | #main table td { 112 | vertical-align: top; 113 | } 114 | #main { 115 | margin: 20px; 116 | } 117 | #note { 118 | font-size: 11.9px; 119 | } 120 | #footer { 121 | bottom: 0px; 122 | background: #E7E7FF; 123 | border-top: 1px solid gray; 124 | } 125 | #poweredBy { 126 | overflow: hidden; 127 | } 128 | #footer { 129 | clear: both; 130 | height: 40px; 131 | position: relative; 132 | } 133 | #footer img { 134 | margin-top: 2px; 135 | margin-left: 2px; 136 | border: 0; 137 | } 138 | #poweredBy h3 { 139 | float: right; 140 | margin-right: 20px; 141 | margin-top: 20px; 142 | } 143 | #poweredBy h3 { 144 | margin: 0; 145 | font-size: 12px; 146 | position: absolute; 147 | bottom: 8px; 148 | right: 8px; 149 | } 150 | .phpinfo table { border: 1px solid #334C66; margin-bottom: 1px; } 151 | .phpinfo table th, .phpinfo table td { border: 1px solid #334C66; } 152 | .phpinfo table th { font-weight: bold; } 153 | .phpinfo .e {background: #81BBF2; font-weight: bold; color: #000000;} 154 | #main .phpinfo .h th {background: #5084D5; font-weight: bold; color: #000000;} 155 | .phpinfo .v {color: #000000;} 156 | .button { } 157 | span.sortarrow { color: white; text-decoration: none; } 158 | table.cycles { border: 1px solid #334C66; margin-bottom: 5px; } 159 | table.cycles .col1 { background: #f5f5f5; } 160 | table.cycles .col2 { background: #e0e0e0; } 161 | table.cycles th, table.cycles td { border: 1px solid #334C66; font-family: monospace; } 162 | #main table.cycles caption { color: white; font-weight: bold; height: 24px; line-height: 24px; font-family: serif; } 163 | #main table.cycles th { background: #81BBF2; color: #334C66; font-weight: bold; height: 20px; line-height: 20px; font-family: serif; } 164 | #main table.cycles th.h { background: #5084D5; } 165 | th.h a:visited 166 | , th.h a:link { color: black; } 167 | th.h a:hover { color: #BB0000; } 168 | th.h a:active { color: red; } 169 | th a { font-weight: bold; display: block; width: 100%; height: 100%; } 170 | th { font-size: 12px; } 171 | input, table { font-family: sans-serif; } 172 | input { font-size: 12px; } 173 | table { border-collapse: collapse; font-size: 11px; margin: 0; } 174 | table caption { 175 | font-size: 14px; 176 | font-weight: bold; 177 | } 178 | 179 | a { 180 | text-decoration: none; 181 | } 182 | #main table td { 183 | vertical-align: middle; 184 | } 185 | .switcher a { color: black; padding: 1px 8px 1px 8px; border: 1px solid white; } 186 | .switcher a { border-color: white; border-bottom-color: #334C66; } 187 | #nav .switcher a { border-color: #5084D5; border-bottom-color: #334C66; } 188 | #nav .switcher a.active, .switcher a.active { color: white; background: #1163BC; border-color: #334C66; border-bottom-color: #1163BC; } 189 | #nav .switcher a:hover.active, .switcher a:hover.active { background: #81BBF2; } 190 | .switcher a:hover { background: #81BBF2; } 191 | #nav .switcher a:active, .switcher a:active { background: #81BBF2; } 192 | -------------------------------------------------------------------------------- /htdocs/common/footer.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /htdocs/common/header.tpl.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | <?php echo sprintf("XCache %s", $xcache_version = defined('XCACHE_VERSION') ? XCACHE_VERSION : ''); ?> - <?php echo ucfirst($GLOBALS['module']); ?> 11 | 12 | 13 | 14 | 29 |
 
30 |
31 | -------------------------------------------------------------------------------- /htdocs/common/lang/en.php: -------------------------------------------------------------------------------- 1 | "帮助文档", 6 | "INI Reference" 7 | => "INI 参考", 8 | "Get Support" 9 | => "获取支持", 10 | "Discusson" 11 | => "讨论", 12 | "Cacher" 13 | => "缓存器", 14 | "Coverager" 15 | => "代码覆盖查看器", 16 | "Diagnosis" 17 | => "诊断", 18 | ); 19 | 20 | -------------------------------------------------------------------------------- /htdocs/common/lang/zh-simplified.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Report-Msgid-Bugs-To: \n" 4 | "POT-Creation-Date: 2013-07-08 14:41+0800\n" 5 | "Language: zh\n" 6 | "MIME-Version: 1.0\n" 7 | "Content-Type: text/plain; charset=UTF-8\n" 8 | "Content-Transfer-Encoding: 8bit\n" 9 | 10 | #: common.php:47 11 | msgid "Document" 12 | msgstr "帮助文档" 13 | 14 | #: common.php:48 15 | msgid "INI Reference" 16 | msgstr "INI 参考" 17 | 18 | #: common.php:49 19 | msgid "Get Support" 20 | msgstr "获取支持" 21 | 22 | #: common.php:50 23 | msgid "Discusson" 24 | msgstr "讨论" 25 | 26 | #: common.php:267 27 | msgid "Cacher" 28 | msgstr "缓存器" 29 | 30 | #: common.php:270 31 | msgid "Coverager" 32 | msgstr "代码覆盖查看器" 33 | 34 | #: common.php:273 35 | msgid "Diagnosis" 36 | msgstr "诊断" 37 | -------------------------------------------------------------------------------- /htdocs/common/lang/zh-traditional.php: -------------------------------------------------------------------------------- 1 | "幫助文檔", 6 | "INI Reference" 7 | => "INI 參考", 8 | "Get Support" 9 | => "獲取支持", 10 | "Discusson" 11 | => "討論", 12 | "Cacher" 13 | => "快取器", 14 | "Coverager" 15 | => "代码覆盖查看器", 16 | "Diagnosis" 17 | => "診斷", 18 | ); 19 | 20 | -------------------------------------------------------------------------------- /htdocs/common/lang/zh-traditional.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Report-Msgid-Bugs-To: \n" 4 | "POT-Creation-Date: 2013-07-08 14:41+0800\n" 5 | "Language: zh_TW\n" 6 | "MIME-Version: 1.0\n" 7 | "Content-Type: text/plain; charset=UTF-8\n" 8 | "Content-Transfer-Encoding: 8bit\n" 9 | 10 | #: common.php:47 11 | msgid "Document" 12 | msgstr "幫助文檔" 13 | 14 | #: common.php:48 15 | msgid "INI Reference" 16 | msgstr "INI 參考" 17 | 18 | #: common.php:49 19 | msgid "Get Support" 20 | msgstr "獲取支持" 21 | 22 | #: common.php:50 23 | msgid "Discusson" 24 | msgstr "討論" 25 | 26 | #: common.php:267 27 | msgid "Cacher" 28 | msgstr "快取器" 29 | 30 | #: common.php:270 31 | msgid "Coverager" 32 | msgstr "代码覆盖查看器" 33 | 34 | #: common.php:273 35 | msgid "Diagnosis" 36 | msgstr "診斷" 37 | -------------------------------------------------------------------------------- /htdocs/common/tablesort.js: -------------------------------------------------------------------------------- 1 | var sort_column; 2 | var prev_span = null; 3 | function get_inner_text(el) { 4 | if((typeof el == 'string')||(typeof el == 'undefined')) 5 | return el; 6 | if(el.innerText) 7 | return el.innerText; 8 | else { 9 | var str = ""; 10 | var cs = el.childNodes; 11 | var l = cs.length; 12 | for (var i=0;i "目录", 6 | "Percent" 7 | => "覆盖率", 8 | "Hits" 9 | => "命中", 10 | "Lines" 11 | => "行数", 12 | "TODO" 13 | => "闲置文件", 14 | "File" 15 | => "文件", 16 | "root" 17 | => "开始", 18 | ); 19 | 20 | -------------------------------------------------------------------------------- /htdocs/coverager/lang/zh-simplified.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Report-Msgid-Bugs-To: \n" 4 | "POT-Creation-Date: 2013-07-08 14:41+0800\n" 5 | "Language: zh\n" 6 | "MIME-Version: 1.0\n" 7 | "Content-Type: text/plain; charset=UTF-8\n" 8 | "Content-Transfer-Encoding: 8bit\n" 9 | 10 | #: coverager.tpl.php:37 11 | msgid "Directory" 12 | msgstr "目录" 13 | 14 | #: coverager.tpl.php:38 coverager.tpl.php:100 15 | msgid "Percent" 16 | msgstr "覆盖率" 17 | 18 | #: coverager.tpl.php:39 coverager.tpl.php:101 19 | msgid "Hits" 20 | msgstr "命中" 21 | 22 | #: coverager.tpl.php:40 coverager.tpl.php:102 23 | msgid "Lines" 24 | msgstr "行数" 25 | 26 | #: coverager.tpl.php:41 27 | msgid "TODO" 28 | msgstr "闲置文件" 29 | 30 | #: coverager.tpl.php:99 31 | msgid "File" 32 | msgstr "文件" 33 | 34 | #: coverager.tpl.php:151 35 | msgid "root" 36 | msgstr "开始" 37 | -------------------------------------------------------------------------------- /htdocs/coverager/lang/zh-traditional.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 10 | 13 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
4 | 5 |
8 | 9 | 11 | 12 | 14 | 15 | 17 | 18 |
29 | 30 | -------------------------------------------------------------------------------- /htdocs/diagnosis/lang/en.php: -------------------------------------------------------------------------------- 1 | $v) { 9 | header("Location: $k/"); 10 | break; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /includes.c: -------------------------------------------------------------------------------- 1 | #include "xcache.h" 2 | #include "mod_cacher/xc_cache.h" 3 | #include "xcache/xc_utils.h" 4 | #include "zend_compile.h" 5 | -------------------------------------------------------------------------------- /mod_assembler/xc_assembler.c: -------------------------------------------------------------------------------- 1 | static void dummy() { } 2 | -------------------------------------------------------------------------------- /mod_cacher/xc_cacher.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_CACHER_H_1CADCD7E46ABC70014D0766CE97B9741 2 | #define XC_CACHER_H_1CADCD7E46ABC70014D0766CE97B9741 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | int xc_cacher_startup_module(); 9 | void xc_cacher_disable(); 10 | 11 | #endif /* XC_CACHER_H_1CADCD7E46ABC70014D0766CE97B9741 */ 12 | -------------------------------------------------------------------------------- /mod_coverager/xc_coverager.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_COVERAGER_H_D5BB29AAB992B932E91C70A8C2F5D2B1 2 | #define XC_COVERAGER_H_D5BB29AAB992B932E91C70A8C2F5D2B1 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #include "php.h" 9 | 10 | int xc_coverager_startup_module(); 11 | 12 | #endif /* XC_COVERAGER_H_D5BB29AAB992B932E91C70A8C2F5D2B1 */ 13 | -------------------------------------------------------------------------------- /mod_decoder/xc_decoder.c: -------------------------------------------------------------------------------- 1 | static void dummy() { } 2 | -------------------------------------------------------------------------------- /mod_disassembler/xc_disassembler.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7 2 | #define XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | int xc_disassembler_startup_module(); 9 | 10 | #endif /* XC_DISASSEMBLER_H_1547840703D7ADD9C19041818BE9E3C7 */ 11 | -------------------------------------------------------------------------------- /mod_encoder/xc_encoder.c: -------------------------------------------------------------------------------- 1 | static void dummy() { } 2 | -------------------------------------------------------------------------------- /mod_optimizer/xc_optimizer.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_OPTIMIZER_H_6614228F428A266C39CDAC30269D9857 2 | #define XC_OPTIMIZER_H_6614228F428A266C39CDAC30269D9857 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #include "php.h" 9 | 10 | int xc_optimizer_startup_module(); 11 | 12 | #endif /* XC_OPTIMIZER_H_6614228F428A266C39CDAC30269D9857 */ 13 | -------------------------------------------------------------------------------- /processor/class-helper.m4: -------------------------------------------------------------------------------- 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 | 9 | if (processor->cache_ce == ce) { 10 | return processor->cache_class_index + 1; 11 | } 12 | for (i = 0; i < php->classinfo_cnt; i ++) { 13 | ceptr = CestToCePtr(php->classinfos[i].cest); 14 | if (ZCEP_REFCOUNT_PTR(ceptr) == ZCEP_REFCOUNT_PTR(ce)) { 15 | processor->cache_ce = ceptr; 16 | processor->cache_class_index = i; 17 | assert(i <= processor->active_class_index); 18 | return i + 1; 19 | } 20 | } 21 | assert(0); 22 | return (zend_ulong) -1; 23 | } 24 | define(`xc_get_class_num', `IFSTORE(``xc_get_class_num'($@)',``xc_get_class_num' can be use in store only')') 25 | /* }}} */ 26 | #ifdef ZEND_ENGINE_2 27 | static zend_class_entry *xc_get_class(xc_processor_t *processor, zend_ulong class_num) { /* {{{ */ 28 | /* must be parent or currrent class */ 29 | assert(class_num > 0); 30 | assert(class_num <= processor->active_class_index + 1); 31 | return CestToCePtr(processor->php_dst->classinfos[class_num - 1].cest); 32 | } 33 | define(`xc_get_class', `IFRESTORE(``xc_get_class'($@)',``xc_get_class' can be use in restore only')') 34 | /* }}} */ 35 | #endif 36 | #ifdef ZEND_ENGINE_2 37 | /* fix method on store */ 38 | static void xc_fix_method(xc_processor_t *processor, zend_op_array *dst TSRMLS_DC) /* {{{ */ 39 | { 40 | zend_function *zf = (zend_function *) dst; 41 | zend_class_entry *ce = processor->active_class_entry_dst; 42 | const zend_class_entry *srcce = processor->active_class_entry_src; 43 | 44 | /* Fixing up the default functions for objects here since 45 | * we need to compare with the newly allocated functions 46 | * 47 | * caveat: a sub-class method can have the same name as the 48 | * parent~s constructor and create problems. 49 | */ 50 | 51 | if (zf->common.fn_flags & ZEND_ACC_CTOR) { 52 | if (!ce->constructor) { 53 | ce->constructor = zf; 54 | } 55 | } 56 | else if (zf->common.fn_flags & ZEND_ACC_DTOR) { 57 | ce->destructor = zf; 58 | } 59 | else if (zf->common.fn_flags & ZEND_ACC_CLONE) { 60 | ce->clone = zf; 61 | } 62 | else { 63 | pushdef(`SET_IF_SAME_NAMEs', ` 64 | SET_IF_SAME_NAME(__get); 65 | SET_IF_SAME_NAME(__set); 66 | #ifdef ZEND_ENGINE_2_1 67 | SET_IF_SAME_NAME(__unset); 68 | SET_IF_SAME_NAME(__isset); 69 | #endif 70 | SET_IF_SAME_NAME(__call); 71 | #ifdef ZEND_CALLSTATIC_FUNC_NAME 72 | SET_IF_SAME_NAME(__callstatic); 73 | #endif 74 | #if defined(ZEND_ENGINE_2_2) || PHP_MAJOR_VERSION >= 6 75 | SET_IF_SAME_NAME(__tostring); 76 | #endif 77 | #if defined(ZEND_ENGINE_2_6) 78 | SET_IF_SAME_NAME(__debugInfo); 79 | #endif 80 | ') 81 | #ifdef IS_UNICODE 82 | if (UG(unicode)) { 83 | #define SET_IF_SAME_NAME(member) \ 84 | do { \ 85 | if (srcce->member && u_strcmp(ZSTR_U(zf->common.function_name), ZSTR_U(srcce->member->common.function_name)) == 0) { \ 86 | ce->member = zf; \ 87 | } \ 88 | } \ 89 | while(0) 90 | 91 | SET_IF_SAME_NAMEs() 92 | #undef SET_IF_SAME_NAME 93 | } 94 | else 95 | #endif 96 | do { 97 | #define SET_IF_SAME_NAME(member) \ 98 | do { \ 99 | if (srcce->member && strcmp(ZSTR_S(zf->common.function_name), ZSTR_S(srcce->member->common.function_name)) == 0) { \ 100 | ce->member = zf; \ 101 | } \ 102 | } \ 103 | while(0) 104 | 105 | SET_IF_SAME_NAMEs() 106 | #undef SET_IF_SAME_NAME 107 | } while (0); 108 | 109 | popdef(`SET_IF_SAME_NAMEs') 110 | 111 | } 112 | } 113 | /* }}} */ 114 | #endif 115 | 116 | define(`xc_lookup_class', `IFRESTORE(``xc_lookup_class'($@)',``xc_lookup_class' can be use in restore only')') 117 | -------------------------------------------------------------------------------- /processor/debug.h: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_XCACHE_TEST 2 | # define RELAYLINE_DC , int relayline 3 | # define RELAYLINE_CC , __LINE__ 4 | #else 5 | # define RELAYLINE_DC 6 | # define RELAYLINE_CC 7 | #endif 8 | 9 | #ifdef HAVE_XCACHE_TEST 10 | # undef NDEBUG 11 | # include 12 | #endif 13 | 14 | #ifndef NDEBUG 15 | # undef inline 16 | #define inline 17 | #endif 18 | 19 | #ifdef NDEBUG 20 | #define notnullable(ptr) (ptr) 21 | #else 22 | static inline void *notnullable(const void *ptr) 23 | { 24 | assert(ptr); 25 | return (void *) ptr; 26 | } 27 | #endif 28 | 29 | #ifdef HAVE_XCACHE_DPRINT 30 | static void xc_dprint_indent(int indent) /* {{{ */ 31 | { 32 | int i; 33 | for (i = 0; i < indent; i ++) { 34 | fprintf(stderr, " "); 35 | } 36 | } 37 | /* }}} */ 38 | static void xc_dprint_str_len(const char *str, int len) /* {{{ */ 39 | { 40 | const unsigned char *p = (const unsigned char *) str; 41 | int i; 42 | for (i = 0; i < len; i ++) { 43 | if (p[i] < 32 || p[i] == 127) { 44 | fprintf(stderr, "\\%03o", (unsigned int) p[i]); 45 | } 46 | else { 47 | fputc(p[i], stderr); 48 | } 49 | } 50 | } 51 | /* }}} */ 52 | #endif 53 | #ifdef HAVE_XCACHE_TEST 54 | static int xc_check_names(const char *file, int line, const char *functionName, const char **assert_names, size_t assert_names_count, HashTable *done_names) /* {{{ field name checker */ 55 | { 56 | int errors = 0; 57 | if (assert_names_count) { 58 | size_t i; 59 | Bucket *b; 60 | 61 | for (i = 0; i < assert_names_count; ++i) { 62 | if (!zend_u_hash_exists(done_names, IS_STRING, assert_names[i], (uint) strlen(assert_names[i]) + 1)) { 63 | fprintf(stderr 64 | , "Error: missing field at %s `#'%d %s`' : %s\n" 65 | , file, line, functionName 66 | , assert_names[i] 67 | ); 68 | ++errors; 69 | } 70 | } 71 | 72 | for (b = done_names->pListHead; b != NULL; b = b->pListNext) { 73 | int known = 0; 74 | for (i = 0; i < assert_names_count; ++i) { 75 | if (strcmp(assert_names[i], BUCKET_KEY_S(b)) == 0) { 76 | known = 1; 77 | break; 78 | } 79 | } 80 | if (!known) { 81 | fprintf(stderr 82 | , "Error: unknown field at %s `#'%d %s`' : %s\n" 83 | , file, line, functionName 84 | , BUCKET_KEY_S(b) 85 | ); 86 | ++errors; 87 | } 88 | } 89 | } 90 | return errors; 91 | } 92 | /* }}} */ 93 | #endif 94 | #ifdef HAVE_XCACHE_TEST 95 | static void *xc_memsetptr(void *mem, void *content, size_t n) /* {{{ */ 96 | { 97 | void **p = (void **) mem; 98 | void **end = (void **) ((char *) mem + n); 99 | while (p < end - sizeof(content)) { 100 | *p = content; 101 | p += sizeof(content); 102 | } 103 | if (p < end) { 104 | memset(p, -1, end - p); 105 | } 106 | return mem; 107 | } 108 | /* }}} */ 109 | #endif 110 | -------------------------------------------------------------------------------- /processor/head.m4: -------------------------------------------------------------------------------- 1 | dnl === program start ======================================== 2 | divert(0) 3 | ifdef(`XCACHE_ENABLE_TEST', ` 4 | m4_errprint(`AUTOCHECK INFO: runtime autocheck Enabled (debug build)') 5 | ', ` 6 | m4_errprint(`AUTOCHECK INFO: runtime autocheck Disabled (optimized build)') 7 | ') 8 | 9 | #include 10 | #include 11 | 12 | #include "php.h" 13 | #include "zend_extensions.h" 14 | #include "zend_compile.h" 15 | #include "zend_API.h" 16 | #include "zend_ini.h" 17 | 18 | EXPORT(`#include ') 19 | EXPORT(`#include "xcache.h"') 20 | EXPORT(`#include "mod_cacher/xc_cache.h"') 21 | EXPORT(`#include "xcache/xc_shm.h"') 22 | EXPORT(`#include "xcache/xc_allocator.h"') 23 | #include "xc_processor.h" 24 | #include "xcache/xc_const_string.h" 25 | #include "xcache/xc_utils.h" 26 | #include "util/xc_align.h" 27 | #include "util/xc_trace.h" 28 | #include "util/xc_util.h" 29 | #include "xcache_globals.h" 30 | 31 | #if defined(HARDENING_PATCH_HASH_PROTECT) && HARDENING_PATCH_HASH_PROTECT 32 | extern unsigned int zend_hash_canary; 33 | #endif 34 | dnl 35 | 36 | #ifdef DEBUG_SIZE 37 | static int xc_totalsize = 0; 38 | #endif 39 | 40 | #include "processor/debug.h" 41 | #include "processor/types.h" 42 | include(__dir__`/types.m4') 43 | 44 | /* {{{ call op_array ctor handler */ 45 | extern zend_bool xc_have_op_array_ctor; 46 | static void xc_zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) 47 | { 48 | if (extension->op_array_ctor) { 49 | extension->op_array_ctor(op_array); 50 | } 51 | } 52 | /* }}} */ 53 | #include "processor/processor-t.h" 54 | 55 | #include "processor/string-helper.h" 56 | include(__dir__`/string-helper.m4') 57 | 58 | include(__dir__`/class-helper.m4') 59 | 60 | #include "processor/var-helper.h" 61 | include(__dir__`/var-helper.m4') 62 | -------------------------------------------------------------------------------- /processor/process.m4: -------------------------------------------------------------------------------- 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 | 75 | , `$1', `xc_ztstring', `PROCESS_xc_ztstring(`$2')' 76 | , `$1', `xc_zval_type_t', `PROCESS_xc_zval_type_t(`$2')' 77 | , `$1', `xc_op_type', `PROCESS_xc_op_type(`$2')' 78 | , `$1', `xc_opcode', `PROCESS_xc_opcode(`$2')' 79 | , `$1', `opcode_handler_t', `/* is copying enough? */PROCESS_CTEXTPOINTER(`$2')' 80 | , `$1', `xc_md5sum_t', `COPY(`$2')' 81 | , `', `', `m4_errprint(`AUTOCHECK ERROR: Unknown type "$1"')define(`EXIT_PENDING', 1)' 82 | ) 83 | ') 84 | define(`PROCESS_ARRAY', `dnl {{{ (1:count, 2:type, 3:elm, [4:real_type]) 85 | if (SRC(`$3')) { 86 | int LOOPCOUNTER; 87 | IFDASM(` 88 | zval *arr; 89 | ALLOC_INIT_ZVAL(arr); 90 | array_init(arr); 91 | 92 | for (LOOPCOUNTER = 0; 93 | ifelse(`$1', `', `SRC(`$3[LOOPCOUNTER]')', 94 | `', `', `LOOPCOUNTER < SRC(`$1')'); 95 | ++LOOPCOUNTER) { 96 | pushdef(`dst', `arr') 97 | pushdef(`SRC', `ifelse(`$4', `', `', `($2)')' defn(`SRC') `[LOOPCOUNTER]') 98 | pushdef(`add_assoc_bool_ex', `add_next_index_bool($1, $3)') 99 | pushdef(`add_assoc_string_ex', `add_next_index_string($1, $3)') 100 | pushdef(`add_assoc_long_ex', `add_next_index_long($1, $3)') 101 | pushdef(`add_assoc_zval_ex', `add_next_index_zval($1, $3)') 102 | DISABLECHECK(` 103 | PROCESS(`$2', `$3') 104 | ') 105 | popdef(`add_assoc_zval_ex') 106 | popdef(`add_assoc_long_ex') 107 | popdef(`add_assoc_string_ex') 108 | popdef(`add_assoc_bool_ex') 109 | popdef(`SRC') 110 | popdef(`dst') 111 | } 112 | add_assoc_zval_ex(dst, XCACHE_STRS("$3"), arr); 113 | ', ` 114 | dnl find count with NULL 115 | ifelse(`$1', `', ` 116 | size_t count = 0; 117 | while (SRC(`$3[count]')) { 118 | ++count; 119 | } 120 | ++count; 121 | pushdef(`STRUCT_COUNT', `count') 122 | ', 123 | `', `', `pushdef(`STRUCT_COUNT', `SRC(`$1')')') 124 | ALLOC(`DST(`$3')', `$2', `STRUCT_COUNT', , `$4') 125 | popdef(`STRUCT_COUNT') 126 | 127 | for (LOOPCOUNTER = 0; 128 | ifelse(`$1', `', `SRC(`$3[LOOPCOUNTER]')', 129 | `', `', `LOOPCOUNTER < SRC(`$1')'); 130 | ++LOOPCOUNTER) { 131 | DISABLECHECK(` 132 | pushdef(`DST', defn(`DST') `[LOOPCOUNTER]') 133 | pushdef(`SRC', `ifelse(`$4', `', `', `', `', `($2)')' defn(`SRC') `[LOOPCOUNTER]') 134 | PROCESS(`$2', `$3') 135 | popdef(`SRC') 136 | popdef(`DST') 137 | ') 138 | } 139 | dnl the end marker 140 | ifelse(`$1', `', `IFCOPY(`DST(`$3[LOOPCOUNTER]') = NULL;')') 141 | ')dnl IFDASM 142 | DONE(`$3') 143 | } 144 | else { 145 | COPYNULL(`$3') 146 | } 147 | ') 148 | dnl }}} 149 | -------------------------------------------------------------------------------- /processor/processor-t.h: -------------------------------------------------------------------------------- 1 | typedef struct _xc_processor_t { 2 | char *p; 3 | size_t size; 4 | HashTable zvalptrs; 5 | zend_bool handle_reference; /* enable if to deal with reference */ 6 | zend_bool have_references; 7 | ptrdiff_t relocatediff; 8 | 9 | const xc_entry_php_t *entry_php_src; 10 | const xc_entry_php_t *entry_php_dst; 11 | const xc_entry_data_php_t *php_src; 12 | const xc_entry_data_php_t *php_dst; 13 | const zend_class_entry *cache_ce; 14 | zend_ulong cache_class_index; 15 | 16 | const zend_op_array *active_op_array_src; 17 | zend_op_array *active_op_array_dst; 18 | const zend_class_entry *active_class_entry_src; 19 | zend_class_entry *active_class_entry_dst; 20 | zend_uint active_class_index; 21 | zend_uint active_op_array_index; 22 | const xc_op_array_info_t *active_op_array_infos_src; 23 | 24 | zend_bool readonly_protection; /* wheather it's present */ 25 | 26 | #include "processor/string-helper-t.h" 27 | #include "processor/var-helper-t.h" 28 | 29 | #ifdef HAVE_XCACHE_TEST 30 | xc_vector_t allocsizes; 31 | #endif 32 | } xc_processor_t; 33 | -------------------------------------------------------------------------------- /processor/string-helper-t.h: -------------------------------------------------------------------------------- 1 | HashTable strings; 2 | -------------------------------------------------------------------------------- /processor/string-helper.h: -------------------------------------------------------------------------------- 1 | #define MAX_DUP_STR_LEN 256 2 | 3 | static inline size_t xc_zstrlen_char(const_zstr s) /* {{{ */ 4 | { 5 | return strlen(ZSTR_S(s)); 6 | } 7 | /* }}} */ 8 | #ifdef IS_UNICODE 9 | static inline size_t xc_zstrlen_uchar(zstr s) /* {{{ */ 10 | { 11 | return u_strlen(ZSTR_U(s)); 12 | } 13 | /* }}} */ 14 | static inline size_t xc_zstrlen(int type, const_zstr s) /* {{{ */ 15 | { 16 | return type == IS_UNICODE ? xc_zstrlen_uchar(s) : xc_zstrlen_char(s); 17 | } 18 | /* }}} */ 19 | #else 20 | /* {{{ xc_zstrlen */ 21 | #define xc_zstrlen(dummy, s) xc_zstrlen_char(s) 22 | /* }}} */ 23 | #endif 24 | -------------------------------------------------------------------------------- /processor/string-helper.m4: -------------------------------------------------------------------------------- 1 | static inline void xc_calc_string_n(xc_processor_t *processor, zend_uchar type, const_zstr str, long size RELAYLINE_DC TSRMLS_DC) { /* {{{ */ 2 | pushdef(`PROCESSOR_TYPE', `calc') 3 | pushdef(`__LINE__', `relayline') 4 | size_t realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size); 5 | long dummy = 1; 6 | 7 | if (realsize > MAX_DUP_STR_LEN) { 8 | ALLOC(, char, realsize) 9 | } 10 | else if (zend_u_hash_add(&processor->strings, type, str, (uint) size, (void *) &dummy, sizeof(dummy), NULL) == SUCCESS) { 11 | /* new string */ 12 | ALLOC(, char, realsize) 13 | } 14 | IFAUTOCHECK(` 15 | else { 16 | dnl fprintf(stderr, "dupstr %s\n", ZSTR_S(str)); 17 | } 18 | ') 19 | popdef(`__LINE__') 20 | popdef(`PROCESSOR_TYPE') 21 | } 22 | /* }}} */ 23 | static inline zstr xc_store_string_n(xc_processor_t *processor, zend_uchar type, const_zstr str, long size RELAYLINE_DC) { /* {{{ */ 24 | pushdef(`PROCESSOR_TYPE', `store') 25 | pushdef(`__LINE__', `relayline') 26 | size_t realsize = UNISW(size, (type == IS_UNICODE) ? UBYTES(size) : size); 27 | zstr ret, *pret; 28 | 29 | if (realsize > MAX_DUP_STR_LEN) { 30 | ALLOC(ZSTR_V(ret), char, realsize) 31 | memcpy(ZSTR_V(ret), ZSTR_V(str), realsize); 32 | return ret; 33 | } 34 | 35 | if (zend_u_hash_find(&processor->strings, type, str, (uint) size, (void **) &pret) == SUCCESS) { 36 | TRACE("found old string %s:%ld %p", str, size, *pret); 37 | return *pret; 38 | } 39 | 40 | /* new string */ 41 | ALLOC(ZSTR_V(ret), char, realsize) 42 | memcpy(ZSTR_V(ret), ZSTR_V(str), realsize); 43 | zend_u_hash_add(&processor->strings, type, str, (uint) size, (void *) &ret, sizeof(zstr), NULL); 44 | TRACE("stored new string %s:%ld %p", str, size, ret); 45 | return ret; 46 | 47 | popdef(`__LINE__') 48 | popdef(`PROCESSOR_TYPE') 49 | } 50 | /* }}} */ 51 | -------------------------------------------------------------------------------- /processor/string.m4: -------------------------------------------------------------------------------- 1 | 2 | dnl {{{ PROC_STRING_N_EX(1:dst, 2:src, 3:size, 4:name, 5:type=char) 3 | define(`PROC_STRING_N_EX', ` 4 | pushdef(`STRTYPE', `ifelse(`$5',,`char',`$5')') 5 | pushdef(`PTRTYPE', ifelse( 6 | STRTYPE, `char', `char', 7 | STRTYPE, `zstr_char', `char', 8 | `', `', `UChar')) 9 | pushdef(`ISTYPE', ifelse(PTRTYPE,`UChar',IS_UNICODE,IS_STRING)) 10 | pushdef(`UNI_STRLEN', ifelse( 11 | STRTYPE, `zstr_uchar', `xc_zstrlen_uchar', 12 | STRTYPE, `zstr_char', `xc_zstrlen_char', 13 | `', `', `strlen')) 14 | pushdef(`SRCSTR', ifelse(STRTYPE,`char',`ZSTR($2)',STRTYPE,`UChar',`ZSTR($2)',`$2')) 15 | pushdef(`SRCPTR', ifelse( 16 | STRTYPE, `zstr_uchar', `ZSTR_U($2)', 17 | STRTYPE, `zstr_char', `ZSTR_S($2)', 18 | `', `', `$2')) 19 | pushdef(`DSTPTR', ifelse( 20 | STRTYPE, `zstr_uchar', `ZSTR_U($1)', 21 | STRTYPE, `zstr_char', `ZSTR_S($1)', 22 | `', `', `$1')) 23 | pushdef(`STRDUP', ifelse( 24 | PTRTYPE, `char', `estrndup', 25 | PTRTYPE, `UChar', `eustrndup')) 26 | if (SRCPTR == NULL) { 27 | IFNOTMEMCPY(`IFCOPY(` 28 | DSTPTR = NULL; 29 | ')') 30 | IFDASM(` 31 | add_assoc_null_ex(dst, XCACHE_STRS("$4")); 32 | ') 33 | } 34 | else { 35 | IFDPRINT(`INDENT() 36 | ifelse(STRTYPE, `zstr_uchar', ` 37 | #ifdef IS_UNICODE 38 | do { 39 | zval zv; 40 | zval reszv; 41 | int usecopy; 42 | 43 | INIT_ZVAL(zv); 44 | ZVAL_UNICODEL(&zv, ZSTR_U($2), $3 - 1, 1); 45 | zend_make_printable_zval(&zv, &reszv, &usecopy); 46 | fprintf(stderr, "string:%s:\t\"", "$1"); 47 | xc_dprint_str_len(Z_STRVAL(reszv), Z_STRLEN(reszv)); 48 | fprintf(stderr, "\" len=%lu\n", (unsigned long) $3 - 1); 49 | if (usecopy) { 50 | zval_dtor(&reszv); 51 | } 52 | zval_dtor(&zv); 53 | } while (0); 54 | #endif 55 | ', ` 56 | fprintf(stderr, "string:%s:\t\"", "$1"); 57 | xc_dprint_str_len(SRCPTR, $3 - 1); 58 | fprintf(stderr, "\" len=%lu\n", (unsigned long) $3 - 1); 59 | ') 60 | ') 61 | IFCALC(`xc_calc_string_n(processor, ISTYPE, SRCSTR, $3 RELAYLINE_CC TSRMLS_CC);') 62 | IFSTORE(`DSTPTR = ifdef(`REALPTRTYPE', `(REALPTRTYPE() *)') ifelse(PTRTYPE,`char',`ZSTR_S',`ZSTR_U')(xc_store_string_n(processor, ISTYPE, SRCSTR, $3 RELAYLINE_CC));') 63 | IFRESTORE(` 64 | DSTPTR = ifdef(`REALPTRTYPE', `(REALPTRTYPE() *)') STRDUP() (SRCPTR, ($3) - 1); 65 | ') 66 | RELOCATE_EX(ifdef(`REALPTRTYPE', `REALPTRTYPE()', `PTRTYPE'), DSTPTR) 67 | IFDASM(` 68 | ifelse(STRTYPE,zstr_uchar, ` 69 | add_assoc_unicodel_ex(dst, XCACHE_STRS("$4"), ZSTR_U($2), $3-1, 1); 70 | ', ` dnl else 71 | ifelse(STRTYPE,zstr_char, ` 72 | add_assoc_stringl_ex(dst, XCACHE_STRS("$4"), (char *) ZSTR_S($2), $3-1, 1); 73 | ', ` 74 | add_assoc_stringl_ex(dst, XCACHE_STRS("$4"), (char *) $2, $3-1, 1); 75 | ') 76 | ') 77 | ') 78 | } 79 | popdef(`STRDUP') 80 | popdef(`DSTPTR') 81 | popdef(`SRCPTR') 82 | popdef(`SRCSTR') 83 | popdef(`UNI_STRLEN') 84 | popdef(`STRTYPE') 85 | popdef(`ISTYPE') 86 | ') 87 | dnl }}} 88 | dnl PROC_STRING_N(1:name, 2:size, 3:type) 89 | define(`PROC_STRING_N', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `SRC(`$2')', `$1', `char')') 90 | define(`PROC_USTRING_N', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `SRC(`$2')', `$1', `UChar')') 91 | 92 | define(`PROC_STRING_L', `DBG(`$0($*)') PROC_STRING_N(`$1', `$2 + 1')') 93 | define(`PROC_USTRING_L', `DBG(`$0($*)') PROC_USTRING_N(`$1', `$2 + 1')') 94 | define(`PROC_STRING', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `strlen(SRC(`$1')) + 1', `$1', `char')') 95 | define(`PROC_USTRING', `DBG(`$0($*)') DONE(`$1')`'PROC_STRING_N_EX(`DST(`$1')', `SRC(`$1')', `strlen(SRC(`$1')) + 1', `$1', `UChar')') 96 | 97 | dnl {{{ PROC_ZSTRING_N(1:type, 2:name, 3:size, 4:size_type) 98 | define(`PROC_ZSTRING_N', ` 99 | DBG(`$0($*)') 100 | #ifdef IS_UNICODE 101 | pushdef(`NSIZE', ifelse( 102 | `$4', `strlen', `UNI_STRLEN (SRC(`$2')) + 1', 103 | `$4', `len', `SRC(`$3') + 1', 104 | `', `', `SRC(`$3')', 105 | )) 106 | DONE(`$2') 107 | ifelse(`$1', `1', `PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', defn(`NSIZE'), `$2', `zstr_uchar') 108 | ', ` 109 | if (ifelse(`$1', `', `UG(unicode)', `SRC(`$1') == IS_UNICODE')) { 110 | PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', defn(`NSIZE'), `$2', `zstr_uchar') 111 | } 112 | else { 113 | PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', defn(`NSIZE'), `$2', `zstr_char') 114 | } 115 | ') 116 | #else 117 | DONE(`$2') 118 | PROC_STRING_N_EX(`DST(`$2')', `SRC(`$2')', NSIZE, `$2', `zstr_char') 119 | #endif 120 | popdef(`NSIZE') 121 | ') 122 | dnl }}} 123 | define(`PROC_ZSTRING_L', `DBG(`$0($*)') PROC_ZSTRING_N(`$1', `$2', `$3', `len')') 124 | define(`PROC_ZSTRING', `DBG(`$0($*)') PROC_ZSTRING_N(`$1', `$2', , `strlen')') 125 | -------------------------------------------------------------------------------- /processor/types.h: -------------------------------------------------------------------------------- 1 | typedef zval *zval_ptr; 2 | typedef zval *zval_ptr_nullable; 3 | typedef char *xc_ztstring; 4 | #ifdef ZEND_ENGINE_2_4 5 | typedef zend_trait_alias *zend_trait_alias_ptr; 6 | typedef zend_trait_precedence *zend_trait_precedence_ptr; 7 | #endif 8 | #ifdef ZEND_ENGINE_2_3 9 | typedef int last_brk_cont_t; 10 | #else 11 | typedef zend_uint last_brk_cont_t; 12 | #endif 13 | 14 | typedef zend_uchar xc_zval_type_t; 15 | typedef int xc_op_type; 16 | typedef zend_uchar xc_opcode; 17 | #ifdef IS_UNICODE 18 | typedef UChar zstr_uchar; 19 | #endif 20 | typedef char zstr_char; 21 | -------------------------------------------------------------------------------- /processor/types.m4: -------------------------------------------------------------------------------- 1 | define(`SIZEOF_zend_uint', `sizeof(zend_uint)') 2 | define(`COUNTOF_zend_uint', `1') 3 | define(`SIZEOF_int', `sizeof(int)') 4 | define(`COUNTOF_int', `1') 5 | define(`SIZEOF_zend_function', `sizeof(zend_function)') 6 | define(`COUNTOF_zend_function', `1') 7 | define(`SIZEOF_zval_ptr', `sizeof(zval_ptr)') 8 | define(`COUNTOF_zval_ptr', `1') 9 | define(`SIZEOF_zval_ptr_nullable', `sizeof(zval_ptr_nullable)') 10 | define(`COUNTOF_zval_ptr_nullable', `1') 11 | define(`SIZEOF_zend_trait_alias_ptr', `sizeof(zend_trait_alias)') 12 | define(`COUNTOF_zend_trait_alias_ptr', `1') 13 | define(`SIZEOF_zend_trait_precedence_ptr', `sizeof(zend_trait_precedence)') 14 | define(`COUNTOF_zend_trait_precedence_ptr', `1') 15 | define(`SIZEOF_xc_entry_name_t', `sizeof(xc_entry_name_t)') 16 | define(`COUNTOF_xc_entry_name_t', `1') 17 | define(`SIZEOF_xc_ztstring', `sizeof(xc_ztstring)') 18 | define(`COUNTOF_xc_ztstring', `1') 19 | 20 | EXPORT(`typedef struct _xc_dasm_t { const zend_op_array *active_op_array_src; } xc_dasm_t;') 21 | 22 | -------------------------------------------------------------------------------- /processor/var-helper-t.h: -------------------------------------------------------------------------------- 1 | /* {{{ var object helpers */ 2 | #ifdef ZEND_ENGINE_2 3 | xc_vector_t objects; /* in calc */ 4 | HashTable handle_to_index; /* in calc/store only */ 5 | zend_object_handle *object_handles; /* in restore only */ 6 | #endif 7 | const xc_entry_var_t *entry_var_src; /* in restore */ 8 | 9 | xc_vector_t class_names; /* in calc only */ 10 | HashTable class_name_to_index; /* in calc/store only */ 11 | zend_class_entry **index_to_ce; /* in restore only */ 12 | /* }}} */ 13 | -------------------------------------------------------------------------------- /processor/var-helper.h: -------------------------------------------------------------------------------- 1 | #ifdef ZEND_ENGINE_2 2 | static void xc_var_collect_object(xc_processor_t *processor, zend_object_handle handle TSRMLS_DC); 3 | static void xc_var_collect_object_in_zval(xc_processor_t *processor, zval *zv TSRMLS_DC); 4 | static void xc_var_collect_object_in_hashtable(xc_processor_t *processor, HashTable *ht TSRMLS_DC); 5 | 6 | static void xc_var_collect_object_in_hashtable(xc_processor_t *processor, HashTable *ht TSRMLS_DC) /* {{{ */ 7 | { 8 | Bucket *bucket; 9 | for (bucket = ht->pListHead; bucket; bucket = bucket->pListNext) { 10 | xc_var_collect_object_in_zval(processor, *(zval **) bucket->pData TSRMLS_CC); 11 | } 12 | } 13 | /* }}} */ 14 | static void xc_var_collect_object_in_zval(xc_processor_t *processor, zval *zv TSRMLS_DC) /* {{{ */ 15 | { 16 | switch (Z_TYPE_P(zv)) { 17 | case IS_OBJECT: 18 | xc_var_collect_object(processor, Z_OBJ_HANDLE_P(zv) TSRMLS_CC); 19 | break; 20 | 21 | case IS_ARRAY: 22 | xc_var_collect_object_in_hashtable(processor, Z_ARRVAL_P(zv) TSRMLS_CC); 23 | break; 24 | } 25 | } 26 | /* }}} */ 27 | static void xc_var_collect_object(xc_processor_t *processor, zend_object_handle handle TSRMLS_DC) /* {{{ */ 28 | { 29 | size_t next_index; 30 | 31 | if (!xc_vector_initialized(&processor->objects)) { 32 | if (zend_hash_num_elements(&processor->handle_to_index)) { 33 | /* collecting process is stopped, may reach here by xc_entry_src_t.objects.properties */ 34 | return; 35 | } 36 | xc_vector_init(zend_object, &processor->objects); 37 | zend_hash_init(&processor->handle_to_index, 0, NULL, NULL, 0); 38 | } 39 | 40 | next_index = xc_vector_size(&processor->objects); 41 | if (_zend_hash_index_update_or_next_insert(&processor->handle_to_index, handle, (void *) &next_index, sizeof(next_index), NULL, HASH_ADD ZEND_FILE_LINE_CC) == SUCCESS) { 42 | zend_object *object = zend_object_store_get_object_by_handle(handle TSRMLS_CC); 43 | 44 | xc_vector_push_back(&processor->objects, object); 45 | 46 | if (object->properties) { 47 | xc_var_collect_object_in_hashtable(processor, object->properties TSRMLS_CC); 48 | } 49 | 50 | #ifdef ZEND_ENGINE_2_4 51 | /* TODO: is this necessary? */ 52 | if (object->properties_table) { 53 | int i, count = zend_hash_num_elements(&object->ce->properties_info); 54 | for (i = 0; i < count; ++i) { 55 | xc_var_collect_object_in_zval(processor, object->properties_table[i] TSRMLS_CC); 56 | } 57 | } 58 | #endif 59 | } 60 | } 61 | /* }}} */ 62 | static size_t xc_var_store_handle(xc_processor_t *processor, zend_object_handle handle TSRMLS_DC) /* {{{ */ 63 | { 64 | size_t *index; 65 | 66 | if (zend_hash_index_find(&processor->handle_to_index, handle, (void **) &index) != SUCCESS) { 67 | php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Internal error: handle %d not found on store", handle); 68 | return (size_t) -1; 69 | } 70 | 71 | return *index; 72 | } 73 | /* }}} */ 74 | static zend_object_handle xc_var_restore_handle(xc_processor_t *processor, size_t index TSRMLS_DC) /* {{{ */ 75 | { 76 | zend_object_handle handle = processor->object_handles[index]; 77 | zend_objects_store_add_ref_by_handle(handle TSRMLS_CC); 78 | return handle; 79 | } 80 | /* }}} */ 81 | #endif 82 | static void xc_var_collect_class(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */ 83 | { 84 | size_t next_index; 85 | 86 | if (!xc_vector_initialized(&processor->class_names)) { 87 | xc_vector_init(xc_constant_string_t, &processor->class_names); 88 | zend_hash_init(&processor->class_name_to_index, 0, NULL, NULL, 0); 89 | } 90 | 91 | /* HashTable <=PHP_4 cannot handle NULL pointers, +1 needed */ 92 | next_index = xc_vector_size(&processor->class_names) + 1; 93 | if (zend_hash_add(&processor->class_name_to_index, ce->name, ce->name_length, (void *) &next_index, sizeof(next_index), NULL) == SUCCESS) { 94 | xc_constant_string_t class_name; 95 | class_name.str = (char *) ce->name; 96 | class_name.len = ce->name_length; 97 | xc_vector_push_back(&processor->class_names, &class_name); 98 | } 99 | } 100 | /* }}} */ 101 | static size_t xc_var_store_ce(xc_processor_t *processor, zend_class_entry *ce TSRMLS_DC) /* {{{ */ 102 | { 103 | size_t *index; 104 | 105 | if (zend_hash_find(&processor->class_name_to_index, ce->name, ce->name_length, (void **) &index) != SUCCESS) { 106 | php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Internal error: class name not found in class names"); 107 | return (size_t) - 1; 108 | } 109 | 110 | return *index - 1; 111 | } 112 | /* }}} */ 113 | /* on restore */ 114 | -------------------------------------------------------------------------------- /processor/var-helper.m4: -------------------------------------------------------------------------------- 1 | define(`xc_collect_object', `IFCALC(``xc_collect_object'($@)',``xc_collect_object' can be use in calc only')') 2 | define(`xc_var_store_handle', `IFSTORE(``xc_var_store_handle'($@)',``xc_var_store_handle' can be use in store only')') 3 | define(`xc_var_restore_handle', `IFRESTORE(``xc_var_restore_handle'($@)',``xc_var_restore_handle' can be use in restore only')') 4 | 5 | define(`xc_collect_class', `IFCALC(``xc_collect_class'($@)',``xc_collect_class' can be use in calc only')') 6 | define(`xc_var_store_ce', `IFSTORE(``xc_var_store_ce'($@)',``xc_var_store_ce' can be use in store only')') 7 | -------------------------------------------------------------------------------- /run-xcachetest: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | getAbsolutePath() { 4 | which readlink >/dev/null 2>&1 && readlink -f "$@" || echo "$@" 5 | } 6 | 7 | # use symlink first 8 | if test -x ./php-cli ; then 9 | php_cli=`getAbsolutePath ./php-cli` 10 | elif test ! -z "$TEST_PHP_EXECUTABLE" && test -x "$TEST_PHP_EXECUTABLE"; then 11 | php_cli="$TEST_PHP_EXECUTABLE" 12 | else 13 | php_cli="`which php`" 14 | fi 15 | 16 | test_args="-c \"$TEST_INI\""' -d "open_basedir=" -d "safe_mode=0" -d "output_buffering=0" -d "memory_limit=-1"' 17 | 18 | if test -x ./php-cgi ; then 19 | php_cgi=`getAbsolutePath ./php-cgi` 20 | else 21 | php_cgi="`which php-cgi`" 22 | fi 23 | 24 | echo '#!/bin/sh' > ./php-cli-test 25 | echo 'exec "'$php_cli'" '$test_args' "$@"' >> php-cli-test 26 | chmod +x ./php-cli-test 27 | 28 | echo '#!/bin/sh' > ./php-cgi-test 29 | echo 'exec "'$php_cgi'" '$test_args' "$@"' >> php-cgi-test 30 | chmod +x ./php-cgi-test 31 | 32 | TEST_PHP_EXECUTABLE=`getAbsolutePath ./php-cli-test` 33 | TEST_PHP_CGI_EXECUTABLE=`getAbsolutePath ./php-cgi-test` 34 | real_php_src=`getAbsolutePath ./php-src`; 35 | test -z "$TEST_PHP_SRCDIR" && TEST_PHP_SRCDIR=$real_php_src 36 | 37 | export TEST_PHP_EXECUTABLE 38 | export TEST_PHP_CGI_EXECUTABLE 39 | export TEST_PHP_SRCDIR 40 | 41 | echo "XCache test running with:" 42 | echo "TEST_PHP_CGI_EXECUTABLE: $TEST_PHP_CGI_EXECUTABLE" 43 | echo "TEST_PHP_EXECUTABLE: $TEST_PHP_EXECUTABLE" 44 | echo "TEST_PHP_SRCDIR: $TEST_PHP_SRCDIR" 45 | 46 | patch_run_tests_ext() { 47 | if test -z "$TEST_EXT" ; then 48 | sed "s#'ext',##g" 49 | else 50 | cat 51 | fi 52 | } 53 | patch_run_tests_report_leaks() { 54 | if test -z "$TEST_REPORT_MEMLEAKS" ; then 55 | sed "s#'report_memleaks=1',#'report_memleaks=0',#g" 56 | else 57 | cat 58 | fi 59 | } 60 | run_tests_src=$real_php_src/run-tests.php 61 | patch_run_tests_ext < "$run_tests_src" | sed "s#^\\\$test_dirs = array('.*#\\\$test_dirs = array();#" | patch_run_tests_report_leaks > run-tests.php 62 | exec "$TEST_PHP_EXECUTABLE" `getAbsolutePath ./run-tests.php` "$@" 63 | -------------------------------------------------------------------------------- /tests/include-skipif.inc: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /tests/skipif.inc: -------------------------------------------------------------------------------- 1 | =') && !extension_loaded("xcache")) { 3 | die("skip xcache extension not loaded"); 4 | } 5 | ?> 6 | -------------------------------------------------------------------------------- /tests/sub-a.inc: -------------------------------------------------------------------------------- 1 | 7 | --INI-- 8 | xcache.readonly_protection=0 9 | xcache.test = 1 10 | xcache.size = 32M 11 | --FILE-- 12 | 20 | --EXPECT-- 21 | 12 22 | -------------------------------------------------------------------------------- /tests/xcache_deep_copy_opcodes_for_const.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache requires deep copying opcodes for __FILE__ and __DIR__ 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | xcache.test = 1 9 | xcache.size = 32M 10 | --FILE-- 11 | 14 | --EXPECTF-- 15 | %sxcache_deep_copy_opcodes_for_const%s 16 | -------------------------------------------------------------------------------- /tests/xcache_deep_copy_static_variables.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache requires deep copying static variables in shallow copy mode 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | xcache.readonly_protection=0 9 | xcache.test = 1 10 | xcache.size = 32M 11 | --FILE-- 12 | 16 | --EXPECT-- 17 | 1 18 | -------------------------------------------------------------------------------- /tests/xcache_include_absolute.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | include absolute path 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | xcache.test = 1 9 | xcache.size = 32M 10 | --FILE-- 11 | 15 | --EXPECTF-- 16 | %stests 17 | %stests%ssub-a.inc 18 | %stests 19 | %stests%ssub-b.inc 20 | -------------------------------------------------------------------------------- /tests/xcache_include_relative_cwd.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | include relative to current working dir 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | xcache.test = 1 9 | xcache.size = 32M 10 | --FILE-- 11 | 16 | --EXPECTF-- 17 | %stests 18 | %stests%ssub-a.inc 19 | %stests 20 | %stests%ssub-b.inc 21 | -------------------------------------------------------------------------------- /tests/xcache_include_relative_file.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | include relative to current file 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | xcache.test = 1 9 | xcache.size = 32M 10 | --FILE-- 11 | 15 | --EXPECTF-- 16 | %stests 17 | %stests%ssub-a.inc 18 | %stests 19 | %stests%ssub-b.inc 20 | -------------------------------------------------------------------------------- /tests/xcache_is_autoglobal.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache_is_autoglobal 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | xcache.test = 1 9 | xcache.size = 32M 10 | --FILE-- 11 | 14 | --EXPECT-- 15 | bool(true) 16 | -------------------------------------------------------------------------------- /tests/xcache_shallow_copy_check_early_binding.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache shallow copying precondition: early binding changes constant inside opcode for PHP5.2- 3 | --SKIPIF-- 4 | =")) { 7 | die("skip only needed for PHP 5.2 or less"); 8 | } 9 | ?> 10 | --INI-- 11 | xcache.test = 1 12 | xcache.size = 32M 13 | --FILE-- 14 | 18 | --EXPECT-- 19 | -------------------------------------------------------------------------------- /tests/xcache_var.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache_set/get test 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | xcache.test = 1 9 | xcache.size = 32M 10 | xcache.var_size = 2M 11 | --FILE-- 12 | 24 | --EXPECT-- 25 | bool(false) 26 | bool(true) 27 | int(1) 28 | bool(true) 29 | int(11) 30 | int(11) 31 | int(6) 32 | int(6) 33 | bool(false) 34 | -------------------------------------------------------------------------------- /tests/xcache_var_object.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache_set/get test for object PHP 5.2+ 3 | --SKIPIF-- 4 | =')) { 7 | echo 'skip for PHP 5.2+ only'; 8 | } 9 | ?> 10 | --INI-- 11 | xcache.test = 1 12 | xcache.size = 32M 13 | xcache.var_size = 2M 14 | --FILE-- 15 | a = $a; 29 | $b->b = $b; 30 | $b->array = array($b, $a); 31 | $b->stdclass = $stdclass; 32 | 33 | var_dump(xcache_set("a", $a)); 34 | unset($a); 35 | var_dump($a = xcache_get("a")); 36 | 37 | var_dump(xcache_set("b", $b)); 38 | unset($b); 39 | var_dump($b = xcache_get("b")); 40 | 41 | $b->test = 1; 42 | var_dump($b->b->test); 43 | ?> 44 | --EXPECT-- 45 | bool(true) 46 | object(a)#4 (0) { 47 | } 48 | bool(true) 49 | object(b)#7 (4) { 50 | ["a"]=> 51 | object(a)#6 (0) { 52 | } 53 | ["b"]=> 54 | *RECURSION* 55 | ["array"]=> 56 | array(2) { 57 | [0]=> 58 | *RECURSION* 59 | [1]=> 60 | object(a)#6 (0) { 61 | } 62 | } 63 | ["stdclass"]=> 64 | object(stdClass)#5 (0) { 65 | } 66 | } 67 | int(1) 68 | -------------------------------------------------------------------------------- /tests/xcache_var_object_5.1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache_set/get test for object 5.1- 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | xcache.test = 1 12 | xcache.size = 32M 13 | xcache.var_size = 2M 14 | --FILE-- 15 | a = $a; 29 | $b->b = $b; 30 | $b->array = array($b, $a); 31 | $b->stdclass = $stdclass; 32 | 33 | var_dump(xcache_set("a", $a)); 34 | unset($a); 35 | var_dump($a = xcache_get("a")); 36 | 37 | var_dump(xcache_set("b", $b)); 38 | unset($b); 39 | var_dump($b = xcache_get("b")); 40 | 41 | $b->test = 1; 42 | var_dump($b->b->test); 43 | ?> 44 | --EXPECT-- 45 | bool(true) 46 | object(a)#4 (0) { 47 | } 48 | bool(true) 49 | object(b)#7 (4) { 50 | ["a"]=> 51 | object(a)#6 (0) { 52 | } 53 | ["b"]=> 54 | object(b)#7 (4) { 55 | ["a"]=> 56 | object(a)#6 (0) { 57 | } 58 | ["b"]=> 59 | *RECURSION* 60 | ["array"]=> 61 | array(2) { 62 | [0]=> 63 | *RECURSION* 64 | [1]=> 65 | object(a)#6 (0) { 66 | } 67 | } 68 | ["stdclass"]=> 69 | object(stdClass)#5 (0) { 70 | } 71 | } 72 | ["array"]=> 73 | array(2) { 74 | [0]=> 75 | object(b)#7 (4) { 76 | ["a"]=> 77 | object(a)#6 (0) { 78 | } 79 | ["b"]=> 80 | *RECURSION* 81 | ["array"]=> 82 | array(2) { 83 | [0]=> 84 | *RECURSION* 85 | [1]=> 86 | object(a)#6 (0) { 87 | } 88 | } 89 | ["stdclass"]=> 90 | object(stdClass)#5 (0) { 91 | } 92 | } 93 | [1]=> 94 | object(a)#6 (0) { 95 | } 96 | } 97 | ["stdclass"]=> 98 | object(stdClass)#5 (0) { 99 | } 100 | } 101 | int(1) 102 | -------------------------------------------------------------------------------- /tests/xcache_var_reference.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache_set/get test for reference for PHP 5.2+ 3 | --SKIPIF-- 4 | =')) { 7 | echo 'skip for PHP 5.2+ only'; 8 | } 9 | ?> 10 | --INI-- 11 | xcache.test = 1 12 | xcache.size = 32M 13 | xcache.var_size = 2M 14 | --FILE-- 15 | 29 | --EXPECT-- 30 | bool(true) 31 | array(1) { 32 | [0]=> 33 | &array(2) { 34 | ["ref"]=> 35 | *RECURSION* 36 | ["array"]=> 37 | array(1) { 38 | [0]=> 39 | *RECURSION* 40 | } 41 | } 42 | } 43 | int(1) 44 | int(1) 45 | -------------------------------------------------------------------------------- /tests/xcache_var_reference_4.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache_set/get test for reference for PHP 4 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | xcache.test = 1 12 | xcache.size = 32M 13 | xcache.var_size = 2M 14 | --FILE-- 15 | 29 | --EXPECT-- 30 | bool(true) 31 | array(1) { 32 | [0]=> 33 | &array(2) { 34 | ["ref"]=> 35 | &array(2) { 36 | ["ref"]=> 37 | *RECURSION* 38 | ["array"]=> 39 | array(1) { 40 | [0]=> 41 | *RECURSION* 42 | } 43 | } 44 | ["array"]=> 45 | array(1) { 46 | [0]=> 47 | &array(2) { 48 | ["ref"]=> 49 | *RECURSION* 50 | ["array"]=> 51 | array(1) { 52 | [0]=> 53 | *RECURSION* 54 | } 55 | } 56 | } 57 | } 58 | } 59 | int(1) 60 | int(1) 61 | -------------------------------------------------------------------------------- /tests/xcache_var_reference_5.1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | xcache_set/get test for reference for PHP 5.{0,1} 3 | --SKIPIF-- 4 | =') && version_compare(phpversion(), '5.2', '<'))) { 7 | echo 'skip for PHP 5.{0,1} only'; 8 | } 9 | ?> 10 | --INI-- 11 | xcache.test = 1 12 | xcache.size = 32M 13 | xcache.var_size = 2M 14 | --FILE-- 15 | 29 | --EXPECT-- 30 | bool(true) 31 | array(1) { 32 | [0]=> 33 | &array(2) { 34 | ["ref"]=> 35 | &array(2) { 36 | ["ref"]=> 37 | *RECURSION* 38 | ["array"]=> 39 | array(1) { 40 | [0]=> 41 | *RECURSION* 42 | } 43 | } 44 | ["array"]=> 45 | array(1) { 46 | [0]=> 47 | &array(2) { 48 | ["ref"]=> 49 | *RECURSION* 50 | ["array"]=> 51 | array(1) { 52 | [0]=> 53 | *RECURSION* 54 | } 55 | } 56 | } 57 | } 58 | } 59 | int(1) 60 | int(1) 61 | -------------------------------------------------------------------------------- /util/README: -------------------------------------------------------------------------------- 1 | generic utility stuffs unrelatived to ZendEngine 2 | -------------------------------------------------------------------------------- /util/xc_align.h: -------------------------------------------------------------------------------- 1 | #ifndef __ALIGN_H 2 | #define __ALIGN_H 3 | #ifndef ALIGN 4 | typedef union align_union { 5 | double d; 6 | void *v; 7 | int (*func)(int); 8 | long l; 9 | } align_union; 10 | 11 | #if (defined (__GNUC__) && __GNUC__ >= 2) 12 | #define XCACHE_PLATFORM_ALIGNMENT (__alignof__ (align_union)) 13 | #else 14 | #define XCACHE_PLATFORM_ALIGNMENT (sizeof(align_union)) 15 | #endif 16 | 17 | #define ALIGN(n) ((((size_t)(n)-1) & ~(XCACHE_PLATFORM_ALIGNMENT-1)) + XCACHE_PLATFORM_ALIGNMENT) 18 | #endif 19 | #endif /* __ALIGN_H */ 20 | -------------------------------------------------------------------------------- /util/xc_foreachcoresig.h: -------------------------------------------------------------------------------- 1 | /* all signals generate coredump by default is list here */ 2 | 3 | #ifdef SIGABRT 4 | FOREACH_SIG(SIGABRT); 5 | #endif 6 | 7 | #ifdef SIGBUS 8 | FOREACH_SIG(SIGBUS); 9 | #endif 10 | 11 | #ifdef SIGEMT 12 | FOREACH_SIG(SIGEMT); 13 | #endif 14 | 15 | #ifdef SIGFPE 16 | FOREACH_SIG(SIGFPE); 17 | #endif 18 | 19 | #ifdef SIGILL 20 | FOREACH_SIG(SIGILL); 21 | #endif 22 | 23 | #ifdef SIGIOT 24 | FOREACH_SIG(SIGIOT); 25 | #endif 26 | 27 | #ifdef SIGQUIT 28 | FOREACH_SIG(SIGQUIT); 29 | #endif 30 | 31 | #ifdef SIGSEGV 32 | FOREACH_SIG(SIGSEGV); 33 | #endif 34 | 35 | #ifdef SIGSYS 36 | FOREACH_SIG(SIGSYS); 37 | #endif 38 | 39 | #ifdef SIGTRAP 40 | FOREACH_SIG(SIGTRAP); 41 | #endif 42 | 43 | #ifdef SIGXCPU 44 | FOREACH_SIG(SIGXCPU); 45 | #endif 46 | 47 | #ifdef SIGXFSZ 48 | FOREACH_SIG(SIGXFSZ); 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /util/xc_trace.c: -------------------------------------------------------------------------------- 1 | #ifdef TEST 2 | # define PHP_DIR_SEPARATOR '/' 3 | #else 4 | # include "php.h" 5 | #endif 6 | #include "xc_trace.h" 7 | #include 8 | #include 9 | #include 10 | 11 | const char *xc_trace_get_basename(const char *path) /* {{{ */ 12 | { 13 | const char *last_separator = strrchr(path, PHP_DIR_SEPARATOR); 14 | return last_separator ? last_separator + 1 : path; 15 | } 16 | /* }}} */ 17 | int xc_vtrace(const char *fmt, va_list args) /* {{{ */ 18 | { 19 | return vfprintf(stderr, fmt, args); 20 | } 21 | /* }}} */ 22 | int xc_trace(const char *fmt, ...) /* {{{ */ 23 | { 24 | va_list args; 25 | int ret; 26 | 27 | va_start(args, fmt); 28 | ret = xc_vtrace(fmt, args); 29 | va_end(args); 30 | return ret; 31 | } 32 | /* }}} */ 33 | 34 | -------------------------------------------------------------------------------- /util/xc_trace.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_TRACE_H_709AE2523EDACB72B54D9CB42DDB0FEE 2 | #define XC_TRACE_H_709AE2523EDACB72B54D9CB42DDB0FEE 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #ifdef ZEND_WIN32 9 | # ifndef inline 10 | # ifdef ZEND_WIN32_FORCE_INLINE 11 | # define inline __forceinline 12 | # else 13 | # define inline 14 | # endif 15 | # endif 16 | #endif 17 | 18 | #ifdef XCACHE_DEBUG 19 | # define IFDEBUG(x) (x) 20 | # include 21 | # include 22 | int xc_vtrace(const char *fmt, va_list args); 23 | int xc_trace(const char *fmt, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2); 24 | 25 | # ifdef ZEND_WIN32 26 | static inline int TRACE(const char *fmt, ...) 27 | { 28 | va_list args; 29 | int ret; 30 | 31 | va_start(args, fmt); 32 | ret = xc_vtrace(fmt, args); 33 | va_end(args); 34 | return ret; 35 | } 36 | # else 37 | const char *xc_trace_get_basename(const char *path); 38 | # define TRACE(fmt, ...) \ 39 | xc_trace("%s:%04d: " fmt "\r\n", xc_trace_get_basename(__FILE__), __LINE__, __VA_ARGS__) 40 | # endif /* ZEND_WIN32 */ 41 | # undef NDEBUG 42 | # undef inline 43 | # define inline 44 | #else /* XCACHE_DEBUG */ 45 | 46 | # ifdef ZEND_WIN32 47 | static inline int TRACE_DUMMY(const char *fmt, ...) 48 | { 49 | return 0; 50 | } 51 | # define TRACE 1 ? 0 : TRACE_DUMMY 52 | # else 53 | # define TRACE(fmt, ...) do { } while (0) 54 | # endif /* ZEND_WIN32 */ 55 | 56 | # define IFDEBUG(x) do { } while (0) 57 | #endif /* XCACHE_DEBUG */ 58 | #include 59 | 60 | #endif /* XC_TRACE_H_709AE2523EDACB72B54D9CB42DDB0FEE */ 61 | -------------------------------------------------------------------------------- /util/xc_util.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_UTIL_H_709AE2523EDACB72B54D9CB42DDB0FEE 2 | #define XC_UTIL_H_709AE2523EDACB72B54D9CB42DDB0FEE 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #define ptradd(type, ptr, ptrdiff) ((type) (((char *) (ptr)) + (ptrdiff))) 9 | #define ptrsub(ptr1, ptr2) (((char *) (ptr1)) - ((char *) (ptr2))) 10 | 11 | #endif /* XC_UTIL_H_709AE2523EDACB72B54D9CB42DDB0FEE */ 12 | -------------------------------------------------------------------------------- /util/xc_vector.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B 2 | #define XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | typedef struct { 13 | void *data_; 14 | size_t size_; 15 | size_t capacity_; 16 | 17 | size_t data_size_; 18 | int persistent_; 19 | } xc_vector_t; 20 | 21 | #define xc_vector_initializer(type, persistent) { \ 22 | NULL, \ 23 | 0, \ 24 | 0, \ 25 | \ 26 | sizeof(type), \ 27 | persistent, \ 28 | } 29 | 30 | #define xc_vector_init_ex(type, vector, data, size, persistent) do { \ 31 | (vector)->data_ = data; \ 32 | (vector)->size_ = (vector)->capacity_ = size; \ 33 | (vector)->data_size_ = sizeof(type); \ 34 | (vector)->persistent_ = persistent; \ 35 | } while (0) 36 | 37 | #define xc_vector_init(type, vector) xc_vector_init_ex(type, vector, NULL, 0, 0) 38 | #define xc_vector_init_persistent(type, vector) xc_vector_init_ex(type, vector, NULL, 0, 1) 39 | 40 | static inline void xc_vector_destroy_impl(xc_vector_t *vector TSRMLS_DC) 41 | { 42 | vector->size_ = 0; 43 | if (vector->data_) { 44 | pefree(vector->data_, vector->persistent_); 45 | vector->data_ = NULL; 46 | } 47 | vector->capacity_ = 0; 48 | vector->data_size_ = 0; 49 | } 50 | 51 | #define xc_vector_destroy(vector) xc_vector_destroy_impl(vector TSRMLS_CC) 52 | #define xc_vector_clear(vector) do { (vector)->size_ = 0; } while (0) 53 | 54 | #define xc_vector_size(vector) ((vector)->size_) 55 | #define xc_vector_initialized(vector) ((vector)->data_size_ != 0) 56 | #define xc_vector_element_ptr_(vector, index) ( \ 57 | (void *) ( \ 58 | ((char *) (vector)->data_) + (index) * (vector)->data_size_ \ 59 | ) \ 60 | ) 61 | 62 | static inline xc_vector_t *xc_vector_check_type_(xc_vector_t *vector, size_t data_size) 63 | { 64 | assert(vector->data_size_ = data_size); 65 | return vector; 66 | } 67 | 68 | #define xc_vector_data(type, vector) ((type *) xc_vector_check_type_(vector, sizeof(type))->data_) 69 | 70 | static void xc_vector_reserve_impl(xc_vector_t *vector, size_t capacity TSRMLS_DC) 71 | { 72 | assert(capacity); 73 | if (!vector->capacity_) { 74 | vector->capacity_ = 8; 75 | } 76 | while (vector->capacity_ <= capacity) { 77 | vector->capacity_ <<= 1; 78 | } 79 | vector->data_ = perealloc(vector->data_, vector->data_size_ * vector->capacity_, vector->persistent_); 80 | } 81 | #define xc_vector_reserve(vector, capacity) xc_vector_reserve_impl(vector, capacity TSRMLS_CC) 82 | 83 | static void xc_vector_resize_impl(xc_vector_t *vector, size_t size TSRMLS_DC) 84 | { 85 | assert(size); 86 | xc_vector_reserve(vector, size); 87 | vector->size_ = size; 88 | } 89 | #define xc_vector_resize(vector, size) xc_vector_resize_impl(vector, size TSRMLS_CC) 90 | 91 | static inline void xc_vector_check_reserve_(xc_vector_t *vector TSRMLS_DC) 92 | { 93 | if (vector->size_ == vector->capacity_) { 94 | if (vector->capacity_) { 95 | vector->capacity_ <<= 1; 96 | } 97 | else { 98 | vector->capacity_ = 8; 99 | } 100 | vector->data_ = perealloc(vector->data_, vector->data_size_ * vector->capacity_, vector->persistent_); 101 | } 102 | } 103 | 104 | #define xc_vector_push_back(vector, value_ptr) do { \ 105 | xc_vector_check_reserve_(vector TSRMLS_CC); \ 106 | memcpy(xc_vector_element_ptr_(vector, (vector)->size_++), value_ptr, (vector)->data_size_); \ 107 | } while (0) 108 | 109 | static inline void *xc_vector_detach_impl(xc_vector_t *vector) 110 | { 111 | void *data = vector->data_; 112 | 113 | vector->data_ = NULL; 114 | vector->capacity_ = 0; 115 | vector->size_ = 0; 116 | return data; 117 | } 118 | 119 | #define xc_vector_detach(type, vector) ((type *) xc_vector_detach_impl(xc_vector_check_type_(vector, sizeof(type)))) 120 | 121 | static inline xc_vector_t *xc_vector_pop_back_check_(xc_vector_t *vector, size_t data_size) 122 | { 123 | assert(vector); 124 | assert(vector->data_size_ == data_size); 125 | assert(vector->capacity_ > 0); 126 | return vector; 127 | } 128 | 129 | #define xc_vector_pop_back(type, vector) xc_vector_data(type, \ 130 | xc_vector_pop_back_check_(vector, sizeof(type)) \ 131 | )[--(vector)->size_] 132 | 133 | static inline void xc_vector_reverse(xc_vector_t *vector) 134 | { 135 | char *left, *right; 136 | void *tmp; 137 | 138 | assert(vector); 139 | assert(vector->data_size_); 140 | tmp = alloca(vector->data_size_); 141 | for (left = vector->data_, right = xc_vector_element_ptr_(vector, vector->size_ - 1); left < right; left += vector->data_size_, right -= vector->data_size_) { 142 | memcpy(tmp, left, vector->data_size_); 143 | memcpy(left, right, vector->data_size_); 144 | memcpy(right, tmp, vector->data_size_); 145 | } 146 | } 147 | 148 | #endif /* XC_VECTOR_H_0957AC4E1A44E838C7B8DBECFF9C4B3B */ 149 | -------------------------------------------------------------------------------- /util/xc_vector_test.c: -------------------------------------------------------------------------------- 1 | 2 | #define TSRMLS_DC 3 | #define TSRMLS_CC 4 | #define pemalloc(size, p) malloc(size) 5 | #define perealloc(ptr, size, p) realloc(ptr, size) 6 | #define pefree(ptr, p) free(ptr) 7 | 8 | #include 9 | #include "xc_vector.h" 10 | 11 | #undef CHECK 12 | #define CHECK(a, msg) do { \ 13 | if (!(a)) { \ 14 | fprintf(stderr, "%s\n", msg); return -1; \ 15 | } \ 16 | } while (0) 17 | 18 | int main() /* {{{ */ 19 | { 20 | xc_vector_t vector = xc_vector_initializer(int, 0); 21 | int t; 22 | 23 | t = 1; xc_vector_push_back(&vector, &t); 24 | t = 2; xc_vector_push_back(&vector, &t); 25 | t = 3; xc_vector_push_back(&vector, &t); 26 | xc_vector_reverse(&vector); 27 | t = xc_vector_pop_back(int, &vector); 28 | CHECK(t == 1, "not 1"); 29 | t = xc_vector_pop_back(int, &vector); 30 | CHECK(t == 2, "not 2"); 31 | t = xc_vector_pop_back(int, &vector); 32 | CHECK(t == 3, "not 3"); 33 | 34 | xc_vector_destroy(&vector); 35 | 36 | return 0; 37 | } 38 | /* }}} */ 39 | -------------------------------------------------------------------------------- /xcache-test.ini: -------------------------------------------------------------------------------- 1 | date.timezone = Asia/Shanghai 2 | memory_limit = 256M 3 | error_reporting = E_ALL|E_STRICT|E_DEPRECATED 4 | display_errors = On 5 | 6 | [xcache] 7 | extension_dir="./.libs/" 8 | extension=xcache.so 9 | xcache.cacher = On 10 | xcache.test = 1 11 | xcache.stat = 1 12 | xcache.experimental = On 13 | xcache.size = 64M 14 | xcache.count = 2 15 | xcache.var_size = 1M 16 | xcache.var_count = 2 17 | xcache.var_slots = 1000 18 | ; xcache.mmap_path = "/dev/zero" 19 | xcache.mmap_path = "/tmp/xcache" 20 | xcache.readonly_protection = Off 21 | xcache.optimizer = On 22 | xcache.coredump_directory = "/tmp/" 23 | ;xcache.coveragedump_directory = "/tmp/pcov/" 24 | xcache.coverager = On 25 | 26 | xcache.admin.user = "test" 27 | xcache.admin.pass = "098f6bcd4621d373cade4e832627b4f6" 28 | -------------------------------------------------------------------------------- /xcache-zh-gb2312.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lighttpd/xcache/6f52434277cd3b8134e899af9b99959f6a99dfff/xcache-zh-gb2312.ini -------------------------------------------------------------------------------- /xcache.h: -------------------------------------------------------------------------------- 1 | #ifndef __XCACHE_H 2 | #define __XCACHE_H 3 | #define XCACHE_NAME "XCache" 4 | #ifndef XCACHE_VERSION 5 | # define XCACHE_VERSION "4.0.0-dev" 6 | #endif 7 | #define XCACHE_AUTHOR "mOo" 8 | #define XCACHE_COPYRIGHT "Copyright (c) 2005-2014" 9 | #define XCACHE_URL "http://xcache.lighttpd.net" 10 | #define XCACHE_WIKI_URL XCACHE_URL "/wiki" 11 | 12 | #include "php.h" 13 | 14 | #if defined(E_STRICT) || defined(E_DEPRECATED) 15 | #define XCACHE_ERROR_CACHING 16 | #endif 17 | 18 | #ifdef HAVE_CONFIG_H 19 | #include 20 | #endif 21 | #include "xcache/xc_shm.h" 22 | #include "xcache/xc_mutex.h" 23 | #include "xcache/xc_compatibility.h" 24 | 25 | extern zend_module_entry xcache_module_entry; 26 | #define phpext_xcache_ptr &xcache_module_entry 27 | 28 | extern zend_bool xc_test; 29 | 30 | #endif /* __XCACHE_H */ 31 | -------------------------------------------------------------------------------- /xcache.ini: -------------------------------------------------------------------------------- 1 | ;; this is an example, it won't work unless properly configured into php.ini 2 | [xcache-common] 3 | ;; non-Windows example: 4 | extension = xcache.so 5 | ;; Windows example: 6 | ; extension = php_xcache.dll 7 | 8 | [xcache.admin] 9 | xcache.admin.enable_auth = On 10 | 11 | ; use http://xcache.lighttpd.net/demo/cacher/mkpassword.php to generate your encrypted password 12 | xcache.admin.user = "mOo" 13 | xcache.admin.pass = "md5 encrypted password" 14 | 15 | [xcache] 16 | ; ini only settings, all the values here is default unless explained 17 | 18 | ; select low level shm implemenation 19 | xcache.shm_scheme = "mmap" 20 | ; to disable: xcache.size=0 21 | ; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows 22 | xcache.size = 60M 23 | ; set to cpu count (cat /proc/cpuinfo |grep -c processor) 24 | xcache.count = 1 25 | ; just a hash hints, you can always store count(items) > slots 26 | xcache.slots = 8K 27 | ; ttl of the cache item, 0=forever 28 | xcache.ttl = 0 29 | ; interval of gc scanning expired items, 0=no scan, other values is in seconds 30 | xcache.gc_interval = 0 31 | 32 | ; same as aboves but for variable cache 33 | xcache.var_size = 4M 34 | xcache.var_count = 1 35 | xcache.var_slots = 8K 36 | ; default value for $ttl parameter of xcache_*() functions 37 | xcache.var_ttl = 0 38 | ; hard limit ttl that cannot be exceed by xcache_*() functions. 0=unlimited 39 | xcache.var_maxttl = 0 40 | xcache.var_gc_interval = 300 41 | 42 | ; mode:0, const string specified by xcache.var_namespace 43 | ; mode:1, $_SERVER[xcache.var_namespace] 44 | ; mode:2, uid or gid (specified by xcache.var_namespace) 45 | xcache.var_namespace_mode = 0 46 | xcache.var_namespace = "" 47 | 48 | ; N/A for /dev/zero 49 | xcache.readonly_protection = Off 50 | ; for *nix, xcache.mmap_path is a file path, not directory. (auto create/overwrite) 51 | ; Use something like "/tmp/xcache" instead of "/dev/*" if you want to turn on ReadonlyProtection 52 | ; different process group of php won't share the same /tmp/xcache 53 | ; for win32, xcache.mmap_path=anonymous map name, not file path 54 | xcache.mmap_path = "/dev/zero" 55 | 56 | 57 | ; Useful when XCache crash. leave it blank(disabled) or "/tmp/phpcore/" (writable by php) 58 | xcache.coredump_directory = "" 59 | ; Windows only. leave it as 0 (default) until you're told by XCache dev 60 | xcache.coredump_type = 0 61 | 62 | ; disable cache after crash 63 | xcache.disable_on_crash = Off 64 | 65 | ; enable experimental documented features for each release if available 66 | xcache.experimental = Off 67 | 68 | ; per request settings. can ini_set, .htaccess etc 69 | xcache.cacher = On 70 | xcache.stat = On 71 | xcache.optimizer = Off 72 | 73 | [xcache.coverager] 74 | ; enabling this feature will impact performance 75 | ; enabled only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value" 76 | 77 | ; per request settings. can ini_set, .htaccess etc 78 | ; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions 79 | xcache.coverager = Off 80 | xcache.coverager_autostart = On 81 | 82 | ; set in php ini file only 83 | ; make sure it's readable (open_basedir is checked) by coverage viewer script 84 | xcache.coveragedump_directory = "" 85 | -------------------------------------------------------------------------------- /xcache/README: -------------------------------------------------------------------------------- 1 | understructure 2 | -------------------------------------------------------------------------------- /xcache/xc_allocator.c: -------------------------------------------------------------------------------- 1 | #ifdef TEST 2 | # ifdef HAVE_CONFIG_H 3 | # include 4 | # endif 5 | #else 6 | # include "xcache.h" 7 | #endif 8 | #include "xc_allocator.h" 9 | #include 10 | #include 11 | 12 | typedef struct { 13 | const char *name; 14 | const xc_allocator_vtable_t *allocator_vtable; 15 | } xc_allocator_info_t; 16 | static xc_allocator_info_t xc_allocator_infos[10]; 17 | 18 | int xc_allocator_register(const char *name, const xc_allocator_vtable_t *allocator_vtable) /* {{{ */ 19 | { 20 | size_t i; 21 | for (i = 0; i < sizeof(xc_allocator_infos) / sizeof(xc_allocator_infos[0]); i ++) { 22 | if (!xc_allocator_infos[i].name) { 23 | xc_allocator_infos[i].name = name; 24 | xc_allocator_infos[i].allocator_vtable = allocator_vtable; 25 | return 1; 26 | } 27 | } 28 | return 0; 29 | } 30 | /* }}} */ 31 | const xc_allocator_vtable_t *xc_allocator_find(const char *name) /* {{{ */ 32 | { 33 | size_t i; 34 | for (i = 0; i < sizeof(xc_allocator_infos) / sizeof(xc_allocator_infos[0]) && xc_allocator_infos[i].name; i ++) { 35 | if (strcmp(xc_allocator_infos[i].name, name) == 0) { 36 | return xc_allocator_infos[i].allocator_vtable; 37 | } 38 | } 39 | return NULL; 40 | } 41 | /* }}} */ 42 | void xc_allocator_init() /* {{{ */ 43 | { 44 | extern void xc_allocator_bestfit_register(); 45 | #ifdef HAVE_XCACHE_TEST 46 | extern void xc_allocator_malloc_register(); 47 | #endif 48 | 49 | memset(xc_allocator_infos, 0, sizeof(xc_allocator_infos)); 50 | xc_allocator_bestfit_register(); 51 | #ifdef HAVE_XCACHE_TEST 52 | xc_allocator_malloc_register(); 53 | #endif 54 | } 55 | /* }}} */ 56 | #ifdef TEST 57 | /* {{{ testing */ 58 | #undef CHECK 59 | #define CHECK(a, msg) do { \ 60 | if (!(a)) { \ 61 | fprintf(stderr, "%s\n", msg); return -1; \ 62 | } \ 63 | } while (0) 64 | 65 | #include 66 | 67 | int testAllocator(const xc_allocator_vtable_t *allocator_vtable) 68 | { 69 | int count = 0; 70 | void *p; 71 | xc_allocator_t *allocator; 72 | void *memory; 73 | void **ptrs; 74 | int size, i; 75 | 76 | #if 0 77 | fprintf(stderr, "%s", "Input test size: "); 78 | scanf("%d", &size); 79 | #else 80 | size = 1024; 81 | #endif 82 | CHECK(memory = malloc(size), "OOM"); 83 | CHECK(ptrs = malloc(size * sizeof(void *)), "OOM"); 84 | allocator = (xc_allocator_t *) memory; 85 | allocator->vtable = allocator_vtable; 86 | CHECK(allocator = allocator->vtable->init(NULL, allocator, size), "Failed init memory allocator"); 87 | 88 | while ((p = allocator->vtable->malloc(allocator, 1))) { 89 | ptrs[count ++] = p; 90 | } 91 | fprintf(stderr, "count=%d, random freeing\n", count); 92 | srandom(time(NULL)); 93 | while (count) { 94 | i = (random() % count); 95 | fprintf(stderr, "freeing %d: ", i); 96 | allocator->vtable->free(allocator, ptrs[i]); 97 | ptrs[i] = ptrs[count - 1]; 98 | count --; 99 | } 100 | 101 | free(ptrs); 102 | free(memory); 103 | return 0; 104 | } 105 | /* }}} */ 106 | int main() /* {{{ */ 107 | { 108 | int i; 109 | 110 | xc_allocator_init(); 111 | 112 | for (i = 0; i < sizeof(xc_allocator_infos) / sizeof(xc_allocator_infos[0]) && xc_allocator_infos[i].name; i ++) { 113 | fprintf(stderr, "testing %s...\n", xc_allocator_infos[i].name); 114 | testAllocator(xc_allocator_infos[i].allocator_vtable); 115 | } 116 | return 0; 117 | } 118 | /* }}} */ 119 | #endif 120 | -------------------------------------------------------------------------------- /xcache/xc_allocator.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_ALLOCATOR_H_155E773CA8AFC18F3CCCDCF0831EE41D 2 | #define XC_ALLOCATOR_H_155E773CA8AFC18F3CCCDCF0831EE41D 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #include "xc_shm.h" 9 | 10 | typedef struct _xc_allocator_vtable_t xc_allocator_vtable_t; 11 | 12 | #ifndef _xc_allocator_t 13 | struct _xc_allocator_t { 14 | const xc_allocator_vtable_t *vtable; 15 | xc_shm_t *shm; 16 | }; 17 | #endif 18 | 19 | typedef struct _xc_allocator_t xc_allocator_t; 20 | typedef struct _xc_allocator_block_t xc_allocator_block_t; 21 | typedef xc_shmsize_t xc_memsize_t; 22 | 23 | /* allocator */ 24 | #define XC_ALLOCATOR_MALLOC(func) void *func(xc_allocator_t *allocator, xc_memsize_t size) 25 | #define XC_ALLOCATOR_FREE(func) xc_memsize_t func(xc_allocator_t *allocator, const void *p) 26 | #define XC_ALLOCATOR_CALLOC(func) void *func(xc_allocator_t *allocator, xc_memsize_t memb, xc_memsize_t size) 27 | #define XC_ALLOCATOR_REALLOC(func) void *func(xc_allocator_t *allocator, const void *p, xc_memsize_t size) 28 | #define XC_ALLOCATOR_AVAIL(func) xc_memsize_t func(const xc_allocator_t *allocator) 29 | #define XC_ALLOCATOR_SIZE(func) xc_memsize_t func(const xc_allocator_t *allocator) 30 | #define XC_ALLOCATOR_FREEBLOCK_FIRST(func) const xc_allocator_block_t *func(const xc_allocator_t *allocator) 31 | #define XC_ALLOCATOR_FREEBLOCK_NEXT(func) const xc_allocator_block_t *func(const xc_allocator_block_t *block) 32 | #define XC_ALLOCATOR_BLOCK_SIZE(func) xc_memsize_t func(const xc_allocator_block_t *block) 33 | #define XC_ALLOCATOR_BLOCK_OFFSET(func) xc_memsize_t func(const xc_allocator_t *allocator, const xc_allocator_block_t *block) 34 | 35 | #define XC_ALLOCATOR_INIT(func) xc_allocator_t *func(xc_shm_t *shm, xc_allocator_t *allocator, xc_memsize_t size) 36 | #define XC_ALLOCATOR_DESTROY(func) void func(xc_allocator_t *allocator) 37 | 38 | #define XC_ALLOCATOR_VTABLE(name) { \ 39 | xc_##name##_malloc \ 40 | , xc_##name##_free \ 41 | , xc_##name##_calloc \ 42 | , xc_##name##_realloc \ 43 | , xc_##name##_avail \ 44 | , xc_##name##_size \ 45 | , xc_##name##_freeblock_first \ 46 | , xc_##name##_freeblock_next \ 47 | , xc_##name##_block_size \ 48 | , xc_##name##_block_offset \ 49 | \ 50 | , xc_##name##_init \ 51 | , xc_##name##_destroy \ 52 | } 53 | 54 | struct _xc_allocator_vtable_t { 55 | XC_ALLOCATOR_MALLOC((*malloc)); 56 | XC_ALLOCATOR_FREE((*free)); 57 | XC_ALLOCATOR_CALLOC((*calloc)); 58 | XC_ALLOCATOR_REALLOC((*realloc)); 59 | XC_ALLOCATOR_AVAIL((*avail)); 60 | XC_ALLOCATOR_SIZE((*size)); 61 | XC_ALLOCATOR_FREEBLOCK_FIRST((*freeblock_first)); 62 | XC_ALLOCATOR_FREEBLOCK_NEXT((*freeblock_next)); 63 | XC_ALLOCATOR_BLOCK_SIZE((*block_size)); 64 | XC_ALLOCATOR_BLOCK_OFFSET((*block_offset)); 65 | 66 | XC_ALLOCATOR_INIT((*init)); 67 | XC_ALLOCATOR_DESTROY((*destroy)); 68 | }; 69 | 70 | int xc_allocator_register(const char *name, const xc_allocator_vtable_t *allocator_vtable); 71 | const xc_allocator_vtable_t *xc_allocator_find(const char *name); 72 | 73 | #endif /* XC_ALLOCATOR_H_155E773CA8AFC18F3CCCDCF0831EE41D */ 74 | -------------------------------------------------------------------------------- /xcache/xc_compatibility.c: -------------------------------------------------------------------------------- 1 | #include "xc_compatibility.h" 2 | 3 | #ifndef ZEND_ENGINE_2_3 4 | #include "ext/standard/php_string.h" 5 | size_t xc_dirname(char *path, size_t len) /* {{{ */ 6 | { 7 | #ifdef ZEND_ENGINE_2 8 | return php_dirname(path, len); 9 | #else 10 | php_dirname(path, len); 11 | return strlen(path); 12 | #endif 13 | } 14 | /* }}} */ 15 | 16 | long xc_atol(const char *str, int str_len) /* {{{ */ 17 | { 18 | long retval; 19 | 20 | if (!str_len) { 21 | str_len = strlen(str); 22 | } 23 | 24 | retval = strtol(str, NULL, 0); 25 | if (str_len > 0) { 26 | switch (str[str_len - 1]) { 27 | case 'g': 28 | case 'G': 29 | retval *= 1024; 30 | /* break intentionally missing */ 31 | case 'm': 32 | case 'M': 33 | retval *= 1024; 34 | /* break intentionally missing */ 35 | case 'k': 36 | case 'K': 37 | retval *= 1024; 38 | break; 39 | } 40 | } 41 | 42 | return retval; 43 | } 44 | /* }}} */ 45 | #endif 46 | 47 | #if defined(ZEND_ENGINE_2) && !defined(ZEND_ENGINE_2_2) 48 | void *xc_object_store_get_object_by_handle(zend_object_handle handle TSRMLS_DC) /* {{{ */ 49 | { 50 | zval zobject; 51 | Z_OBJ_HANDLE_P(&zobject) = handle; 52 | return zend_object_store_get_object(&zobject TSRMLS_CC); 53 | } 54 | /* }}} */ 55 | void xc_objects_store_add_ref_by_handle(zend_object_handle handle TSRMLS_DC) /* {{{ */ 56 | { 57 | zval zobject; 58 | Z_OBJ_HANDLE_P(&zobject) = handle; 59 | zend_objects_store_add_ref(&zobject TSRMLS_CC); 60 | } 61 | /* }}} */ 62 | void xc_objects_store_del_ref_by_handle(zend_object_handle handle TSRMLS_DC) /* {{{ */ 63 | { 64 | zval zobject; 65 | Z_OBJ_HANDLE_P(&zobject) = handle; 66 | zobject.refcount = 0; 67 | zend_objects_store_del_ref(&zobject TSRMLS_CC); 68 | } 69 | /* }}} */ 70 | #endif 71 | -------------------------------------------------------------------------------- /xcache/xc_const_string.c: -------------------------------------------------------------------------------- 1 | #include "xcache.h" 2 | #include "xc_const_string.h" 3 | 4 | /* {{{ xc_get_op_type */ 5 | static const char *const op_type_names[] = { 6 | /* 0 */ "NULL?", 7 | /* 1 */ "IS_CONST", 8 | /* 2 */ "IS_TMP_VAR", 9 | /* 3 */ NULL, 10 | /* 4 */ "IS_VAR", 11 | /* 5 */ NULL, 12 | /* 6 */ NULL, 13 | /* 7 */ NULL, 14 | /* 8 */ "IS_UNUSED", 15 | #ifdef IS_CV 16 | /* 9 */ NULL, 17 | /* 10 */ NULL, 18 | /* 11 */ NULL, 19 | /* 12 */ NULL, 20 | /* 13 */ NULL, 21 | /* 14 */ NULL, 22 | /* 15 */ NULL, 23 | /* 16 */ "IS_CV" 24 | #endif 25 | }; 26 | 27 | zend_uchar xc_get_op_type_count() 28 | { 29 | return sizeof(op_type_names) / sizeof(op_type_names[0]); 30 | } 31 | 32 | const char *xc_get_op_type(zend_uchar op_type) 33 | { 34 | assert(op_type < xc_get_op_type_count()); 35 | return op_type_names[op_type]; 36 | } 37 | /* }}} */ 38 | /* {{{ xc_get_data_type */ 39 | static const char *const data_type_names[] = { 40 | /* 0 */ "IS_NULL", 41 | /* 1 */ "IS_LONG", 42 | /* 2 */ "IS_DOUBLE", 43 | #ifdef ZEND_ENGINE_2_1 44 | /* 3 */ "IS_BOOL", 45 | #else 46 | /* 6 */ "IS_STRING", 47 | #endif 48 | /* 4 */ "IS_ARRAY", 49 | /* 5 */ "IS_OBJECT", 50 | #ifdef ZEND_ENGINE_2_1 51 | /* 6 */ "IS_STRING", 52 | #else 53 | /* 3 */ "IS_BOOL", 54 | #endif 55 | /* 7 */ "IS_RESOURCE", 56 | /* 8 */ "IS_CONSTANT", 57 | /* 9 */ "IS_CONSTANT_ARRAY", 58 | /* 10 */ "IS_UNICODE" 59 | }; 60 | 61 | zend_uchar xc_get_data_type_count() 62 | { 63 | return sizeof(data_type_names) / sizeof(data_type_names[0]); 64 | } 65 | 66 | const char *xc_get_data_type(zend_uchar data_type) 67 | { 68 | return data_type_names[(data_type & IS_CONSTANT_TYPE_MASK)]; 69 | } 70 | /* }}} */ 71 | /* {{{ xc_get_opcode */ 72 | #if PHP_MAJOR_VERSION >= 6 73 | # include "xc_const_string_opcodes_php6.x.h" 74 | #elif defined(ZEND_ENGINE_2_6) 75 | # include "xc_const_string_opcodes_php5.6.h" 76 | #elif defined(ZEND_ENGINE_2_5) 77 | # include "xc_const_string_opcodes_php5.5.h" 78 | #elif defined(ZEND_ENGINE_2_4) 79 | # include "xc_const_string_opcodes_php5.4.h" 80 | #elif defined(ZEND_ENGINE_2_3) 81 | # include "xc_const_string_opcodes_php5.3.h" 82 | #elif defined(ZEND_ENGINE_2_2) 83 | # include "xc_const_string_opcodes_php5.2.h" 84 | #elif defined(ZEND_ENGINE_2_1) 85 | # include "xc_const_string_opcodes_php5.1.h" 86 | #elif defined(ZEND_ENGINE_2) 87 | # include "xc_const_string_opcodes_php5.0.h" 88 | #else 89 | # include "xc_const_string_opcodes_php4.x.h" 90 | #endif 91 | 92 | zend_uchar xc_get_opcode_count() 93 | { 94 | return sizeof(xc_opcode_names) / sizeof(xc_opcode_names[0]); 95 | } 96 | 97 | const char *xc_get_opcode(zend_uchar opcode) 98 | { 99 | assert(opcode < xc_get_opcode_count()); 100 | return xc_opcode_names[opcode]; 101 | } 102 | /* }}} */ 103 | -------------------------------------------------------------------------------- /xcache/xc_const_string.h: -------------------------------------------------------------------------------- 1 | #include "php.h" 2 | 3 | zend_uchar xc_get_op_type_count(); 4 | const char *xc_get_op_type(zend_uchar op_type); 5 | zend_uchar xc_get_data_type_count(); 6 | const char *xc_get_data_type(zend_uchar data_type); 7 | zend_uchar xc_get_opcode_count(); 8 | const char *xc_get_opcode(zend_uchar opcode); 9 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php4.x.h: -------------------------------------------------------------------------------- 1 | /* size = 113 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "JMP_NO_CTOR", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM_OBJ", 79 | /* 76 */ "ISSET_ISEMPTY", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "DECLARE_FUNCTION_OR_CLASS", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "UNDEF", 111 | /* 108 */ "UNDEF", 112 | /* 109 */ "UNDEF", 113 | /* 110 */ "DO_FCALL_BY_FUNC", 114 | /* 111 */ "INIT_FCALL_BY_FUNC", 115 | /* 112 */ "UNDEF" 116 | }; 117 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php5.0.h: -------------------------------------------------------------------------------- 1 | /* size = 150 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "JMP_NO_CTOR", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM_OBJ", 79 | /* 76 */ "UNDEF", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "UNDEF", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "INIT_CTOR_CALL", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "UNDEF", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "UNDEF", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION" 153 | }; 154 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php5.1.h: -------------------------------------------------------------------------------- 1 | /* size = 151 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "UNDEF", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM", 79 | /* 76 */ "UNSET_OBJ", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "UNDEF", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "UNDEF", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "UNDEF", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "UNDEF", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION", 153 | /* 150 */ "USER_OPCODE" 154 | }; 155 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php5.2.h: -------------------------------------------------------------------------------- 1 | /* size = 151 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "UNDEF", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM", 79 | /* 76 */ "UNSET_OBJ", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "UNDEF", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "UNDEF", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "UNDEF", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "UNDEF", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION", 153 | /* 150 */ "USER_OPCODE" 154 | }; 155 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php5.3.h: -------------------------------------------------------------------------------- 1 | /* size = 154 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "INIT_NS_FCALL_BY_NAME", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM", 79 | /* 76 */ "UNSET_OBJ", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "GOTO", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "UNDEF", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "DECLARE_CONST", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "DECLARE_INHERITED_CLASS_DELAYED", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION", 153 | /* 150 */ "USER_OPCODE", 154 | /* 151 */ "UNDEF", 155 | /* 152 */ "JMP_SET", 156 | /* 153 */ "DECLARE_LAMBDA_FUNCTION" 157 | }; 158 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php5.4.h: -------------------------------------------------------------------------------- 1 | /* size = 159 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "INIT_NS_FCALL_BY_NAME", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM", 79 | /* 76 */ "UNSET_OBJ", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "GOTO", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "RETURN_BY_REF", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "DECLARE_CONST", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "DECLARE_INHERITED_CLASS_DELAYED", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION", 153 | /* 150 */ "USER_OPCODE", 154 | /* 151 */ "UNDEF", 155 | /* 152 */ "JMP_SET", 156 | /* 153 */ "DECLARE_LAMBDA_FUNCTION", 157 | /* 154 */ "ADD_TRAIT", 158 | /* 155 */ "BIND_TRAITS", 159 | /* 156 */ "SEPARATE", 160 | /* 157 */ "QM_ASSIGN_VAR", 161 | /* 158 */ "JMP_SET_VAR" 162 | }; 163 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php5.5.h: -------------------------------------------------------------------------------- 1 | /* size = 164 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "INIT_NS_FCALL_BY_NAME", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM", 79 | /* 76 */ "UNSET_OBJ", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "GOTO", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "RETURN_BY_REF", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "DECLARE_CONST", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "DECLARE_INHERITED_CLASS_DELAYED", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION", 153 | /* 150 */ "USER_OPCODE", 154 | /* 151 */ "UNDEF", 155 | /* 152 */ "JMP_SET", 156 | /* 153 */ "DECLARE_LAMBDA_FUNCTION", 157 | /* 154 */ "ADD_TRAIT", 158 | /* 155 */ "BIND_TRAITS", 159 | /* 156 */ "SEPARATE", 160 | /* 157 */ "QM_ASSIGN_VAR", 161 | /* 158 */ "JMP_SET_VAR", 162 | /* 159 */ "DISCARD_EXCEPTION", 163 | /* 160 */ "YIELD", 164 | /* 161 */ "GENERATOR_RETURN", 165 | /* 162 */ "FAST_CALL", 166 | /* 163 */ "FAST_RET" 167 | }; 168 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php5.6.h: -------------------------------------------------------------------------------- 1 | /* size = 168 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "INIT_NS_FCALL_BY_NAME", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM", 79 | /* 76 */ "UNSET_OBJ", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "GOTO", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "RETURN_BY_REF", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "DECLARE_CONST", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "DECLARE_INHERITED_CLASS_DELAYED", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION", 153 | /* 150 */ "USER_OPCODE", 154 | /* 151 */ "UNDEF", 155 | /* 152 */ "JMP_SET", 156 | /* 153 */ "DECLARE_LAMBDA_FUNCTION", 157 | /* 154 */ "ADD_TRAIT", 158 | /* 155 */ "BIND_TRAITS", 159 | /* 156 */ "SEPARATE", 160 | /* 157 */ "QM_ASSIGN_VAR", 161 | /* 158 */ "JMP_SET_VAR", 162 | /* 159 */ "DISCARD_EXCEPTION", 163 | /* 160 */ "YIELD", 164 | /* 161 */ "GENERATOR_RETURN", 165 | /* 162 */ "FAST_CALL", 166 | /* 163 */ "FAST_RET", 167 | /* 164 */ "RECV_VARIADIC", 168 | /* 165 */ "SEND_UNPACK", 169 | /* 166 */ "POW", 170 | /* 167 */ "ASSIGN_POW" 171 | }; 172 | -------------------------------------------------------------------------------- /xcache/xc_const_string_opcodes_php6.x.h: -------------------------------------------------------------------------------- 1 | /* size = 159 */ 2 | static const char *const xc_opcode_names[] = { 3 | /* 0 */ "NOP", 4 | /* 1 */ "ADD", 5 | /* 2 */ "SUB", 6 | /* 3 */ "MUL", 7 | /* 4 */ "DIV", 8 | /* 5 */ "MOD", 9 | /* 6 */ "SL", 10 | /* 7 */ "SR", 11 | /* 8 */ "CONCAT", 12 | /* 9 */ "BW_OR", 13 | /* 10 */ "BW_AND", 14 | /* 11 */ "BW_XOR", 15 | /* 12 */ "BW_NOT", 16 | /* 13 */ "BOOL_NOT", 17 | /* 14 */ "BOOL_XOR", 18 | /* 15 */ "IS_IDENTICAL", 19 | /* 16 */ "IS_NOT_IDENTICAL", 20 | /* 17 */ "IS_EQUAL", 21 | /* 18 */ "IS_NOT_EQUAL", 22 | /* 19 */ "IS_SMALLER", 23 | /* 20 */ "IS_SMALLER_OR_EQUAL", 24 | /* 21 */ "CAST", 25 | /* 22 */ "QM_ASSIGN", 26 | /* 23 */ "ASSIGN_ADD", 27 | /* 24 */ "ASSIGN_SUB", 28 | /* 25 */ "ASSIGN_MUL", 29 | /* 26 */ "ASSIGN_DIV", 30 | /* 27 */ "ASSIGN_MOD", 31 | /* 28 */ "ASSIGN_SL", 32 | /* 29 */ "ASSIGN_SR", 33 | /* 30 */ "ASSIGN_CONCAT", 34 | /* 31 */ "ASSIGN_BW_OR", 35 | /* 32 */ "ASSIGN_BW_AND", 36 | /* 33 */ "ASSIGN_BW_XOR", 37 | /* 34 */ "PRE_INC", 38 | /* 35 */ "PRE_DEC", 39 | /* 36 */ "POST_INC", 40 | /* 37 */ "POST_DEC", 41 | /* 38 */ "ASSIGN", 42 | /* 39 */ "ASSIGN_REF", 43 | /* 40 */ "ECHO", 44 | /* 41 */ "PRINT", 45 | /* 42 */ "JMP", 46 | /* 43 */ "JMPZ", 47 | /* 44 */ "JMPNZ", 48 | /* 45 */ "JMPZNZ", 49 | /* 46 */ "JMPZ_EX", 50 | /* 47 */ "JMPNZ_EX", 51 | /* 48 */ "CASE", 52 | /* 49 */ "SWITCH_FREE", 53 | /* 50 */ "BRK", 54 | /* 51 */ "CONT", 55 | /* 52 */ "BOOL", 56 | /* 53 */ "INIT_STRING", 57 | /* 54 */ "ADD_CHAR", 58 | /* 55 */ "ADD_STRING", 59 | /* 56 */ "ADD_VAR", 60 | /* 57 */ "BEGIN_SILENCE", 61 | /* 58 */ "END_SILENCE", 62 | /* 59 */ "INIT_FCALL_BY_NAME", 63 | /* 60 */ "DO_FCALL", 64 | /* 61 */ "DO_FCALL_BY_NAME", 65 | /* 62 */ "RETURN", 66 | /* 63 */ "RECV", 67 | /* 64 */ "RECV_INIT", 68 | /* 65 */ "SEND_VAL", 69 | /* 66 */ "SEND_VAR", 70 | /* 67 */ "SEND_REF", 71 | /* 68 */ "NEW", 72 | /* 69 */ "INIT_NS_FCALL_BY_NAME", 73 | /* 70 */ "FREE", 74 | /* 71 */ "INIT_ARRAY", 75 | /* 72 */ "ADD_ARRAY_ELEMENT", 76 | /* 73 */ "INCLUDE_OR_EVAL", 77 | /* 74 */ "UNSET_VAR", 78 | /* 75 */ "UNSET_DIM", 79 | /* 76 */ "UNSET_OBJ", 80 | /* 77 */ "FE_RESET", 81 | /* 78 */ "FE_FETCH", 82 | /* 79 */ "EXIT", 83 | /* 80 */ "FETCH_R", 84 | /* 81 */ "FETCH_DIM_R", 85 | /* 82 */ "FETCH_OBJ_R", 86 | /* 83 */ "FETCH_W", 87 | /* 84 */ "FETCH_DIM_W", 88 | /* 85 */ "FETCH_OBJ_W", 89 | /* 86 */ "FETCH_RW", 90 | /* 87 */ "FETCH_DIM_RW", 91 | /* 88 */ "FETCH_OBJ_RW", 92 | /* 89 */ "FETCH_IS", 93 | /* 90 */ "FETCH_DIM_IS", 94 | /* 91 */ "FETCH_OBJ_IS", 95 | /* 92 */ "FETCH_FUNC_ARG", 96 | /* 93 */ "FETCH_DIM_FUNC_ARG", 97 | /* 94 */ "FETCH_OBJ_FUNC_ARG", 98 | /* 95 */ "FETCH_UNSET", 99 | /* 96 */ "FETCH_DIM_UNSET", 100 | /* 97 */ "FETCH_OBJ_UNSET", 101 | /* 98 */ "FETCH_DIM_TMP_VAR", 102 | /* 99 */ "FETCH_CONSTANT", 103 | /* 100 */ "GOTO", 104 | /* 101 */ "EXT_STMT", 105 | /* 102 */ "EXT_FCALL_BEGIN", 106 | /* 103 */ "EXT_FCALL_END", 107 | /* 104 */ "EXT_NOP", 108 | /* 105 */ "TICKS", 109 | /* 106 */ "SEND_VAR_NO_REF", 110 | /* 107 */ "CATCH", 111 | /* 108 */ "THROW", 112 | /* 109 */ "FETCH_CLASS", 113 | /* 110 */ "CLONE", 114 | /* 111 */ "RETURN_BY_REF", 115 | /* 112 */ "INIT_METHOD_CALL", 116 | /* 113 */ "INIT_STATIC_METHOD_CALL", 117 | /* 114 */ "ISSET_ISEMPTY_VAR", 118 | /* 115 */ "ISSET_ISEMPTY_DIM_OBJ", 119 | /* 116 */ "UNDEF", 120 | /* 117 */ "UNDEF", 121 | /* 118 */ "UNDEF", 122 | /* 119 */ "UNDEF", 123 | /* 120 */ "UNDEF", 124 | /* 121 */ "UNDEF", 125 | /* 122 */ "UNDEF", 126 | /* 123 */ "UNDEF", 127 | /* 124 */ "UNDEF", 128 | /* 125 */ "UNDEF", 129 | /* 126 */ "UNDEF", 130 | /* 127 */ "UNDEF", 131 | /* 128 */ "UNDEF", 132 | /* 129 */ "UNDEF", 133 | /* 130 */ "UNDEF", 134 | /* 131 */ "UNDEF", 135 | /* 132 */ "PRE_INC_OBJ", 136 | /* 133 */ "PRE_DEC_OBJ", 137 | /* 134 */ "POST_INC_OBJ", 138 | /* 135 */ "POST_DEC_OBJ", 139 | /* 136 */ "ASSIGN_OBJ", 140 | /* 137 */ "OP_DATA", 141 | /* 138 */ "INSTANCEOF", 142 | /* 139 */ "DECLARE_CLASS", 143 | /* 140 */ "DECLARE_INHERITED_CLASS", 144 | /* 141 */ "DECLARE_FUNCTION", 145 | /* 142 */ "RAISE_ABSTRACT_ERROR", 146 | /* 143 */ "DECLARE_CONST", 147 | /* 144 */ "ADD_INTERFACE", 148 | /* 145 */ "DECLARE_INHERITED_CLASS_DELAYED", 149 | /* 146 */ "VERIFY_ABSTRACT_CLASS", 150 | /* 147 */ "ASSIGN_DIM", 151 | /* 148 */ "ISSET_ISEMPTY_PROP_OBJ", 152 | /* 149 */ "HANDLE_EXCEPTION", 153 | /* 150 */ "USER_OPCODE", 154 | /* 151 */ "UNDEF", 155 | /* 152 */ "JMP_SET", 156 | /* 153 */ "DECLARE_LAMBDA_FUNCTION", 157 | /* 154 */ "ADD_TRAIT", 158 | /* 155 */ "BIND_TRAITS", 159 | /* 156 */ "SEPARATE", 160 | /* 157 */ "QM_ASSIGN_VAR", 161 | /* 158 */ "JMP_SET_VAR" 162 | }; 163 | -------------------------------------------------------------------------------- /xcache/xc_extension.c: -------------------------------------------------------------------------------- 1 | 2 | #include "xc_extension.h" 3 | #include "xcache.h" 4 | #include "util/xc_trace.h" 5 | 6 | 7 | int xcache_zend_extension_add(zend_extension *new_extension, zend_bool prepend) /* {{{ */ 8 | { 9 | zend_extension extension; 10 | 11 | extension = *new_extension; 12 | extension.handle = 0; 13 | 14 | zend_extension_dispatch_message(ZEND_EXTMSG_NEW_EXTENSION, &extension); 15 | 16 | if (prepend) { 17 | zend_llist_prepend_element(&zend_extensions, &extension); 18 | } 19 | else { 20 | zend_llist_add_element(&zend_extensions, &extension); 21 | } 22 | TRACE("%s", "registered"); 23 | return SUCCESS; 24 | } 25 | /* }}} */ 26 | static int xc_ptr_compare_func(void *p1, void *p2) /* {{{ */ 27 | { 28 | return p1 == p2; 29 | } 30 | /* }}} */ 31 | static int xc_zend_extension_remove(zend_extension *extension) /* {{{ */ 32 | { 33 | llist_dtor_func_t dtor; 34 | 35 | assert(extension); 36 | dtor = zend_extensions.dtor; /* avoid dtor */ 37 | zend_extensions.dtor = NULL; 38 | zend_llist_del_element(&zend_extensions, extension, xc_ptr_compare_func); 39 | zend_extensions.dtor = dtor; 40 | return SUCCESS; 41 | } 42 | /* }}} */ 43 | int xcache_zend_extension_remove(zend_extension *extension) /* {{{ */ 44 | { 45 | zend_extension *ext = zend_get_extension(extension->name); 46 | if (!ext) { 47 | return FAILURE; 48 | } 49 | 50 | if (ext->shutdown) { 51 | ext->shutdown(ext); 52 | } 53 | xc_zend_extension_remove(ext); 54 | return SUCCESS; 55 | } 56 | /* }}} */ 57 | 58 | void xcache_llist_prepend(zend_llist *l, zend_llist_element *element) /* {{{ */ 59 | { 60 | element->next = l->head; 61 | element->prev = NULL; 62 | if (l->head) { 63 | l->head->prev = element; 64 | } 65 | else { 66 | l->tail = element; 67 | } 68 | l->head = element; 69 | ++l->count; 70 | } 71 | /* }}} */ 72 | void xcache_llist_unlink(zend_llist *l, zend_llist_element *element) /* {{{ */ 73 | { 74 | if ((element)->prev) { 75 | (element)->prev->next = (element)->next; 76 | } 77 | else { 78 | (l)->head = (element)->next; 79 | } 80 | 81 | if ((element)->next) { 82 | (element)->next->prev = (element)->prev; 83 | } 84 | else { 85 | (l)->tail = (element)->prev; 86 | } 87 | 88 | --l->count; 89 | } 90 | /* }}} */ 91 | -------------------------------------------------------------------------------- /xcache/xc_extension.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_EXTENSION_H_9885D3A6DE7C469D13E34AF331E02BB8 2 | #define XC_EXTENSION_H_9885D3A6DE7C469D13E34AF331E02BB8 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #include "zend_extensions.h" 9 | int xcache_zend_extension_add(zend_extension *new_extension, zend_bool prepend); 10 | int xcache_zend_extension_remove(zend_extension *extension); 11 | 12 | void xcache_llist_prepend(zend_llist *l, zend_llist_element *element); 13 | void xcache_llist_unlink(zend_llist *l, zend_llist_element *element); 14 | 15 | #endif /* XC_EXTENSION_H_9885D3A6DE7C469D13E34AF331E02BB8 */ 16 | -------------------------------------------------------------------------------- /xcache/xc_ini.c: -------------------------------------------------------------------------------- 1 | #include "xc_ini.h" 2 | 3 | PHP_INI_MH(xcache_OnUpdateDummy) 4 | { 5 | return SUCCESS; 6 | } 7 | 8 | PHP_INI_MH(xcache_OnUpdateULong) 9 | { 10 | zend_ulong *p = (zend_ulong *) mh_arg1; 11 | 12 | *p = (zend_ulong) atoi(new_value); 13 | return SUCCESS; 14 | } 15 | 16 | PHP_INI_MH(xcache_OnUpdateBool) 17 | { 18 | zend_bool *p = (zend_bool *)mh_arg1; 19 | 20 | if (strncasecmp("on", new_value, sizeof("on"))) { 21 | *p = (zend_bool) atoi(new_value); 22 | } 23 | else { 24 | *p = (zend_bool) 1; 25 | } 26 | return SUCCESS; 27 | } 28 | 29 | PHP_INI_MH(xcache_OnUpdateString) 30 | { 31 | char **p = (char**)mh_arg1; 32 | if (*p) { 33 | pefree(*p, 1); 34 | } 35 | *p = pemalloc(strlen(new_value) + 1, 1); 36 | strcpy(*p, new_value); 37 | return SUCCESS; 38 | } 39 | -------------------------------------------------------------------------------- /xcache/xc_ini.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_INI_H_E208B8E597E7FAD950D249BE9C6B6F53 2 | #define XC_INI_H_E208B8E597E7FAD950D249BE9C6B6F53 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #include "php.h" 9 | #include "php_ini.h" 10 | 11 | PHP_INI_MH(xcache_OnUpdateDummy); 12 | PHP_INI_MH(xcache_OnUpdateULong); 13 | PHP_INI_MH(xcache_OnUpdateBool); 14 | PHP_INI_MH(xcache_OnUpdateString); 15 | #ifndef ZEND_ENGINE_2 16 | #define OnUpdateLong OnUpdateInt 17 | #endif 18 | 19 | #endif /* XC_INI_H_E208B8E597E7FAD950D249BE9C6B6F53 */ 20 | -------------------------------------------------------------------------------- /xcache/xc_mutex.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_MUTEX_H_1913F3DED68715D7CDA5A055E79FE0FF 2 | #define XC_MUTEX_H_1913F3DED68715D7CDA5A055E79FE0FF 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | #include 9 | 10 | typedef struct _xc_mutex_t xc_mutex_t; 11 | 12 | size_t xc_mutex_size(void); 13 | xc_mutex_t *xc_mutex_init(xc_mutex_t *shared_mutex, const char *pathname, unsigned char want_inter_process); 14 | void xc_mutex_destroy(xc_mutex_t *mutex); 15 | void xc_mutex_lock(xc_mutex_t *mutex); 16 | void xc_mutex_unlock(xc_mutex_t *mutex); 17 | 18 | #endif /* XC_MUTEX_H_1913F3DED68715D7CDA5A055E79FE0FF */ 19 | -------------------------------------------------------------------------------- /xcache/xc_opcode_spec.c: -------------------------------------------------------------------------------- 1 | #include "xcache.h" 2 | #include "xc_opcode_spec.h" 3 | #include "xc_const_string.h" 4 | 5 | /* {{{ opcode_spec */ 6 | #define OPSPEC(ext, op1, op2, res) { OPSPEC_##ext, OPSPEC_##op1, OPSPEC_##op2, OPSPEC_##res }, 7 | #ifdef ZEND_ENGINE_2 8 | # define OPSPEC_VAR_2 OPSPEC_STD 9 | #else 10 | # define OPSPEC_VAR_2 OPSPEC_VAR 11 | #endif 12 | #ifdef ZEND_ENGINE_2_4 13 | #undef OPSPEC_FETCH 14 | #define OPSPEC_FETCH OPSPEC_STD 15 | #endif 16 | #include "xc_opcode_spec_def.h" 17 | 18 | zend_uchar xc_get_opcode_spec_count() 19 | { 20 | return sizeof(xc_opcode_spec) / sizeof(xc_opcode_spec[0]); 21 | } 22 | 23 | const xc_opcode_spec_t *xc_get_opcode_spec(zend_uchar opcode) 24 | { 25 | #ifndef NDEBUG 26 | if (xc_get_opcode_count() != xc_get_opcode_spec_count()) { 27 | fprintf(stderr, "count mismatch: xc_get_opcode_count=%d, xc_get_opcode_spec_count=%d\n", xc_get_opcode_count(), xc_get_opcode_spec_count()); 28 | } 29 | #endif 30 | assert(xc_get_opcode_count() == xc_get_opcode_spec_count()); 31 | assert(opcode < xc_get_opcode_spec_count()); 32 | return &xc_opcode_spec[opcode]; 33 | } 34 | /* }}} */ 35 | /* {{{ op_spec */ 36 | 37 | #define OPSPECS_DEF_NAME(name) #name, 38 | static const char *xc_op_spec[] = { OPSPECS(OPSPECS_DEF_NAME) }; 39 | 40 | zend_uchar xc_get_op_spec_count() 41 | { 42 | return sizeof(xc_op_spec) / sizeof(xc_op_spec[0]); 43 | } 44 | 45 | const char *xc_get_op_spec(zend_uchar spec) 46 | { 47 | assert(spec < xc_get_op_spec_count()); 48 | return xc_op_spec[spec]; 49 | } 50 | /* }}} */ 51 | -------------------------------------------------------------------------------- /xcache/xc_opcode_spec.h: -------------------------------------------------------------------------------- 1 | #include "php.h" 2 | 3 | #define OPSPECS(OPSPEC) \ 4 | OPSPEC(STD) \ 5 | OPSPEC(UNUSED) \ 6 | OPSPEC(OPLINE) \ 7 | OPSPEC(FCALL) \ 8 | OPSPEC(INIT_FCALL) \ 9 | OPSPEC(ARG) \ 10 | OPSPEC(CAST) \ 11 | OPSPEC(FETCH) \ 12 | OPSPEC(DECLARE) \ 13 | OPSPEC(SEND) \ 14 | OPSPEC(SEND_NOREF) \ 15 | OPSPEC(FCLASS) \ 16 | OPSPEC(UCLASS) \ 17 | OPSPEC(CLASS) \ 18 | OPSPEC(FE) \ 19 | OPSPEC(IFACE) \ 20 | OPSPEC(ISSET) \ 21 | OPSPEC(BIT) \ 22 | OPSPEC(VAR) \ 23 | OPSPEC(TMP) \ 24 | OPSPEC(JMPADDR) \ 25 | OPSPEC(BRK) \ 26 | OPSPEC(CONT) \ 27 | OPSPEC(INCLUDE) \ 28 | OPSPEC(ASSIGN) \ 29 | OPSPEC(FETCHTYPE) 30 | 31 | #define OPSPECS_DEF_ENUM(name) OPSPEC_##name, 32 | typedef enum { OPSPECS(OPSPECS_DEF_ENUM) OPSPEC_DUMMY } xc_op_spec_t; 33 | 34 | typedef struct { 35 | xc_op_spec_t ext; 36 | xc_op_spec_t op1; 37 | xc_op_spec_t op2; 38 | xc_op_spec_t res; 39 | } xc_opcode_spec_t; 40 | 41 | const xc_opcode_spec_t *xc_get_opcode_spec(zend_uchar opcode); 42 | zend_uchar xc_get_opcode_spec_count(); 43 | zend_uchar xc_get_op_spec_count(); 44 | const char *xc_get_op_spec(zend_uchar spec); 45 | -------------------------------------------------------------------------------- /xcache/xc_processor.c: -------------------------------------------------------------------------------- 1 | #include "xc_processor.c.h" 2 | -------------------------------------------------------------------------------- /xcache/xc_sandbox.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_SANDBOX_H_3AFE4094B1D005188B909F9B6538599C 2 | #define XC_SANDBOX_H_3AFE4094B1D005188B909F9B6538599C 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif /* _MSC_VER > 1000 */ 7 | 8 | /* Purpose: run specified function in compiler sandbox, restore everything to previous state after it returns 9 | */ 10 | 11 | #include "xc_compatibility.h" 12 | 13 | int xc_sandbox_module_init(int module_number TSRMLS_DC); 14 | void xc_sandbox_module_shutdown(); 15 | 16 | /* return op_array to install */ 17 | typedef zend_op_array *(*xc_sandboxed_func_t)(void *data TSRMLS_DC); 18 | zend_op_array *xc_sandbox(xc_sandboxed_func_t sandboxed_func, void *data, ZEND_24(NOTHING, const) char *filename TSRMLS_DC); 19 | const Bucket *xc_sandbox_user_function_begin(TSRMLS_D); 20 | const Bucket *xc_sandbox_user_class_begin(TSRMLS_D); 21 | zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D); 22 | #ifdef XCACHE_ERROR_CACHING 23 | struct _xc_compilererror_t; 24 | struct _xc_compilererror_t *xc_sandbox_compilererrors(TSRMLS_D); 25 | zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D); 26 | #endif 27 | 28 | #endif /* XC_SANDBOX_H_3AFE4094B1D005188B909F9B6538599C */ 29 | -------------------------------------------------------------------------------- /xcache/xc_shm.c: -------------------------------------------------------------------------------- 1 | #ifdef TEST 2 | # ifdef HAVE_CONFIG_H 3 | # include 4 | # endif 5 | # include 6 | # include 7 | #else 8 | # include "xcache.h" 9 | #endif 10 | #include "xc_shm.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | struct _xc_shm_scheme_t { 17 | const char *name; 18 | const xc_shm_vtable_t *vtable; 19 | }; 20 | static xc_shm_scheme_t xc_shm_schemes[10]; 21 | 22 | void xc_shm_init_modules() /* {{{ */ 23 | { 24 | extern void xc_allocator_init(); 25 | #ifdef HAVE_XCACHE_TEST 26 | extern void xc_shm_malloc_register(); 27 | #endif 28 | extern void xc_shm_mmap_register(); 29 | 30 | memset(xc_shm_schemes, 0, sizeof(xc_shm_schemes)); 31 | xc_allocator_init(); 32 | #ifdef HAVE_XCACHE_TEST 33 | xc_shm_malloc_register(); 34 | #endif 35 | xc_shm_mmap_register(); 36 | } 37 | /* }}} */ 38 | int xc_shm_scheme_register(const char *name, const xc_shm_vtable_t *vtable) /* {{{ */ 39 | { 40 | int i; 41 | for (i = 0; i < 10; i ++) { 42 | if (!xc_shm_schemes[i].name) { 43 | xc_shm_schemes[i].name = name; 44 | xc_shm_schemes[i].vtable = vtable; 45 | return 1; 46 | } 47 | } 48 | return 0; 49 | } 50 | /* }}} */ 51 | const xc_shm_vtable_t *xc_shm_scheme_find(const char *name) /* {{{ */ 52 | { 53 | int i; 54 | for (i = 0; i < 10 && xc_shm_schemes[i].name; i ++) { 55 | if (strcmp(xc_shm_schemes[i].name, name) == 0) { 56 | return xc_shm_schemes[i].vtable; 57 | } 58 | } 59 | return NULL; 60 | } 61 | /* }}} */ 62 | xc_shm_scheme_t *xc_shm_scheme_first() /* {{{ */ 63 | { 64 | return xc_shm_schemes; 65 | } 66 | /* }}} */ 67 | xc_shm_scheme_t *xc_shm_scheme_next(xc_shm_scheme_t *scheme) /* {{{ */ 68 | { 69 | scheme ++; 70 | return scheme->name ? scheme : NULL; 71 | } 72 | /* }}} */ 73 | const char *xc_shm_scheme_name(xc_shm_scheme_t *scheme) /* {{{ */ 74 | { 75 | assert(scheme); 76 | return scheme->name; 77 | } 78 | /* }}} */ 79 | xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2) /* {{{ */ 80 | { 81 | const xc_shm_vtable_t *vtable = xc_shm_scheme_find(type); 82 | 83 | if (vtable) { 84 | xc_shm_t *shm = vtable->init(size, readonly_protection, arg1, arg2); 85 | if (shm) { 86 | shm->vtable = vtable; 87 | } 88 | return shm; 89 | } 90 | 91 | return NULL; 92 | } 93 | /* }}} */ 94 | void xc_shm_destroy(xc_shm_t *shm) /* {{{ */ 95 | { 96 | shm->vtable->destroy(shm); 97 | } 98 | /* }}} */ 99 | 100 | int xc_shm_can_readonly(const xc_shm_t *shm) /* {{{ */ 101 | { 102 | return ((xc_shm_base_t *)shm)->readonlydiff != 0; 103 | } 104 | /* }}} */ 105 | void *xc_shm_to_readwrite(const xc_shm_t *shm_, void *p) /* {{{ */ 106 | { 107 | const xc_shm_base_t *shm = (const xc_shm_base_t *) shm_; 108 | 109 | if (shm->readonlydiff) { 110 | assert(shm->vtable->is_readonly(shm_, p)); 111 | p = ((char *) p) - shm->readonlydiff; 112 | } 113 | assert(shm->vtable->is_readwrite(shm_, p)); 114 | return p; 115 | } 116 | /* }}} */ 117 | void *xc_shm_to_readonly(const xc_shm_t *shm_, void *p) /* {{{ */ 118 | { 119 | const xc_shm_base_t *shm = (const xc_shm_base_t *) shm_; 120 | 121 | assert(shm->vtable->is_readwrite(shm_, p)); 122 | if (shm->readonlydiff) { 123 | p = ((char *) p) + shm->readonlydiff; 124 | assert(shm->vtable->is_readonly(shm_, p)); 125 | } 126 | return p; 127 | } 128 | /* }}} */ 129 | -------------------------------------------------------------------------------- /xcache/xc_shm.h: -------------------------------------------------------------------------------- 1 | #ifndef XC_SHM_H 2 | #define XC_SHM_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef XC_SHM_T_DEFINED 9 | typedef struct _xc_shm_base_t xc_shm_t; 10 | #define XC_SHM_T_DEFINED 11 | #endif 12 | 13 | typedef struct _xc_shm_vtable_t xc_shm_vtable_t; 14 | 15 | typedef struct _xc_shm_base_t { 16 | const xc_shm_vtable_t *vtable; 17 | ptrdiff_t readonlydiff; 18 | } xc_shm_base_t; 19 | 20 | typedef size_t xc_shmsize_t; 21 | 22 | /* shm */ 23 | #define XC_SHM_IS_READWRITE(func) int func(const xc_shm_t *shm, const void *p) 24 | #define XC_SHM_IS_READONLY(func) int func(const xc_shm_t *shm, const void *p) 25 | 26 | #define XC_SHM_INIT(func) xc_shm_t *func(xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2) 27 | #define XC_SHM_DESTROY(func) void func(xc_shm_t *shm) 28 | 29 | #define XC_SHM_MEMINIT(func) void *func(xc_shm_t *shm, xc_shmsize_t size) 30 | #define XC_SHM_MEMDESTROY(func) void func(void *mem) 31 | 32 | #define XC_SHM_VTABLE(name) { \ 33 | xc_##name##_init \ 34 | , xc_##name##_destroy \ 35 | , xc_##name##_is_readwrite \ 36 | , xc_##name##_is_readonly \ 37 | \ 38 | \ 39 | , xc_##name##_meminit \ 40 | , xc_##name##_memdestroy \ 41 | } 42 | 43 | struct _xc_shm_vtable_t { 44 | XC_SHM_INIT((*init)); 45 | XC_SHM_DESTROY((*destroy)); 46 | XC_SHM_IS_READWRITE((*is_readwrite)); 47 | XC_SHM_IS_READONLY((*is_readonly)); 48 | 49 | XC_SHM_MEMINIT((*meminit)); 50 | XC_SHM_MEMDESTROY((*memdestroy)); 51 | }; 52 | 53 | typedef struct _xc_shm_scheme_t xc_shm_scheme_t; 54 | 55 | void xc_shm_init_modules(); 56 | int xc_shm_scheme_register(const char *name, const xc_shm_vtable_t *vtable); 57 | const xc_shm_vtable_t *xc_shm_scheme_find(const char *name); 58 | xc_shm_scheme_t *xc_shm_scheme_first(); 59 | xc_shm_scheme_t *xc_shm_scheme_next(xc_shm_scheme_t *scheme); 60 | const char *xc_shm_scheme_name(xc_shm_scheme_t *scheme); 61 | 62 | xc_shm_t *xc_shm_init(const char *type, xc_shmsize_t size, int readonly_protection, const void *arg1, const void *arg2); 63 | void xc_shm_destroy(xc_shm_t *shm); 64 | 65 | int xc_shm_can_readonly(const xc_shm_t *shm); 66 | void *xc_shm_to_readwrite(const xc_shm_t *shm_, void *p); 67 | void *xc_shm_to_readonly(const xc_shm_t *shm_, void *p); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /xcache/xc_utils.h: -------------------------------------------------------------------------------- 1 | #include "xcache.h" 2 | #include "xc_compatibility.h" 3 | 4 | #define XCACHE_STRS(str) (str), sizeof(str) 5 | #define XCACHE_STRL(str) (str), (sizeof(str) - 1) 6 | 7 | typedef zend_op_array *(zend_compile_file_t)(zend_file_handle *h, int type TSRMLS_DC); 8 | 9 | typedef struct _xc_compilererror_t { 10 | int type; 11 | uint lineno; 12 | int error_len; 13 | char *error; 14 | } xc_compilererror_t; 15 | 16 | typedef struct _xc_compile_result_t { 17 | zend_op_array *op_array; 18 | HashTable *function_table; 19 | HashTable *class_table; 20 | } xc_compile_result_t; 21 | 22 | xc_compile_result_t *xc_compile_result_init(xc_compile_result_t *cr, 23 | zend_op_array *op_array, 24 | HashTable *function_table, 25 | HashTable *class_table); 26 | void xc_compile_result_free(xc_compile_result_t *cr); 27 | xc_compile_result_t *xc_compile_result_init_cur(xc_compile_result_t *cr, zend_op_array *op_array TSRMLS_DC); 28 | /* apply func */ 29 | int xc_apply_op_array(xc_compile_result_t *cr, apply_func_t applyer TSRMLS_DC); 30 | 31 | int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC); 32 | int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC); 33 | int xc_fix_opcode(zend_op_array *op_array TSRMLS_DC); 34 | int xc_undo_fix_opcode(zend_op_array *op_array TSRMLS_DC); 35 | zend_uchar xc_get_fixed_opcode(zend_uchar opcode, int line); 36 | 37 | typedef void (*xc_foreach_early_binding_class_cb)(zend_op *opline, int oplineno, void *data TSRMLS_DC); 38 | int xc_foreach_early_binding_class(zend_op_array *op_array, xc_foreach_early_binding_class_cb callback, void *data TSRMLS_DC); 39 | 40 | /* installer */ 41 | #ifdef HAVE_XCACHE_CONSTANT 42 | void xc_install_constant(ZEND_24(NOTHING, const) char *filename, zend_constant *constant, zend_uchar type, const24_zstr key, uint len, ulong h TSRMLS_DC); 43 | #endif 44 | void xc_install_function(ZEND_24(NOTHING, const) char *filename, zend_function *func, zend_uchar type, const24_zstr key, uint len, ulong h TSRMLS_DC); 45 | ZESW(xc_cest_t *, void) xc_install_class(ZEND_24(NOTHING, const) char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, const24_zstr key, uint len, ulong h TSRMLS_DC); 46 | 47 | typedef zend_bool (*xc_if_func_t)(void *data); 48 | 49 | void xc_hash_copy_if(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, xc_if_func_t checker); 50 | #ifdef HAVE_XCACHE_CONSTANT 51 | void xc_zend_constant_ctor(zend_constant *c); 52 | void xc_zend_constant_dtor(zend_constant *c); 53 | void xc_copy_internal_zend_constants(HashTable *target, HashTable *source); 54 | #endif 55 | 56 | #ifndef ZEND_COMPILE_DELAYED_BINDING 57 | int xc_do_early_binding(zend_op_array *op_array, HashTable *class_table, int oplineno TSRMLS_DC); 58 | #endif 59 | 60 | zend_class_entry *xc_lookup_class(const char *class_name, int class_name_len, zend_bool autoload TSRMLS_DC); 61 | -------------------------------------------------------------------------------- /xcache_globals.h: -------------------------------------------------------------------------------- 1 | #include "util/xc_vector.h" 2 | 3 | ZEND_BEGIN_MODULE_GLOBALS(xcache) 4 | zend_bool initial_compile_file_called; /* true if origin_compile_file is called */ 5 | zend_bool cacher; /* true if enabled */ 6 | zend_bool stat; 7 | zend_bool experimental; 8 | #ifdef HAVE_XCACHE_OPTIMIZER 9 | zend_bool optimizer; /* true if enabled */ 10 | #endif 11 | #ifdef HAVE_XCACHE_COVERAGER 12 | zend_bool coverager; 13 | zend_bool coverager_autostart; 14 | zend_bool coverager_started; 15 | HashTable *coverages; /* coverages[file][line] = times */ 16 | #endif 17 | #ifndef ZEND_WIN32 18 | pid_t holds_pid; 19 | #endif 20 | xc_vector_t *php_holds; 21 | zend_uint php_holds_size; 22 | xc_vector_t *var_holds; 23 | zend_uint var_holds_size; 24 | time_t request_time; 25 | long var_ttl; 26 | #ifdef IS_UNCODE 27 | zval uvar_namespace_hard; 28 | zval uvar_namespace_soft; 29 | #endif 30 | zval var_namespace_hard; 31 | zval var_namespace_soft; 32 | 33 | zend_llist gc_op_arrays; 34 | #ifdef ZEND_ACC_ALIAS 35 | zend_llist gc_class_entries; 36 | #endif 37 | 38 | #ifdef HAVE_XCACHE_CONSTANT 39 | HashTable internal_constant_table; 40 | #endif 41 | HashTable internal_function_table; 42 | HashTable internal_class_table; 43 | zend_bool internal_table_copied; 44 | 45 | void *sandbox; 46 | zend_uint op_array_dummy_refcount_holder; 47 | ZEND_END_MODULE_GLOBALS(xcache) 48 | 49 | ZEND_EXTERN_MODULE_GLOBALS(xcache) 50 | 51 | #ifdef ZTS 52 | # define XG(v) TSRMG(xcache_globals_id, zend_xcache_globals *, v) 53 | #else 54 | # define XG(v) (xcache_globals.v) 55 | #endif 56 | --------------------------------------------------------------------------------