Bug 1808216 part 3 - Remove JSContext* argument from FoldConstants. r=arai

Differential Revision: https://phabricator.services.mozilla.com/D165829
This commit is contained in:
Jan de Mooij 2023-01-05 12:31:37 +00:00
Родитель 09a87896a1
Коммит 3fb0073a8b
3 изменённых файлов: 24 добавлений и 29 удалений

Просмотреть файл

@ -33,7 +33,6 @@ using mozilla::NegativeInfinity;
using mozilla::PositiveInfinity;
struct FoldInfo {
JSContext* cx;
FrontendContext* fc;
JS::NativeStackLimit stackLimit;
ParserAtomsTable& parserAtoms;
@ -1315,20 +1314,17 @@ 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, fc_, stackLimit_, parserAtoms, handler};
return FoldInfo{fc_, stackLimit_, parserAtoms, handler};
}
public:
FoldVisitor(JSContext* cx, FrontendContext* fc,
JS::NativeStackLimit stackLimit, ParserAtomsTable& parserAtoms,
FullParseHandler* handler)
FoldVisitor(FrontendContext* fc, JS::NativeStackLimit stackLimit,
ParserAtomsTable& parserAtoms, FullParseHandler* handler)
: RewritingParseNodeVisitor(fc, stackLimit),
cx(cx),
parserAtoms(parserAtoms),
handler(handler) {}
@ -1575,20 +1571,19 @@ class FoldVisitor : public RewritingParseNodeVisitor<FoldVisitor> {
}
};
static bool Fold(JSContext* cx, FrontendContext* fc,
JS::NativeStackLimit stackLimit, ParserAtomsTable& parserAtoms,
FullParseHandler* handler, ParseNode** pnp) {
FoldVisitor visitor(cx, fc, stackLimit, parserAtoms, handler);
static bool Fold(FrontendContext* fc, JS::NativeStackLimit stackLimit,
ParserAtomsTable& parserAtoms, FullParseHandler* handler,
ParseNode** pnp) {
FoldVisitor visitor(fc, stackLimit, parserAtoms, handler);
return visitor.visit(*pnp);
}
static bool Fold(FoldInfo info, ParseNode** pnp) {
return Fold(info.cx, info.fc, info.stackLimit, info.parserAtoms, info.handler,
pnp);
return Fold(info.fc, info.stackLimit, info.parserAtoms, info.handler, pnp);
}
bool frontend::FoldConstants(JSContext* cx, FrontendContext* fc,
bool frontend::FoldConstants(FrontendContext* fc,
JS::NativeStackLimit stackLimit,
ParserAtomsTable& parserAtoms, ParseNode** pnp,
FullParseHandler* handler) {
return Fold(cx, fc, stackLimit, parserAtoms, handler, pnp);
return Fold(fc, stackLimit, parserAtoms, handler, pnp);
}

Просмотреть файл

@ -33,16 +33,16 @@ class ParserAtomsTable;
// if (!pn) {
// return false;
// }
// if (!FoldConstants(cx, parserAtoms, &pn, parser)) {
// if (!FoldConstants(fc, stackLimit, parserAtoms, &pn, parser)) {
// return false;
// }
[[nodiscard]] extern bool FoldConstants(JSContext* cx, FrontendContext* fc,
[[nodiscard]] extern bool FoldConstants(FrontendContext* fc,
JS::NativeStackLimit stackLimit,
ParserAtomsTable& parserAtoms,
ParseNode** pnp,
FullParseHandler* handler);
[[nodiscard]] inline bool FoldConstants(JSContext* cx, FrontendContext* fc,
[[nodiscard]] inline bool FoldConstants(FrontendContext* fc,
JS::NativeStackLimit stackLimit,
ParserAtomsTable& parserAtoms,
typename SyntaxParseHandler::Node* pnp,

Просмотреть файл

@ -425,7 +425,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(cx_, this->fc_, this->stackLimit_, this->parserAtoms(),
if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(),
&node, &handler_)) {
return null();
}
@ -1783,8 +1783,8 @@ 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(cx_, this->fc_, this->stackLimit_, this->parserAtoms(),
&node, &handler_)) {
if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node,
&handler_)) {
return null();
}
}
@ -1851,8 +1851,8 @@ 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(cx_, this->fc_, this->stackLimit_, this->parserAtoms(),
&node, &handler_)) {
if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node,
&handler_)) {
return null();
}
}
@ -1989,8 +1989,8 @@ 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(cx_, this->fc_, this->stackLimit_, this->parserAtoms(),
&node, &handler_)) {
if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node,
&handler_)) {
return null();
}
}
@ -2388,8 +2388,8 @@ 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(cx_, this->fc_, this->stackLimit_, this->parserAtoms(),
&node, &handler_)) {
if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node,
&handler_)) {
return null();
}
}
@ -3440,8 +3440,8 @@ 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(cx_, this->fc_, this->stackLimit_, this->parserAtoms(),
&node, &handler_)) {
if (!FoldConstants(this->fc_, this->stackLimit_, this->parserAtoms(), &node,
&handler_)) {
return null();
}
}