mirror of
https://github.com/php/php-src.git
synced 2026-03-29 03:32:20 +02:00
Added ZEND_COMPILE_WITHOUT_EXECUTION and ZEND_COMPILE_PRELOAD to determine when PHP compiler is invoked by opcache_compile_file() or preloading.
This commit is contained in:
@@ -1042,6 +1042,12 @@ END_EXTERN_C()
|
||||
/* ignore functions and classes declared in other files */
|
||||
#define ZEND_COMPILE_IGNORE_OTHER_FILES (1<<12)
|
||||
|
||||
/* this flag is set when compiler invoked by opcache_compile_file() */
|
||||
#define ZEND_COMPILE_WITHOUT_EXECUTION (1<<13)
|
||||
|
||||
/* this flag is set when compiler invoked during preloading */
|
||||
#define ZEND_COMPILE_PRELOAD (1<<14)
|
||||
|
||||
/* The default value for CG(compiler_options) */
|
||||
#define ZEND_COMPILE_DEFAULT ZEND_COMPILE_HANDLE_OP_ARRAY
|
||||
|
||||
|
||||
@@ -3749,6 +3749,7 @@ static int accel_preload(const char *config)
|
||||
accelerator_orig_compile_file = preload_compile_file;
|
||||
|
||||
orig_compiler_options = CG(compiler_options);
|
||||
CG(compiler_options) |= ZEND_COMPILE_PRELOAD;
|
||||
CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY;
|
||||
// CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES;
|
||||
CG(compiler_options) |= ZEND_COMPILE_DELAYED_BINDING;
|
||||
|
||||
@@ -844,6 +844,7 @@ static ZEND_FUNCTION(opcache_compile_file)
|
||||
zend_file_handle handle;
|
||||
zend_op_array *op_array = NULL;
|
||||
zend_execute_data *orig_execute_data = NULL;
|
||||
uint32_t orig_compiler_options;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &script_name, &script_name_len) == FAILURE) {
|
||||
return;
|
||||
@@ -855,6 +856,8 @@ static ZEND_FUNCTION(opcache_compile_file)
|
||||
handle.type = ZEND_HANDLE_FILENAME;
|
||||
|
||||
orig_execute_data = EG(current_execute_data);
|
||||
orig_compiler_options = CG(compiler_options);
|
||||
CG(compiler_options) |= ZEND_COMPILE_WITHOUT_EXECUTION;
|
||||
|
||||
zend_try {
|
||||
op_array = persistent_compile_file(&handle, ZEND_INCLUDE);
|
||||
@@ -863,6 +866,8 @@ static ZEND_FUNCTION(opcache_compile_file)
|
||||
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " could not compile file %s", handle.filename);
|
||||
} zend_end_try();
|
||||
|
||||
CG(compiler_options) = orig_compiler_options;
|
||||
|
||||
if(op_array != NULL) {
|
||||
destroy_op_array(op_array);
|
||||
efree(op_array);
|
||||
|
||||
Reference in New Issue
Block a user