Browse Source

Fix compact_literals of INIT_METHOD_CALL with CONST op1

pull/1548/merge
Nikita Popov 9 years ago
parent
commit
0beccc51f1
  1. 3
      ext/opcache/Optimizer/compact_literals.c
  2. 14
      ext/opcache/tests/method_call_on_literal.phpt

3
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,

14
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
Loading…
Cancel
Save