From: Andi Gutmans Date: Thu, 24 Oct 2002 18:04:12 +0000 (+0000) Subject: - Improve performance of part of the jmps. More to follow. X-Git-Tag: php-4.3.0pre2~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80109314b918e776205003212e494bfbf4a559a3;p=php - Improve performance of part of the jmps. More to follow. --- diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index b919cd23b3..be6ed94078 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -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 { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 80187c6efe..7709d4bab0 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -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 */ } diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index 493d276c1a..fb7b8b2787 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -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; }