Closed Bug 1365699 Opened 7 years ago Closed 7 years ago

Unreachable code in /js/src/jit/x86-shared/Disassembler-x86-shared.cpp

Categories

(Core :: JavaScript Engine: JIT, defect)

47 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: janx, Assigned: janx)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

When running static analysis on /js/src/jit/x86-shared/Disassembler-x86-shared.cpp with the following command:

    $ run-clang-tidy-4.0.py -j 18 -p obj-x86_64-pc-linux-gnu/ -checks=-*,clang-analyzer-deadcode.DeadStores js/src/jit/x86-shared/

We get the following warnings:

    /home/user/firefox/js/src/jit/x86-shared/Disassembler-x86-shared.cpp:226:13: warning: Value stored to 'l' is never read [clang-analyzer-deadcode.DeadStores]
                l = (c4b >> 2) & 0x1;
                ^
    /home/user/firefox/js/src/jit/x86-shared/Disassembler-x86-shared.cpp:226:13: note: Value stored to 'l' is never read
                l = (c4b >> 2) & 0x1;
                ^
    /home/user/firefox/js/src/jit/x86-shared/Disassembler-x86-shared.cpp:236:13: warning: Value stored to 'l' is never read [clang-analyzer-deadcode.DeadStores]
                l = (c5 >> 2) & 0x1;
                ^
    /home/user/firefox/js/src/jit/x86-shared/Disassembler-x86-shared.cpp:236:13: note: Value stored to 'l' is never read
                l = (c5 >> 2) & 0x1;
                ^

This is because the `switch (m)` at Disassembler-x86-shared.cpp:245 jumps out of the scope (either with a `goto opcode_done` or a `MOZ_CRASH(...)`) before the `if (l != 0) // 256-bit SIMD` check can be reached, causing the variable `l` to never be read.
By moving the sanity check above the switch, we make the code reachable again.
Attachment #8868684 - Flags: review?(bbouvier)
Fixed to 4-space indent.
Attachment #8868698 - Flags: review?(bbouvier)
Attachment #8868684 - Attachment is obsolete: true
Attachment #8868684 - Flags: review?(bbouvier)
Comment on attachment 8868698 [details] [diff] [review]
Fix unreachable code in Disassembler-x86-shared.cpp.

Review of attachment 8868698 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good! If this passes jit tests, let's land it. Thanks for the patch!
Attachment #8868698 - Flags: review?(bbouvier) → review+
Attachment #8868698 - Attachment is obsolete: true
The assertion failures in /src/ld/ld.hpp on "OS X 10.7 opt" seem unrelated (see orange try jobs "cgc" and "p"). Please land this patch.
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/37e9f6f9d1e8
Fix unreachable code in Disassembler-x86-shared.cpp. r=bbouvier
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/37e9f6f9d1e8
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
No longer depends on: clang-based-analysis
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: