Optimise String.prototype.replace and String.prototype.split in CacheIR and Warp
Categories
(Core :: JavaScript Engine: JIT, task, P1)
Tracking
()
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(9 files, 2 obsolete files)
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review | |
47 bytes,
text/x-phabricator-request
|
Details | Review |
Support StringReplaceString
, StringSplitString
, and ObjectHasPrototype
in CacheIR and Warp. Plus transpile any remaining CacheIR ops used within String.prototype.replace
and String.prototype.split
(i.e. LoadValueTag
and GuardTagNotEqual
).
To ensure the generated code looks sensible (*), also apply additional optimisations to MCompare
and replace the GetBuiltinPrototype()
and GetBuiltinConstructor()
intrinsics with a new JSOp
.
(*) The generated code will look almost sensible, except that it's still cluttered with MBail
instructions in unreachable code. This is probably caused by https://searchfox.org/mozilla-central/rev/cf561cece0ca9aeaf0202e68699836d957d0c670/js/src/jit/WarpBuilder.cpp#3094-3095.
Assignee | ||
Comment 1•5 years ago
|
||
LoadValueTag is used when comparing strictly different types. This happens in
the string built-ins when the this-value is a primitive string and it is
compared against null or undefined.
Value tags are represented as MIRType::Int32 and folding is supported to be
able to optimise away the checks after inlining.
Assignee | ||
Comment 2•5 years ago
|
||
Swapping bi
's operands should depend on bi
itself being commutative.
Drive-by change: Use std::swap
to swap the operands.
Depends on D84976
Assignee | ||
Comment 3•5 years ago
|
||
Depends on D84977
Assignee | ||
Comment 4•5 years ago
|
||
This is part two to support comparing strictly different types in Warp.
The operation doesn't have any result, so when folding it, MNop
is used to
optimise it away when the value tags are already different at compile time.
Depends on D84978
Assignee | ||
Comment 5•5 years ago
|
||
The next part will add a different tryFoldTypeOf()
method, so rename the
existing one to avoid any confusion.
Drive-by change: Correct the access specifiers.
Depends on D84980
Assignee | ||
Comment 6•5 years ago
|
||
String built-ins use typeof thing === "string"
to check for string values.
These were compiled to LTypeOfV
followed by a string comparison. Using
MLoadValueTag
from part 1 can make this more efficient.
Depends on D84982
Assignee | ||
Comment 7•5 years ago
|
||
Inling ObjectHasPrototype()
using the GuardProto
CacheIR op for the normal
case when the prototype chain wasn't modified.
Also change intrinsic_ObjectHasPrototype()
to expect that both objects are
NativeObject
, because then we don't need to handle proxies in CacheIR.
Drive-by change:
- Use
staticPrototype()
in ObjectOperations-inl.h instead of effectively inlining it.
Depends on D84983
Assignee | ||
Comment 8•5 years ago
|
||
Drive-by change:
- Remove a bogus
resumeAfter()
,MStringReplace
is never effectful.
Depends on D84984
Assignee | ||
Comment 9•5 years ago
|
||
Warp can't currently fold away MToString
, as a workaround handle the already
string case in WarpBuilder.
Depends on D84987
Assignee | ||
Comment 10•5 years ago
|
||
Drive-by change:
- Make
intrinsic_StringSplitString
a static function.
Depends on D84988
Assignee | ||
Comment 11•5 years ago
|
||
Callers to GetBuiltinPrototype()
rely on inlining the function itself plus
optimising the object access, so that the property value is directly seen as a
constant in the compiler. By changing GetBuiltinPrototype()
and
GetBuiltinConstructor()
to be directly translated into a JSOp, we can avoid
heavily relying on the compiler to optimise these two functions.
The new opcode replaces the existing JSOp::FunctionProto opcode. It doesn't
use JSProtoKey directly in order to help jsparagus (bug 1622530), but instead
uses its own set of mapping from enum values to built-in prototypes and
constructors.
This change also resolves bug 1377264.
Depends on D84989
Comment 12•5 years ago
|
||
That GetBuiltinPrototype
change is great! I ran into that a few weeks ago when optimizing the RegExp intrinsics, and the old code was surprising.
Updated•5 years ago
|
Comment 13•5 years ago
|
||
Comment 14•5 years ago
•
|
||
Backed out 11 changesets (bug 1655465) for build bustage in builds/worker/checkouts/gecko/js/src/jit/MIR.cpp. CLOSED TREE
Log:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=311630553&repo=autoland&lineNumber=31233
Log:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=311630575&repo=autoland&lineNumber=3716
Log:
https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=311630574&repo=autoland&lineNumber=22479
Push with failures:
https://treeherder.mozilla.org/#/jobs?repo=autoland&group_state=expanded&revision=c477201186138888f467cb1c996bd467eb57f7d7
Backout:
https://hg.mozilla.org/integration/autoland/rev/8c8ff40a0a104cf8a5165a57dcd10aa7c9c48156
Assignee | ||
Updated•5 years ago
|
Comment 15•5 years ago
|
||
Comment 16•5 years ago
|
||
Backed out for breaking SM builds
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=311684869&repo=autoland&lineNumber=4939
Backout: https://hg.mozilla.org/integration/autoland/rev/801b59414882378eff04a7e5ac0b27a8c91fd59d
Comment 17•5 years ago
|
||
Also caused jit test failures: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=311688205&repo=autoland&lineNumber=1739
Comment 18•5 years ago
|
||
Support for GuardTagNotEqual would be great to have. This is also used by (obj = GuardToArrayIterator(this)) === null
in ArrayIteratorNext
.
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 19•5 years ago
|
||
Comment 20•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/b1062d8261fc
https://hg.mozilla.org/mozilla-central/rev/1dc74f4f2413
https://hg.mozilla.org/mozilla-central/rev/c0d82360f73b
https://hg.mozilla.org/mozilla-central/rev/35399bebf4b6
https://hg.mozilla.org/mozilla-central/rev/5b74237b6a7e
https://hg.mozilla.org/mozilla-central/rev/2867f1a4afcb
https://hg.mozilla.org/mozilla-central/rev/b958b136e2a8
https://hg.mozilla.org/mozilla-central/rev/02cbce29b638
https://hg.mozilla.org/mozilla-central/rev/834447abbbf1
Updated•5 years ago
|
Description
•