Closed Bug 1664826 Opened 1 year ago Closed 1 year ago

Update js::StaticStrings optimization to support $, _

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

References

Details

Attachments

(1 file)

In the js::StaticStrings optimization, we fast-path length-2 strings whose characters are matched by this. This covers the usual alpha-numeric ASCII set and also [ and ~. In JS the rule for identifiers allows $ and _ and minifiers use this. We should change the the set of small-chars to match this. The lookup during atomization is table-based so this change does not have an impact on lookup complexity.

For example, on the cadmium_core bundle that Netflix loads, this change fast-paths 3000 atomize calls in the parser.

The $ and _ characters are legal JS identifiers and can show up a fair
bit in large minified code-bases. This changes the {to,from}SmallChar which
is used during StaticStrings::init. We already use a table-based lookup
while atomizing so there isn't additional perf cost during atomization.

Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2267cc975235
Update StaticStrings small-chars to include '$', '_' r=djvj

(backout reason is in Bug 1664312)

Flags: needinfo?(tcampbell)
Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/931771ff71c2
Update StaticStrings small-chars to include '$', '_' r=djvj
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch
You need to log in before you can comment on or make changes to this bug.