com php-src: Fix update_opX_const lowercasing: Zend/t ests/varSyntax/static_prop_on_expr_class.phpt ext/o pcache/Optimizer/zend_optimizer.c
| From: | Nikita Popov | Date: | Sat, 07 Nov 2015 11:04:51 +0000 |
| Subject: | com php-src: Fix update_opX_const lowercasing: Zend/t ests/varSyntax/static_prop_on_expr_class.phpt ext/o pcache/Optimizer/zend_optimizer.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89627@lists.php.net to get a copy of this message | ||
Commit: 632bee4abbcca0f3ab6ec2b15c87fb946b6d7129
Author: Nikita Popov <nikic@php.net> Fri, 6 Nov 2015 23:00:39 +0100
Parents: c263dcee2ff727946b66380b6374f5d753bd8d36
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=632bee4abbcca0f3ab6ec2b15c87fb946b6d7129
Log:
Fix update_opX_const lowercasing
It was lowering in-place.
Changed paths:
A Zend/tests/varSyntax/static_prop_on_expr_class.phpt
M ext/opcache/Optimizer/zend_optimizer.c
Diff:
diff --git a/Zend/tests/varSyntax/static_prop_on_expr_class.phpt
b/Zend/tests/varSyntax/static_prop_on_expr_class.phpt
new file mode 100644
index 0000000..d17b6cd
--- /dev/null
+++ b/Zend/tests/varSyntax/static_prop_on_expr_class.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Accessing a static property on a statically evaluable class expression
+--FILE--
+<?php
+
+class A {
+ public static $b = 42;
+}
+var_dump(('A' . (string) '')::$b);
+
+?>
+--EXPECT--
+int(42)
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index 22bb806..1f5e4f1 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -110,6 +110,13 @@ int zend_optimizer_add_literal(zend_op_array *op_array, zval *zv)
return i;
}
+static inline int zend_optimizer_add_literal_string(zend_op_array *op_array, zend_string *str) {
+ zval zv;
+ ZVAL_STR(&zv, str);
+ zend_string_hash_val(str);
+ return zend_optimizer_add_literal(op_array, &zv);
+}
+
int zend_optimizer_is_disabled_func(const char *name, size_t len) {
zend_function *fbc = (zend_function *)zend_hash_str_find_ptr(EG(function_table), name, len);
@@ -137,9 +144,7 @@ void zend_optimizer_update_op1_const(zend_op_array *op_array,
zend_string_hash_val(Z_STR(ZEND_OP1_LITERAL(opline)));
Z_CACHE_SLOT(op_array->literals[opline->op1.constant]) = op_array->cache_size;
op_array->cache_size += sizeof(void*);
- zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
- zend_optimizer_add_literal(op_array, val);
- zend_string_hash_val(Z_STR(op_array->literals[opline->op1.constant+1]));
+ zend_optimizer_add_literal_string(op_array, zend_string_tolower(Z_STR_P(val)));
break;
default:
opline->op1.constant = zend_optimizer_add_literal(op_array, val);
@@ -195,23 +200,17 @@ void zend_optimizer_update_op2_const(zend_op_array *op_array,
case ZEND_INSTANCEOF:
Z_CACHE_SLOT(op_array->literals[opline->op2.constant]) = op_array->cache_size;
op_array->cache_size += sizeof(void*);
- zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
- zend_optimizer_add_literal(op_array, val);
- zend_string_hash_val(Z_STR(op_array->literals[opline->op2.constant+1]));
+ zend_optimizer_add_literal_string(op_array, zend_string_tolower(Z_STR_P(val)));
break;
case ZEND_INIT_DYNAMIC_CALL:
opline->opcode = ZEND_INIT_FCALL_BY_NAME;
Z_CACHE_SLOT(op_array->literals[opline->op2.constant]) = op_array->cache_size;
op_array->cache_size += sizeof(void*);
- zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
- zend_optimizer_add_literal(op_array, val);
- zend_string_hash_val(Z_STR(op_array->literals[opline->op2.constant+1]));
+ zend_optimizer_add_literal_string(op_array, zend_string_tolower(Z_STR_P(val)));
break;
case ZEND_INIT_METHOD_CALL:
case ZEND_INIT_STATIC_METHOD_CALL:
- zend_str_tolower(Z_STRVAL_P(val), Z_STRLEN_P(val));
- zend_optimizer_add_literal(op_array, val);
- zend_string_hash_val(Z_STR(op_array->literals[opline->op2.constant+1]));
+ zend_optimizer_add_literal_string(op_array, zend_string_tolower(Z_STR_P(val)));
/* break missing intentionally */
/*case ZEND_FETCH_CONSTANT:*/
case ZEND_ASSIGN_OBJ: