[1] | 1 | #include "php.h" |
---|
[593] | 2 | #include "xcache.h" |
---|
[1] | 3 | |
---|
[593] | 4 | #ifdef DEBUG |
---|
| 5 | # define IFDEBUG(x) (x) |
---|
[600] | 6 | int xc_vtrace(const char *fmt, va_list args); |
---|
[593] | 7 | int xc_trace(const char *fmt, ...) ZEND_ATTRIBUTE_PTR_FORMAT(printf, 1, 2); |
---|
[600] | 8 | |
---|
| 9 | # ifdef ZEND_WIN32 |
---|
| 10 | static inline int TRACE(const char *fmt, ...) |
---|
| 11 | { |
---|
| 12 | va_list args; |
---|
| 13 | int ret; |
---|
| 14 | |
---|
| 15 | va_start(args, fmt); |
---|
| 16 | ret = xc_vtrace(fmt, args); |
---|
| 17 | va_end(args); |
---|
| 18 | return ret; |
---|
| 19 | } |
---|
| 20 | # else |
---|
| 21 | # define TRACE(fmt, ...) \ |
---|
| 22 | xc_trace("%s:%d: " fmt "\r\n", __FILE__, __LINE__, __VA_ARGS__) |
---|
| 23 | # endif /* ZEND_WIN32 */ |
---|
[593] | 24 | # undef NDEBUG |
---|
| 25 | # undef inline |
---|
| 26 | # define inline |
---|
[600] | 27 | #else /* DEBUG */ |
---|
| 28 | |
---|
| 29 | # ifdef ZEND_WIN32 |
---|
| 30 | static inline int TRACE_DUMMY(const char *fmt, ...) |
---|
| 31 | { |
---|
| 32 | return 0; |
---|
| 33 | } |
---|
| 34 | # define TRACE 1 ? 0 : TRACE_DUMMY |
---|
| 35 | # else |
---|
| 36 | # define TRACE(fmt, ...) do { } while (0) |
---|
| 37 | # endif /* ZEND_WIN32 */ |
---|
| 38 | |
---|
[593] | 39 | # define IFDEBUG(x) do { } while (0) |
---|
| 40 | # ifndef NDEBUG |
---|
| 41 | # define NDEBUG |
---|
| 42 | # endif |
---|
[600] | 43 | #endif /* DEBUG */ |
---|
[593] | 44 | #include <assert.h> |
---|
| 45 | |
---|
[1] | 46 | typedef struct { |
---|
| 47 | int alloc; |
---|
| 48 | zend_op_array *op_array; |
---|
| 49 | HashTable *function_table; |
---|
| 50 | HashTable *class_table; |
---|
| 51 | } xc_compile_result_t; |
---|
| 52 | |
---|
| 53 | xc_compile_result_t *xc_compile_result_init(xc_compile_result_t *cr, |
---|
| 54 | zend_op_array *op_array, |
---|
| 55 | HashTable *function_table, |
---|
| 56 | HashTable *class_table); |
---|
| 57 | void xc_compile_result_free(xc_compile_result_t *cr); |
---|
| 58 | xc_compile_result_t *xc_compile_result_init_cur(xc_compile_result_t *cr, zend_op_array *op_array TSRMLS_DC); |
---|
| 59 | /* apply func */ |
---|
| 60 | int xc_apply_function(zend_function *zf, apply_func_t applyer TSRMLS_DC); |
---|
| 61 | int xc_apply_class(zend_class_entry *ce, apply_func_t applyer TSRMLS_DC); |
---|
| 62 | int xc_apply_op_array(xc_compile_result_t *cr, apply_func_t applyer TSRMLS_DC); |
---|
| 63 | |
---|
| 64 | int xc_undo_pass_two(zend_op_array *op_array TSRMLS_DC); |
---|
| 65 | int xc_redo_pass_two(zend_op_array *op_array TSRMLS_DC); |
---|
| 66 | int xc_fix_opcode(zend_op_array *op_array TSRMLS_DC); |
---|
| 67 | int xc_undo_fix_opcode(zend_op_array *op_array TSRMLS_DC); |
---|
| 68 | zend_uchar xc_get_fixed_opcode(zend_uchar opcode, int line); |
---|
| 69 | |
---|
[212] | 70 | int xc_foreach_early_binding_class(zend_op_array *op_array, void (*callback)(zend_op *opline, int oplineno, void *data TSRMLS_DC), void *data TSRMLS_DC); |
---|
| 71 | |
---|
[1] | 72 | /* installer */ |
---|
[95] | 73 | #ifdef HAVE_XCACHE_CONSTANT |
---|
[622] | 74 | void xc_install_constant(char *filename, zend_constant *constant, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC); |
---|
[95] | 75 | #endif |
---|
[622] | 76 | void xc_install_function(char *filename, zend_function *func, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC); |
---|
| 77 | ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, zstr key, uint len, ulong h TSRMLS_DC); |
---|
[1] | 78 | |
---|
| 79 | /* sandbox */ |
---|
| 80 | typedef struct { |
---|
| 81 | int alloc; |
---|
[209] | 82 | int orig_user_error_handler_error_reporting; |
---|
[1] | 83 | char *filename; |
---|
| 84 | |
---|
| 85 | HashTable orig_included_files; |
---|
| 86 | HashTable *tmp_included_files; |
---|
| 87 | |
---|
[95] | 88 | #ifdef HAVE_XCACHE_CONSTANT |
---|
| 89 | HashTable *orig_zend_constants; |
---|
| 90 | HashTable tmp_zend_constants; |
---|
| 91 | #endif |
---|
[1] | 92 | HashTable *orig_function_table; |
---|
| 93 | HashTable *orig_class_table; |
---|
[268] | 94 | HashTable *orig_auto_globals; |
---|
[1] | 95 | HashTable tmp_function_table; |
---|
| 96 | HashTable tmp_class_table; |
---|
[268] | 97 | HashTable tmp_auto_globals; |
---|
[378] | 98 | Bucket *tmp_internal_function_tail; |
---|
| 99 | Bucket *tmp_internal_class_tail; |
---|
[1] | 100 | } xc_sandbox_t; |
---|
| 101 | |
---|
[408] | 102 | typedef enum _xc_install_action_t { |
---|
| 103 | XC_NoInstall, |
---|
| 104 | XC_Install, |
---|
| 105 | XC_InstallNoBinding |
---|
| 106 | } xc_install_action_t; |
---|
| 107 | |
---|
[378] | 108 | void xc_zend_class_add_ref(zend_class_entry ZESW(*ce, **ce)); |
---|
[1] | 109 | xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC); |
---|
[408] | 110 | void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC); |
---|