Comment #2 on issue 436 by erik.corry: Numeric results are wrong on some systems due to x87 extended double precision http://code.google.com/p/v8/issues/detail?id=436
I think our current behaviour matches Firefox on Linux. It's fairly painful to fix on Linux as detailed below and it seems in practice the extra precision doesn't break anything other than tests. There are two issues here: C++ code and generated code. Issue 1: The C library on Linux (and Mac?) insists on the fpu being in extended precision mode, so we can't just switch to double precision mode for the thread using V8. We can use the -fstore-floats option to gcc, which slows down V8 a little by storing results in memory between each operation. I think there is also a gcc option to use SSE2, but that would only be usable on MacOS, since it can't adapt at runtime. Transcendental functions (sin, tan, exp, etc) generate different results on different platforms, probably because of this. Issue 2: In the generated code we are currently so bad at register allocating in fp that we always end up storing fp values to memory in between each operation. This naturally truncates them to double precision from extended double precision. This ameliorates or even solves the problem. If we still have problems with this we should switch to using SSE2 instead of x87 which would solve the problem for all systems that have SSE2, which is all 64 bit systems and all 32 bit systems built after around 2001 (Intel) or 2003 (AMD). All Macs have SSE2. Transcendental functions are performed both in C++ code and in generated code with x87 fsin instructions. For the ones done in generated code it might be necessary to switch the fpu mode before and after. The performance implications are not known but are rumoured to be severe. At the moment we don't have the infrastructure in the VM to switch the fpu mode on return from C++ code (it's just a normal return to normal generated code I think) so it wouldn't be easy to run all generated code with a different FPU mode to the C++ code. -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
