diff options
author | Dmitry Stogov <dmitry@zend.com> | 2014-12-12 10:19:41 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2014-12-12 10:19:41 +0300 |
commit | 14e29f51460ecd1ec9ae7a26dfb9dcb2c81768d5 (patch) | |
tree | 98658f59f7973c3bcc538ddea39e3a4953fb325c /sapi/phpdbg/phpdbg_opcode.c | |
parent | 9ea35a37b9425fc0dc392a754dac7e53791f5521 (diff) | |
download | php-git-14e29f51460ecd1ec9ae7a26dfb9dcb2c81768d5.tar.gz |
Reduced size of zend_op on 64-bit systems.
the main idea - the smaller the zend_op structure, the lees memory traffic is required to load VM instructions during execution. The patch reduces the size of each opcode from 48 to 32 bytes (saves 16 bytes for each opcode, and applications use thousands of opoceds). This reduced the number of CPU cache misses by 12% and improved performance of real-life apps by 1-2%.
The patch affects how constants and jump targets are represented in VM during execution. Previously they were implemented as absolute 64-bit pointers. Now they are relative 32-bit offsets.
In run-time constant now should be accessed as:
RT_CONSTANT(op_array, opine->op1) instead of opline->op1.zv
EX_CONSTANT(opline->op1) instead of opline->op1.zv
Jump targets:
OP_JMP_ADDR(opline, opline->op2) instead of opline->op2.jmp_addr
The patch doesn't change zend_op representation for 32-bit systems. They still use absolute addresses. The compile-time representation is also kept the same.
Diffstat (limited to 'sapi/phpdbg/phpdbg_opcode.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_opcode.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sapi/phpdbg/phpdbg_opcode.c b/sapi/phpdbg/phpdbg_opcode.c index 99f43344a4..20841cbc42 100644 --- a/sapi/phpdbg/phpdbg_opcode.c +++ b/sapi/phpdbg/phpdbg_opcode.c @@ -64,7 +64,7 @@ static inline char *phpdbg_decode_op(zend_op_array *ops, znode_op *op, uint32_t } break; case IS_CONST: - asprintf(&decode, "C%u", phpdbg_decode_literal(ops, op->zv TSRMLS_CC)); + asprintf(&decode, "C%u", phpdbg_decode_literal(ops, RT_CONSTANT(ops, *op) TSRMLS_CC)); break; case IS_UNUSED: @@ -86,7 +86,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRM #ifdef ZEND_FAST_CALL case ZEND_FAST_CALL: #endif - asprintf(&decode[1], "J%ld", op->op1.jmp_addr - ops->opcodes); + asprintf(&decode[1], "J%ld", OP_JMP_ADDR(op, op->op1) - ops->opcodes); goto format; case ZEND_JMPZNZ: @@ -103,7 +103,7 @@ char *phpdbg_decode_opline(zend_op_array *ops, zend_op *op, HashTable *vars TSRM case ZEND_JMP_SET: #endif decode[1] = phpdbg_decode_op(ops, &op->op1, op->op1_type, vars TSRMLS_CC); - asprintf(&decode[2], "J%ld", op->op2.jmp_addr - ops->opcodes); + asprintf(&decode[2], "J%ld", OP_JMP_ADDR(op, op->op2) - ops->opcodes); goto result; case ZEND_RECV_INIT: |