Skip to content

Commit b1a0c96

Browse files
committed
[MERGE #5207 @MikeHolman] add NaN check for simple Sets
Merge pull request #5207 from MikeHolman:setnan It is possible for sign bit to be set on NaNs (e.g. when they are the result of some math operations), so canonicalize them when adding to simple set in order to avoid duplicating entries. We can do this because the sign bit on NaN is not observable to JS code. OS: 17498790
2 parents 22e34d8 + f5f4a43 commit b1a0c96

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/Runtime/Language/JavascriptConversion.inl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,15 @@ namespace Js {
292292
{
293293
return taggedInt;
294294
}
295-
296295
#if FLOATVAR
297-
return value;
296+
if (typeId == TypeIds_Number)
297+
{
298+
// NaN could have sign bit set, but that isn't observable so canonicalize to positive NaN
299+
double numberValue = JavascriptNumber::GetValue(value);
300+
return JavascriptNumber::IsNan(numberValue)
301+
? JavascriptNumber::ToVar(JavascriptNumber::NaN)
302+
: value;
303+
}
298304
#else
299305
return nullptr;
300306
#endif

0 commit comments

Comments
 (0)