Warp: Fold non-index strings in MGuardStringToInt32 and MGuardStringToDouble
Categories
(Core :: JavaScript Engine: JIT, enhancement)
Tracking
()
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
Assignee | ||
Comment 1•4 years ago
|
||
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.
Assignee | ||
Comment 2•4 years ago
|
||
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
Assignee | ||
Comment 3•4 years ago
|
||
num_parseInt
is no longer accessed outside of "jsnum.cpp", so we might as
well change it to static
.
Depends on D94300
Assignee | ||
Comment 4•4 years ago
|
||
Split some number parsing functions in preparation for the next part:
js::GetPrefixInteger()
:
JSContext*
is only needed when callingComputeAccurateDecimalInteger()
,
so split that call out ofGetPrefixInteger()
, so we can call
GetPrefixInteger()
from the compiler without aJSContext*
.
js::CharsToNumber()
:
- Split
CharToNumber()
andCharsToNonDecimalNumber()
fromjs::CharsToNumber()
,
so we can reuse both functions in the next part more easily. - Also rename
bp
tostart
to be more consistent with the rest of "jsnum.cpp".
Depends on D94301
Assignee | ||
Comment 5•4 years ago
|
||
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
Comment 7•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8653ea92590d
https://hg.mozilla.org/mozilla-central/rev/16ef1f850113
https://hg.mozilla.org/mozilla-central/rev/02c688def296
https://hg.mozilla.org/mozilla-central/rev/3bcd5365903e
https://hg.mozilla.org/mozilla-central/rev/899e66b63e53
Description
•