com php-src: Adjust tempoary variable used in caller's side: ext/opcache/Optimizer/optimize_temp_vars_5.c
| From: | Xinchen Hui | Date: | Thu, 25 Dec 2014 06:57:58 +0000 |
| Subject: | com php-src: Adjust tempoary variable used in caller's side: ext/opcache/Optimizer/optimize_temp_vars_5.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83864@lists.php.net to get a copy of this message | ||
Commit: 3d4babdc2b03515fa30e382125a7e79d10bafe7e
Author: Xinchen Hui <laruence@gmail.com> Thu, 25 Dec 2014 14:27:20 +0800
Parents: 457c53182b9945d941ef50c658920768888d3f68
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3d4babdc2b03515fa30e382125a7e79d10bafe7e
Log:
Adjust tempoary variable used in caller's side
Changed paths:
M ext/opcache/Optimizer/optimize_temp_vars_5.c
Diff:
diff --git a/ext/opcache/Optimizer/optimize_temp_vars_5.c
b/ext/opcache/Optimizer/optimize_temp_vars_5.c
index a7838cb..cb7d4e4 100644
--- a/ext/opcache/Optimizer/optimize_temp_vars_5.c
+++ b/ext/opcache/Optimizer/optimize_temp_vars_5.c
@@ -37,6 +37,54 @@
if (i > max) { \
max = i; \
}
+
+void optimize_adjust_fcall_stack_size(zend_op_array *callee, uint32_t delta, zend_optimizer_ctx
*ctx) {
+ zval *val;
+ zend_op *start, *end;
+ zend_op_array *op_array;
+ zend_string *name;
+
+ if (!delta || !callee->function_name) {
+ return;
+ }
+
+ name = zend_string_tolower(callee->function_name);
+ op_array = &ctx->script->main_op_array;
+ start = op_array->opcodes;
+ end = op_array->opcodes + op_array->last - 1;
+ while (start < end) {
+ if (start->opcode == ZEND_INIT_FCALL) {
+ zval *zv = RT_CONSTANT(op_array, start->op2);
+ if (Z_STR_P(zv) == name ||
+ ((Z_STRLEN_P(zv) == name->len) &&
+ !memcmp(Z_STRVAL_P(zv), name->val, name->len))) {
+ start->op1.num -= (delta * sizeof(zval));
+ }
+ }
+ start++;
+ }
+
+ ZEND_HASH_REVERSE_FOREACH_VAL(&ctx->script->function_table, val) {
+ op_array = Z_PTR_P(val);
+ if (op_array == callee) {
+ continue; /* we can not break here */
+ }
+ start = op_array->opcodes;
+ end = op_array->opcodes + op_array->last - 1;
+ while (start < end) {
+ if (start->opcode == ZEND_INIT_FCALL) {
+ zval *zv = RT_CONSTANT(op_array, start->op2);
+ if (Z_STR_P(zv) == name ||
+ ((Z_STRLEN_P(zv) == name->len) &&
+ !memcmp(Z_STRVAL_P(zv), name->val, name->len))) {
+ start->op1.num -= (delta * sizeof(zval));
+ }
+ }
+ start++;
+ }
+ } ZEND_HASH_FOREACH_END();
+ zend_string_release(name);
+}
void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer_ctx *ctx)
{
@@ -180,5 +228,8 @@ void optimize_temporary_variables(zend_op_array *op_array, zend_optimizer_ctx *c
}
zend_arena_release(&ctx->arena, checkpoint);
+ if (op_array->scope == NULL) {
+ optimize_adjust_fcall_stack_size(op_array, op_array->T - (max + 1), ctx);
+ }
op_array->T = max + 1;
}