summaryrefslogtreecommitdiff
path: root/xcache
diff options
context:
space:
mode:
authorXuefer <xuefer@gmail.com>2013-07-15 17:37:57 +0000
committerXuefer <xuefer@gmail.com>2013-07-15 17:37:57 +0000
commit02eb6beda4627c219a98ea35cb66375fee6d8d9d (patch)
treeb98438f3e2177a5650fe31fda4edd5e67e56b228 /xcache
parentb166cbc63e1e972149085e7a512256f3fca385cd (diff)
downloadxcache-02eb6beda4627c219a98ea35cb66375fee6d8d9d.tar.gz
xcache-02eb6beda4627c219a98ea35cb66375fee6d8d9d.zip
add back PHP_4 code for disassembler
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@1321 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
Diffstat (limited to 'xcache')
-rw-r--r--xcache/xc_compatibility.c12
-rw-r--r--xcache/xc_compatibility.h32
-rw-r--r--xcache/xc_const_string.c4
-rw-r--r--xcache/xc_const_string_opcodes_php4.x.h116
-rw-r--r--xcache/xc_const_string_opcodes_php5.3.h2
-rw-r--r--xcache/xc_ini.h3
-rw-r--r--xcache/xc_opcode_spec.c6
-rw-r--r--xcache/xc_opcode_spec_def.h99
-rw-r--r--xcache/xc_sandbox.c6
-rw-r--r--xcache/xc_utils.c112
-rw-r--r--xcache/xc_utils.h2
11 files changed, 321 insertions, 73 deletions
diff --git a/xcache/xc_compatibility.c b/xcache/xc_compatibility.c
index 22a57c3..07ad6f5 100644
--- a/xcache/xc_compatibility.c
+++ b/xcache/xc_compatibility.c
@@ -1,6 +1,18 @@
#include "xc_compatibility.h"
#ifndef ZEND_ENGINE_2_3
+#include "ext/standard/php_string.h"
+size_t xc_dirname(char *path, size_t len) /* {{{ */
+{
+#ifdef ZEND_ENGINE_2
+ return php_dirname(path, len);
+#else
+ php_dirname(path, len);
+ return strlen(path);
+#endif
+}
+/* }}} */
+
long xc_atol(const char *str, int str_len) /* {{{ */
{
long retval;
diff --git a/xcache/xc_compatibility.h b/xcache/xc_compatibility.h
index 98305f0..e96f74f 100644
--- a/xcache/xc_compatibility.h
+++ b/xcache/xc_compatibility.h
@@ -27,7 +27,12 @@
#endif
#define NOTHING
-/* ZendEngine version code Switcher */
+/* ZendEngine code Switcher */
+#ifndef ZEND_ENGINE_2
+# define ZESW(v1, v2) v1
+#else
+# define ZESW(v1, v2) v2
+#endif
#ifdef ZEND_ENGINE_2_4
# define ZEND_24(pre24, v24) v24
#else
@@ -207,9 +212,24 @@ typedef const zstr const_zstr;
#endif
/* }}} */
+/* the class entry type to be stored in class_table */
+typedef ZESW(zend_class_entry, zend_class_entry*) xc_cest_t;
+
+/* xc_cest_t to (zend_class_entry*) */
+#define CestToCePtr(st) (ZESW(\
+ &(st), \
+ st \
+ ) )
+
+/* ZCEP=zend class entry ptr */
+#define ZCEP_REFCOUNT_PTR(pce) (ZESW( \
+ (pce)->refcount, \
+ &((pce)->refcount) \
+ ))
+
#ifndef ZEND_ENGINE_2_3
-#include "ext/standard/php_string.h"
-static inline size_t zend_dirname(char *path, size_t len) { return php_dirname(path, len); }
+size_t xc_dirname(char *path, size_t len);
+#define zend_dirname xc_dirname
long xc_atol(const char *str, int len);
#define zend_atol xc_atol
#endif
@@ -219,7 +239,11 @@ long xc_atol(const char *str, int len);
#endif
#ifndef PHP_FE_END
-# define PHP_FE_END {NULL, NULL, NULL, 0, 0}
+# ifdef ZEND_ENGINE_2
+# define PHP_FE_END {NULL, NULL, NULL, 0, 0}
+# else
+# define PHP_FE_END {NULL, NULL, NULL}
+# endif
#endif
#endif /* XC_COMPATIBILITY_H_54F26ED90198353558718191D5EE244C */
diff --git a/xcache/xc_const_string.c b/xcache/xc_const_string.c
index ea39838..def49da 100644
--- a/xcache/xc_const_string.c
+++ b/xcache/xc_const_string.c
@@ -71,8 +71,10 @@ const char *xc_get_data_type(zend_uchar data_type)
# include "xc_const_string_opcodes_php5.3.h"
#elif defined(ZEND_ENGINE_2_1)
# include "xc_const_string_opcodes_php5.1.h"
-#else
+#elif defined(ZEND_ENGINE_2)
# include "xc_const_string_opcodes_php5.0.h"
+#else
+# include "xc_const_string_opcodes_php4.x.h"
#endif
zend_uchar xc_get_opcode_count()
diff --git a/xcache/xc_const_string_opcodes_php4.x.h b/xcache/xc_const_string_opcodes_php4.x.h
new file mode 100644
index 0000000..c40396e
--- /dev/null
+++ b/xcache/xc_const_string_opcodes_php4.x.h
@@ -0,0 +1,116 @@
+/* size = 113 */
+static const char *const xc_opcode_names[] = {
+/* 0 */ "NOP",
+/* 1 */ "ADD",
+/* 2 */ "SUB",
+/* 3 */ "MUL",
+/* 4 */ "DIV",
+/* 5 */ "MOD",
+/* 6 */ "SL",
+/* 7 */ "SR",
+/* 8 */ "CONCAT",
+/* 9 */ "BW_OR",
+/* 10 */ "BW_AND",
+/* 11 */ "BW_XOR",
+/* 12 */ "BW_NOT",
+/* 13 */ "BOOL_NOT",
+/* 14 */ "BOOL_XOR",
+/* 15 */ "IS_IDENTICAL",
+/* 16 */ "IS_NOT_IDENTICAL",
+/* 17 */ "IS_EQUAL",
+/* 18 */ "IS_NOT_EQUAL",
+/* 19 */ "IS_SMALLER",
+/* 20 */ "IS_SMALLER_OR_EQUAL",
+/* 21 */ "CAST",
+/* 22 */ "QM_ASSIGN",
+/* 23 */ "ASSIGN_ADD",
+/* 24 */ "ASSIGN_SUB",
+/* 25 */ "ASSIGN_MUL",
+/* 26 */ "ASSIGN_DIV",
+/* 27 */ "ASSIGN_MOD",
+/* 28 */ "ASSIGN_SL",
+/* 29 */ "ASSIGN_SR",
+/* 30 */ "ASSIGN_CONCAT",
+/* 31 */ "ASSIGN_BW_OR",
+/* 32 */ "ASSIGN_BW_AND",
+/* 33 */ "ASSIGN_BW_XOR",
+/* 34 */ "PRE_INC",
+/* 35 */ "PRE_DEC",
+/* 36 */ "POST_INC",
+/* 37 */ "POST_DEC",
+/* 38 */ "ASSIGN",
+/* 39 */ "ASSIGN_REF",
+/* 40 */ "ECHO",
+/* 41 */ "PRINT",
+/* 42 */ "JMP",
+/* 43 */ "JMPZ",
+/* 44 */ "JMPNZ",
+/* 45 */ "JMPZNZ",
+/* 46 */ "JMPZ_EX",
+/* 47 */ "JMPNZ_EX",
+/* 48 */ "CASE",
+/* 49 */ "SWITCH_FREE",
+/* 50 */ "BRK",
+/* 51 */ "CONT",
+/* 52 */ "BOOL",
+/* 53 */ "INIT_STRING",
+/* 54 */ "ADD_CHAR",
+/* 55 */ "ADD_STRING",
+/* 56 */ "ADD_VAR",
+/* 57 */ "BEGIN_SILENCE",
+/* 58 */ "END_SILENCE",
+/* 59 */ "INIT_FCALL_BY_NAME",
+/* 60 */ "DO_FCALL",
+/* 61 */ "DO_FCALL_BY_NAME",
+/* 62 */ "RETURN",
+/* 63 */ "RECV",
+/* 64 */ "RECV_INIT",
+/* 65 */ "SEND_VAL",
+/* 66 */ "SEND_VAR",
+/* 67 */ "SEND_REF",
+/* 68 */ "NEW",
+/* 69 */ "JMP_NO_CTOR",
+/* 70 */ "FREE",
+/* 71 */ "INIT_ARRAY",
+/* 72 */ "ADD_ARRAY_ELEMENT",
+/* 73 */ "INCLUDE_OR_EVAL",
+/* 74 */ "UNSET_VAR",
+/* 75 */ "UNSET_DIM_OBJ",
+/* 76 */ "ISSET_ISEMPTY",
+/* 77 */ "FE_RESET",
+/* 78 */ "FE_FETCH",
+/* 79 */ "EXIT",
+/* 80 */ "FETCH_R",
+/* 81 */ "FETCH_DIM_R",
+/* 82 */ "FETCH_OBJ_R",
+/* 83 */ "FETCH_W",
+/* 84 */ "FETCH_DIM_W",
+/* 85 */ "FETCH_OBJ_W",
+/* 86 */ "FETCH_RW",
+/* 87 */ "FETCH_DIM_RW",
+/* 88 */ "FETCH_OBJ_RW",
+/* 89 */ "FETCH_IS",
+/* 90 */ "FETCH_DIM_IS",
+/* 91 */ "FETCH_OBJ_IS",
+/* 92 */ "FETCH_FUNC_ARG",
+/* 93 */ "FETCH_DIM_FUNC_ARG",
+/* 94 */ "FETCH_OBJ_FUNC_ARG",
+/* 95 */ "FETCH_UNSET",
+/* 96 */ "FETCH_DIM_UNSET",
+/* 97 */ "FETCH_OBJ_UNSET",
+/* 98 */ "FETCH_DIM_TMP_VAR",
+/* 99 */ "FETCH_CONSTANT",
+/* 100 */ "DECLARE_FUNCTION_OR_CLASS",
+/* 101 */ "EXT_STMT",
+/* 102 */ "EXT_FCALL_BEGIN",
+/* 103 */ "EXT_FCALL_END",
+/* 104 */ "EXT_NOP",
+/* 105 */ "TICKS",
+/* 106 */ "SEND_VAR_NO_REF",
+/* 107 */ "UNDEF",
+/* 108 */ "UNDEF",
+/* 109 */ "UNDEF",
+/* 110 */ "DO_FCALL_BY_FUNC",
+/* 111 */ "INIT_FCALL_BY_FUNC",
+/* 112 */ "UNDEF"
+};
diff --git a/xcache/xc_const_string_opcodes_php5.3.h b/xcache/xc_const_string_opcodes_php5.3.h
index 48bea60..585720e 100644
--- a/xcache/xc_const_string_opcodes_php5.3.h
+++ b/xcache/xc_const_string_opcodes_php5.3.h
@@ -151,9 +151,7 @@ static const char *const xc_opcode_names[] = {
/* 148 */ "ISSET_ISEMPTY_PROP_OBJ",
/* 149 */ "HANDLE_EXCEPTION",
/* 150 */ "USER_OPCODE",
-#ifdef ZEND_ENGINE_2_3
/* 151 */ "UNDEF",
/* 152 */ "JMP_SET",
/* 153 */ "DECLARE_LAMBDA_FUNCTION"
-#endif
};
diff --git a/xcache/xc_ini.h b/xcache/xc_ini.h
index 5086424..ee72a96 100644
--- a/xcache/xc_ini.h
+++ b/xcache/xc_ini.h
@@ -12,5 +12,8 @@ PHP_INI_MH(xcache_OnUpdateDummy);
PHP_INI_MH(xcache_OnUpdateULong);
PHP_INI_MH(xcache_OnUpdateBool);
PHP_INI_MH(xcache_OnUpdateString);
+#ifndef ZEND_ENGINE_2
+#define OnUpdateLong OnUpdateInt
+#endif
#endif /* XC_INI_H_E208B8E597E7FAD950D249BE9C6B6F53 */
diff --git a/xcache/xc_opcode_spec.c b/xcache/xc_opcode_spec.c
index 5043506..fe86eb0 100644
--- a/xcache/xc_opcode_spec.c
+++ b/xcache/xc_opcode_spec.c
@@ -4,7 +4,11 @@
/* {{{ opcode_spec */
#define OPSPEC(ext, op1, op2, res) { OPSPEC_##ext, OPSPEC_##op1, OPSPEC_##op2, OPSPEC_##res },
-#define OPSPEC_VAR_2 OPSPEC_STD
+#ifdef ZEND_ENGINE_2
+# define OPSPEC_VAR_2 OPSPEC_STD
+#else
+# define OPSPEC_VAR_2 OPSPEC_VAR
+#endif
#ifdef ZEND_ENGINE_2_4
#undef OPSPEC_FETCH
#define OPSPEC_FETCH OPSPEC_STD
diff --git a/xcache/xc_opcode_spec_def.h b/xcache/xc_opcode_spec_def.h
index 6898740..af33a61 100644
--- a/xcache/xc_opcode_spec_def.h
+++ b/xcache/xc_opcode_spec_def.h
@@ -22,6 +22,7 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( UNUSED, STD, STD, TMP) /* 20 IS_SMALLER_OR_EQUAL */
OPSPEC( CAST, STD, UNUSED, TMP) /* 21 CAST */
OPSPEC( UNUSED, STD, UNUSED, TMP) /* 22 QM_ASSIGN */
+#ifdef ZEND_ENGINE_2
OPSPEC( ASSIGN, STD, STD, VAR) /* 23 ASSIGN_ADD */
OPSPEC( ASSIGN, STD, STD, VAR) /* 24 ASSIGN_SUB */
OPSPEC( ASSIGN, STD, STD, VAR) /* 25 ASSIGN_MUL */
@@ -33,6 +34,19 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( ASSIGN, STD, STD, VAR) /* 31 ASSIGN_BW_OR */
OPSPEC( ASSIGN, STD, STD, VAR) /* 32 ASSIGN_BW_AND */
OPSPEC( ASSIGN, STD, STD, VAR) /* 33 ASSIGN_BW_XOR */
+#else
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+ OPSPEC( UNUSED, VAR, STD, VAR)
+#endif
OPSPEC( UNUSED, VAR, UNUSED, VAR) /* 34 PRE_INC */
OPSPEC( UNUSED, VAR, UNUSED, VAR) /* 35 PRE_DEC */
OPSPEC( UNUSED, VAR, UNUSED, TMP) /* 36 POST_INC */
@@ -41,12 +55,23 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( UNUSED, VAR, VAR, VAR) /* 39 ASSIGN_REF */
OPSPEC( UNUSED, STD, UNUSED, UNUSED) /* 40 ECHO */
OPSPEC( UNUSED, STD, UNUSED, TMP) /* 41 PRINT */
+#ifdef ZEND_ENGINE_2
OPSPEC( UNUSED, JMPADDR, UNUSED, UNUSED) /* 42 JMP */
OPSPEC( UNUSED, STD, JMPADDR, UNUSED) /* 43 JMPZ */
OPSPEC( UNUSED, STD, JMPADDR, UNUSED) /* 44 JMPNZ */
+#else
+ OPSPEC( UNUSED, OPLINE, UNUSED, UNUSED)
+ OPSPEC( UNUSED, STD, OPLINE, UNUSED)
+ OPSPEC( UNUSED, STD, OPLINE, UNUSED)
+#endif
OPSPEC( OPLINE, STD, OPLINE, UNUSED) /* 45 JMPZNZ */
+#ifdef ZEND_ENGINE_2
OPSPEC( UNUSED, STD, JMPADDR, TMP) /* 46 JMPZ_EX */
OPSPEC( UNUSED, STD, JMPADDR, TMP) /* 47 JMPNZ_EX */
+#else
+ OPSPEC( UNUSED, STD, OPLINE, TMP)
+ OPSPEC( UNUSED, STD, OPLINE, TMP)
+#endif
OPSPEC( UNUSED, STD, STD, TMP) /* 48 CASE */
OPSPEC( BIT, STD, UNUSED, UNUSED) /* 49 SWITCH_FREE */
OPSPEC( UNUSED, BRK, STD, UNUSED) /* 50 BRK */
@@ -59,15 +84,24 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( UNUSED, UNUSED, UNUSED, TMP) /* 57 BEGIN_SILENCE */
OPSPEC( UNUSED, TMP, UNUSED, UNUSED) /* 58 END_SILENCE */
OPSPEC(INIT_FCALL, STD, STD, UNUSED) /* 59 INIT_FCALL_BY_NAME */
+#ifdef ZEND_ENGINE_2
OPSPEC( FCALL, STD, OPLINE, VAR) /* 60 DO_FCALL */
OPSPEC( FCALL, STD, OPLINE, VAR) /* 61 DO_FCALL_BY_NAME */
+#else
+ OPSPEC( FCALL, STD, UNUSED, VAR)
+ OPSPEC( FCALL, STD, UNUSED, VAR)
+#endif
OPSPEC( UNUSED, STD, UNUSED, UNUSED) /* 62 RETURN */
OPSPEC( UNUSED, ARG, UNUSED, VAR) /* 63 RECV */
OPSPEC( UNUSED, ARG, STD, VAR) /* 64 RECV_INIT */
OPSPEC( SEND, STD, ARG, UNUSED) /* 65 SEND_VAL */
OPSPEC( SEND, VAR, ARG, UNUSED) /* 66 SEND_VAR */
OPSPEC( SEND, VAR, ARG, UNUSED) /* 67 SEND_REF */
+#ifdef ZEND_ENGINE_2
OPSPEC( UNUSED, CLASS, UNUSED, VAR) /* 68 NEW */
+#else
+ OPSPEC( UNUSED, STD, UNUSED, VAR)
+#endif
#ifdef ZEND_ENGINE_2_3
OPSPEC( STD, STD, STD, UNUSED) /* 69 INIT_NS_FCALL_BY_NAME */
#elif defined(ZEND_ENGINE_2_1)
@@ -114,8 +148,10 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( UNUSED, STD, STD, VAR) /* 98 FETCH_DIM_TMP_VAR */
#ifdef ZEND_ENGINE_2_3
OPSPEC( UNUSED, VAR_2, STD, TMP) /* 99 FETCH_CONSTANT */
-#else
+#elif defined(ZEND_ENGINE_2)
OPSPEC( UNUSED, UCLASS, STD, TMP) /* 99 FETCH_CONSTANT */
+#else
+ OPSPEC( UNUSED, STD, UNUSED, TMP) /* 99 FETCH_CONSTANT */
#endif
#ifdef ZEND_ENGINE_2_3
OPSPEC( STD, JMPADDR, STD, UNUSED) /* 100 GOTO */
@@ -128,27 +164,28 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 104 EXT_NOP */
OPSPEC( UNUSED, STD, UNUSED, UNUSED) /* 105 TICKS */
OPSPEC(SEND_NOREF, VAR, ARG, UNUSED) /* 106 SEND_VAR_NO_REF */
-#ifdef ZEND_ENGINE_2_4
+#ifdef ZEND_ENGINE_2
+# ifdef ZEND_ENGINE_2_4
OPSPEC( OPLINE, STD, STD, UNUSED) /* 107 CATCH */
-#else
+# else
OPSPEC( OPLINE, CLASS, STD, UNUSED) /* 107 CATCH */
-#endif
+# endif
OPSPEC( UNUSED, STD, OPLINE, UNUSED) /* 108 THROW */
OPSPEC( FCLASS, STD, STD, CLASS) /* 109 FETCH_CLASS */
OPSPEC( UNUSED, STD, UNUSED, VAR) /* 110 CLONE */
-#ifdef ZEND_ENGINE_2_4
+# ifdef ZEND_ENGINE_2_4
OPSPEC( UNUSED, STD, UNUSED, UNUSED) /* 111 RETURN_BY_REF */
-#else
+# else
OPSPEC( UNUSED, STD, UNUSED, UNUSED) /* 111 INIT_CTOR_CALL */
-#endif
+# endif
OPSPEC( UNUSED, STD, STD, VAR) /* 112 INIT_METHOD_CALL */
-#ifdef ZEND_ENGINE_2_3
+# ifdef ZEND_ENGINE_2_3
OPSPEC( UNUSED, STD, STD, UNUSED) /* 113 INIT_STATIC_METHOD_CALL */
-#else
+# else
OPSPEC( UNUSED, UCLASS, STD, UNUSED) /* 113 INIT_STATIC_METHOD_CALL */
-#endif
+# endif
OPSPEC( ISSET, STD, FETCH, TMP) /* 114 ISSET_ISEMPTY_VAR */
OPSPEC( ISSET, STD, STD, TMP) /* 115 ISSET_ISEMPTY_DIM_OBJ */
@@ -180,45 +217,53 @@ static const xc_opcode_spec_t xc_opcode_spec[] = {
OPSPEC( CLASS, STD, STD, CLASS) /* 140 DECLARE_INHERITED_CLASS */
OPSPEC( UNUSED, STD, STD, UNUSED) /* 141 DECLARE_FUNCTION */
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 142 RAISE_ABSTRACT_ERROR */
-#ifdef ZEND_ENGINE_2_3
+# ifdef ZEND_ENGINE_2_3
OPSPEC( DECLARE, STD, STD, UNUSED) /* 143 DECLARE_CONST */
-#else
+# else
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 143 UNDEF-143 */
-#endif
-#ifdef ZEND_ENGINE_2_3
+# endif
+# ifdef ZEND_ENGINE_2_3
OPSPEC( IFACE, CLASS, STD, UNUSED) /* 144 ADD_INTERFACE */
-#else
+# else
OPSPEC( IFACE, CLASS, CLASS, UNUSED) /* 144 ADD_INTERFACE */
-#endif
-#ifdef ZEND_ENGINE_2_3
+# endif
+# ifdef ZEND_ENGINE_2_3
OPSPEC( CLASS, STD, STD, OPLINE) /* 145 DECLARE_INHERITED_CLASS_DELAYED */
-#else
+# else
OPSPEC( UNUSED, CLASS, STD, UNUSED) /* 145 VERIFY_INSTANCEOF */
-#endif
+# endif
OPSPEC( UNUSED, CLASS, UNUSED, UNUSED) /* 146 VERIFY_ABSTRACT_CLASS */
OPSPEC( UNUSED, STD, STD, VAR) /* 147 ASSIGN_DIM */
OPSPEC( ISSET, STD, STD, TMP) /* 148 ISSET_ISEMPTY_PROP_OBJ */
OPSPEC( STD, UNUSED, UNUSED, STD) /* 149 HANDLE_EXCEPTION */
-#ifdef ZEND_ENGINE_2_1
+# ifdef ZEND_ENGINE_2_1
OPSPEC( STD, UNUSED, UNUSED, STD) /* 150 USER_OPCODE */
-#endif
-#ifdef ZEND_ENGINE_2_3
+# endif
+# ifdef ZEND_ENGINE_2_3
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 151 UNDEF */
OPSPEC( UNUSED, STD, JMPADDR, TMP) /* 152 JMP_SET */
OPSPEC( UNUSED, STD, STD, TMP) /* 153 DECLARE_LAMBDA_FUNCTION */
-#endif
-#ifdef ZEND_ENGINE_2_4
+# endif
+# ifdef ZEND_ENGINE_2_4
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 154 ADD_TRAIT */
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 155 BIND_TRAITS */
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 156 SEPARATE */
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 157 QM_ASSIGN_VAR */
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 158 JMP_SET_VAR */
-#endif
-#ifdef ZEND_ENGINE_2_5
+# endif
+# ifdef ZEND_ENGINE_2_5
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 159 DISCARD_EXCEPTION */
OPSPEC( UNUSED, STD, STD, UNUSED) /* 160 YIELD */
OPSPEC( UNUSED, STD, UNUSED, UNUSED) /* 161 GENERATOR_RETURN */
OPSPEC( UNUSED, JMPADDR, UNUSED, UNUSED) /* 162 FAST_CALL */
OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 163 FAST_RET */
-#endif
+# endif
+#else /* ZEND_ENGINE_2 */
+ OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 107 UNDEF */
+ OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 108 UNDEF */
+ OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 109 UNDEF */
+ OPSPEC( FCALL, STD, OPLINE, VAR) /* 61 DO_FCALL_BY_FUNC */
+ OPSPEC(INIT_FCALL, STD, STD, UNUSED) /* 111 INIT_FCALL_BY_FUNC */
+ OPSPEC( UNUSED, UNUSED, UNUSED, UNUSED) /* 112 UNDEF */
+#endif /* ZEND_ENGINE_2 */
};
diff --git a/xcache/xc_sandbox.c b/xcache/xc_sandbox.c
index fb56250..ff038a3 100644
--- a/xcache/xc_sandbox.c
+++ b/xcache/xc_sandbox.c
@@ -194,8 +194,8 @@ static xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, ZEND_24(NOTHING, con
zend_hash_init_ex(&TG(class_table), 16, NULL, ZEND_CLASS_DTOR, h->persistent, h->bApplyProtection);
#if 0 && TODO
{
- zend_class_entry *dummy_class_entry;
- zend_hash_copy(&TG(class_table), &XG(internal_class_table), NULL, (void *) &dummy_class_entry, sizeof(dummy_class_entry));
+ xc_cest_t tmp_cest;
+ zend_hash_copy(&TG(class_table), &XG(internal_class_table), NULL, (void *) &tmp_cest, sizeof(tmp_cest));
}
#endif
TG(internal_class_tail) = TG(class_table).pListTail;
@@ -277,7 +277,7 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox TSRMLS_DC) /* {{{ */
b = TG(internal_class_tail) ? TG(internal_class_tail)->pListNext : TG(class_table).pListHead;
/* install class */
while (b != NULL) {
- xc_install_class(sandbox->filename, *(zend_class_entry **)b->pData, -1,
+ xc_install_class(sandbox->filename, (xc_cest_t*) b->pData, -1,
BUCKET_KEY_TYPE(b), ZSTR(BUCKET_KEY_S(b)), b->nKeyLength, b->h TSRMLS_CC);
b = b->pListNext;
}
diff --git a/xcache/xc_utils.c b/xcache/xc_utils.c
index abedd14..43933ea 100644
--- a/xcache/xc_utils.c
+++ b/xcache/xc_utils.c
@@ -77,20 +77,35 @@ typedef struct {
int xc_apply_method(zend_function *zf, xc_apply_method_info *mi TSRMLS_DC) /* {{{ */
{
/* avoid duplicate apply for shadowed method */
+#ifdef ZEND_ENGINE_2
if (mi->ce != zf->common.scope) {
/* fprintf(stderr, "avoided duplicate %s\n", zf->common.function_name); */
return 0;
}
+#else
+ char *name = zf->common.function_name;
+ int name_s = strlen(name) + 1;
+ zend_class_entry *ce;
+ zend_function *ptr;
+
+ for (ce = mi->ce->parent; ce; ce = ce->parent) {
+ if (zend_hash_find(&ce->function_table, name, name_s, (void **) &ptr) == SUCCESS) {
+ if (ptr->op_array.refcount == zf->op_array.refcount) {
+ return 0;
+ }
+ }
+ }
+#endif
return xc_apply_function(zf, &mi->fi TSRMLS_CC);
}
/* }}} */
-static int xc_apply_class(zend_class_entry **ce, xc_apply_func_info *fi TSRMLS_DC) /* {{{ */
+static int xc_apply_cest(xc_cest_t *cest, xc_apply_func_info *fi TSRMLS_DC) /* {{{ */
{
xc_apply_method_info mi;
mi.fi = *fi;
- mi.ce = *ce;
- zend_hash_apply_with_argument(&((*ce)->function_table), (apply_func_arg_t) xc_apply_method, &mi TSRMLS_CC);
+ mi.ce = CestToCePtr(*cest);
+ zend_hash_apply_with_argument(&(CestToCePtr(*cest)->function_table), (apply_func_arg_t) xc_apply_method, &mi TSRMLS_CC);
return 0;
}
/* }}} */
@@ -99,14 +114,16 @@ int xc_apply_op_array(xc_compile_result_t *cr, apply_func_t applyer TSRMLS_DC) /
xc_apply_func_info fi;
fi.applyer = applyer;
zend_hash_apply_with_argument(cr->function_table, (apply_func_arg_t) xc_apply_function, &fi TSRMLS_CC);
- zend_hash_apply_with_argument(cr->class_table, (apply_func_arg_t) xc_apply_class, &fi TSRMLS_CC);
+ zend_hash_apply_with_argument(cr->class_table, (apply_func_arg_t) xc_apply_cest, &fi TSRMLS_CC);
return applyer(cr->op_array TSRMLS_CC);
}
/* }}} */
int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
+#ifdef ZEND_ENGINE_2
zend_op *opline, *opline_end;
+#endif
#ifdef ZEND_ENGINE_2_4
if (!(op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO)) {
@@ -118,26 +135,27 @@ int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
}
#endif
+#ifdef ZEND_ENGINE_2
opline = op_array->opcodes;
opline_end = opline + op_array->last;
while (opline < opline_end) {
-#ifdef ZEND_ENGINE_2_4
+# ifdef ZEND_ENGINE_2_4
if (opline->op1_type == IS_CONST) {
opline->op1.constant = opline->op1.literal - op_array->literals;
}
if (opline->op2_type == IS_CONST) {
opline->op2.constant = opline->op2.literal - op_array->literals;
}
-#endif
+# endif
switch (opline->opcode) {
-#ifdef ZEND_GOTO
+# ifdef ZEND_GOTO
case ZEND_GOTO:
-#endif
+# endif
case ZEND_JMP:
-#ifdef ZEND_FAST_CALL
+# ifdef ZEND_FAST_CALL
case ZEND_FAST_CALL:
-#endif
+# endif
assert(Z_OP(opline->op1).jmp_addr >= op_array->opcodes && (zend_uint) (Z_OP(opline->op1).jmp_addr - op_array->opcodes) < op_array->last);
Z_OP(opline->op1).opline_num = Z_OP(opline->op1).jmp_addr - op_array->opcodes;
break;
@@ -145,18 +163,20 @@ int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
-#ifdef ZEND_JMP_SET
+# ifdef ZEND_JMP_SET
case ZEND_JMP_SET:
-#endif
-#ifdef ZEND_JMP_SET_VAR
+# endif
+# ifdef ZEND_JMP_SET_VAR
case ZEND_JMP_SET_VAR:
-#endif
+# endif
assert(Z_OP(opline->op2).jmp_addr >= op_array->opcodes && (zend_uint) (Z_OP(opline->op2).jmp_addr - op_array->opcodes) < op_array->last);
Z_OP(opline->op2).opline_num = Z_OP(opline->op2).jmp_addr - op_array->opcodes;
break;
}
opline++;
}
+#endif /* ZEND_ENGINE_2 */
+
#ifdef ZEND_ENGINE_2_4
op_array->fn_flags &= ~ZEND_ACC_DONE_PASS_TWO;
#else
@@ -168,7 +188,9 @@ int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
/* }}} */
int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
+#ifdef ZEND_ENGINE_2
zend_op *opline, *opline_end;
+#endif
#ifdef ZEND_ENGINE_2_4
zend_literal *literal = op_array->literals;
#endif
@@ -198,17 +220,18 @@ int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
}
#endif
+#ifdef ZEND_ENGINE_2
opline = op_array->opcodes;
opline_end = opline + op_array->last;
while (opline < opline_end) {
-#ifdef ZEND_ENGINE_2_4
+# ifdef ZEND_ENGINE_2_4
if (opline->op1_type == IS_CONST) {
opline->op1.literal = op_array->literals + opline->op1.constant;
}
if (opline->op2_type == IS_CONST) {
opline->op2.literal = op_array->literals + opline->op2.constant;
}
-#else
+# else
if (Z_OP_TYPE(opline->op1) == IS_CONST) {
Z_SET_ISREF(Z_OP_CONSTANT(opline->op1));
Z_SET_REFCOUNT(Z_OP_CONSTANT(opline->op1), 2); /* Make sure is_ref won't be reset */
@@ -217,15 +240,15 @@ int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
Z_SET_ISREF(Z_OP_CONSTANT(opline->op2));
Z_SET_REFCOUNT(Z_OP_CONSTANT(opline->op2), 2);
}
-#endif
+# endif
switch (opline->opcode) {
-#ifdef ZEND_GOTO
+# ifdef ZEND_GOTO
case ZEND_GOTO:
-#endif
+# endif
case ZEND_JMP:
-#ifdef ZEND_FAST_CALL
+# ifdef ZEND_FAST_CALL
case ZEND_FAST_CALL:
-#endif
+# endif
assert(Z_OP(opline->op1).opline_num < op_array->last);
Z_OP(opline->op1).jmp_addr = op_array->opcodes + Z_OP(opline->op1).opline_num;
break;
@@ -233,12 +256,12 @@ int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
case ZEND_JMPNZ:
case ZEND_JMPZ_EX:
case ZEND_JMPNZ_EX:
-#ifdef ZEND_JMP_SET
+# ifdef ZEND_JMP_SET
case ZEND_JMP_SET:
-#endif
-#ifdef ZEND_JMP_SET_VAR
+# endif
+# ifdef ZEND_JMP_SET_VAR
case ZEND_JMP_SET_VAR:
-#endif
+# endif
assert(Z_OP(opline->op2).opline_num < op_array->last);
Z_OP(opline->op2).jmp_addr = op_array->opcodes + Z_OP(opline->op2).opline_num;
break;
@@ -246,6 +269,7 @@ int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
/* ZEND_VM_SET_OPCODE_HANDLER(opline); this is not undone, don't redo. only do this for loader */
opline++;
}
+#endif /* ZEND_ENGINE_2 */
#ifdef ZEND_ENGINE_2_4
op_array->fn_flags |= ZEND_ACC_DONE_PASS_TWO;
@@ -258,6 +282,7 @@ int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC) /* {{{ */
static void xc_fix_opcode_ex_znode(int tofix, xc_op_spec_t spec, Z_OP_TYPEOF_TYPE *op_type, znode_op *op, int type TSRMLS_DC) /* {{{ */
{
+#ifdef ZEND_ENGINE_2
if ((*op_type != IS_UNUSED && (spec == OPSPEC_UCLASS || spec == OPSPEC_CLASS)) ||
spec == OPSPEC_FETCH) {
if (tofix) {
@@ -283,6 +308,7 @@ static void xc_fix_opcode_ex_znode(int tofix, xc_op_spec_t spec, Z_OP_TYPEOF_TYP
Z_OP(*op).var *= sizeof(temp_variable);
}
}
+#endif
}
/* }}} */
@@ -359,9 +385,17 @@ int xc_foreach_early_binding_class(zend_op_array *op_array, xc_foreach_early_bin
opline = opline_end;
break;
+#ifdef ZEND_ENGINE_2
case ZEND_DECLARE_INHERITED_CLASS:
callback(opline, opline - begin, data TSRMLS_CC);
break;
+#else
+ case ZEND_DECLARE_FUNCTION_OR_CLASS:
+ if (opline->extended_value == ZEND_DECLARE_INHERITED_CLASS) {
+ callback(opline, opline - begin, data TSRMLS_CC);
+ }
+ break;
+#endif
}
if (opline < next) {
@@ -385,6 +419,7 @@ int xc_do_early_binding(zend_op_array *op_array, HashTable *class_table, int opl
opline = &(op_array->opcodes[oplineno]);
switch (opline->opcode) {
+#ifdef ZEND_ENGINE_2
case ZEND_DECLARE_INHERITED_CLASS:
{
zval *parent_name;
@@ -433,6 +468,12 @@ int xc_do_early_binding(zend_op_array *op_array, HashTable *class_table, int opl
abstract_op->opcode = ZEND_NOP;
ZEND_VM_SET_OPCODE_HANDLER(abstract_op);
}
+#else
+ case ZEND_DECLARE_FUNCTION_OR_CLASS:
+ if (do_bind_function_or_class(opline, NULL, class_table, 1) == FAILURE) {
+ return FAILURE;
+ }
+#endif
break;
default:
@@ -494,7 +535,7 @@ void xc_install_function(ZEND_24(NOTHING, const) char *filename, zend_function *
func, sizeof(zend_op_array),
NULL
) == FAILURE) {
- CG(zend_lineno) = func->op_array.line_start;
+ CG(zend_lineno) = ZESW(func->op_array.opcodes[0].lineno, func->op_array.line_start);
#ifdef IS_UNICODE
zend_error(E_ERROR, "Cannot redeclare %R()", type, key);
#else
@@ -504,9 +545,11 @@ void xc_install_function(ZEND_24(NOTHING, const) char *filename, zend_function *
}
}
/* }}} */
-void xc_install_class(ZEND_24(NOTHING, const) char *filename, zend_class_entry *ce, int oplineno, zend_uchar type, const24_zstr key, uint len, ulong h TSRMLS_DC) /* {{{ */
+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) /* {{{ */
{
zend_bool istmpkey;
+ zend_class_entry *cep = CestToCePtr(*cest);
+ ZESW(void *stored_ce_ptr, NOTHING);
#ifdef IS_UNICODE
istmpkey = (type == IS_STRING && ZSTR_S(key)[0] == 0) || ZSTR_U(key)[0] == 0;
@@ -515,8 +558,8 @@ void xc_install_class(ZEND_24(NOTHING, const) char *filename, zend_class_entry *
#endif
if (istmpkey) {
zend_u_hash_quick_update(CG(class_table), type, key, len, h,
- &ce, sizeof(zend_class_entry *),
- NULL
+ cest, sizeof(xc_cest_t),
+ ZESW(&stored_ce_ptr, NULL)
);
#ifndef ZEND_COMPILE_DELAYED_BINDING
if (oplineno != -1) {
@@ -525,17 +568,18 @@ void xc_install_class(ZEND_24(NOTHING, const) char *filename, zend_class_entry *
#endif
}
else if (zend_u_hash_quick_add(CG(class_table), type, key, len, h,
- &ce, sizeof(zend_class_entry *),
- NULL
+ cest, sizeof(xc_cest_t),
+ ZESW(&stored_ce_ptr, NULL)
) == FAILURE) {
- CG(zend_lineno) = Z_CLASS_INFO(*ce).line_start;
+ CG(zend_lineno) = ZESW(0, Z_CLASS_INFO(*cep).line_start);
#ifdef IS_UNICODE
- zend_error(E_ERROR, "Cannot redeclare class %R", type, ce->name);
+ zend_error(E_ERROR, "Cannot redeclare class %R", type, cep->name);
#else
- zend_error(E_ERROR, "Cannot redeclare class %s", ce->name);
+ zend_error(E_ERROR, "Cannot redeclare class %s", cep->name);
#endif
assert(oplineno == -1);
}
+ ZESW(return (xc_cest_t *) stored_ce_ptr, NOTHING);
}
/* }}} */
diff --git a/xcache/xc_utils.h b/xcache/xc_utils.h
index 0688059..eae8826 100644
--- a/xcache/xc_utils.h
+++ b/xcache/xc_utils.h
@@ -42,7 +42,7 @@ int xc_foreach_early_binding_class(zend_op_array *op_array, xc_foreach_early_bin
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);
#endif
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);
-void xc_install_class(ZEND_24(NOTHING, const) char *filename, zend_class_entry *class_entry, int oplineno, zend_uchar type, const24_zstr key, uint len, ulong h TSRMLS_DC);
+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);
typedef zend_bool (*xc_if_func_t)(void *data);