com php-src: Fix compact_literals of INIT_METHOD_CALL with CONST op1: ext/opcache/Optimizer/compact_li terals.c
ext/opcache/tests/method_call_on_literal.p hpt
| From: | Nikita Popov | Date: | Sat, 15 Apr 2017 10:35:09 +0000 |
| Subject: | com php-src: Fix compact_literals of INIT_METHOD_CALL with CONST op1: ext/opcache/Optimizer/compact_li terals.c ext/opcache/tests/method_call_on_literal.p hpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97617@lists.php.net to get a copy of this message | ||
Commit: 0beccc51f1bf44fb3efeb1131f8c86eb7dc5014f
Author: Nikita Popov <nikita.ppv@gmail.com> Sat, 15 Apr 2017 12:35:09 +0200
Parents: 35a28fac51e4b210f8f3f51b754786908a977462
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0beccc51f1bf44fb3efeb1131f8c86eb7dc5014f
Log:
Fix compact_literals of INIT_METHOD_CALL with CONST op1
Changed paths:
M ext/opcache/Optimizer/compact_literals.c
A ext/opcache/tests/method_call_on_literal.phpt
Diff:
diff --git a/ext/opcache/Optimizer/compact_literals..c b/ext/opcache/Optimizer/compact_literals.c
index 0637d77..f417bef 100644
--- a/ext/opcache/Optimizer/compact_literals.c
+++ b/ext/opcache/Optimizer/compact_literals.c
@@ -146,6 +146,9 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
LITERAL_INFO(opline->op2.constant, LITERAL_FUNC, 1, 1, 3);
break;
case ZEND_INIT_METHOD_CALL:
+ if (ZEND_OP1_TYPE(opline) == IS_CONST) {
+ LITERAL_INFO(opline->op1.constant, LITERAL_VALUE, 1, 0, 1);
+ }
if (ZEND_OP2_TYPE(opline) == IS_CONST) {
optimizer_literal_obj_info(
info,
diff --git a/ext/opcache/tests/method_call_on_literal.phpt
b/ext/opcache/tests/method_call_on_literal.phpt
new file mode 100644
index 0000000..bf89caa
--- /dev/null
+++ b/ext/opcache/tests/method_call_on_literal.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Literal compaction should take method calls on literals into account
+--FILE--
+<?php
+
+try {
+ (42)->foo();
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Call to a member function foo() on integer