Precalculate principal for AutoCheckRecursionLimit in frontend
Categories
(Core :: JavaScript Engine, task, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox105 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(7 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
The principal calculation requires JSContext*
, and also the calculation inside AutoCheckRecursionLimit
is problematic in term of performance.
MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkWithStackPointerDontReport(
JSContext* cx, void* sp) const {
// getStackLimitSlow(cx) is pretty slow because it has to do an uninlined
// call to runningWithTrustedPrincipals to determine which stack limit to
// use. To work around this, check the untrusted limit first to avoid the
// overhead in most cases.
uintptr_t untrustedLimit =
getStackLimitHelper(cx, JS::StackForUntrustedScript, 0);
if (MOZ_LIKELY(checkLimitImpl(untrustedLimit, sp))) {
return true;
}
return checkLimitImpl(getStackLimitSlow(cx), sp);
Inside frontend, the principal is already known and it doesn't change during single compilation, and we should pre-calculate it and feed the stack limit directly.
Assignee | ||
Comment 1•3 years ago
|
||
Instead of using JSContext*
to calculate the stack limit internally,
receive the stack limit as parameter.
Assignee | ||
Comment 2•3 years ago
|
||
Move the stack limit calculation around principal into JSContext
method,
so that some consumer can pre-calculate it and feed it to
AutoCheckRecursionLimit
.
Depends on D152772
Assignee | ||
Comment 3•3 years ago
|
||
Depends on D152773
Assignee | ||
Comment 4•3 years ago
|
||
parent
parameter is used only internally.
Remove parent
parameter from public methods.
This simplifies the stack limit parameter in the next patch.
Depends on D152774
Assignee | ||
Comment 5•3 years ago
|
||
Depends on D152775
Assignee | ||
Comment 6•3 years ago
|
||
FoldVisitor is subclass of RewritingParseNodeVisitor, which has
JSContext* field. and FoldVisitor doesn't have to have the same field.
Depends on D152776
Assignee | ||
Comment 7•3 years ago
|
||
Depends on D152777
Comment 9•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/4e1f50a9d0d7
https://hg.mozilla.org/mozilla-central/rev/17314cfdf984
https://hg.mozilla.org/mozilla-central/rev/a6da48864831
https://hg.mozilla.org/mozilla-central/rev/ad790c2acf09
https://hg.mozilla.org/mozilla-central/rev/aff25780db95
https://hg.mozilla.org/mozilla-central/rev/240d1931ce20
https://hg.mozilla.org/mozilla-central/rev/c6adbe1e7195
Description
•