mirror of
https://github.com/php/php-src.git
synced 2024-12-19 06:50:17 +08:00
Merge branch 'PHP-7.3'
This commit is contained in:
commit
6debea2fd8
@ -485,10 +485,12 @@ static inline zend_string *zval_make_interned_string(zval *zv) /* {{{ */
|
||||
/* Common part of zend_add_literal and zend_append_individual_literal */
|
||||
static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int literal_position) /* {{{ */
|
||||
{
|
||||
zval *lit = CT_CONSTANT_EX(op_array, literal_position);
|
||||
if (Z_TYPE_P(zv) == IS_STRING) {
|
||||
zval_make_interned_string(zv);
|
||||
}
|
||||
ZVAL_COPY_VALUE(CT_CONSTANT_EX(op_array, literal_position), zv);
|
||||
ZVAL_COPY_VALUE(lit, zv);
|
||||
Z_EXTRA_P(lit) = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -2336,7 +2338,6 @@ static inline void zend_handle_numeric_dim(zend_op *opline, znode *dim_node) /*
|
||||
return;
|
||||
}
|
||||
}
|
||||
Z_EXTRA_P(CT_CONSTANT(opline->op2)) = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -310,13 +310,13 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
|
||||
int i, use_copy;
|
||||
fprintf(stderr, "File %s func %s\n", op_array->filename->val,
|
||||
op_array->function_name ? op_array->function_name->val : "main");
|
||||
fprintf(stderr, "Literlas table size %d\n", op_array->last_literal);
|
||||
fprintf(stderr, "Literals table size %d\n", op_array->last_literal);
|
||||
|
||||
for (i = 0; i < op_array->last_literal; i++) {
|
||||
zval zv;
|
||||
ZVAL_COPY_VALUE(&zv, op_array->literals + i);
|
||||
use_copy = zend_make_printable_zval(op_array->literals + i, &zv);
|
||||
fprintf(stderr, "Literal %d, val (%d):%s\n", i, Z_STRLEN(zv), Z_STRVAL(zv));
|
||||
fprintf(stderr, "Literal %d, val (%zu):%s\n", i, Z_STRLEN(zv), Z_STRVAL(zv));
|
||||
if (use_copy) {
|
||||
zval_ptr_dtor_nogc(&zv);
|
||||
}
|
||||
@ -377,7 +377,6 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
|
||||
} else {
|
||||
map[i] = j;
|
||||
ZVAL_LONG(&zv, j);
|
||||
Z_EXTRA(op_array->literals[i]) = 0; /* allow merging with FETCH_DIM_... */
|
||||
zend_hash_index_add_new(&hash, Z_LVAL(op_array->literals[i]), &zv);
|
||||
if (i != j) {
|
||||
op_array->literals[j] = op_array->literals[i];
|
||||
@ -820,13 +819,13 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx
|
||||
#if DEBUG_COMPACT_LITERALS
|
||||
{
|
||||
int i, use_copy;
|
||||
fprintf(stderr, "Optimized literlas table size %d\n", op_array->last_literal);
|
||||
fprintf(stderr, "Optimized literals table size %d\n", op_array->last_literal);
|
||||
|
||||
for (i = 0; i < op_array->last_literal; i++) {
|
||||
zval zv;
|
||||
ZVAL_COPY_VALUE(&zv, op_array->literals + i);
|
||||
use_copy = zend_make_printable_zval(op_array->literals + i, &zv);
|
||||
fprintf(stderr, "Literal %d, val (%d):%s\n", i, Z_STRLEN(zv), Z_STRVAL(zv));
|
||||
fprintf(stderr, "Literal %d, val (%zu):%s\n", i, Z_STRLEN(zv), Z_STRVAL(zv));
|
||||
if (use_copy) {
|
||||
zval_ptr_dtor_nogc(&zv);
|
||||
}
|
||||
|
@ -206,6 +206,7 @@ int zend_optimizer_add_literal(zend_op_array *op_array, zval *zv)
|
||||
op_array->last_literal++;
|
||||
op_array->literals = (zval*)erealloc(op_array->literals, op_array->last_literal * sizeof(zval));
|
||||
ZVAL_COPY_VALUE(&op_array->literals[i], zv);
|
||||
Z_EXTRA(op_array->literals[i]) = 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -526,7 +527,6 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
|
||||
}
|
||||
}
|
||||
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
|
||||
Z_EXTRA(op_array->literals[opline->op2.constant]) = 0;
|
||||
} else {
|
||||
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
|
||||
}
|
||||
@ -555,7 +555,6 @@ int zend_optimizer_update_op2_const(zend_op_array *op_array,
|
||||
}
|
||||
}
|
||||
opline->op2.constant = zend_optimizer_add_literal(op_array, val);
|
||||
Z_EXTRA(op_array->literals[opline->op2.constant]) = 0;
|
||||
break;
|
||||
case ZEND_ADD_ARRAY_ELEMENT:
|
||||
case ZEND_INIT_ARRAY:
|
||||
|
30
ext/opcache/tests/bug77275.phpt
Normal file
30
ext/opcache/tests/bug77275.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Bug #77275: OPcache optimization problem for ArrayAccess->offsetGet(string)
|
||||
--INI--
|
||||
opcache.enable_cli=1
|
||||
opcache.optimization_level=-1
|
||||
--FILE--
|
||||
<?php
|
||||
namespace Foo;
|
||||
class Bar { public function get() {} }
|
||||
class Record implements \ArrayAccess {
|
||||
public function offsetSet($offset, $value) { throw new \Exception; }
|
||||
public function offsetGet($offset) { var_dump($offset); }
|
||||
public function offsetExists($offset) { throw new \Exception; }
|
||||
public function offsetUnset($offset) { throw new \Exception; }
|
||||
}
|
||||
class Baz {
|
||||
public function run() {
|
||||
$a = pow(1, 2);
|
||||
$b = new Bar();
|
||||
$c = new Bar();
|
||||
$d = new Bar();
|
||||
$id = $b->get('a', 'b', 'c');
|
||||
$rec = new Record();
|
||||
$id = $rec['a'];
|
||||
}
|
||||
}
|
||||
(new Baz())->run();
|
||||
?>
|
||||
--EXPECT--
|
||||
string(1) "a"
|
Loading…
Reference in New Issue
Block a user