Closed Bug 1548908 Opened 5 years ago Closed 5 years ago

Clean up NaN handling in Value.h

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
mozilla69
Tracking Status
firefox69 --- fixed

People

(Reporter: iain, Assigned: iain)

Details

Attachments

(5 files)

While reviewing Bug 1401624, it became clear that our handling of NaNs could use some tidying. Putting these patches in a separate bug because they are only tangentially related to object-biased NaN-boxing.

We can't generate a constexpr uint64_t containing the bits for positive/negative infinity, because of a (very sensible) static_assert in SpecificNaNBits. This patch adds support to FloatingPoint.h for infinity, and uses it to make JS::InfinityValue constexpr (to match JS::NaNValue).

IsCanonical was only used in StructuredCloneReader::CheckDouble. Two of CheckDouble's three uses already canonicalized the double before checking it, and the third should have already done so.

Back when we first freed the lizard in 1998, it made sense to have copies of NaN/+Inf/-Inf living on the runtime, because Values didn't store doubles inline. That hasn't been true for a long time. This patch gets rid of those.

Depends on D29867

  1. CanonicalizedDoubleValue should reuse the logic in CanonicalizeNaN.
  2. Places that call DoubleValue(CanonicalizeNaN(d)) should just use CanonicalizedDoubleValue(d).
Attachment #9062566 - Attachment description: Bug 1548908: Clean up JS::CanonicalizedDoubleValue r=tcampbell → Bug 1548903: Clean up JS::CanonicalizedDoubleValue r=tcampbell
Attachment #9062563 - Attachment description: Bug 1548908: Make JS::InfinityValue constexpr r=jwalden → Bug 1548903: Add InfinityBits to FloatingPoint.h r=jwalden
Attachment #9062565 - Attachment description: Bug 1548908: Remove "well-known numbers" from JSRuntime r=tcampbell → Bug 1548903: Remove "well-known numbers" from JSRuntime r=tcampbell
Attachment #9062564 - Attachment description: Bug 1548908: Remove IsCanonical and simplify StructuredCloneReader r=tcampbell → Bug 1548903: Remove IsCanonical and simplify StructuredCloneReader r=tcampbell
Attachment #9062566 - Attachment description: Bug 1548903: Clean up JS::CanonicalizedDoubleValue r=tcampbell → Bug 1548908: Clean up JS::CanonicalizedDoubleValue r=tcampbell
Attachment #9062563 - Attachment description: Bug 1548903: Add InfinityBits to FloatingPoint.h r=jwalden → Bug 1548908: Add InfinityBits to FloatingPoint.h r=jwalden
Attachment #9062565 - Attachment description: Bug 1548903: Remove "well-known numbers" from JSRuntime r=tcampbell → Bug 1548908: Remove "well-known numbers" from JSRuntime r=tcampbell
Attachment #9062564 - Attachment description: Bug 1548903: Remove IsCanonical and simplify StructuredCloneReader r=tcampbell → Bug 1548908: Remove IsCanonical and simplify StructuredCloneReader r=tcampbell

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:iain, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(iireland)

These patches (and the related patches in Bug 1401624) were waiting until 68.

Flags: needinfo?(iireland)
Pushed by iireland@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cfde75f084e0
Clean up JS::CanonicalizedDoubleValue r=tcampbell
https://hg.mozilla.org/integration/autoland/rev/f42ce0774d43
Add InfinityBits to FloatingPoint.h r=jwalden
https://hg.mozilla.org/integration/autoland/rev/2953a85f6b5f
Remove "well-known numbers" from JSRuntime r=tcampbell
https://hg.mozilla.org/integration/autoland/rev/411b72386829
Remove IsCanonical and simplify StructuredCloneReader r=tcampbell
https://hg.mozilla.org/integration/autoland/rev/b7340dfe4325
Verify during JS_Init that the hardware NaN is sane r=jwalden
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: