From 87b741714090db91c796e3fbcd86003ebb23f93e Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa <arai_a@mac.com> Date: Wed, 31 May 2023 01:26:45 +0000 Subject: [PATCH] Bug 1834483 - Part 8: Remove NativeStackLimit field from Parser and BytecodeEmitter. r=bthrall Differential Revision: https://phabricator.services.mozilla.com/D179009 --- js/public/friend/StackLimits.h | 21 ++++--- js/src/builtin/ReflectParse.cpp | 3 +- js/src/debugger/Debugger.cpp | 3 +- js/src/frontend/BytecodeCompiler.cpp | 20 +++--- js/src/frontend/BytecodeEmitter.cpp | 26 +++----- js/src/frontend/BytecodeEmitter.h | 20 +++--- js/src/frontend/FoldConstants.cpp | 35 +++++------ js/src/frontend/FoldConstants.h | 5 +- js/src/frontend/NameFunctions.cpp | 13 ++-- js/src/frontend/NameFunctions.h | 2 - js/src/frontend/ParseNodeVerify.cpp | 13 ++-- js/src/frontend/ParseNodeVerify.h | 4 -- js/src/frontend/ParseNodeVisitor.h | 14 ++--- js/src/frontend/Parser.cpp | 85 ++++++++++++-------------- js/src/frontend/Parser.h | 21 +++---- js/src/jsfriendapi.cpp | 6 ++ js/src/shell/js.cpp | 10 +-- js/src/vm/CompilationAndEvaluation.cpp | 8 +-- js/src/wasm/AsmJS.cpp | 8 +-- 19 files changed, 134 insertions(+), 183 deletions(-) diff --git a/js/public/friend/StackLimits.h b/js/public/friend/StackLimits.h index 558b3fdd28799..061c0efcf027c 100644 --- a/js/public/friend/StackLimits.h +++ b/js/public/friend/StackLimits.h @@ -71,6 +71,8 @@ class MOZ_RAII AutoCheckRecursionLimit { MOZ_ALWAYS_INLINE JS::NativeStackLimit getStackLimitHelper( JSContext* cx, JS::StackKind kind, int extraAllowance) const; + JS::NativeStackLimit getStackLimit(FrontendContext* fc) const; + JS_PUBLIC_API JS::StackKind stackKindForCurrentPrincipal(JSContext* cx) const; JS_PUBLIC_API void assertMainThread(JSContext* cx) const; @@ -150,17 +152,16 @@ class MOZ_RAII AutoCheckRecursionLimit { void operator=(const AutoCheckRecursionLimit&) = delete; [[nodiscard]] MOZ_ALWAYS_INLINE bool check(JSContext* cx) const; - [[nodiscard]] MOZ_ALWAYS_INLINE bool check(FrontendContext* fc, - JS::NativeStackLimit limit) const; + [[nodiscard]] MOZ_ALWAYS_INLINE bool check(FrontendContext* fc) const; [[nodiscard]] MOZ_ALWAYS_INLINE bool checkDontReport(JSContext* cx) const; [[nodiscard]] MOZ_ALWAYS_INLINE bool checkDontReport( - JS::NativeStackLimit limit) const; + FrontendContext* fc) const; [[nodiscard]] MOZ_ALWAYS_INLINE bool checkWithExtra(JSContext* cx, size_t extra) const; [[nodiscard]] MOZ_ALWAYS_INLINE bool checkWithStackPointerDontReport( JSContext* cx, void* sp) const; [[nodiscard]] MOZ_ALWAYS_INLINE bool checkWithStackPointerDontReport( - JS::NativeStackLimit limit, void* sp) const; + FrontendContext* fc, void* sp) const; [[nodiscard]] MOZ_ALWAYS_INLINE bool checkConservative(JSContext* cx) const; [[nodiscard]] MOZ_ALWAYS_INLINE bool checkConservativeDontReport( @@ -222,8 +223,8 @@ MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::check(JSContext* cx) const { } MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::check( - FrontendContext* fc, JS::NativeStackLimit limit) const { - if (MOZ_UNLIKELY(!checkDontReport(limit))) { + FrontendContext* fc) const { + if (MOZ_UNLIKELY(!checkDontReport(fc))) { ReportOverRecursed(fc); return false; } @@ -237,9 +238,9 @@ MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkDontReport( } MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkDontReport( - JS::NativeStackLimit limit) const { + FrontendContext* fc) const { int stackDummy; - return checkWithStackPointerDontReport(limit, &stackDummy); + return checkWithStackPointerDontReport(fc, &stackDummy); } MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkWithStackPointerDontReport( @@ -257,8 +258,8 @@ MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkWithStackPointerDontReport( } MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkWithStackPointerDontReport( - JS::NativeStackLimit limit, void* sp) const { - return checkLimitImpl(limit, sp); + FrontendContext* fc, void* sp) const { + return checkLimitImpl(getStackLimit(fc), sp); } MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkWithExtra( diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index e2f37abb0c4f9..c3a0e1afc04d8 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -3745,8 +3745,7 @@ static bool reflect_parse(JSContext* cx, uint32_t argc, Value* vp) { } Parser<FullParseHandler, char16_t> parser( - &fc, cx->stackLimitForCurrentPrincipal(), options, chars.begin().get(), - chars.length(), + &fc, options, chars.begin().get(), chars.length(), /* foldConstants = */ false, compilationState, /* syntaxParser = */ nullptr); if (!parser.checkOptions()) { diff --git a/js/src/debugger/Debugger.cpp b/js/src/debugger/Debugger.cpp index 711bca9a491b5..ff0b8d36d884d 100644 --- a/js/src/debugger/Debugger.cpp +++ b/js/src/debugger/Debugger.cpp @@ -6141,8 +6141,7 @@ bool Debugger::isCompilableUnit(JSContext* cx, unsigned argc, Value* vp) { } frontend::Parser<frontend::FullParseHandler, char16_t> parser( - &fc, cx->stackLimitForCurrentPrincipal(), options, chars.twoByteChars(), - length, + &fc, options, chars.twoByteChars(), length, /* foldConstants = */ true, compilationState, /* syntaxParser = */ nullptr); if (!parser.checkOptions() || !parser.parse()) { diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index 5583a7e35b3d2..ba5f767f2d1b4 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -630,7 +630,7 @@ bool SourceAwareCompiler<Unit>::createSourceAndParser(FrontendContext* fc) { MOZ_ASSERT(compilationState_.canLazilyParse == CanLazilyParse(compilationState_.input.options)); if (compilationState_.canLazilyParse) { - syntaxParser.emplace(fc_, fc_->stackLimit(), options, sourceBuffer_.units(), + syntaxParser.emplace(fc_, options, sourceBuffer_.units(), sourceBuffer_.length(), /* foldConstants = */ false, compilationState_, /* syntaxParser = */ nullptr); @@ -639,8 +639,7 @@ bool SourceAwareCompiler<Unit>::createSourceAndParser(FrontendContext* fc) { } } - parser.emplace(fc_, fc_->stackLimit(), options, sourceBuffer_.units(), - sourceBuffer_.length(), + parser.emplace(fc_, options, sourceBuffer_.units(), sourceBuffer_.length(), /* foldConstants = */ true, compilationState_, syntaxParser.ptrOr(nullptr)); parser->ss = compilationState_.source.get(); @@ -652,8 +651,7 @@ static bool EmplaceEmitter(CompilationState& compilationState, const EitherParser& parser, SharedContext* sc) { BytecodeEmitter::EmitterMode emitterMode = sc->selfHosted() ? BytecodeEmitter::SelfHosting : BytecodeEmitter::Normal; - emitter.emplace(fc, fc->stackLimit(), parser, sc, compilationState, - emitterMode); + emitter.emplace(fc, parser, sc, compilationState, emitterMode); return emitter->init(); } @@ -1177,10 +1175,10 @@ static bool CompileLazyFunctionToStencilMaybeInstantiate( return false; } - Parser<FullParseHandler, Unit> parser( - fc, fc->stackLimit(), input.options, units, length, - /* foldConstants = */ true, compilationState, - /* syntaxParser = */ nullptr); + Parser<FullParseHandler, Unit> parser(fc, input.options, units, length, + /* foldConstants = */ true, + compilationState, + /* syntaxParser = */ nullptr); if (!parser.checkOptions()) { return false; } @@ -1192,8 +1190,8 @@ static bool CompileLazyFunctionToStencilMaybeInstantiate( return false; } - BytecodeEmitter bce(fc, fc->stackLimit(), &parser, pn->funbox(), - compilationState, BytecodeEmitter::LazyFunction); + BytecodeEmitter bce(fc, &parser, pn->funbox(), compilationState, + BytecodeEmitter::LazyFunction); if (!bce.init(pn->pn_pos)) { return false; } diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index a790bb5472a1d..66d56147157aa 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -60,7 +60,6 @@ #include "frontend/WhileEmitter.h" // WhileEmitter #include "js/friend/ErrorMessages.h" // JSMSG_* #include "js/friend/StackLimits.h" // AutoCheckRecursionLimit -#include "js/Stack.h" // JS::NativeStackLimit #include "util/StringBuffer.h" // StringBuffer #include "vm/BytecodeUtil.h" // JOF_*, IsArgOp, IsLocalOp, SET_UINT24, SET_ICINDEX, BytecodeFallsThrough, BytecodeIsJumpTarget #include "vm/CompletionKind.h" // CompletionKind @@ -133,14 +132,12 @@ static bool ShouldSuppressBreakpointsAndSourceNotes( } BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent, FrontendContext* fc, - JS::NativeStackLimit stackLimit, SharedContext* sc, const ErrorReporter& errorReporter, CompilationState& compilationState, EmitterMode emitterMode) : sc(sc), fc(fc), - stackLimit(stackLimit), parent(parent), bytecodeSection_(fc, sc->extent().lineno, sc->extent().column), perScriptData_(fc, compilationState), @@ -149,22 +146,19 @@ BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent, FrontendContext* fc, suppressBreakpointsAndSourceNotes( ShouldSuppressBreakpointsAndSourceNotes(sc, emitterMode)), emitterMode(emitterMode) { - MOZ_ASSERT_IF(parent, stackLimit == parent->stackLimit); MOZ_ASSERT_IF(parent, fc == parent->fc); } BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent, SharedContext* sc) - : BytecodeEmitter(parent, parent->fc, parent->stackLimit, sc, - parent->errorReporter_, parent->compilationState, - parent->emitterMode) {} + : BytecodeEmitter(parent, parent->fc, sc, parent->errorReporter_, + parent->compilationState, parent->emitterMode) {} BytecodeEmitter::BytecodeEmitter(FrontendContext* fc, - JS::NativeStackLimit stackLimit, const EitherParser& parser, SharedContext* sc, CompilationState& compilationState, EmitterMode emitterMode) - : BytecodeEmitter(nullptr, fc, stackLimit, sc, parser.errorReporter(), - compilationState, emitterMode) { + : BytecodeEmitter(nullptr, fc, sc, parser.errorReporter(), compilationState, + emitterMode) { ep_.emplace(parser); } @@ -820,7 +814,7 @@ JSOp BytecodeEmitter::strictifySetNameOp(JSOp op) { bool BytecodeEmitter::checkSideEffects(ParseNode* pn, bool* answer) { AutoCheckRecursionLimit recursion(fc); - if (!recursion.check(fc, stackLimit)) { + if (!recursion.check(fc)) { return false; } @@ -2441,7 +2435,7 @@ bool BytecodeEmitter::emitScript(ParseNode* body) { return false; } - if (!NameFunctions(fc, stackLimit, parserAtoms(), body)) { + if (!NameFunctions(fc, parserAtoms(), body)) { return false; } @@ -2524,7 +2518,7 @@ bool BytecodeEmitter::emitFunctionScript(FunctionNode* funNode) { } if (funbox->index() == CompilationStencil::TopLevelIndex) { - if (!NameFunctions(fc, stackLimit, parserAtoms(), funNode)) { + if (!NameFunctions(fc, parserAtoms(), funNode)) { return false; } } @@ -7633,7 +7627,7 @@ bool BytecodeEmitter::emitOptionalCalleeAndThis(ParseNode* callee, CallOrNewEmitter& cone, OptionalEmitter& oe) { AutoCheckRecursionLimit recursion(fc); - if (!recursion.check(fc, stackLimit)) { + if (!recursion.check(fc)) { return false; } @@ -8302,7 +8296,7 @@ bool BytecodeEmitter::emitOptionalTree( ParseNode* pn, OptionalEmitter& oe, ValueUsage valueUsage /* = ValueUsage::WantValue */) { AutoCheckRecursionLimit recursion(fc); - if (!recursion.check(fc, stackLimit)) { + if (!recursion.check(fc)) { return false; } ParseNodeKind kind = pn->getKind(); @@ -11251,7 +11245,7 @@ bool BytecodeEmitter::emitTree( ParseNode* pn, ValueUsage valueUsage /* = ValueUsage::WantValue */, EmitLineNumberNote emitLineNote /* = EMIT_LINENOTE */) { AutoCheckRecursionLimit recursion(fc); - if (!recursion.check(fc, stackLimit)) { + if (!recursion.check(fc)) { return false; } diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h index 97b88a82d1443..6d9c6eed0aa3f 100644 --- a/js/src/frontend/BytecodeEmitter.h +++ b/js/src/frontend/BytecodeEmitter.h @@ -34,7 +34,6 @@ #include "frontend/SourceNotes.h" // SrcNoteType #include "frontend/ValueUsage.h" // ValueUsage #include "js/AllocPolicy.h" // ReportOutOfMemory -#include "js/Stack.h" // JS::NativeStackLimit #include "js/TypeDecls.h" // jsbytecode #include "vm/BuiltinObjectKind.h" // BuiltinObjectKind #include "vm/CheckIsObjectKind.h" // CheckIsObjectKind @@ -211,8 +210,6 @@ struct MOZ_STACK_CLASS BytecodeEmitter { FrontendContext* const fc = nullptr; - JS::NativeStackLimit stackLimit; - // Enclosing function or global context. BytecodeEmitter* const parent = nullptr; @@ -328,8 +325,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter { private: // Internal constructor, for delegation use only. BytecodeEmitter(BytecodeEmitter* parent, FrontendContext* fc, - JS::NativeStackLimit stackLimit, SharedContext* sc, - const ErrorReporter& errorReporter, + SharedContext* sc, const ErrorReporter& errorReporter, CompilationState& compilationState, EmitterMode emitterMode); BytecodeEmitter(BytecodeEmitter* parent, SharedContext* sc); @@ -337,18 +333,16 @@ struct MOZ_STACK_CLASS BytecodeEmitter { void initFromBodyPosition(TokenPos bodyPosition); public: - BytecodeEmitter(FrontendContext* fc, JS::NativeStackLimit stackLimit, - const EitherParser& parser, SharedContext* sc, - CompilationState& compilationState, + BytecodeEmitter(FrontendContext* fc, const EitherParser& parser, + SharedContext* sc, CompilationState& compilationState, EmitterMode emitterMode = Normal); template <typename Unit> - BytecodeEmitter(FrontendContext* fc, JS::NativeStackLimit stackLimit, - Parser<FullParseHandler, Unit>* parser, SharedContext* sc, - CompilationState& compilationState, + BytecodeEmitter(FrontendContext* fc, Parser<FullParseHandler, Unit>* parser, + SharedContext* sc, CompilationState& compilationState, EmitterMode emitterMode = Normal) - : BytecodeEmitter(fc, stackLimit, EitherParser(parser), sc, - compilationState, emitterMode) {} + : BytecodeEmitter(fc, EitherParser(parser), sc, compilationState, + emitterMode) {} [[nodiscard]] bool init(); [[nodiscard]] bool init(TokenPos bodyPosition); diff --git a/js/src/frontend/FoldConstants.cpp b/js/src/frontend/FoldConstants.cpp index 1bec3ea0a7318..829a9fb5055fa 100644 --- a/js/src/frontend/FoldConstants.cpp +++ b/js/src/frontend/FoldConstants.cpp @@ -17,9 +17,8 @@ #include "frontend/ParseNodeVisitor.h" #include "frontend/ParserAtom.h" // ParserAtomsTable, TaggedParserAtomIndex #include "js/Conversions.h" -#include "js/friend/StackLimits.h" // js::AutoCheckRecursionLimit -#include "js/Stack.h" // JS::NativeStackLimit -#include "util/StringBuffer.h" // StringBuffer +#include "js/Stack.h" // JS::NativeStackLimit +#include "util/StringBuffer.h" // StringBuffer using namespace js; using namespace js::frontend; @@ -33,7 +32,6 @@ using mozilla::PositiveInfinity; struct FoldInfo { FrontendContext* fc; - JS::NativeStackLimit stackLimit; ParserAtomsTable& parserAtoms; FullParseHandler* handler; }; @@ -82,7 +80,7 @@ static bool ListContainsHoistedDeclaration(FoldInfo& info, ListNode* list, static bool ContainsHoistedDeclaration(FoldInfo& info, ParseNode* node, bool* result) { AutoCheckRecursionLimit recursion(info.fc); - if (!recursion.check(info.fc, info.stackLimit)) { + if (!recursion.check(info.fc)) { return false; } @@ -1316,14 +1314,12 @@ class FoldVisitor : public RewritingParseNodeVisitor<FoldVisitor> { ParserAtomsTable& parserAtoms; FullParseHandler* handler; - FoldInfo info() const { - return FoldInfo{fc_, stackLimit_, parserAtoms, handler}; - } + FoldInfo info() const { return FoldInfo{fc_, parserAtoms, handler}; } public: - FoldVisitor(FrontendContext* fc, JS::NativeStackLimit stackLimit, - ParserAtomsTable& parserAtoms, FullParseHandler* handler) - : RewritingParseNodeVisitor(fc, stackLimit), + FoldVisitor(FrontendContext* fc, ParserAtomsTable& parserAtoms, + FullParseHandler* handler) + : RewritingParseNodeVisitor(fc), parserAtoms(parserAtoms), handler(handler) {} @@ -1570,19 +1566,16 @@ class FoldVisitor : public RewritingParseNodeVisitor<FoldVisitor> { } }; -static bool Fold(FrontendContext* fc, JS::NativeStackLimit stackLimit, - ParserAtomsTable& parserAtoms, FullParseHandler* handler, - ParseNode** pnp) { - FoldVisitor visitor(fc, stackLimit, parserAtoms, handler); +static bool Fold(FrontendContext* fc, ParserAtomsTable& parserAtoms, + FullParseHandler* handler, ParseNode** pnp) { + FoldVisitor visitor(fc, parserAtoms, handler); return visitor.visit(*pnp); } static bool Fold(FoldInfo info, ParseNode** pnp) { - return Fold(info.fc, info.stackLimit, info.parserAtoms, info.handler, pnp); + return Fold(info.fc, info.parserAtoms, info.handler, pnp); } -bool frontend::FoldConstants(FrontendContext* fc, - JS::NativeStackLimit stackLimit, - ParserAtomsTable& parserAtoms, ParseNode** pnp, - FullParseHandler* handler) { - return Fold(fc, stackLimit, parserAtoms, handler, pnp); +bool frontend::FoldConstants(FrontendContext* fc, ParserAtomsTable& parserAtoms, + ParseNode** pnp, FullParseHandler* handler) { + return Fold(fc, parserAtoms, handler, pnp); } diff --git a/js/src/frontend/FoldConstants.h b/js/src/frontend/FoldConstants.h index beeb358d8e17c..70252b148b0aa 100644 --- a/js/src/frontend/FoldConstants.h +++ b/js/src/frontend/FoldConstants.h @@ -8,7 +8,6 @@ #define frontend_FoldConstants_h #include "frontend/SyntaxParseHandler.h" -#include "js/Stack.h" // JS::NativeStackLimit namespace js { @@ -33,17 +32,15 @@ class ParserAtomsTable; // if (!pn) { // return false; // } -// if (!FoldConstants(fc, stackLimit, parserAtoms, &pn, parser)) { +// if (!FoldConstants(fc, parserAtoms, &pn, parser)) { // return false; // } [[nodiscard]] extern bool FoldConstants(FrontendContext* fc, - JS::NativeStackLimit stackLimit, ParserAtomsTable& parserAtoms, ParseNode** pnp, FullParseHandler* handler); [[nodiscard]] inline bool FoldConstants(FrontendContext* fc, - JS::NativeStackLimit stackLimit, ParserAtomsTable& parserAtoms, typename SyntaxParseHandler::Node* pnp, SyntaxParseHandler* handler) { diff --git a/js/src/frontend/NameFunctions.cpp b/js/src/frontend/NameFunctions.cpp index b84912bd6b36d..0ad8e5575833c 100644 --- a/js/src/frontend/NameFunctions.cpp +++ b/js/src/frontend/NameFunctions.cpp @@ -13,7 +13,6 @@ #include "frontend/ParseNodeVisitor.h" #include "frontend/ParserAtom.h" // ParserAtomsTable #include "frontend/SharedContext.h" -#include "js/Stack.h" // JS::NativeStackLimit #include "util/Poison.h" #include "util/StringBuffer.h" @@ -489,9 +488,8 @@ class NameResolver : public ParseNodeVisitor<NameResolver> { return internalVisitSpecList(pn); } - NameResolver(FrontendContext* fc, JS::NativeStackLimit stackLimit, - ParserAtomsTable& parserAtoms) - : ParseNodeVisitor(fc, stackLimit), + NameResolver(FrontendContext* fc, ParserAtomsTable& parserAtoms) + : ParseNodeVisitor(fc), fc_(fc), parserAtoms_(parserAtoms), nparents_(0), @@ -526,9 +524,8 @@ class NameResolver : public ParseNodeVisitor<NameResolver> { } /* anonymous namespace */ -bool frontend::NameFunctions(FrontendContext* fc, - JS::NativeStackLimit stackLimit, - ParserAtomsTable& parserAtoms, ParseNode* pn) { - NameResolver nr(fc, stackLimit, parserAtoms); +bool frontend::NameFunctions(FrontendContext* fc, ParserAtomsTable& parserAtoms, + ParseNode* pn) { + NameResolver nr(fc, parserAtoms); return nr.visit(pn); } diff --git a/js/src/frontend/NameFunctions.h b/js/src/frontend/NameFunctions.h index 51cfb140adb34..aec65bdc5ea61 100644 --- a/js/src/frontend/NameFunctions.h +++ b/js/src/frontend/NameFunctions.h @@ -7,7 +7,6 @@ #ifndef frontend_NameFunctions_h #define frontend_NameFunctions_h -#include "js/Stack.h" // JS::NativeStackLimit #include "js/TypeDecls.h" namespace js { @@ -20,7 +19,6 @@ class ParseNode; class ParserAtomsTable; [[nodiscard]] bool NameFunctions(FrontendContext* fc, - JS::NativeStackLimit stackLimit, ParserAtomsTable& parserAtoms, ParseNode* pn); } /* namespace frontend */ diff --git a/js/src/frontend/ParseNodeVerify.cpp b/js/src/frontend/ParseNodeVerify.cpp index 3b4428e6c60c8..b23a60649ebc8 100644 --- a/js/src/frontend/ParseNodeVerify.cpp +++ b/js/src/frontend/ParseNodeVerify.cpp @@ -7,7 +7,6 @@ #include "frontend/ParseNodeVerify.h" #include "frontend/ParseNodeVisitor.h" -#include "js/Stack.h" // JS::NativeStackLimit using namespace js; @@ -22,9 +21,8 @@ class ParseNodeVerifier : public ParseNodeVisitor<ParseNodeVerifier> { const LifoAlloc& alloc_; public: - ParseNodeVerifier(FrontendContext* fc, JS::NativeStackLimit stackLimit, - const LifoAlloc& alloc) - : Base(fc, stackLimit), alloc_(alloc) {} + ParseNodeVerifier(FrontendContext* fc, const LifoAlloc& alloc) + : Base(fc), alloc_(alloc) {} [[nodiscard]] bool visit(ParseNode* pn) { // pn->size() asserts that pn->pn_kind is valid, so we don't redundantly @@ -43,10 +41,9 @@ class ParseNodeVerifier : public ParseNodeVisitor<ParseNodeVerifier> { } // namespace frontend } // namespace js -bool frontend::CheckParseTree(FrontendContext* fc, - JS::NativeStackLimit stackLimit, - const LifoAlloc& alloc, ParseNode* pn) { - ParseNodeVerifier verifier(fc, stackLimit, alloc); +bool frontend::CheckParseTree(FrontendContext* fc, const LifoAlloc& alloc, + ParseNode* pn) { + ParseNodeVerifier verifier(fc, alloc); return verifier.visit(pn); } diff --git a/js/src/frontend/ParseNodeVerify.h b/js/src/frontend/ParseNodeVerify.h index 3a690c453c155..1898e122d4354 100644 --- a/js/src/frontend/ParseNodeVerify.h +++ b/js/src/frontend/ParseNodeVerify.h @@ -8,7 +8,6 @@ #define frontend_ParseNodeVerify_h #include "frontend/SyntaxParseHandler.h" // SyntaxParseHandler::Node -#include "js/Stack.h" // JS::NativeStackLimit namespace js { @@ -28,11 +27,9 @@ class ParseNode; #ifdef DEBUG [[nodiscard]] extern bool CheckParseTree(FrontendContext* fc, - JS::NativeStackLimit stackLimit, const LifoAlloc& alloc, ParseNode* pn); #else [[nodiscard]] inline bool CheckParseTree(FrontendContext* fc, - JS::NativeStackLimit stackLimit, const LifoAlloc& alloc, ParseNode* pn) { return true; @@ -40,7 +37,6 @@ class ParseNode; #endif [[nodiscard]] inline bool CheckParseTree(FrontendContext* fc, - JS::NativeStackLimit stackLimit, const LifoAlloc& alloc, SyntaxParseHandler::Node pn) { return true; diff --git a/js/src/frontend/ParseNodeVisitor.h b/js/src/frontend/ParseNodeVisitor.h index 8f93445c8b382..18e57d68e61c8 100644 --- a/js/src/frontend/ParseNodeVisitor.h +++ b/js/src/frontend/ParseNodeVisitor.h @@ -11,7 +11,6 @@ #include "frontend/ParseNode.h" #include "js/friend/StackLimits.h" // js::AutoCheckRecursionLimit -#include "js/Stack.h" // JS::NativeStackLimit namespace js { @@ -55,14 +54,12 @@ template <typename Derived> class ParseNodeVisitor { public: FrontendContext* fc_; - JS::NativeStackLimit stackLimit_; - ParseNodeVisitor(FrontendContext* fc, JS::NativeStackLimit stackLimit) - : fc_(fc), stackLimit_(stackLimit) {} + explicit ParseNodeVisitor(FrontendContext* fc) : fc_(fc) {} [[nodiscard]] bool visit(ParseNode* pn) { AutoCheckRecursionLimit recursion(fc_); - if (!recursion.check(fc_, stackLimit_)) { + if (!recursion.check(fc_)) { return false; } @@ -102,15 +99,12 @@ template <typename Derived> class RewritingParseNodeVisitor { public: FrontendContext* fc_; - JS::NativeStackLimit stackLimit_; - RewritingParseNodeVisitor(FrontendContext* fc, - JS::NativeStackLimit stackLimit) - : fc_(fc), stackLimit_(stackLimit) {} + explicit RewritingParseNodeVisitor(FrontendContext* fc) : fc_(fc) {} [[nodiscard]] bool visit(ParseNode*& pn) { AutoCheckRecursionLimit recursion(fc_); - if (!recursion.check(fc_, stackLimit_)) { + if (!recursion.check(fc_)) { return false; } diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index e68529876610b..f907b6acef623 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -160,14 +160,13 @@ void ParserSharedBase::dumpAtom(TaggedParserAtomIndex index) const { } #endif -ParserBase::ParserBase(FrontendContext* fc, JS::NativeStackLimit stackLimit, +ParserBase::ParserBase(FrontendContext* fc, const ReadOnlyCompileOptions& options, bool foldConstants, CompilationState& compilationState) : ParserSharedBase(fc, compilationState, ParserSharedBase::Kind::Parser), anyChars(fc, options, this), ss(nullptr), foldConstants_(foldConstants), - stackLimit_(stackLimit), #ifdef DEBUG checkOptionsCalled_(false), #endif @@ -195,10 +194,10 @@ JSAtom* ParserBase::liftParserAtomToJSAtom(TaggedParserAtomIndex index) { template <class ParseHandler> PerHandlerParser<ParseHandler>::PerHandlerParser( - FrontendContext* fc, JS::NativeStackLimit stackLimit, - const ReadOnlyCompileOptions& options, bool foldConstants, - CompilationState& compilationState, void* internalSyntaxParser) - : ParserBase(fc, stackLimit, options, foldConstants, compilationState), + FrontendContext* fc, const ReadOnlyCompileOptions& options, + bool foldConstants, CompilationState& compilationState, + void* internalSyntaxParser) + : ParserBase(fc, options, foldConstants, compilationState), handler_(fc, compilationState), internalSyntaxParser_(internalSyntaxParser) { MOZ_ASSERT(compilationState.isInitialStencil() == @@ -207,12 +206,10 @@ PerHandlerParser<ParseHandler>::PerHandlerParser( template <class ParseHandler, typename Unit> GeneralParser<ParseHandler, Unit>::GeneralParser( - FrontendContext* fc, JS::NativeStackLimit stackLimit, - const ReadOnlyCompileOptions& options, const Unit* units, size_t length, - bool foldConstants, CompilationState& compilationState, - SyntaxParser* syntaxParser) - : Base(fc, stackLimit, options, foldConstants, compilationState, - syntaxParser), + FrontendContext* fc, const ReadOnlyCompileOptions& options, + const Unit* units, size_t length, bool foldConstants, + CompilationState& compilationState, SyntaxParser* syntaxParser) + : Base(fc, options, foldConstants, compilationState, syntaxParser), tokenStream(fc, &compilationState.parserAtoms, options, units, length) {} template <typename Unit> @@ -420,7 +417,7 @@ typename ParseHandler::ListNodeType GeneralParser<ParseHandler, Unit>::parse() { return null(); } - if (!CheckParseTree(this->fc_, this->stackLimit_, alloc_, stmtList)) { + if (!CheckParseTree(this->fc_, alloc_, stmtList)) { return null(); } @@ -429,8 +426,7 @@ typename ParseHandler::ListNodeType GeneralParser<ParseHandler, Unit>::parse() { // Don't constant-fold inside "use asm" code, as this could create a parse // tree that doesn't type-check as asm.js. if (!pc_->useAsmOrInsideUseAsm()) { - if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), - &node, &handler_)) { + if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) { return null(); } } @@ -1779,7 +1775,7 @@ LexicalScopeNode* Parser<FullParseHandler, Unit>::evalBody( } #endif - if (!CheckParseTree(this->fc_, this->stackLimit_, alloc_, body)) { + if (!CheckParseTree(this->fc_, alloc_, body)) { return null(); } @@ -1787,8 +1783,7 @@ LexicalScopeNode* Parser<FullParseHandler, Unit>::evalBody( // Don't constant-fold inside "use asm" code, as this could create a parse // tree that doesn't type-check as asm.js. if (!pc_->useAsmOrInsideUseAsm()) { - if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node, - &handler_)) { + if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) { return null(); } } @@ -1843,7 +1838,7 @@ ListNode* Parser<FullParseHandler, Unit>::globalBody( return nullptr; } - if (!CheckParseTree(this->fc_, this->stackLimit_, alloc_, body)) { + if (!CheckParseTree(this->fc_, alloc_, body)) { return null(); } @@ -1855,8 +1850,7 @@ ListNode* Parser<FullParseHandler, Unit>::globalBody( // Don't constant-fold inside "use asm" code, as this could create a parse // tree that doesn't type-check as asm.js. if (!pc_->useAsmOrInsideUseAsm()) { - if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node, - &handler_)) { + if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) { return null(); } } @@ -1985,7 +1979,7 @@ ModuleNode* Parser<FullParseHandler, Unit>::moduleBody( } } - if (!CheckParseTree(this->fc_, this->stackLimit_, alloc_, stmtList)) { + if (!CheckParseTree(this->fc_, alloc_, stmtList)) { return null(); } @@ -1993,8 +1987,7 @@ ModuleNode* Parser<FullParseHandler, Unit>::moduleBody( // Don't constant-fold inside "use asm" code, as this could create a parse // tree that doesn't type-check as asm.js. if (!pc_->useAsmOrInsideUseAsm()) { - if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node, - &handler_)) { + if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) { return null(); } } @@ -2384,7 +2377,7 @@ FunctionNode* Parser<FullParseHandler, Unit>::standaloneFunction( return null(); } - if (!CheckParseTree(this->fc_, this->stackLimit_, alloc_, funNode)) { + if (!CheckParseTree(this->fc_, alloc_, funNode)) { return null(); } @@ -2392,8 +2385,7 @@ FunctionNode* Parser<FullParseHandler, Unit>::standaloneFunction( // Don't constant-fold inside "use asm" code, as this could create a parse // tree that doesn't type-check as asm.js. if (!pc_->useAsmOrInsideUseAsm()) { - if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node, - &handler_)) { + if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) { return null(); } } @@ -3435,7 +3427,7 @@ FunctionNode* Parser<FullParseHandler, Unit>::standaloneLazyFunction( } } - if (!CheckParseTree(this->fc_, this->stackLimit_, alloc_, funNode)) { + if (!CheckParseTree(this->fc_, alloc_, funNode)) { return null(); } @@ -3443,8 +3435,7 @@ FunctionNode* Parser<FullParseHandler, Unit>::standaloneLazyFunction( // Don't constant-fold inside "use asm" code, as this could create a parse // tree that doesn't type-check as asm.js. if (!pc_->useAsmOrInsideUseAsm()) { - if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node, - &handler_)) { + if (!FoldConstants(this->fc_, this->parserAtoms(), &node, &handler_)) { return null(); } } @@ -3876,8 +3867,8 @@ bool Parser<FullParseHandler, Unit>::asmJS(ListNodeType list) { // function from the beginning. Reparsing is triggered by marking that a // new directive has been encountered and returning 'false'. bool validated; - if (!CompileAsmJS(this->fc_, this->stackLimit_, this->parserAtoms(), *this, - list, &validated)) { + if (!CompileAsmJS(this->fc_, this->fc_->stackLimit(), this->parserAtoms(), + *this, list, &validated)) { return false; } if (!validated) { @@ -4016,7 +4007,7 @@ template <class ParseHandler, typename Unit> typename ParseHandler::ListNodeType GeneralParser<ParseHandler, Unit>::statementList(YieldHandling yieldHandling) { AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -4335,7 +4326,7 @@ GeneralParser<ParseHandler, Unit>::objectBindingPattern( MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftCurly)); AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -4490,7 +4481,7 @@ GeneralParser<ParseHandler, Unit>::arrayBindingPattern( MOZ_ASSERT(anyChars.isCurrentTokenType(TokenKind::LeftBracket)); AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -9342,7 +9333,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::statement( MOZ_ASSERT(checkOptionsCalled_); AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -9589,7 +9580,7 @@ GeneralParser<ParseHandler, Unit>::statementListItem( MOZ_ASSERT(checkOptionsCalled_); AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -10151,7 +10142,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::assignExpr( PossibleError* possibleError /* = nullptr */, InvokedPrediction invoked /* = PredictUninvoked */) { AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -10529,7 +10520,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::optionalExpr( TokenKind tt, PossibleError* possibleError /* = nullptr */, InvokedPrediction invoked /* = PredictUninvoked */) { AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -10641,7 +10632,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::unaryExpr( InvokedPrediction invoked /* = PredictUninvoked */, PrivateNameHandling privateNameHandling /* = PrivateNameProhibited */) { AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -10916,7 +10907,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::memberExpr( Node lhs; AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } @@ -11517,8 +11508,9 @@ RegExpLiteral* Parser<FullParseHandler, Unit>::newRegExp() { // Verify that the Regexp will syntax parse when the time comes to // instantiate it. If we have already done a syntax parse, we can // skip this. - if (!irregexp::CheckPatternSyntax(this->alloc_, this->stackLimit_, anyChars, - range, flags, Some(line), Some(column))) { + if (!irregexp::CheckPatternSyntax(this->alloc_, this->fc_->stackLimit(), + anyChars, range, flags, Some(line), + Some(column))) { return nullptr; } } @@ -11558,8 +11550,9 @@ Parser<SyntaxParseHandler, Unit>::newRegExp() { tokenStream.computeLineAndColumn(offset, &line, &column); mozilla::Range<const char16_t> source(chars.begin(), chars.length()); - if (!irregexp::CheckPatternSyntax(this->alloc_, this->stackLimit_, anyChars, - source, flags, Some(line), Some(column))) { + if (!irregexp::CheckPatternSyntax(this->alloc_, this->fc_->stackLimit(), + anyChars, source, flags, Some(line), + Some(column))) { return null(); } @@ -12864,7 +12857,7 @@ typename ParseHandler::Node GeneralParser<ParseHandler, Unit>::primaryExpr( TokenKind tt, PossibleError* possibleError, InvokedPrediction invoked) { MOZ_ASSERT(anyChars.isCurrentTokenType(tt)); AutoCheckRecursionLimit recursion(this->fc_); - if (!recursion.check(this->fc_, this->stackLimit_)) { + if (!recursion.check(this->fc_)) { return null(); } diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h index 6a4749f5f4104..5f14a76227253 100644 --- a/js/src/frontend/Parser.h +++ b/js/src/frontend/Parser.h @@ -184,7 +184,6 @@ #include "frontend/SyntaxParseHandler.h" #include "frontend/TokenStream.h" #include "js/friend/ErrorMessages.h" // JSErrNum, JSMSG_* -#include "js/Stack.h" // JS::NativeStackLimit #include "vm/GeneratorAndAsyncKind.h" // js::GeneratorKind, js::FunctionAsyncKind namespace js { @@ -287,8 +286,6 @@ class MOZ_STACK_CLASS ParserBase : public ParserSharedBase, const bool foldConstants_ : 1; protected: - JS::NativeStackLimit stackLimit_; - #if DEBUG /* Our fallible 'checkOptions' member function has been called. */ bool checkOptionsCalled_ : 1; @@ -323,9 +320,8 @@ class MOZ_STACK_CLASS ParserBase : public ParserSharedBase, template <class, typename> friend class AutoInParametersOfAsyncFunction; - ParserBase(FrontendContext* fc, JS::NativeStackLimit stackLimit, - const JS::ReadOnlyCompileOptions& options, bool foldConstants, - CompilationState& compilationState); + ParserBase(FrontendContext* fc, const JS::ReadOnlyCompileOptions& options, + bool foldConstants, CompilationState& compilationState); ~ParserBase(); bool checkOptions(); @@ -472,19 +468,19 @@ class MOZ_STACK_CLASS PerHandlerParser : public ParserBase { // NOTE: The argument ordering here is deliberately different from the // public constructor so that typos calling the public constructor // are less likely to select this overload. - PerHandlerParser(FrontendContext* fc, JS::NativeStackLimit stackLimit, + PerHandlerParser(FrontendContext* fc, const JS::ReadOnlyCompileOptions& options, bool foldConstants, CompilationState& compilationState, void* internalSyntaxParser); protected: template <typename Unit> - PerHandlerParser(FrontendContext* fc, JS::NativeStackLimit stackLimit, + PerHandlerParser(FrontendContext* fc, const JS::ReadOnlyCompileOptions& options, bool foldConstants, CompilationState& compilationState, GeneralParser<SyntaxParseHandler, Unit>* syntaxParser) - : PerHandlerParser(fc, stackLimit, options, foldConstants, - compilationState, static_cast<void*>(syntaxParser)) {} + : PerHandlerParser(fc, options, foldConstants, compilationState, + static_cast<void*>(syntaxParser)) {} static typename ParseHandler::NullNode null() { return ParseHandler::null(); } @@ -926,9 +922,8 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> { TokenStream tokenStream; public: - GeneralParser(FrontendContext* fc, JS::NativeStackLimit stackLimit, - const JS::ReadOnlyCompileOptions& options, const Unit* units, - size_t length, bool foldConstants, + GeneralParser(FrontendContext* fc, const JS::ReadOnlyCompileOptions& options, + const Unit* units, size_t length, bool foldConstants, CompilationState& compilationState, SyntaxParser* syntaxParser); inline void setAwaitHandling(AwaitHandling awaitHandling); diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 8e96cb45a3a71..4fb2c99a1e840 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -15,6 +15,7 @@ #include "builtin/BigInt.h" #include "builtin/MapObject.h" #include "builtin/TestingFunctions.h" +#include "frontend/FrontendContext.h" // FrontendContext #include "gc/PublicIterators.h" #include "gc/WeakMap.h" #include "js/experimental/CodeCoverage.h" @@ -361,6 +362,11 @@ JS_PUBLIC_API void js::AutoCheckRecursionLimit::assertMainThread( MOZ_ASSERT(cx->isMainThreadContext()); } +JS::NativeStackLimit AutoCheckRecursionLimit::getStackLimit( + FrontendContext* fc) const { + return fc->stackLimit(); +} + JS_PUBLIC_API JSFunction* js::DefineFunctionWithReserved( JSContext* cx, JSObject* objArg, const char* name, JSNative call, unsigned nargs, unsigned attrs) { diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index d0fa8f570dfb1..7a5c14e2f9985 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -5353,10 +5353,10 @@ static bool DumpAST(JSContext* cx, const JS::ReadOnlyCompileOptions& options, using namespace js::frontend; AutoReportFrontendContext fc(cx); - Parser<FullParseHandler, Unit> parser( - &fc, cx->stackLimitForCurrentPrincipal(), options, units, length, - /* foldConstants = */ false, compilationState, - /* syntaxParser = */ nullptr); + Parser<FullParseHandler, Unit> parser(&fc, options, units, length, + /* foldConstants = */ false, + compilationState, + /* syntaxParser = */ nullptr); if (!parser.checkOptions()) { return false; } @@ -5726,7 +5726,7 @@ static bool SyntaxParse(JSContext* cx, unsigned argc, Value* vp) { } Parser<frontend::SyntaxParseHandler, char16_t> parser( - &fc, cx->stackLimitForCurrentPrincipal(), options, chars, length, + &fc, options, chars, length, /* foldConstants = */ false, compilationState, /* syntaxParser = */ nullptr); if (!parser.checkOptions()) { diff --git a/js/src/vm/CompilationAndEvaluation.cpp b/js/src/vm/CompilationAndEvaluation.cpp index 87e3b6f3ce95e..786002beb07a5 100644 --- a/js/src/vm/CompilationAndEvaluation.cpp +++ b/js/src/vm/CompilationAndEvaluation.cpp @@ -207,10 +207,10 @@ JS_PUBLIC_API bool JS_Utf8BufferIsCompilableUnit(JSContext* cx, return false; } - Parser<FullParseHandler, char16_t> parser( - &fc, cx->stackLimitForCurrentPrincipal(), options, chars.get(), length, - /* foldConstants = */ true, compilationState, - /* syntaxParser = */ nullptr); + Parser<FullParseHandler, char16_t> parser(&fc, options, chars.get(), length, + /* foldConstants = */ true, + compilationState, + /* syntaxParser = */ nullptr); if (!parser.checkOptions() || !parser.parse()) { // We ran into an error. If it was because we ran out of source, we // return false so our caller knows to try to collect more buffered diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp index abc659efd2457..9e7b606433baf 100644 --- a/js/src/wasm/AsmJS.cpp +++ b/js/src/wasm/AsmJS.cpp @@ -4583,7 +4583,7 @@ static bool CheckCoercedCall(FunctionValidator<Unit>& f, ParseNode* call, MOZ_ASSERT(ret.isCanonical()); AutoCheckRecursionLimit recursion(f.fc()); - if (!recursion.checkDontReport(f.stackLimit())) { + if (!recursion.checkDontReport(f.fc())) { return f.m().failOverRecursed(); } @@ -4916,7 +4916,7 @@ template <typename Unit> static bool CheckAddOrSub(FunctionValidator<Unit>& f, ParseNode* expr, Type* type, unsigned* numAddOrSubOut = nullptr) { AutoCheckRecursionLimit recursion(f.fc()); - if (!recursion.checkDontReport(f.stackLimit())) { + if (!recursion.checkDontReport(f.fc())) { return f.m().failOverRecursed(); } @@ -5299,7 +5299,7 @@ static bool CheckBitwise(FunctionValidator<Unit>& f, ParseNode* bitwise, template <typename Unit> static bool CheckExpr(FunctionValidator<Unit>& f, ParseNode* expr, Type* type) { AutoCheckRecursionLimit recursion(f.fc()); - if (!recursion.checkDontReport(f.stackLimit())) { + if (!recursion.checkDontReport(f.fc())) { return f.m().failOverRecursed(); } @@ -6034,7 +6034,7 @@ static bool CheckBreakOrContinue(FunctionValidatorShared& f, bool isBreak, template <typename Unit> static bool CheckStatement(FunctionValidator<Unit>& f, ParseNode* stmt) { AutoCheckRecursionLimit recursion(f.fc()); - if (!recursion.checkDontReport(f.stackLimit())) { + if (!recursion.checkDontReport(f.fc())) { return f.m().failOverRecursed(); } -- GitLab