diff options
| author | Zeev Suraski <zeev@php.net> | 2000-08-09 19:22:35 +0000 |
|---|---|---|
| committer | Zeev Suraski <zeev@php.net> | 2000-08-09 19:22:35 +0000 |
| commit | c06692e9ec92bdbe22e7a4149b5365635c4ad950 (patch) | |
| tree | fb3e7ccb8c5187dd8d39aacd97d2707739982769 /Zend/zend.c | |
| parent | 609577d8826e5a23565eb8fdf5033d60ed505c4e (diff) | |
| download | php-git-c06692e9ec92bdbe22e7a4149b5365635c4ad950.tar.gz | |
The patch we promised - redesigned the compilation/execution API:
Advantages:
- Smaller memory footprint for the op arrays
- Slightly faster compilation times (due to saved erealloc() calls and faster zend_op
initialization)
- include_once() & require_once() share the same file list
- Consistency between include() and require() - this mostly means that return()
works inside require()'d files just as it does in include() files (it used to
be meaningless in require()'d files, most of the time (see below))
- Made require() consistent with itself. Before, if the argument was not a constant
string, require() took the include() behavior (with return()).
- Removed lots of duplicate code.
Bottom line - require() and include() are very similar now; require() is simply an include()
which isn't allowed to fail. Due to the erealloc() calls for large op arrays, require()
didn't end up being any faster than include() in the Zend engine.
Diffstat (limited to 'Zend/zend.c')
| -rw-r--r-- | Zend/zend.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Zend/zend.c b/Zend/zend.c index 7c73765dfd..5a12267e9c 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -357,7 +357,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i zend_get_ini_entry_p = utility_functions->get_ini_entry; zend_ticks_function = utility_functions->ticks_function; - zend_v_compile_files = v_compile_files; + zend_compile_file = compile_file; zend_execute = execute; zend_startup_extensions(); @@ -692,3 +692,35 @@ ZEND_API void zend_output_debug_string(zend_bool trigger_break, char *format, .. va_end(args); #endif } + + +ZEND_API int zend_execute_scripts(int type CLS_DC ELS_DC, int file_count, ...) +{ + va_list files; + int i; + zend_file_handle *file_handle; + + va_start(files, file_count); + for (i=0; i<file_count; i++) { + file_handle = va_arg(files, zend_file_handle *); + if (!file_handle) { + continue; + } + EG(active_op_array) = zend_compile_file(file_handle CLS_CC); + if (EG(active_op_array)) { + zend_execute(EG(active_op_array) ELS_CC); + zval_ptr_dtor(EG(return_value_ptr_ptr)); + EG(return_value_ptr_ptr) = &EG(global_return_value_ptr); + EG(global_return_value_ptr) = NULL; + destroy_op_array(EG(active_op_array)); + efree(EG(active_op_array)); + } else if (type==ZEND_REQUIRE) { + va_end(files); + return FAILURE; + } + } + va_end(files); + + return SUCCESS; +} + |
