]> granicus.if.org Git - php/commitdiff
Optimized zend_try/zend_catch macroses (eliminated memcpy())
authorDmitry Stogov <dmitry@php.net>
Fri, 19 May 2006 06:11:02 +0000 (06:11 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 19 May 2006 06:11:02 +0000 (06:11 +0000)
Zend/zend.c
Zend/zend.h
Zend/zend_extensions.h
Zend/zend_globals.h
ext/standard/basic_functions.c
main/main.c

index db3dcf2cea1b15e96b2ab15a4fc56e66d62e449a..6afcf6d369c0281665498a4ae5f00f406654ba67 100644 (file)
@@ -1192,14 +1192,14 @@ ZEND_API void _zend_bailout(char *filename, uint lineno)
 {
        TSRMLS_FETCH();
 
-       if (!EG(bailout_set)) {
+       if (!EG(bailout)) {
                zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno);
                exit(-1);
        }
        CG(unclean_shutdown) = 1;
        CG(in_compilation) = EG(in_execution) = 0;
        EG(current_execute_data) = NULL;
-       longjmp(EG(bailout), FAILURE);
+       longjmp(*EG(bailout), FAILURE);
 }
 END_EXTERN_C()
 
index 493ac8b01e56b19f8eaeda8ba318e827b68ce783..87fd9d839e39bea95b06c529ff3e1854863a479a 100644 (file)
@@ -489,19 +489,19 @@ END_EXTERN_C()
 
 #define zend_try                                                                                               \
        {                                                                                                                       \
-               jmp_buf orig_bailout;                                                                   \
-               zend_bool orig_bailout_set=EG(bailout_set);                             \
+               jmp_buf *orig_bailout = EG(bailout);                                    \
+               jmp_buf bailout;                                                                                \
                                                                                                                                \
-               EG(bailout_set) = 1;                                                                    \
-               memcpy(&orig_bailout, &EG(bailout), sizeof(jmp_buf));   \
-               if (setjmp(EG(bailout))==0)
+               EG(bailout) = &bailout;                                                                 \
+               if (setjmp(bailout)==0) {
 #define zend_catch                                                                                             \
-               else
+               } else {                                                                                                \
+                       EG(bailout) = orig_bailout;
 #define zend_end_try()                                                                                 \
-               memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf));   \
-               EG(bailout_set) = orig_bailout_set;                                             \
+               }                                                                                                               \
+               EG(bailout) = orig_bailout;                                                             \
        }
-#define zend_first_try         EG(bailout_set)=0;      zend_try
+#define zend_first_try         EG(bailout)=NULL;       zend_try
 
 BEGIN_EXTERN_C()
 ZEND_API char *get_zend_version(void);
index 268f013663f64e122ea71a58cbc9e9338eefdfa4..58a26d6c72f49041628c38669e7683dfbdb0d948 100644 (file)
@@ -27,7 +27,7 @@
 /* The first number is the engine version and the rest is the date.
  * This way engine 2/3 API no. is always greater than engine 1 API no..
  */
-#define ZEND_EXTENSION_API_NO  320051025
+#define ZEND_EXTENSION_API_NO  320060519
 
 typedef struct _zend_extension_version_info {
        int zend_extension_api_no;
index 1c6d5c46031efbb3c4d1d68c6bd527b18673dc98..6c423cc515c7c37cdc8e01fa38517fc7682212be 100644 (file)
@@ -169,7 +169,7 @@ struct _zend_executor_globals {
 
        HashTable included_files;       /* files already included */
 
-       jmp_buf bailout;
+       jmp_buf *bailout;
 
        int error_reporting;
        int orig_error_reporting;
@@ -192,7 +192,6 @@ struct _zend_executor_globals {
        zend_bool in_execution;
        HashTable *in_autoload;
        zend_function *autoload_func;
-       zend_bool bailout_set;
        zend_bool full_tables_cleanup;
 
        /* for extended information support */
index 317ef378033e0d23d278a6f15a150115d5ee9f49..32643ea3b86b0a7a0eb7aa3365b42139210113ed 100644 (file)
@@ -2316,13 +2316,13 @@ static int user_tick_function_compare(user_tick_function_entry * tick_fe1, user_
 
 void php_call_shutdown_functions(TSRMLS_D)
 {
-       if (BG(user_shutdown_function_names))
+       if (BG(user_shutdown_function_names)) {
                zend_try {
                        zend_hash_apply(BG(user_shutdown_function_names), (apply_func_t) user_shutdown_function_call TSRMLS_CC);
-                       memcpy(&EG(bailout), &orig_bailout, sizeof(jmp_buf));
-                       php_free_shutdown_functions(TSRMLS_C);
                }
                zend_end_try();
+               php_free_shutdown_functions(TSRMLS_C);
+       }
 }
 
 void php_free_shutdown_functions(TSRMLS_D)
index 0fc8da9940b2577ef44eb9a6ae30c721e89df2b2..7910e9120f5da0ce0d82bae04222f76631688d52 100644 (file)
@@ -1540,7 +1540,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, NULL);
        core_globals = ts_resource(core_globals_id);
 #endif
-       EG(bailout_set) = 0;
+       EG(bailout) = NULL;
        EG(error_reporting) = E_ALL & ~E_NOTICE;
 
        PG(header_is_being_sent) = 0;