com php-src: Speed up self::$property access by 20%: Zend/zend_compile.c
| From: | Bob Weinand | Date: | Mon, 05 Oct 2015 19:52:09 +0000 |
| Subject: | com php-src: Speed up self::$property access by 20%: Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89298@lists.php.net to get a copy of this message | ||
Commit: 0fbd3e5fe7c2df5f8eb8cf2f217902f80a9fd894
Author: Bob Weinand <bobwei9@hotmail.com> Mon, 5 Oct 2015 21:52:09 +0200
Parents: 8c33bdb976e957ea67ebffd424e0a133a79c6ebe
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0fbd3e5fe7c2df5f8eb8cf2f217902f80a9fd894
Log:
Speed up self::$property access by 20%
Changed paths:
M Zend/zend_compile.c
Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 6d8f794..56d946b 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -2368,12 +2368,21 @@ zend_op *zend_compile_static_prop_common(znode *result, zend_ast *ast,
uint32_t
znode class_node, prop_node;
zend_op *opline;
+ uint32_t fetch_type = class_ast->kind == ZEND_AST_ZVAL ?
zend_get_class_fetch_type_ast(class_ast) : -1;
- if (zend_is_const_default_class_ref(class_ast)) {
+ if (fetch_type == ZEND_FETCH_CLASS_DEFAULT) {
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, 1);
+ /* we do not have any reference to the extends_ast/name of parent at compile-time, hence only
resolving self:: for now */
+ if (zend_is_scope_known() && fetch_type == ZEND_FETCH_CLASS_SELF) {
+ zend_ensure_valid_class_fetch_type(fetch_type);
+
+ class_node.op_type = IS_CONST;
+ ZVAL_STR_COPY(&class_node.u.constant, CG(active_class_entry)->name);
+ } else {
+ zend_compile_class_ref(&class_node, class_ast, 1);
+ }
}
zend_compile_expr(&prop_node, prop_ast);
@@ -3315,7 +3324,7 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /*
{{
class_node.op_type = IS_CONST;
ZVAL_STR_COPY(&class_node.u.constant, CG(active_class_entry)->name);
} else {
- opline = zend_compile_class_ref(&class_node, class_ast, 1);
+ zend_compile_class_ref(&class_node, class_ast, 1);
}
}