Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Improve performance of part of the jmps. More to follow.

  • Loading branch information...
commit 80109314b918e776205003212e494bfbf4a559a3 1 parent e4becf4
@andigutmans andigutmans authored
Showing with 18 additions and 8 deletions.
  1. +4 −2 Zend/zend_compile.h
  2. +4 −4 Zend/zend_execute.c
  3. +10 −2 Zend/zend_opcode.c
View
6 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 {
View
8 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 */
}
View
12 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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.