Bug 1781183 - Part 4: Simplify BytecodeEmitter constructor. r=bthrall

`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

Differential Revision: https://phabricator.services.mozilla.com/D152775
This commit is contained in:
Tooru Fujisawa 2022-07-30 04:45:18 +00:00
Родитель 9c8206ed56
Коммит 8520999b66
3 изменённых файлов: 13 добавлений и 16 удалений

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

@ -627,8 +627,7 @@ static bool EmplaceEmitter(CompilationState& compilationState,
const EitherParser& parser, SharedContext* sc) {
BytecodeEmitter::EmitterMode emitterMode =
sc->selfHosted() ? BytecodeEmitter::SelfHosting : BytecodeEmitter::Normal;
emitter.emplace(/* parent = */ nullptr, parser, sc, compilationState,
emitterMode);
emitter.emplace(parser, sc, compilationState, emitterMode);
return emitter->init();
}
@ -1132,8 +1131,8 @@ static bool CompileLazyFunctionToStencilMaybeInstantiate(
return false;
}
BytecodeEmitter bce(/* parent = */ nullptr, &parser, pn->funbox(),
compilationState, BytecodeEmitter::LazyFunction);
BytecodeEmitter bce(&parser, pn->funbox(), compilationState,
BytecodeEmitter::LazyFunction);
if (!bce.init(pn->pn_pos)) {
return false;
}

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

@ -153,11 +153,10 @@ BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent,
parser = handle;
}
BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent,
const EitherParser& parser, SharedContext* sc,
BytecodeEmitter::BytecodeEmitter(const EitherParser& parser, SharedContext* sc,
CompilationState& compilationState,
EmitterMode emitterMode)
: BytecodeEmitter(parent, sc, compilationState, emitterMode) {
: BytecodeEmitter(nullptr, sc, compilationState, emitterMode) {
ep_.emplace(parser);
this->parser = ep_.ptr();
}

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

@ -314,6 +314,10 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
BytecodeEmitter(BytecodeEmitter* parent, SharedContext* sc,
CompilationState& compilationState, EmitterMode emitterMode);
BytecodeEmitter(BytecodeEmitter* parent, BCEParserHandle* handle,
SharedContext* sc, CompilationState& compilationState,
EmitterMode emitterMode);
void initFromBodyPosition(TokenPos bodyPosition);
/*
@ -325,20 +329,15 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
void reportNeedMoreArgsError(CallNode* callNode, uint32_t requiredArgs);
public:
BytecodeEmitter(BytecodeEmitter* parent, BCEParserHandle* handle,
SharedContext* sc, CompilationState& compilationState,
EmitterMode emitterMode = Normal);
BytecodeEmitter(BytecodeEmitter* parent, const EitherParser& parser,
SharedContext* sc, CompilationState& compilationState,
BytecodeEmitter(const EitherParser& parser, SharedContext* sc,
CompilationState& compilationState,
EmitterMode emitterMode = Normal);
template <typename Unit>
BytecodeEmitter(BytecodeEmitter* parent,
Parser<FullParseHandler, Unit>* parser, SharedContext* sc,
BytecodeEmitter(Parser<FullParseHandler, Unit>* parser, SharedContext* sc,
CompilationState& compilationState,
EmitterMode emitterMode = Normal)
: BytecodeEmitter(parent, EitherParser(parser), sc, compilationState,
: BytecodeEmitter(EitherParser(parser), sc, compilationState,
emitterMode) {}
[[nodiscard]] bool init();