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