]> granicus.if.org Git - php/commitdiff
Keep the same JIT code for PHP-8.0 and master (workaround against PHP-8.0 ABI freeze)
authorDmitry Stogov <dmitry@zend.com>
Fri, 9 Oct 2020 13:54:26 +0000 (16:54 +0300)
committerDmitry Stogov <dmitry@zend.com>
Fri, 9 Oct 2020 13:54:26 +0000 (16:54 +0300)
ext/opcache/jit/zend_jit.c
ext/opcache/jit/zend_jit_disasm_x86.c
ext/opcache/jit/zend_jit_helpers.c
ext/opcache/jit/zend_jit_x86.dasc

index 5ebf1c079c760f6f4af915e5a8ef589648e84e6d..41793fc299d3a1aadc68cbca91ef5ec020b3a413 100644 (file)
@@ -16,6 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
+#include "php_version.h"
 #include <ZendAccelerator.h>
 #include "zend_shared_alloc.h"
 #include "Zend/zend_execute.h"
index a470179917e6d776671c237c8c4a807c5532b27a..730a5d13196f8ccb36fb50ceecefb90f95f9ef74 100644 (file)
@@ -490,6 +490,9 @@ static int zend_jit_disasm_init(void)
        REGISTER_HELPER(zend_jit_pre_dec_obj_helper);
        REGISTER_HELPER(zend_jit_post_inc_obj_helper);
        REGISTER_HELPER(zend_jit_post_dec_obj_helper);
+#if (PHP_VERSION_ID <= 80000) && (SIZEOF_SIZE_T == 4)
+       REGISTER_HELPER(zval_jit_update_constant_ex);
+#endif
 #undef  REGISTER_HELPER
 
 #ifndef _WIN32
index 22904a8e1d3bc6c0671d383b6ca8384f509cfadc..c366e6274a01162e78047c9a4ae0ce8ab20c4502 100644 (file)
@@ -2609,3 +2609,32 @@ static void ZEND_FASTCALL zend_jit_post_dec_obj_helper(zend_object *zobj, zend_s
                zval_ptr_dtor(z);
        }
 }
+
+#if (PHP_VERSION_ID <= 80000) && (SIZEOF_SIZE_T == 4)
+static zend_result ZEND_FASTCALL zval_jit_update_constant_ex(zval *p, zend_class_entry *scope)
+{
+       if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
+               zend_ast *ast = Z_ASTVAL_P(p);
+
+               if (ast->kind == ZEND_AST_CONSTANT) {
+                       zend_string *name = zend_ast_get_constant_name(ast);
+                       zval *zv = zend_get_constant_ex(name, scope, ast->attr);
+                       if (UNEXPECTED(zv == NULL)) {
+                               return FAILURE;
+                       }
+
+                       zval_ptr_dtor_nogc(p);
+                       ZVAL_COPY_OR_DUP(p, zv);
+               } else {
+                       zval tmp;
+
+                       if (UNEXPECTED(zend_ast_evaluate(&tmp, ast, scope) != SUCCESS)) {
+                               return FAILURE;
+                       }
+                       zval_ptr_dtor_nogc(p);
+                       ZVAL_COPY_VALUE(p, &tmp);
+               }
+       }
+       return SUCCESS;
+}
+#endif
\ No newline at end of file
index 066a8ea07395e66970b2bc16b8186c5575afbcf4..bf190427fbce557be95d93a64c3365cd0ce23c98 100644 (file)
@@ -12413,19 +12413,18 @@ static int zend_jit_recv_init(dasm_State **Dst, const zend_op *opline, const zen
                } else {
                        |       ADDR_OP2_2 mov, aword EX->opline, opline, r0
                }
-               |.if X64
-                       |       LOAD_ZVAL_ADDR CARG1, res_addr
-                       |       mov r0, EX->func
-                       |       mov CARG2, [r0 + offsetof(zend_op_array, scope)]
-                       |       EXT_CALL zval_update_constant_ex, r0
-               |.else
-                       |       sub r4, 8
-                       |       mov r0, EX->func
-                       |       push dword [r0 + offsetof(zend_op_array, scope)]
-                       |       PUSH_ZVAL_ADDR res_addr, r0
-                       |       EXT_CALL zval_update_constant_ex, r0
-                       |       add r4, 16
-               |.endif
+               |       LOAD_ZVAL_ADDR FCARG1a, res_addr
+               |       mov r0, EX->func
+               |       mov FCARG2a, [r0 + offsetof(zend_op_array, scope)]
+               |       .if X64
+               |               EXT_CALL zval_update_constant_ex, r0
+               |       .else
+               ||#if (PHP_VERSION_ID <= 80000)
+               |               EXT_CALL zval_jit_update_constant_ex, r0
+               ||#else
+               |               EXT_CALL zval_update_constant_ex, r0
+               ||#endif
+               |       .endif
                |       test al, al
                |       jnz >1
                |.cold_code