Skip to content

Commit fc14dbb

Browse files
committed
Keep the same JIT code for PHP-8.0 and master (workaround against PHP-8.0 ABI freeze)
1 parent 3836870 commit fc14dbb

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
+----------------------------------------------------------------------+
1717
*/
1818

19+
#include "php_version.h"
1920
#include <ZendAccelerator.h>
2021
#include "zend_shared_alloc.h"
2122
#include "Zend/zend_execute.h"

ext/opcache/jit/zend_jit_disasm_x86.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ static int zend_jit_disasm_init(void)
490490
REGISTER_HELPER(zend_jit_pre_dec_obj_helper);
491491
REGISTER_HELPER(zend_jit_post_inc_obj_helper);
492492
REGISTER_HELPER(zend_jit_post_dec_obj_helper);
493+
#if (PHP_VERSION_ID <= 80000) && (SIZEOF_SIZE_T == 4)
494+
REGISTER_HELPER(zval_jit_update_constant_ex);
495+
#endif
493496
#undef REGISTER_HELPER
494497

495498
#ifndef _WIN32

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,3 +2609,32 @@ static void ZEND_FASTCALL zend_jit_post_dec_obj_helper(zend_object *zobj, zend_s
26092609
zval_ptr_dtor(z);
26102610
}
26112611
}
2612+
2613+
#if (PHP_VERSION_ID <= 80000) && (SIZEOF_SIZE_T == 4)
2614+
static zend_result ZEND_FASTCALL zval_jit_update_constant_ex(zval *p, zend_class_entry *scope)
2615+
{
2616+
if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
2617+
zend_ast *ast = Z_ASTVAL_P(p);
2618+
2619+
if (ast->kind == ZEND_AST_CONSTANT) {
2620+
zend_string *name = zend_ast_get_constant_name(ast);
2621+
zval *zv = zend_get_constant_ex(name, scope, ast->attr);
2622+
if (UNEXPECTED(zv == NULL)) {
2623+
return FAILURE;
2624+
}
2625+
2626+
zval_ptr_dtor_nogc(p);
2627+
ZVAL_COPY_OR_DUP(p, zv);
2628+
} else {
2629+
zval tmp;
2630+
2631+
if (UNEXPECTED(zend_ast_evaluate(&tmp, ast, scope) != SUCCESS)) {
2632+
return FAILURE;
2633+
}
2634+
zval_ptr_dtor_nogc(p);
2635+
ZVAL_COPY_VALUE(p, &tmp);
2636+
}
2637+
}
2638+
return SUCCESS;
2639+
}
2640+
#endif

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12413,19 +12413,18 @@ static int zend_jit_recv_init(dasm_State **Dst, const zend_op *opline, const zen
1241312413
} else {
1241412414
| ADDR_OP2_2 mov, aword EX->opline, opline, r0
1241512415
}
12416-
|.if X64
12417-
| LOAD_ZVAL_ADDR CARG1, res_addr
12418-
| mov r0, EX->func
12419-
| mov CARG2, [r0 + offsetof(zend_op_array, scope)]
12420-
| EXT_CALL zval_update_constant_ex, r0
12421-
|.else
12422-
| sub r4, 8
12423-
| mov r0, EX->func
12424-
| push dword [r0 + offsetof(zend_op_array, scope)]
12425-
| PUSH_ZVAL_ADDR res_addr, r0
12426-
| EXT_CALL zval_update_constant_ex, r0
12427-
| add r4, 16
12428-
|.endif
12416+
| LOAD_ZVAL_ADDR FCARG1a, res_addr
12417+
| mov r0, EX->func
12418+
| mov FCARG2a, [r0 + offsetof(zend_op_array, scope)]
12419+
| .if X64
12420+
| EXT_CALL zval_update_constant_ex, r0
12421+
| .else
12422+
||#if (PHP_VERSION_ID <= 80000)
12423+
| EXT_CALL zval_jit_update_constant_ex, r0
12424+
||#else
12425+
| EXT_CALL zval_update_constant_ex, r0
12426+
||#endif
12427+
| .endif
1242912428
| test al, al
1243012429
| jnz >1
1243112430
|.cold_code

0 commit comments

Comments
 (0)