Bug 1569315 - Factor out FunctionCreationData from AllocNewFunction r=tcampbell,jonco

Differential Revision: https://phabricator.services.mozilla.com/D39771
This commit is contained in:
Matthew Gaudet
2019-08-01 16:09:05 +00:00
parent e2d9749a1c
commit d558fd88df
3 changed files with 70 additions and 30 deletions

View File

@@ -261,10 +261,15 @@ JS::Result<FunctionBox*> BinASTParserPerTokenizer<Tok>::buildFunctionBox(
// Allocate the function before walking down the tree.
RootedFunction fun(cx_);
BINJS_TRY_VAR(fun, !pc_ ? lazyScript_->functionNonDelazifying()
: AllocNewFunction(cx_, atom, syntax, generatorKind,
functionAsyncKind));
MOZ_ASSERT_IF(pc_, fun->explicitName() == atom);
if (pc_) {
Rooted<FunctionCreationData> fcd(
cx_, GenerateFunctionCreationData(atom, syntax, generatorKind,
functionAsyncKind));
BINJS_TRY_VAR(fun, AllocNewFunction(cx_, fcd));
MOZ_ASSERT(fun->explicitName() == atom);
} else {
BINJS_TRY_VAR(fun, lazyScript_->functionNonDelazifying());
}
mozilla::Maybe<Directives> directives;
if (pc_) {