]> granicus.if.org Git - php/commitdiff
- Improve performance of part of the jmps. More to follow.
authorAndi Gutmans <andi@php.net>
Thu, 24 Oct 2002 18:04:12 +0000 (18:04 +0000)
committerAndi Gutmans <andi@php.net>
Thu, 24 Oct 2002 18:04:12 +0000 (18:04 +0000)
Zend/zend_compile.h
Zend/zend_execute.c
Zend/zend_opcode.c

index b919cd23b38cccc32c526bfdf66762b59c90b897..be6ed9407850836df02b1058d33e69f00a539164 100644 (file)
@@ -41,6 +41,7 @@
 #define HANDLE_INTERACTIVE()  if (CG(interactive)) { execute_new_code(TSRMLS_C); }
 
 typedef struct _zend_op_array zend_op_array;
+typedef struct _zend_op zend_op;
 
 typedef struct _znode {
        int op_type;
@@ -52,6 +53,7 @@ typedef struct _znode {
                zend_uint opline_num; /*  Needs to be signed */
                zend_op_array *op_array;
                zend_class_entry *previously_active_class_entry; /* Used at compile-time */
+               zend_op *jmp_addr;
                struct {
                        zend_uint var;  /* dummy */
                        zend_uint type;
@@ -68,7 +70,7 @@ typedef int (*opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS);
 
 extern opcode_handler_t zend_opcode_handlers[512];
 
-typedef struct _zend_op {
+struct _zend_op {
        zend_uchar opcode;
        znode result;
        znode op1;
@@ -76,7 +78,7 @@ typedef struct _zend_op {
        ulong extended_value;
        uint lineno;
        opcode_handler_t handler;
-} zend_op;
+};
 
 
 typedef struct _zend_brk_cont_element {
index 80187c6efea63b8f9c5150d16ba954671386869a..7709d4bab034ad952f6bcc5def3c2bc64704dc01 100644 (file)
@@ -5,7 +5,7 @@
    | Copyright (c) 1998-2002 Zend Technologies Ltd. (http://www.zend.com) |
    +----------------------------------------------------------------------+
    | This source file is subject to version 2.00 of the Zend license,     |
-   | that is bundled with this package in the file LICENSE, and is        | 
+   | that is bundled with this package in the file LICENSE, and is        |
    | available at through the world-wide-web at                           |
    | http://www.zend.com/license/2_00.txt.                                |
    | If you did not receive a copy of the Zend license and are unable to  |
@@ -1869,7 +1869,7 @@ int zend_jmp_handler(ZEND_OPCODE_HANDLER_ARGS)
 #if DEBUG_ZEND>=2
        printf("Jumping to %d\n", EX(opline)->op1.u.opline_num);
 #endif
-       EX(opline) = &op_array->opcodes[EX(opline)->op1.u.opline_num];
+       EX(opline) = EX(opline)->op1.u.jmp_addr;
        return 0; /* CHECK_ME */
 }
 
@@ -1881,7 +1881,7 @@ int zend_jmpz_handler(ZEND_OPCODE_HANDLER_ARGS)
 #if DEBUG_ZEND>=2
                printf("Conditional jmp to %d\n", EX(opline)->op2.u.opline_num);
 #endif
-               EX(opline) = &op_array->opcodes[EX(opline)->op2.u.opline_num];
+               EX(opline) = EX(opline)->op2.u.jmp_addr;
                FREE_OP(EX(Ts), op1, EG(free_op1));
                return 0; /* CHECK_ME */
        }
@@ -1898,7 +1898,7 @@ int zend_jmpnz_handler(ZEND_OPCODE_HANDLER_ARGS)
 #if DEBUG_ZEND>=2
                printf("Conditional jmp to %d\n", EX(opline)->op2.u.opline_num);
 #endif
-               EX(opline) = &op_array->opcodes[EX(opline)->op2.u.opline_num];
+               EX(opline) = EX(opline)->op2.u.jmp_addr;
                FREE_OP(EX(Ts), op1, EG(free_op1));
                return 0; /* CHECK_ME */
        }
index 493d276c1a8f08a4e096f717f263023d4c2c8ba3..fb7b8b27871cba427bf1455d81f68fa964906d43 100644 (file)
@@ -295,6 +295,9 @@ int pass_two(zend_op_array *op_array TSRMLS_DC)
                zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_op_array_handler, op_array TSRMLS_CC);
        }
 
+       op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
+       op_array->size = op_array->last;
+
        opline = op_array->opcodes;
        end = opline + op_array->last;
        while (opline < end) {
@@ -306,11 +309,16 @@ int pass_two(zend_op_array *op_array TSRMLS_DC)
                        opline->op2.u.constant.is_ref = 1;
                        opline->op2.u.constant.refcount = 2;
                }
+               if (opline->opcode == ZEND_JMP) {
+                       opline->op1.u.jmp_addr = &op_array->opcodes[opline->op1.u.opline_num];
+               }
+               if (opline->opcode == ZEND_JMPZ || opline->opcode == ZEND_JMPNZ) {
+                       opline->op2.u.jmp_addr = &op_array->opcodes[opline->op2.u.opline_num];
+               }
                opline->handler = zend_opcode_handlers[opline->opcode];
                opline++;
        }
-       op_array->opcodes = (zend_op *) erealloc(op_array->opcodes, sizeof(zend_op)*op_array->last);
-       op_array->size = op_array->last;
+       
        op_array->done_pass_two = 1;
        return 0;
 }