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

diff --git a/NEWS b/NEWS
index c072888ff70af97e121c780f59f4637b4fe3202a..01e22c54b7520f898aa174264dc448c5f8d37341 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP                                                                        NEWS
 ?? ??? 2006, PHP 5.2.0
 - Disable realpath cache when open_basedir or safe_mode are enabled on a 
   per-request basis. (Ilia)
+- Optimized zend_try/zend_catch macroses (eliminated memcpy()). (Dmitry)
 - Optimized require_once/include_once (eliminated fopen() on second usage).
   (Dmitry)
 - Optimized request shutdown sequence. Restoring ini directives now
index d52b43a9fb67c1ff65be8a7150d9da3687f40710..b445e3409002e4cf7d47c00cd420d53b3bf66f6e 100644 (file)
@@ -760,14 +760,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 b9557af3620e8be665a4a4574ed92a3b8f297520..7d4ea5b52f0c8022c01797f84653396df0f1107a 100644 (file)
@@ -448,19 +448,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 9fa0e1fd5127bc5701226bfbdf3f8f2a608de2a9..2ae7bb25c03ac12d17a6c8e8d6ceb3664cc04087 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  220060510
+#define ZEND_EXTENSION_API_NO  220060519
 
 typedef struct _zend_extension_version_info {
        int zend_extension_api_no;
index ea2d4f219e61fefe0c28cd4e371a6dd97765ce66..d1bda5b0646442cdebbd0db732837230e6b84e8e 100644 (file)
@@ -176,7 +176,7 @@ struct _zend_executor_globals {
 
        HashTable included_files;       /* files already included */
 
-       jmp_buf bailout;
+       jmp_buf *bailout;
 
        int error_reporting;
        int orig_error_reporting;
@@ -199,7 +199,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 e495de48e9fabe39ea96223ed0bb1e9ed4f59757..fbc35c71eb83be5ce8061505a925ce98ed3e3023 100644 (file)
@@ -2366,13 +2366,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 9335f3dc7311c15661c95aaf6b611d2f3c819be1..c22071632f2b1f7d8bb5e39b708b9955c0deda4e 100644 (file)
@@ -1437,7 +1437,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;