]> granicus.if.org Git - php/commitdiff
Fixed JIT for recursive functions with type-hints
authorDmitry Stogov <dmitry@zend.com>
Thu, 18 Apr 2019 09:29:02 +0000 (12:29 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 18 Apr 2019 09:32:31 +0000 (12:32 +0300)
ext/opcache/jit/zend_jit.c
ext/opcache/jit/zend_jit_x86.dasc

index bbe872cbe7a23e6c8dbf2cdd9fdd4ce6fb789d3d..2b885a77b94de3512177df6f379f75ea5d9a1b94 100644 (file)
@@ -593,12 +593,7 @@ static int zend_jit_build_cfg(zend_op_array *op_array, zend_cfg *cfg)
 {
        uint32_t flags;
 
-       flags = ZEND_CFG_STACKLESS | ZEND_RT_CONSTANTS | ZEND_CFG_NO_ENTRY_PREDECESSORS | ZEND_SSA_RC_INFERENCE_FLAG | ZEND_SSA_USE_CV_RESULTS;
-
-       if (!(op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) {
-               /* First RECV/RECV_INIT instructions may be skipped */
-               flags |= ZEND_CFG_RECV_ENTRY;
-       }
+       flags = ZEND_CFG_STACKLESS | ZEND_RT_CONSTANTS | ZEND_CFG_NO_ENTRY_PREDECESSORS | ZEND_SSA_RC_INFERENCE_FLAG | ZEND_SSA_USE_CV_RESULTS | ZEND_CFG_RECV_ENTRY;
 
        if (zend_build_cfg(&CG(arena), op_array, flags, cfg) != SUCCESS) {
                return FAILURE;
index cab7793462e5a8148951ceb43a6100c9e7ed347b..b42072c0b5adce89f4e53727bbbb62c5e89591ef 100644 (file)
@@ -7551,6 +7551,21 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, zend_op_ar
                                        |       mov aword EX->opline, FCARG1a
                                }
                        }
+
+                       if (op_array == &func->op_array) {
+                               /* recursive call */
+#ifdef CONTEXT_THREADED_JIT
+                               |       call >1
+                               |.cold_code
+                               |1:
+                               |       pop r0
+                               |       jmp =>num_args
+                               |.code
+#else
+                               |       jmp =>num_args
+#endif
+                               return 1;
+                       }
                } else {
                        |       // opline = op_array->opcodes
                        if (GCC_GLOBAL_REGS) {
@@ -7606,51 +7621,26 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, zend_op_ar
                        |3:
                }
 
-               if (func && op_array == &func->op_array) {
-                       /* recursive call */
-                       uint32_t num_args;
-
-                       if (func->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) {
-                               num_args = skip_valid_arguments(op_array, ssa, call_info);
-                       } else {
-                               num_args = call_info->num_args;
-                       }
-
 #ifdef CONTEXT_THREADED_JIT
-                       |       call >1
-                       |.cold_code
-                       |1:
-                       |       pop r0
-                       |       jmp =>num_args
-                       |.code
-                       if (!func) {
-                               |       jmp >9
-                       }
+               |       call ->context_threaded_call
+               if (!func) {
+                       |       jmp >9
+               }
 #else
-                       |       jmp =>num_args
-#endif
+               if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
+                       |       add r4, HYBRID_SPAD
+                       |       JMP_IP
+               } else if (GCC_GLOBAL_REGS) {
+                       |       add r4, SPAD // stack alignment
+                       |       JMP_IP
                } else {
-#ifdef CONTEXT_THREADED_JIT
-                       |       call ->context_threaded_call
-                       if (!func) {
-                               |       jmp >9
-                       }
-#else
-                       if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
-                               |       add r4, HYBRID_SPAD
-                               |       JMP_IP
-                       } else if (GCC_GLOBAL_REGS) {
-                               |       add r4, SPAD // stack alignment
-                               |       JMP_IP
-                       } else {
-                               |       mov FP, aword T2 // restore FP
-                               |       mov RX, aword T3 // restore IP
-                               |       add r4, NR_SPAD // stack alignment
-                               |       mov r0, 1 // ZEND_VM_ENTER
-                               |       ret
-                       }
-#endif
+                       |       mov FP, aword T2 // restore FP
+                       |       mov RX, aword T3 // restore IP
+                       |       add r4, NR_SPAD // stack alignment
+                       |       mov r0, 1 // ZEND_VM_ENTER
+                       |       ret
                }
+#endif
        }
 
        if (!func || func->type == ZEND_INTERNAL_FUNCTION) {