From 14e29f51460ecd1ec9ae7a26dfb9dcb2c81768d5 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 12 Dec 2014 10:19:41 +0300 Subject: 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. --- ext/reflection/php_reflection.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 7d8f2b43ea..18906d6004 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -722,7 +722,7 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg zend_class_entry *old_scope; string_write(str, " = ", sizeof(" = ")-1); - ZVAL_DUP(&zv, precv->op2.zv); + ZVAL_DUP(&zv, RT_CONSTANT(&fptr->op_array, precv->op2)); old_scope = EG(scope); EG(scope) = fptr->common.scope; zval_update_constant_ex(&zv, 1, NULL TSRMLS_CC); @@ -2618,7 +2618,7 @@ ZEND_METHOD(reflection_parameter, getDefaultValue) return; } - ZVAL_COPY_VALUE(return_value, precv->op2.zv); + ZVAL_COPY_VALUE(return_value, RT_CONSTANT(¶m->fptr->op_array, precv->op2)); if (Z_CONSTANT_P(return_value)) { zend_class_entry *old_scope = EG(scope); @@ -2648,7 +2648,7 @@ ZEND_METHOD(reflection_parameter, isDefaultValueConstant) } precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); - if (precv && Z_TYPE_P(precv->op2.zv) == IS_CONSTANT) { + if (precv && Z_TYPE_P(RT_CONSTANT(¶m->fptr->op_array, precv->op2)) == IS_CONSTANT) { RETURN_TRUE; } @@ -2673,8 +2673,8 @@ ZEND_METHOD(reflection_parameter, getDefaultValueConstantName) } precv = _reflection_param_get_default_precv(INTERNAL_FUNCTION_PARAM_PASSTHRU, param); - if (precv && Z_TYPE_P(precv->op2.zv) == IS_CONSTANT) { - RETURN_STR(zend_string_copy(Z_STR_P(precv->op2.zv))); + if (precv && Z_TYPE_P(RT_CONSTANT(¶m->fptr->op_array, precv->op2)) == IS_CONSTANT) { + RETURN_STR(zend_string_copy(Z_STR_P(RT_CONSTANT(¶m->fptr->op_array, precv->op2)))); } } /* }}} */ -- cgit v1.2.1