mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1781008 - Part 5: Use JSContext-free variant of AutoCheckRecursionLimit in frontend. r=bthrall
Depends on D152782 Differential Revision: https://phabricator.services.mozilla.com/D152783
This commit is contained in:
parent
7ed1d2a8c0
commit
fa7764a2a3
@ -827,7 +827,7 @@ JSOp BytecodeEmitter::strictifySetNameOp(JSOp op) {
|
||||
}
|
||||
|
||||
bool BytecodeEmitter::checkSideEffects(ParseNode* pn, bool* answer) {
|
||||
AutoCheckRecursionLimit recursion(cx);
|
||||
AutoCheckRecursionLimit recursion(ec);
|
||||
if (!recursion.check(ec, stackLimit)) {
|
||||
return false;
|
||||
}
|
||||
@ -7546,7 +7546,7 @@ bool BytecodeEmitter::emitOptionalCalleeAndThis(ParseNode* callee,
|
||||
CallNode* call,
|
||||
CallOrNewEmitter& cone,
|
||||
OptionalEmitter& oe) {
|
||||
AutoCheckRecursionLimit recursion(cx);
|
||||
AutoCheckRecursionLimit recursion(ec);
|
||||
if (!recursion.check(ec, stackLimit)) {
|
||||
return false;
|
||||
}
|
||||
@ -8206,7 +8206,7 @@ bool BytecodeEmitter::emitPrivateInExpr(ListNode* node) {
|
||||
bool BytecodeEmitter::emitOptionalTree(
|
||||
ParseNode* pn, OptionalEmitter& oe,
|
||||
ValueUsage valueUsage /* = ValueUsage::WantValue */) {
|
||||
AutoCheckRecursionLimit recursion(cx);
|
||||
AutoCheckRecursionLimit recursion(ec);
|
||||
if (!recursion.check(ec, stackLimit)) {
|
||||
return false;
|
||||
}
|
||||
@ -10951,7 +10951,7 @@ bool BytecodeEmitter::emitExportDefault(BinaryNode* exportNode) {
|
||||
bool BytecodeEmitter::emitTree(
|
||||
ParseNode* pn, ValueUsage valueUsage /* = ValueUsage::WantValue */,
|
||||
EmitLineNumberNote emitLineNote /* = EMIT_LINENOTE */) {
|
||||
AutoCheckRecursionLimit recursion(cx);
|
||||
AutoCheckRecursionLimit recursion(ec);
|
||||
if (!recursion.check(ec, stackLimit)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ static bool ListContainsHoistedDeclaration(FoldInfo& info, ListNode* list,
|
||||
// |node| being completely eliminated as dead.
|
||||
static bool ContainsHoistedDeclaration(FoldInfo& info, ParseNode* node,
|
||||
bool* result) {
|
||||
AutoCheckRecursionLimit recursion(info.cx);
|
||||
AutoCheckRecursionLimit recursion(info.ec);
|
||||
if (!recursion.check(info.ec, info.stackLimit)) {
|
||||
return false;
|
||||
}
|
||||
@ -1313,17 +1313,19 @@ static bool FoldAdd(FoldInfo info, ParseNode** nodePtr) {
|
||||
class FoldVisitor : public RewritingParseNodeVisitor<FoldVisitor> {
|
||||
using Base = RewritingParseNodeVisitor;
|
||||
|
||||
JSContext* cx;
|
||||
ParserAtomsTable& parserAtoms;
|
||||
FullParseHandler* handler;
|
||||
|
||||
FoldInfo info() const {
|
||||
return FoldInfo{cx_, ec_, stackLimit_, parserAtoms, handler};
|
||||
return FoldInfo{cx, ec_, stackLimit_, parserAtoms, handler};
|
||||
}
|
||||
|
||||
public:
|
||||
FoldVisitor(JSContext* cx, ErrorContext* ec, uintptr_t stackLimit,
|
||||
ParserAtomsTable& parserAtoms, FullParseHandler* handler)
|
||||
: RewritingParseNodeVisitor(cx, ec, stackLimit),
|
||||
: RewritingParseNodeVisitor(ec, stackLimit),
|
||||
cx(cx),
|
||||
parserAtoms(parserAtoms),
|
||||
handler(handler) {}
|
||||
|
||||
|
@ -26,6 +26,7 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
|
||||
static const size_t MaxParents = 100;
|
||||
|
||||
JSContext* cx_;
|
||||
ParserAtomsTable& parserAtoms_;
|
||||
TaggedParserAtomIndex prefix_;
|
||||
|
||||
@ -451,7 +452,8 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
|
||||
NameResolver(JSContext* cx, ErrorContext* ec, uintptr_t stackLimit,
|
||||
ParserAtomsTable& parserAtoms)
|
||||
: ParseNodeVisitor(cx, ec, stackLimit),
|
||||
: ParseNodeVisitor(ec, stackLimit),
|
||||
cx_(cx),
|
||||
parserAtoms_(parserAtoms),
|
||||
nparents_(0),
|
||||
buf_(cx) {}
|
||||
|
@ -21,9 +21,9 @@ class ParseNodeVerifier : public ParseNodeVisitor<ParseNodeVerifier> {
|
||||
const LifoAlloc& alloc_;
|
||||
|
||||
public:
|
||||
ParseNodeVerifier(JSContext* cx, ErrorContext* ec, uintptr_t stackLimit,
|
||||
ParseNodeVerifier(ErrorContext* ec, uintptr_t stackLimit,
|
||||
const LifoAlloc& alloc)
|
||||
: Base(cx, ec, stackLimit), alloc_(alloc) {}
|
||||
: Base(ec, stackLimit), alloc_(alloc) {}
|
||||
|
||||
[[nodiscard]] bool visit(ParseNode* pn) {
|
||||
// pn->size() asserts that pn->pn_kind is valid, so we don't redundantly
|
||||
@ -42,10 +42,9 @@ class ParseNodeVerifier : public ParseNodeVisitor<ParseNodeVerifier> {
|
||||
} // namespace frontend
|
||||
} // namespace js
|
||||
|
||||
bool frontend::CheckParseTree(JSContext* cx, ErrorContext* ec,
|
||||
uintptr_t stackLimit, const LifoAlloc& alloc,
|
||||
ParseNode* pn) {
|
||||
ParseNodeVerifier verifier(cx, ec, stackLimit, alloc);
|
||||
bool frontend::CheckParseTree(ErrorContext* ec, uintptr_t stackLimit,
|
||||
const LifoAlloc& alloc, ParseNode* pn) {
|
||||
ParseNodeVerifier verifier(ec, stackLimit, alloc);
|
||||
return verifier.visit(pn);
|
||||
}
|
||||
|
||||
|
@ -26,20 +26,17 @@ class ParseNode;
|
||||
// If the ParseNode is actually bad, we crash.
|
||||
|
||||
#ifdef DEBUG
|
||||
[[nodiscard]] extern bool CheckParseTree(JSContext* cx, ErrorContext* ec,
|
||||
uintptr_t stackLimit,
|
||||
[[nodiscard]] extern bool CheckParseTree(ErrorContext* ec, uintptr_t stackLimit,
|
||||
const LifoAlloc& alloc, ParseNode* pn);
|
||||
#else
|
||||
[[nodiscard]] inline bool CheckParseTree(JSContext* cx, ErrorContext* ec,
|
||||
uintptr_t stackLimit,
|
||||
[[nodiscard]] inline bool CheckParseTree(ErrorContext* ec, uintptr_t stackLimit,
|
||||
const LifoAlloc& alloc,
|
||||
ParseNode* pn) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
[[nodiscard]] inline bool CheckParseTree(JSContext* cx, ErrorContext* ec,
|
||||
uintptr_t stackLimit,
|
||||
[[nodiscard]] inline bool CheckParseTree(ErrorContext* ec, uintptr_t stackLimit,
|
||||
const LifoAlloc& alloc,
|
||||
SyntaxParseHandler::Node pn) {
|
||||
return true;
|
||||
|
@ -53,15 +53,14 @@ namespace frontend {
|
||||
template <typename Derived>
|
||||
class ParseNodeVisitor {
|
||||
public:
|
||||
JSContext* cx_;
|
||||
ErrorContext* ec_;
|
||||
uintptr_t stackLimit_;
|
||||
|
||||
ParseNodeVisitor(JSContext* cx, ErrorContext* ec, uintptr_t stackLimit)
|
||||
: cx_(cx), ec_(ec), stackLimit_(stackLimit) {}
|
||||
ParseNodeVisitor(ErrorContext* ec, uintptr_t stackLimit)
|
||||
: ec_(ec), stackLimit_(stackLimit) {}
|
||||
|
||||
[[nodiscard]] bool visit(ParseNode* pn) {
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(ec_);
|
||||
if (!recursion.check(ec_, stackLimit_)) {
|
||||
return false;
|
||||
}
|
||||
@ -101,16 +100,14 @@ class ParseNodeVisitor {
|
||||
template <typename Derived>
|
||||
class RewritingParseNodeVisitor {
|
||||
public:
|
||||
JSContext* cx_;
|
||||
ErrorContext* ec_;
|
||||
uintptr_t stackLimit_;
|
||||
|
||||
RewritingParseNodeVisitor(JSContext* cx, ErrorContext* ec,
|
||||
uintptr_t stackLimit)
|
||||
: cx_(cx), ec_(ec), stackLimit_(stackLimit) {}
|
||||
RewritingParseNodeVisitor(ErrorContext* ec, uintptr_t stackLimit)
|
||||
: ec_(ec), stackLimit_(stackLimit) {}
|
||||
|
||||
[[nodiscard]] bool visit(ParseNode*& pn) {
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(ec_);
|
||||
if (!recursion.check(ec_, stackLimit_)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ typename ParseHandler::ListNodeType GeneralParser<ParseHandler, Unit>::parse() {
|
||||
return null();
|
||||
}
|
||||
|
||||
if (!CheckParseTree(cx_, this->ec_, this->stackLimit_, alloc_, stmtList)) {
|
||||
if (!CheckParseTree(this->ec_, this->stackLimit_, alloc_, stmtList)) {
|
||||
return null();
|
||||
}
|
||||
|
||||
@ -1766,7 +1766,7 @@ LexicalScopeNode* Parser<FullParseHandler, Unit>::evalBody(
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!CheckParseTree(cx_, this->ec_, this->stackLimit_, alloc_, body)) {
|
||||
if (!CheckParseTree(this->ec_, this->stackLimit_, alloc_, body)) {
|
||||
return null();
|
||||
}
|
||||
|
||||
@ -1830,7 +1830,7 @@ ListNode* Parser<FullParseHandler, Unit>::globalBody(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!CheckParseTree(cx_, this->ec_, this->stackLimit_, alloc_, body)) {
|
||||
if (!CheckParseTree(this->ec_, this->stackLimit_, alloc_, body)) {
|
||||
return null();
|
||||
}
|
||||
|
||||
@ -1972,7 +1972,7 @@ ModuleNode* Parser<FullParseHandler, Unit>::moduleBody(
|
||||
}
|
||||
}
|
||||
|
||||
if (!CheckParseTree(cx_, this->ec_, this->stackLimit_, alloc_, stmtList)) {
|
||||
if (!CheckParseTree(this->ec_, this->stackLimit_, alloc_, stmtList)) {
|
||||
return null();
|
||||
}
|
||||
|
||||
@ -2371,7 +2371,7 @@ FunctionNode* Parser<FullParseHandler, Unit>::standaloneFunction(
|
||||
return null();
|
||||
}
|
||||
|
||||
if (!CheckParseTree(cx_, this->ec_, this->stackLimit_, alloc_, funNode)) {
|
||||
if (!CheckParseTree(this->ec_, this->stackLimit_, alloc_, funNode)) {
|
||||
return null();
|
||||
}
|
||||
|
||||
@ -3459,7 +3459,7 @@ FunctionNode* Parser<FullParseHandler, Unit>::standaloneLazyFunction(
|
||||
}
|
||||
}
|
||||
|
||||
if (!CheckParseTree(cx_, this->ec_, this->stackLimit_, alloc_, funNode)) {
|
||||
if (!CheckParseTree(this->ec_, this->stackLimit_, alloc_, funNode)) {
|
||||
return null();
|
||||
}
|
||||
|
||||
@ -4038,7 +4038,7 @@ bool GeneralParser<ParseHandler, Unit>::maybeParseDirective(
|
||||
template <class ParseHandler, typename Unit>
|
||||
typename ParseHandler::ListNodeType
|
||||
GeneralParser<ParseHandler, Unit>::statementList(YieldHandling yieldHandling) {
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -4357,7 +4357,7 @@ GeneralParser<ParseHandler, Unit>::objectBindingPattern(
|
||||
DeclarationKind kind, YieldHandling yieldHandling) {
|
||||
MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftCurly));
|
||||
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -4512,7 +4512,7 @@ GeneralParser<ParseHandler, Unit>::arrayBindingPattern(
|
||||
DeclarationKind kind, YieldHandling yieldHandling) {
|
||||
MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftBracket));
|
||||
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -8908,7 +8908,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::statement(
|
||||
YieldHandling yieldHandling) {
|
||||
MOZ_ASSERT(checkOptionsCalled_);
|
||||
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -9155,7 +9155,7 @@ GeneralParser<ParseHandler, Unit>::statementListItem(
|
||||
YieldHandling yieldHandling, bool canHaveDirectives /* = false */) {
|
||||
MOZ_ASSERT(checkOptionsCalled_);
|
||||
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -9712,7 +9712,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::assignExpr(
|
||||
TripledotHandling tripledotHandling,
|
||||
PossibleError* possibleError /* = nullptr */,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */) {
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -10090,7 +10090,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::optionalExpr(
|
||||
YieldHandling yieldHandling, TripledotHandling tripledotHandling,
|
||||
TokenKind tt, PossibleError* possibleError /* = nullptr */,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */) {
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -10202,7 +10202,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::unaryExpr(
|
||||
PossibleError* possibleError /* = nullptr */,
|
||||
InvokedPrediction invoked /* = PredictUninvoked */,
|
||||
PrivateNameHandling privateNameHandling /* = PrivateNameProhibited */) {
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -10477,7 +10477,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::memberExpr(
|
||||
|
||||
Node lhs;
|
||||
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
@ -12385,7 +12385,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::primaryExpr(
|
||||
YieldHandling yieldHandling, TripledotHandling tripledotHandling,
|
||||
TokenKind tt, PossibleError* possibleError, InvokedPrediction invoked) {
|
||||
MOZ_ASSERT(anyChars.isCurrentTokenType(tt));
|
||||
AutoCheckRecursionLimit recursion(cx_);
|
||||
AutoCheckRecursionLimit recursion(this->ec_);
|
||||
if (!recursion.check(this->ec_, this->stackLimit_)) {
|
||||
return null();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user