From 02fae1fc537cd256233a5c0f51207a68fe2bd3d8 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 29 Jul 2020 17:32:57 +0300 Subject: [PATCH] Fixed bug #79888 (Incorrect execution with JIT enabled) --- NEWS | 1 + ext/opcache/jit/zend_jit_x86.dasc | 5 +++- ext/opcache/tests/jit/bug79888.phpt | 38 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/jit/bug79888.phpt diff --git a/NEWS b/NEWS index 220f1890ac..e64b2efad8 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ PHP NEWS - JIT: . Fixed bug #79864 (JIT segfault in Symfony OptionsResolver). (Dmitry) + . Fixed bug #79888 (Incorrect execution with JIT enabled). (Dmitry) - LDAP: . Fixed memory leaks. (ptomulik) diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index a63db2ad9a..d18c3ca2ec 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -12576,7 +12576,10 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend } } else { ZEND_REGSET_INCL(regset, ZREG_R0); - ZEND_REGSET_INCL(regset, ZREG_R1); + ZEND_REGSET_INCL(regset, ZREG_R2); + if (opline->op2_type == IS_CONST) { + ZEND_REGSET_INCL(regset, ZREG_R1); + } } } break; diff --git a/ext/opcache/tests/jit/bug79888.phpt b/ext/opcache/tests/jit/bug79888.phpt new file mode 100644 index 0000000000..02d4b62ea9 --- /dev/null +++ b/ext/opcache/tests/jit/bug79888.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #79888 (Incorrect execution with JIT enabled) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=64 +opcache.jit=1205 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Testing Primes until: 1000 +Primect: 168 -- 2.50.1