com php-src: Inline self-constants if possible at compile time: Zend/zend_compile.c
| From: | Bob Weinand | Date: | Sat, 24 Jan 2015 18:19:02 +0000 |
| Subject: | com php-src: Inline self-constants if possible at compile time: Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84354@lists.php.net to get a copy of this message | ||
Commit: f3675d950d8b9847ed390e7a4d2d94d992909845
Author: Bob Weinand <bobwei9@hotmail.com> Sat, 24 Jan 2015 19:19:02 +0100
Parents: a98fd7125ac9165822fa34a01e35a97a2076c3b9
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f3675d950d8b9847ed390e7a4d2d94d992909845
Log:
Inline self-constants if possible at compile time
Changed paths:
M Zend/zend_compile.c
Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 274920c..77dd639 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5720,17 +5720,32 @@ void zend_compile_class_const(znode *result, zend_ast *ast) /* {{{ */
zend_ast *const_ast = ast->child[1];
znode class_node, const_node;
- zend_op *opline;
+ zend_op *opline, *class_op = NULL;
if (zend_is_const_default_class_ref(class_ast)) {
class_node.op_type = IS_CONST;
ZVAL_STR(&class_node.u.constant, zend_resolve_class_name_ast(class_ast));
} else {
- zend_compile_class_ref(&class_node, class_ast);
+ class_op = zend_compile_class_ref(&class_node, class_ast);
}
zend_compile_expr(&const_node, const_ast);
+ if (class_op && const_node.op_type == IS_CONST && class_op->extended_value ==
ZEND_FETCH_CLASS_SELF && Z_TYPE(const_node.u.constant) == IS_STRING)
+ zval *const_zv = zend_hash_find(&CG(active_class_entry)->constants_table,
Z_STR(const_node.u.constant))
+ if (const_zv && Z_TYPE_P(const_zv) < IS_CONSTANT) {
+ CG(active_op_array)->last--;
+ CG(active_op_array)->T--;
+
+ result->op_type = IS_CONST;
+ Z_TRY_ADDREF_P(const_zv);
+ result->u.constant = *const_zv;
+
+ zend_string_release(Z_STR(const_node.u.constant));
+ return;
+ }
+ }
+
opline = zend_emit_op_tmp(result, ZEND_FETCH_CONSTANT, NULL, &const_node);
zend_set_class_name_op1(opline, &class_node);