]> granicus.if.org Git - php/commitdiff
Changed exception handling. Now each op_array doesn't contain ZEND_HANDLE_EXCEPTION...
authorDmitry Stogov <dmitry@php.net>
Mon, 21 Jan 2008 19:39:55 +0000 (19:39 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 21 Jan 2008 19:39:55 +0000 (19:39 +0000)
NEWS
Zend/zend_compile.c
Zend/zend_exceptions.c
Zend/zend_execute.c
Zend/zend_execute_API.c
Zend/zend_globals.h
Zend/zend_language_scanner.l

diff --git a/NEWS b/NEWS
index 5a25980bfc23a021811397041d86f9c083346b74..9a511347fdf52711ba018fe8751fa86e9e249350 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -76,6 +76,9 @@ PHP                                                                        NEWS
   (Dmitry, Pierre)
 - Added lcfirst() function. (David C)
 
+- Changed exception handling. Now each op_array doesn't contain
+  ZEND_HANDLE_EXCEPTION opcode in the end. (Dmitry)
+
 - Fixed possible crash in ext/soap because of uninitialized value. (Zdash Urf)
 
 - Fixed bug #43808 (date_create never fails (even when it should)). (Derick)
index c5d061ede33aec59f1e8a3430d2f1b717c08ad32..68b27d5ebe24ad2f23260ee0333b57217214421a 100644 (file)
@@ -1303,7 +1303,6 @@ void zend_do_end_function_declaration(znode *function_token TSRMLS_DC)
 
        zend_do_extended_info(TSRMLS_C);
        zend_do_return(NULL, 0 TSRMLS_CC);
-       zend_do_handle_exception(TSRMLS_C);
 
        pass_two(CG(active_op_array) TSRMLS_CC);
 
index f226a09552b66e6f0afa6d7d0eede24973233618..15eb21433fc6902571aa94adb22ac038571d1e59 100644 (file)
@@ -26,6 +26,7 @@
 #include "zend_builtin_functions.h"
 #include "zend_interfaces.h"
 #include "zend_exceptions.h"
+#include "zend_vm.h"
 
 zend_class_entry *default_exception_ce;
 zend_class_entry *error_exception_ce;
@@ -55,7 +56,7 @@ void zend_throw_exception_internal(zval *exception TSRMLS_DC) /* {{{ */
                return;
        }
        EG(opline_before_exception) = EG(current_execute_data)->opline;
-       EG(current_execute_data)->opline = &EG(active_op_array)->opcodes[EG(active_op_array)->last-1-1];
+       EG(current_execute_data)->opline = EG(exception_op);
 }
 /* }}} */
 
@@ -567,6 +568,23 @@ void zend_register_default_exception(TSRMLS_D) /* {{{ */
 {
        zend_class_entry ce;
 
+       memset(EG(exception_op), 0, sizeof(EG(exception_op)));
+       EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION;
+       EG(exception_op)[0].op1.op_type = IS_UNUSED;
+       EG(exception_op)[0].op2.op_type = IS_UNUSED;
+       EG(exception_op)[0].result.op_type = IS_UNUSED;
+       ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op));
+       EG(exception_op)[1].opcode = ZEND_HANDLE_EXCEPTION;
+       EG(exception_op)[1].op1.op_type = IS_UNUSED;
+       EG(exception_op)[1].op2.op_type = IS_UNUSED;
+       EG(exception_op)[1].result.op_type = IS_UNUSED;
+       ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+1);
+       EG(exception_op)[2].opcode = ZEND_HANDLE_EXCEPTION;
+       EG(exception_op)[2].op1.op_type = IS_UNUSED;
+       EG(exception_op)[2].op2.op_type = IS_UNUSED;
+       EG(exception_op)[2].result.op_type = IS_UNUSED;
+       ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+2);
+
        INIT_CLASS_ENTRY(ce, "Exception", default_exception_functions);
        default_exception_ce = zend_register_internal_class(&ce TSRMLS_CC);
        default_exception_ce->create_object = zend_default_exception_new;
index f0283731db5cad7fb1ffab82bec83cd6ac09eacb..08ba4fa63e2c959d39c52c21068b173c920e16f5 100644 (file)
@@ -1446,15 +1446,14 @@ ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_v
        EX(opline) = new_op
 
 #define ZEND_VM_JMP(new_op) \
-     CHECK_SYMBOL_TABLES() \
-          EX(opline) = EG(exception)?EX(opline)+1:new_op; \
-     ZEND_VM_CONTINUE()
+       CHECK_SYMBOL_TABLES() \
+       if (EXPECTED(!EG(exception))) { \
+               EX(opline) = new_op; \
+       } \
+       ZEND_VM_CONTINUE()
 
 #define ZEND_VM_INC_OPCODE() \
-       if (!EG(exception)) { \
-               CHECK_SYMBOL_TABLES() \
-               EX(opline)++; \
-       }
+       EX(opline)++
 
 #define ZEND_VM_EXIT_FROM_EXECUTE_LOOP() \
        free_alloca(EX(CVs), EX(use_heap)); \
index 9b9b10055baa3b6641db8590d6fe57f118464916..d8ab3b7d854da21557d579ca25d71be2fcd44e6a 100644 (file)
@@ -1320,8 +1320,6 @@ void execute_new_code(TSRMLS_D) /* {{{ */
        INIT_ZVAL(ret_opline->op1.u.constant);
        SET_UNUSED(ret_opline->op2);
 
-       zend_do_handle_exception(TSRMLS_C);
-
        if (!CG(active_op_array)->start_op) {
                CG(active_op_array)->start_op = CG(active_op_array)->opcodes;
        }
@@ -1365,7 +1363,7 @@ void execute_new_code(TSRMLS_D) /* {{{ */
                zend_exception_error(EG(exception) TSRMLS_CC);
        }
 
-       CG(active_op_array)->last -= 2; /* get rid of that ZEND_RETURN and ZEND_HANDLE_EXCEPTION */
+       CG(active_op_array)->last -= 1; /* get rid of that ZEND_RETURN */
        CG(active_op_array)->start_op = CG(active_op_array)->opcodes+CG(active_op_array)->last;
 }
 /* }}} */
index 88da21372c2c14f4d2ffc9929f9a3e0742345a4a..1845b90a1505cd14bacece4bfa09f2bf96fdad16 100644 (file)
@@ -233,6 +233,7 @@ struct _zend_executor_globals {
        zend_objects_store objects_store;
        zval *exception;
        zend_op *opline_before_exception;
+       zend_op exception_op[3];
 
        struct _zend_execute_data *current_execute_data;
 
index 4f58c84315e37248857dc9edd2c94f04bdb6b95b..34078fdda0292707196ac007f1e13c85a82cc7e8 100644 (file)
@@ -399,7 +399,6 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSR
                CG(active_op_array) = op_array;
                compiler_result = zendparse(TSRMLS_C);
                zend_do_return(&retval_znode, 0 TSRMLS_CC);
-               zend_do_handle_exception(TSRMLS_C);
                CG(in_compilation) = original_in_compilation;
                if (compiler_result==1) { /* parser error */
                        zend_bailout();
@@ -572,7 +571,6 @@ zend_op_array *compile_string(zval *source_string, char *filename TSRMLS_DC)
                        retval = NULL;
                } else {
                        zend_do_return(NULL, 0 TSRMLS_CC);
-                       zend_do_handle_exception(TSRMLS_C);
                        CG(active_op_array) = original_active_op_array;
                        pass_two(op_array TSRMLS_CC);
                        retval = op_array;