Closed Bug 1879997 Opened 1 year ago Closed 1 year ago

Use __builtin_clz or std::countl_one in InflateUTF8ToUTF16

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
125 Branch
Tracking Status
firefox125 --- fixed

People

(Reporter: arai, Assigned: sfink)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

https://phabricator.services.mozilla.com/D201330#inline-1116243

https://searchfox.org/mozilla-central/rev/471301f58df4e9aa3496ce387d2340af5e3502e4/js/src/vm/CharacterEncoding.cpp#278-282

// Non-ASCII code unit.  Determine its length in bytes (n).
uint32_t n = 1;
while (v & (0x80 >> n)) {
  n++;
}

The code counts the number of leading 1 bits, as part of decoding UTF-8 code units.

Either of the following can be used:
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fclz
https://en.cppreference.com/w/cpp/numeric/countl_one

Summary: Use __builtin_clz or std::countl_one in → Use __builtin_clz or std::countl_one in InflateUTF8ToUTF16

There's an MFBT function for this: CountLeadingZeroes32

Severity: -- → N/A
Priority: -- → P3
Assignee: nobody → sphink
Status: NEW → ASSIGNED
Pushed by sfink@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/695de01232f0 use CountLeadingZeroes32 r=spidermonkey-reviewers,arai

I uploaded a fix and requested re-review.

Flags: needinfo?(sphink)
Pushed by sfink@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/533127adaec7 use CountLeadingZeroes32 r=spidermonkey-reviewers,arai
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 125 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: