Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit c92d5c4

Browse files
committed
Bug 1534516 - Use correct AutoGCRooter::Tag in BinASTParserBase. r=Yoric
Differential Revision: https://phabricator.services.mozilla.com/D23083 --HG-- extra : moz-landing-system : lando
1 parent 1c0b93a commit c92d5c4

8 files changed

Lines changed: 19 additions & 13 deletions

File tree

js/public/RootingAPI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ class JS_PUBLIC_API AutoGCRooter {
911911
ValueArray, /* js::AutoValueArray */
912912
Parser, /* js::frontend::Parser */
913913
#if defined(JS_BUILD_BINAST)
914-
BinParser, /* js::frontend::BinSource */
914+
BinASTParser, /* js::frontend::BinASTParser */
915915
#endif // defined(JS_BUILD_BINAST)
916916
WrapperVector, /* js::AutoWrapperVector */
917917
Wrapper, /* js::AutoWrapperRooter */

js/src/frontend/BinASTParserBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ namespace frontend {
1414
BinASTParserBase::BinASTParserBase(JSContext* cx, LifoAlloc& alloc,
1515
UsedNameTracker& usedNames,
1616
HandleScriptSourceObject sourceObject)
17-
: ParserSharedBase(cx, alloc, usedNames, sourceObject) {}
17+
: ParserSharedBase(cx, alloc, usedNames, sourceObject,
18+
ParserSharedBase::Kind::BinASTParser) {}
1819

1920
} // namespace frontend
2021
} // namespace js

js/src/frontend/BinASTParserPerTokenizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ bool BinASTParserPerTokenizer<Tok>::computeErrorMetadata(
769769
return true;
770770
}
771771

772-
void TraceBinParser(JSTracer* trc, JS::AutoGCRooter* parser) {
772+
void TraceBinASTParser(JSTracer* trc, JS::AutoGCRooter* parser) {
773773
static_cast<BinASTParserBase*>(parser)->trace(trc);
774774
}
775775

js/src/frontend/BinASTParserPerTokenizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class BinParseContext : public ParseContext {
323323
newDirectives, /* isFull = */ true) {}
324324
};
325325

326-
void TraceBinParser(JSTracer* trc, JS::AutoGCRooter* parser);
326+
void TraceBinASTParser(JSTracer* trc, JS::AutoGCRooter* parser);
327327

328328
extern template class BinASTParserPerTokenizer<BinTokenReaderMultipart>;
329329

js/src/frontend/BytecodeCompiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void TraceParser(JSTracer* trc, JS::AutoGCRooter* parser);
198198

199199
/* Trace all GC things reachable from binjs parser. Defined in
200200
* BinASTParserPerTokenizer.cpp. */
201-
void TraceBinParser(JSTracer* trc, JS::AutoGCRooter* parser);
201+
void TraceBinASTParser(JSTracer* trc, JS::AutoGCRooter* parser);
202202

203203
#endif // defined(JS_BUILD_BINAST)
204204

js/src/frontend/Parser.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ bool GeneralParser<ParseHandler, Unit>::mustMatchTokenInternal(
137137

138138
ParserSharedBase::ParserSharedBase(JSContext* cx, LifoAlloc& alloc,
139139
UsedNameTracker& usedNames,
140-
ScriptSourceObject* sourceObject)
141-
: JS::AutoGCRooter(cx, AutoGCRooter::Tag::Parser),
140+
ScriptSourceObject* sourceObject, Kind kind)
141+
: JS::AutoGCRooter(cx, kind == Kind::Parser
142+
? JS::AutoGCRooter::Tag::Parser
143+
: JS::AutoGCRooter::Tag::BinASTParser),
142144
cx_(cx),
143145
alloc_(alloc),
144146
traceListHead_(nullptr),
@@ -167,7 +169,8 @@ ParserBase::ParserBase(JSContext* cx, LifoAlloc& alloc,
167169
const ReadOnlyCompileOptions& options,
168170
bool foldConstants, UsedNameTracker& usedNames,
169171
ScriptSourceObject* sourceObject, ParseGoal parseGoal)
170-
: ParserSharedBase(cx, alloc, usedNames, sourceObject),
172+
: ParserSharedBase(cx, alloc, usedNames, sourceObject,
173+
ParserSharedBase::Kind::Parser),
171174
anyChars(cx, options, thisForCtor()),
172175
ss(nullptr),
173176
foldConstants_(foldConstants),

js/src/frontend/Parser.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,10 @@ class AutoInParametersOfAsyncFunction;
240240

241241
class MOZ_STACK_CLASS ParserSharedBase : private JS::AutoGCRooter {
242242
public:
243+
enum class Kind { Parser, BinASTParser };
244+
243245
ParserSharedBase(JSContext* cx, LifoAlloc& alloc, UsedNameTracker& usedNames,
244-
ScriptSourceObject* sourceObject);
246+
ScriptSourceObject* sourceObject, Kind kind);
245247
~ParserSharedBase();
246248

247249
public:
@@ -271,8 +273,8 @@ class MOZ_STACK_CLASS ParserSharedBase : private JS::AutoGCRooter {
271273
JS::AutoGCRooter* parser);
272274

273275
#if defined(JS_BUILD_BINAST)
274-
friend void js::frontend::TraceBinParser(JSTracer* trc,
275-
JS::AutoGCRooter* parser);
276+
friend void js::frontend::TraceBinASTParser(JSTracer* trc,
277+
JS::AutoGCRooter* parser);
276278
#endif // JS_BUILD_BINAST
277279

278280
private:

js/src/gc/RootMarking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ inline void AutoGCRooter::trace(JSTracer* trc) {
159159
return;
160160

161161
#if defined(JS_BUILD_BINAST)
162-
case Tag::BinParser:
163-
frontend::TraceBinParser(trc, this);
162+
case Tag::BinASTParser:
163+
frontend::TraceBinASTParser(trc, this);
164164
return;
165165
#endif // defined(JS_BUILD_BINAST)
166166

0 commit comments

Comments
 (0)