Closed Bug 1413944 Opened 7 years ago Closed 7 years ago

Remove unreachable code in VMFunction's StringFromCharCode

Categories

(Core :: JavaScript Engine: JIT, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(1 file)

- StringFromCharCode is only called [1] when the string cannot be loaded from StaticStrings, so this condition always evaluates to false [2]. - If the string isn't in StaticStrings, it's guaranteed to be a two-byte string, so we can directly call NewStringCopyNDontDeflate in [3]. [1] https://searchfox.org/mozilla-central/rev/423b2522c48e1d654e30ffc337164d677f934ec3/js/src/jit/CodeGenerator.cpp#8147-8149 [2] https://searchfox.org/mozilla-central/rev/423b2522c48e1d654e30ffc337164d677f934ec3/js/src/jit/VMFunctions.cpp#469-470 [3] https://searchfox.org/mozilla-central/rev/423b2522c48e1d654e30ffc337164d677f934ec3/js/src/jit/VMFunctions.cpp#472
(In reply to André Bargull [:anba] from comment #0) > - StringFromCharCode is only called [1] when the string cannot be loaded > from StaticStrings, so this condition always evaluates to false [2]. Derp, that's wrong because of `String.fromCharCode(0x10000 | 0x41)`.
Attached patch bug1413944.patchSplinter Review
The code unit can't be deflated to Latin-1, so we can directly call NewStringCopyNDontDeflate. This also realigns the code with CodeUnitToString in jsstr.cpp.
Attachment #8924595 - Flags: review?(jdemooij)
Comment on attachment 8924595 [details] [diff] [review] bug1413944.patch Review of attachment 8924595 [details] [diff] [review]: ----------------------------------------------------------------- LGTM, thanks.
Attachment #8924595 - Flags: review?(jdemooij) → review+
Priority: -- → P2
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/f858fa7ff379 Don't try to deflate two-byte code unit in StringFromCharCode. r=jandem
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: