diff --git a/coverager.c b/coverager.c index 846340b..b120700 100644 --- a/coverager.c +++ b/coverager.c @@ -245,7 +245,11 @@ void xc_coverager_request_init(TSRMLS_D) /* {{{ */ { if (XG(coverager)) { xc_coverager_enable(TSRMLS_C); +#ifdef ZEND_COMPILE_EXTENDED_INFO + CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; +#else CG(extended_info) = 1; +#endif } else { XG(coverage_enabled) = 0; diff --git a/processor/processor.m4 b/processor/processor.m4 index d7afe51..691ac08 100644 --- a/processor/processor.m4 +++ b/processor/processor.m4 @@ -505,7 +505,12 @@ DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{ dnl readonly_protection=on dnl main op_array && have early binding zend_uint ii; - if (!processor->readonly_protection && !(src == processor->php_src->op_array && processor->php_src->have_early_binding)) { +#ifdef ZEND_COMPILE_DELAYED_BINDING + zend_bool need_early_binding = 0; +#else + zend_bool need_early_binding = processor->php_src->have_early_binding; +#endif + if (!processor->readonly_protection && !(src == processor->php_src->op_array && need_early_binding)) { /* really fast shallow copy */ memcpy(dst, src, sizeof(src[0])); dst->refcount[0] = 1000; @@ -632,6 +637,9 @@ DEF_STRUCT_P_FUNC(`zend_op_array', , `dnl {{{ DISPATCH(int, doc_comment_len) PROC_ZSTRING_L(, doc_comment, doc_comment_len) #endif +#ifdef ZEND_COMPILE_DELAYED_BINDING + DISPATCH(zend_uint, early_binding); +#endif /* reserved */ DONE(reserved) @@ -729,7 +737,9 @@ DEF_STRUCT_P_FUNC(`xc_classinfo_t', , `dnl {{{ #else STRUCT(zend_class_entry, cest) #endif +#ifndef ZEND_COMPILE_DELAYED_BINDING DISPATCH(int, oplineno) +#endif ') dnl }}} #ifdef ZEND_ENGINE_2_1 @@ -806,7 +816,9 @@ DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{ STRUCT_ARRAY(compilererror_cnt, xc_compilererror_t, compilererrors) ') #endif +#ifndef ZEND_COMPILE_DELAYED_BINDING DISPATCH(zend_bool, have_early_binding) +#endif DISPATCH(zend_bool, have_references) ') dnl }}} diff --git a/utils.c b/utils.c index aba5d50..4b3ae25 100644 --- a/utils.c +++ b/utils.c @@ -499,9 +499,11 @@ ZESW(xc_cest_t *, void) xc_install_class(char *filename, xc_cest_t *cest, int op cest, sizeof(xc_cest_t), ZESW(&stored_ce_ptr, NULL) ); +#ifndef ZEND_COMPILE_DELAYED_BINDING if (oplineno != -1) { xc_do_early_binding(CG(active_op_array), CG(class_table), oplineno TSRMLS_CC); } +#endif } else if (zend_u_hash_quick_add(CG(class_table), type, key, len, h, cest, sizeof(xc_cest_t), @@ -672,6 +674,13 @@ xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) / zend_error_cb = xc_sandbox_error_cb; #endif +#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES + sandbox->orig_compiler_options = CG(compiler_options); + /* Using ZEND_COMPILE_IGNORE_INTERNAL_CLASSES for ZEND_FETCH_CLASS_RT_NS_CHECK + */ + CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_DELAYED_BINDING; +#endif + XG(sandbox) = (void *) sandbox; return sandbox; } @@ -727,9 +736,13 @@ static void xc_sandbox_install(xc_sandbox_t *sandbox, xc_install_action_t instal #endif if (install != XC_InstallNoBinding) { +#ifdef ZEND_COMPILE_DELAYED_BINDING + zend_do_delayed_early_binding(CG(active_op_array) TSRMLS_CC); +#else xc_undo_pass_two(CG(active_op_array) TSRMLS_CC); xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC); xc_redo_pass_two(CG(active_op_array) TSRMLS_CC); +#endif } #ifdef E_STRICT @@ -804,6 +817,11 @@ void xc_sandbox_free(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_D efree(sandbox->compilererrors); } #endif + +#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES + CG(compiler_options) = sandbox->orig_compiler_options; +#endif + if (sandbox->alloc) { efree(sandbox); } diff --git a/utils.h b/utils.h index 69e90ae..ff81469 100644 --- a/utils.h +++ b/utils.h @@ -104,6 +104,10 @@ typedef struct { zend_uint compilererror_size; xc_compilererror_t *compilererrors; #endif + +#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES + zend_uint orig_compiler_options; +#endif } xc_sandbox_t; typedef enum _xc_install_action_t { diff --git a/xcache.c b/xcache.c index 2f0de76..84cd4d6 100644 --- a/xcache.c +++ b/xcache.c @@ -719,8 +719,13 @@ static zend_op_array *xc_entry_install(xc_entry_t *xce, zend_file_handle *h TSRM } new_cest_ptrs[i] = #endif +#ifdef ZEND_COMPILE_DELAYED_BINDING + xc_install_class(xce->name.str.val, &ci->cest, -1, + UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC); +#else xc_install_class(xce->name.str.val, &ci->cest, ci->oplineno, UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC); +#endif } #ifdef ZEND_ENGINE_2_1 @@ -1042,6 +1047,7 @@ static int xc_entry_init_key_php_md5(xc_entry_data_php_t *php, xc_entry_t *xce T return SUCCESS; } /* }}} */ +#ifndef ZEND_COMPILE_DELAYED_BINDING static void xc_cache_early_binding_class_cb(zend_op *opline, int oplineno, void *data TSRMLS_DC) /* {{{ */ { char *class_name; @@ -1069,6 +1075,7 @@ static void xc_cache_early_binding_class_cb(zend_op *opline, int oplineno, void } } /* }}} */ +#endif static void xc_free_php(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ { #define X_FREE(var) do {\ @@ -1237,6 +1244,7 @@ static zend_op_array *xc_compile_php(xc_entry_data_php_t *php, zend_file_handle php->compilererrors = ((xc_sandbox_t *) XG(sandbox))->compilererrors; php->compilererror_cnt = ((xc_sandbox_t *) XG(sandbox))->compilererror_cnt; #endif +#ifndef ZEND_COMPILE_DELAYED_BINDING /* {{{ find inherited classes that should be early-binding */ php->have_early_binding = 0; for (i = 0; i < php->classinfo_cnt; i ++) { @@ -1247,6 +1255,7 @@ static zend_op_array *xc_compile_php(xc_entry_data_php_t *php, zend_file_handle xc_foreach_early_binding_class(php->op_array, xc_cache_early_binding_class_cb, (void *) php TSRMLS_CC); xc_redo_pass_two(php->op_array TSRMLS_CC); /* }}} */ +#endif return op_array; diff --git a/xcache.h b/xcache.h index 575edf7..bebc1cb 100644 --- a/xcache.h +++ b/xcache.h @@ -242,7 +242,9 @@ typedef struct { zend_uint key_size; ulong h; xc_cest_t cest; +#ifndef ZEND_COMPILE_DELAYED_BINDING int oplineno; +#endif } xc_classinfo_t; /* }}} */ #ifdef HAVE_XCACHE_CONSTANT @@ -315,7 +317,9 @@ struct _xc_entry_data_php_t { zend_uint classinfo_cnt; xc_classinfo_t *classinfos; +#ifndef ZEND_COMPILE_DELAYED_BINDING zend_bool have_early_binding; +#endif #ifdef ZEND_ENGINE_2_1 zend_uint autoglobal_cnt;