|
From: Wilfried G. <dot...@ci...> - 2015-12-07 11:56:31
|
Hi Everyone, Duplicating the discussion from the V8 user group: > > >https://groups.google.com/forum/#!topic/v8-users/qRorKvYNq24 On Fri, Dec >4, 2015 at 3:26 PM, Wilfried Gösgens <doth...@gmailcom> wrote: >> Hi everyone >> Using the regular d8 shell: >> >> # ./d8 >> V8 version 4.8.271.5 >> d8> Math.pow(0, 0.1); >> 0 >> d8> >> >> gives proper results. >> But using d8 in valgrind gives: >> >> /usr/bin/valgrind.bin --log-file=/tmp/valgrindlog.%p >> --show-reachable=yes --leak-check=full ./d8 >> Math.pow(0, 0.1); >> V8 version 4.8.271.5 >> d8> NaN >> d8> >> >> Is this a bug in V8 or in Valgrind? > > > > > >I can reproduce what you describe and it doesn't go away when you pass >--smc-check=all to Valgrind or --nofast_math to V8. > >I'm inclined to suspect Valgrind but I'm honestly not sure. `pow(0, >0.1)` from C code or a Perl script doesn't exhibit the same behavior. >Those may not be issuing the same instructions, of course. d8 is the sample shell provided by the V8 project for testing the V8 javascript engine. It will be built alongside the V8 engine: https://developers.google.com/v8/build?hl=en Does valgrind replace mathematical functions? Cheers, Willi |
|
From: Tom H. <to...@co...> - 2015-12-07 12:36:14
|
On 07/12/15 11:40, Wilfried Goesgens wrote: > Does valgrind replace mathematical functions? No, but see the section on x86/AMD64 floating point support in the manual: http://valgrind.org/docs/manual/manual-core.html#manual-core.limits Tom -- Tom Hughes (to...@co...) http://compton.nu/ |
|
From: John R. <jr...@bi...> - 2015-12-07 12:39:53
|
> Duplicating the discussion from the V8 user group: > > https://groups.google.com/forum/#!topic/v8-users/qRorKvYNq24 > > On Fri, Dec 4, 2015 at 3:26 PM, Wilfried Gösgens <doth...@gmail.com> wrote: > > Hi everyone > > Using the regular d8 shell: > > > > # ./d8 > > V8 version 4.8.271.5 > > d8> Math.pow(0, 0.1); > > 0 > > d8> > > > > gives proper results. > > But using d8 in valgrind gives: > > > > /usr/bin/valgrind.bin --log-file=/tmp/valgrindlog.%p > > --show-reachable=yes --leak-check=full ./d8 > > Math.pow(0, 0.1); > > V8 version 4.8.271.5 > > d8> NaN > > d8> > Does valgrind replace mathematical functions? No, but valgrind forces round-to-nearest 64-bit result for every floating-point operation: no extra precision nor exponent range for 80-bit extended opcodes, and no directed rounding (truncate, ceil, floor). This is well documented. Thus if the user code relies on 80-bit mode or rounding other than round-to-nearest, then "bad results" may ensue. The bug is in V8 not diagnosing the actual environment before proceeding. Never run a laboratory experiment for quantitative results without first calibrating the instruments. |