Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2(PHP_5_3) / Zend.m4 acinclude.m4 zend_float.h zend_operators.c zend_strtod.c /tests float_prec_001.phpt

[email protected] (Christian Seiler) Wed, 18 Mar 2009 03:08:03 +0100
Newsgroups php.zend-engine.cvs
Message-ID <[email protected]>
Hi Dmitry,

Here's a first draft of a patch for the issue:

http://www.christian-seiler.de/temp/php/2009-03-17/fpu-cw-performance-5.3.patch

The idea is the following: When the compiler is initialized, the current
FPU control word is stored and when the compiler is shut down (end of
request) the saved FPU control word is restored. Since the data type of
the control word is not a priori clear (it depends on the selected
platform/compiler combination), I've added a void * pointer to
compiler_globals that is allocated upon storage of the control word.
This ensures that the compiler_globals structure does not have to care
about the data type of the control word and thus ensuring higher binary
compability.

Note: The compiler may not be the best place to initialize this stuff
(and compiler_globals not the best place to store it). As I said: It's a
first draft.

I also added the following function: zend_ensure_fpu_mode() This is
currently not used, it is however intended as a means for extensions
that call library functions that are known to change the control word -
should those exist at all. The idea would be to call the above function
after calling the library function in order to ensure that PHP always
uses the corrent control word.

Also, I didn't have time to test that on different platforms, I only did
that on Linux. Since I haven't changed any platform-dependent logic
behind all of this, I'm extremely confident that I didn't break anything
but one never knows...

Regards,
Christian