> Diff:
> diff --git a/Zend/Zend.m4 b/Zend/Zend.m4
> index 16f2d5f..e12b00d 100644
> --- a/Zend/Zend.m4
> +++ b/Zend/Zend.m4
> @@ -409,3 +409,48 @@ else
>      AC_MSG_RESULT(no)
>    fi
>  fi
> +
> +AC_ARG_ENABLE(gcc-global-regs,
> +[  --disable-gcc-global-regs
> +                          whether to enable GCC global register
> variables],[
> +  ZEND_GCC_GLOBAL_REGS=$enableval
> +],[
> +  ZEND_GCC_GLOBAL_REGS=yes
> +])
> +AC_MSG_CHECKING(for global register variables support)
> +if test "$ZEND_GCC_GLOBAL_REGS" != "no"; then
> +  AC_TRY_COMPILE([
> +  ],[
> +#if defined(__GNUC__) && defined(i386)
> +# define ZEND_VM_FP_GLOBAL_REG "%esi"
> +# define ZEND_VM_IP_GLOBAL_REG "%edi"
> +#elif defined(__GNUC__) && defined(__x86_64__)
> +# define ZEND_VM_FP_GLOBAL_REG "%r14"
> +# define ZEND_VM_IP_GLOBAL_REG "%r15"
> +#else
> +# error "global register variables are not supported"
> +#endif
> +typedef int (*opcode_handler_t)(void);
> +register void *FP  __asm__(ZEND_VM_FP_GLOBAL_REG);
> +register const opcode_handler_t *IP __asm__(ZEND_VM_IP_GLOBAL_REG);
> +int emu(const opcode_handler_t *ip, void *fp) {
> +       const opcode_handler_t *orig_ip = IP;
> +       void *orig_fp = FP;
> +       IP = ip;
> +       FP = fp;
> +       while ((*ip)());
> +       FP = orig_fp;
> +       IP = orig_ip;
> +}
> +  ], [
> +    ZEND_GCC_GLOBAL_REGS=yes
> +  ], [
> +    ZEND_GCC_GLOBAL_REGS=no
> +  ])
> +fi
> +if test "$ZEND_GCC_GLOBAL_REGS" = "yes"; then
> +  AC_DEFINE([HAVE_GCC_GLOBAL_REGS], 1, [Define if the target system has
> support for global register variables])
> +else
> +  HAVE_GCC_GLOBAL_REGS=no
> +fi
> +AC_MSG_RESULT(ZEND_GCC_GLOBAL_REGS)

Dmitry, the perf boost of this is awesome, but is it completely safe?
Won't a signal potentially overwrite a register variable here? Like on a
timeout, for example?

-Rasmus

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to