Remove unreachable code in VMFunction's StringFromCharCode

RESOLVED FIXED in Firefox 58

Status

()

enhancement
P2
normal
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: anba, Assigned: anba)

Tracking

Trunk
mozilla58
Points:
---

Firefox Tracking Flags

(firefox58 fixed)

Details

Attachments

(1 attachment)

- 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)`.
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
https://hg.mozilla.org/mozilla-central/rev/f858fa7ff379
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
You need to log in before you can comment on or make changes to this bug.