-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Buffer floating point write signaling NaNs #4648
Comments
Small update: I think
The above returns I'm going to start digging into the v8 source and see if I can identify what's going on. |
cc/ @bnoordhuis (any insights appreciated) |
Here is the full chain of execution v8 uses to evaluate an argument with
So the whole thing seems to boil down to a few |
@bnoordhuis This issue also occurs in node's Typed Arrays implementation: var buf = new Buffer(8);
var fview = new Float64Array(buf);
fview[0] = NaN;
// <Buffer 00 00 00 00 00 00 f8 ff> And in d8's as well: var buf = new ArrayBuffer(8);
var fview = new Float64Array(buf);
var uiview = new Uint8Array(buf);
uiview[6].toString(16) + ' ' + uiview[7].toString(16)
// f8 ff So imho reverting back to the old way of writing buffer floats doesn't make a lot of sense in terms of the previous code complexity and performance hit, when all current implementations have the same problem. |
hopped into llvm irc and told me to file a bug: http://llvm.org/bugs/show_bug.cgi?id=15054 |
Bummer, I guess you're right. Okay, I'll leave the changes in. You might want to mention on that llvm bug that it appears to be some kind of weak interaction between clang and the system headers because the builtins return the right values. |
Will do. And thanks for figuring out what was going on. Would've taken me a week to see that. |
@bnoordhuis well that didn't take long.
I'll build and test it out, but close the bug for now. And figured I'd throw in the diff for the fix: *losesInfo = lostFraction != lfExactlyZero || X86SpecialNan;
+
+ // For x87 extended precision, we want to make a NaN, not a special NaN if
+ // the input wasn't special either.
+ if (!X86SpecialNan && semantics == &APFloat::x87DoubleExtended)
+ APInt::tcSetBit(significandParts(), semantics->precision - 1);
+
// gcc forces the Quiet bit on, which means (float)(double)(float_sNan) |
When Node is compiled for ia32 with clang 3.2,
writeFloatLE|BE
andwriteDoubleLE|BE
output signaling NaNs not quiet NaNs.Investigating why this is happening.
The text was updated successfully, but these errors were encountered: