Closed Bug 1672373 Opened 4 years ago Closed 4 years ago

Warp: Fold non-index strings in MGuardStringToInt32 and MGuardStringToDouble

Categories

(Core :: JavaScript Engine: JIT, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: anba, Assigned: anba)

References

()

Details

Attachments

(5 files)

In bug 1607986 we've observed that the script obfuscator from http://paper-io.com/?referer=paper.io&channel=11 executes hex_string - 0 millions of times. MGuardStringToInt32 and MGuardStringToDouble are currently only able to constant-fold index strings, but we also need to handle hexadecimal strings for the obfuscator from that web page.

Calls to GetPrefixInteger() with base=16:

  • without constant folding hex-strings: ~80,000,000
  • with constant folding hex-strings: ~5,800,000

Use explicit template instantiations instead of using the indirection through
CharsToNumberImpl. That way CharsToNumber works more similar to the other
parsing functions from this file.

Using only "Pure" as the suffix is more common throughout the code base than
"HelperPure", so remove "Helper" from {Int32,Number}ToStringHelperPure.

Depends on D94299

num_parseInt is no longer accessed outside of "jsnum.cpp", so we might as
well change it to static.

Depends on D94300

Split some number parsing functions in preparation for the next part:

js::GetPrefixInteger():

  • JSContext* is only needed when calling ComputeAccurateDecimalInteger(),
    so split that call out of GetPrefixInteger(), so we can call
    GetPrefixInteger() from the compiler without a JSContext*.

js::CharsToNumber():

  • Split CharToNumber() and CharsToNonDecimalNumber() from js::CharsToNumber(),
    so we can reuse both functions in the next part more easily.
  • Also rename bp to start to be more consistent with the rest of "jsnum.cpp".

Depends on D94301

Constant fold all strings in MGuardStringToInt32 and MGuardStringToDouble, as
long as we don't need to call into js_strtod_harder. js_strtod_harder
requires to have a DtoaState and because we don't have a DtoaState at hand
during constant folding and because we probably don't want to create it for
each and every MGuardStringToInt32 and MGuardStringToDouble node, we don't yet
support constant folding strings with fractional numbers.

Depends on D94302

Pushed by rmaries@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8653ea92590d
Part 1: Remove indirection in CharsToNumber. r=jandem
https://hg.mozilla.org/integration/autoland/rev/16ef1f850113
Part 2: Drop "Helper" from {Int32,Number}ToStringHelperPure. r=jandem
https://hg.mozilla.org/integration/autoland/rev/02c688def296
Part 3: Change num_parseInt to a static function. r=jandem
https://hg.mozilla.org/integration/autoland/rev/3bcd5365903e
Part 4: Split some number parsing functions. r=jandem
https://hg.mozilla.org/integration/autoland/rev/899e66b63e53
Part 5: Fold non-index strings in MGuardStringToInt32 and MGuardStringToDouble. r=jandem
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: