Skip to content

Commit 9c1159a

Browse files
committed
Merge branch 'master' of github.com:php/php-src
* 'master' of github.com:php/php-src: Fix bug #81090 in JIT as well Fixed bug #81090
2 parents 660585e + 445b649 commit 9c1159a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Zend/zend_execute.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,13 @@ static zend_never_inline void zend_binary_assign_op_typed_ref(zend_reference *re
13961396
{
13971397
zval z_copy;
13981398

1399+
/* Make sure that in-place concatenation is used if the LHS is a string. */
1400+
if (opline->extended_value == ZEND_CONCAT && Z_TYPE(ref->val) == IS_STRING) {
1401+
concat_function(&ref->val, &ref->val, value);
1402+
ZEND_ASSERT(Z_TYPE(ref->val) == IS_STRING && "Concat should return string");
1403+
return;
1404+
}
1405+
13991406
zend_binary_op(&z_copy, &ref->val, value OPLINE_CC);
14001407
if (EXPECTED(zend_verify_ref_assignable_zval(ref, &z_copy, EX_USES_STRICT_TYPES()))) {
14011408
zval_ptr_dtor(&ref->val);
@@ -1409,6 +1416,13 @@ static zend_never_inline void zend_binary_assign_op_typed_prop(zend_property_inf
14091416
{
14101417
zval z_copy;
14111418

1419+
/* Make sure that in-place concatenation is used if the LHS is a string. */
1420+
if (opline->extended_value == ZEND_CONCAT && Z_TYPE_P(zptr) == IS_STRING) {
1421+
concat_function(zptr, zptr, value);
1422+
ZEND_ASSERT(Z_TYPE_P(zptr) == IS_STRING && "Concat should return string");
1423+
return;
1424+
}
1425+
14121426
zend_binary_op(&z_copy, zptr, value OPLINE_CC);
14131427
if (EXPECTED(zend_verify_property_type(prop_info, &z_copy, EX_USES_STRICT_TYPES()))) {
14141428
zval_ptr_dtor(zptr);

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,13 @@ static void ZEND_FASTCALL zend_jit_assign_op_to_typed_ref(zend_reference *ref, z
19181918
{
19191919
zval z_copy;
19201920

1921+
/* Make sure that in-place concatenation is used if the LHS is a string. */
1922+
if (binary_op == concat_function && Z_TYPE(ref->val) == IS_STRING) {
1923+
concat_function(&ref->val, &ref->val, val);
1924+
ZEND_ASSERT(Z_TYPE(ref->val) == IS_STRING && "Concat should return string");
1925+
return;
1926+
}
1927+
19211928
binary_op(&z_copy, &ref->val, val);
19221929
if (EXPECTED(zend_verify_ref_assignable_zval(ref, &z_copy, ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data))))) {
19231930
zval_ptr_dtor(&ref->val);
@@ -2117,6 +2124,13 @@ static void ZEND_FASTCALL zend_jit_assign_op_to_typed_prop(zval *zptr, zend_prop
21172124
zval z_copy;
21182125

21192126
ZVAL_DEREF(zptr);
2127+
/* Make sure that in-place concatenation is used if the LHS is a string. */
2128+
if (binary_op == concat_function && Z_TYPE_P(zptr) == IS_STRING) {
2129+
concat_function(zptr, zptr, value);
2130+
ZEND_ASSERT(Z_TYPE_P(zptr) == IS_STRING && "Concat should return string");
2131+
return;
2132+
}
2133+
21202134
binary_op(&z_copy, zptr, value);
21212135
if (EXPECTED(zend_verify_property_type(prop_info, &z_copy, EX_USES_STRICT_TYPES()))) {
21222136
zval_ptr_dtor(zptr);

0 commit comments

Comments
 (0)