Permalink
Browse files

Eliminated useless allocation of FPU control word on each request sta…

…rtup
  • Loading branch information...
1 parent bc1f1d2 commit 5438a9d23c4bae10a1f38967f84f0f0420971676 Dmitry Stogov committed Jul 9, 2010
Showing with 12 additions and 14 deletions.
  1. +7 −13 Zend/zend_float.c
  2. +5 −1 Zend/zend_globals.h
View
20 Zend/zend_float.c
@@ -27,31 +27,25 @@ ZEND_API void zend_init_fpu(TSRMLS_D) /* {{{ */
#if XPFPA_HAVE_CW
XPFPA_DECLARE
- if (!EG(saved_fpu_cw)) {
- EG(saved_fpu_cw) = emalloc(sizeof(XPFPA_CW_DATATYPE));
+ if (!EG(saved_fpu_cw_ptr)) {
+ EG(saved_fpu_cw_ptr) = (void*)&EG(saved_fpu_cw);
}
- XPFPA_STORE_CW(EG(saved_fpu_cw));
+ XPFPA_STORE_CW(EG(saved_fpu_cw_ptr));
XPFPA_SWITCH_DOUBLE();
#else
- if (EG(saved_fpu_cw)) {
- efree(EG(saved_fpu_cw));
- }
- EG(saved_fpu_cw) = NULL;
+ EG(saved_fpu_cw_ptr) = NULL;
#endif
}
/* }}} */
ZEND_API void zend_shutdown_fpu(TSRMLS_D) /* {{{ */
{
#if XPFPA_HAVE_CW
- if (EG(saved_fpu_cw)) {
- XPFPA_RESTORE_CW(EG(saved_fpu_cw));
+ if (EG(saved_fpu_cw_ptr)) {
+ XPFPA_RESTORE_CW(EG(saved_fpu_cw_ptr));
}
#endif
- if (EG(saved_fpu_cw)) {
- efree(EG(saved_fpu_cw));
- EG(saved_fpu_cw) = NULL;
- }
+ EG(saved_fpu_cw_ptr) = NULL;
}
/* }}} */
View
6 Zend/zend_globals.h
@@ -34,6 +34,7 @@
#include "zend_objects.h"
#include "zend_objects_API.h"
#include "zend_modules.h"
+#include "zend_float.h"
#ifdef ZEND_MULTIBYTE
#include "zend_multibyte.h"
@@ -261,7 +262,10 @@ struct _zend_executor_globals {
zend_bool active;
- void *saved_fpu_cw;
+ void *saved_fpu_cw_ptr;
+#if XPFPA_HAVE_CW
+ XPFPA_CW_DATATYPE saved_fpu_cw;
+#endif
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};

0 comments on commit 5438a9d

Please sign in to comment.