From cc2ee58041d0774571e094250d0b35268af1e7e1 Mon Sep 17 00:00:00 2001 From: Ted Campbell Date: Fri, 25 Oct 2019 13:07:36 +0000 Subject: [PATCH] Bug 1589904 - Remove LazyScript::functionNonDelazifying() r=jandem Replace with LazyScript::function() for the same reasons as removing JSScript::functionNonDelazifying(). Depends on D50505 Differential Revision: https://phabricator.services.mozilla.com/D50506 --HG-- extra : moz-landing-system : lando --- js/src/debugger/Script.cpp | 6 +++--- js/src/frontend/BinASTParserPerTokenizer.cpp | 7 +++---- js/src/frontend/BytecodeCompiler.cpp | 10 ++++------ js/src/gc/PublicIterators.cpp | 2 +- js/src/vm/JSFunction.cpp | 4 ++-- js/src/vm/JSFunction.h | 4 ++-- js/src/vm/JSScript.cpp | 4 ++-- js/src/vm/JSScript.h | 4 +--- 8 files changed, 18 insertions(+), 23 deletions(-) diff --git a/js/src/debugger/Script.cpp b/js/src/debugger/Script.cpp index c8e9f24e2a21..300c01057ed7 100644 --- a/js/src/debugger/Script.cpp +++ b/js/src/debugger/Script.cpp @@ -153,7 +153,7 @@ static JSScript* DelazifyScript(JSContext* cx, Handle lazyScript) { } MOZ_ASSERT(lazyScript->enclosingScriptHasEverBeenCompiled()); - RootedFunction fun(cx, lazyScript->functionNonDelazifying()); + RootedFunction fun(cx, lazyScript->function()); AutoRealm ar(cx, fun); return JSFunction::getOrCreateScript(cx, fun); } @@ -334,8 +334,8 @@ bool DebuggerScript::CallData::getDisplayName() { if (!ensureScriptMaybeLazy()) { return false; } - JSFunction* func = CallScriptMethod(obj, &JSScript::function, - &LazyScript::functionNonDelazifying); + JSFunction* func = + CallScriptMethod(obj, &JSScript::function, &LazyScript::function); Debugger* dbg = Debugger::fromChildJSObject(obj); JSString* name = func ? func->displayAtom() : nullptr; diff --git a/js/src/frontend/BinASTParserPerTokenizer.cpp b/js/src/frontend/BinASTParserPerTokenizer.cpp index 62af242a77bc..195bce536045 100644 --- a/js/src/frontend/BinASTParserPerTokenizer.cpp +++ b/js/src/frontend/BinASTParserPerTokenizer.cpp @@ -165,7 +165,7 @@ JS::Result BinASTParserPerTokenizer::parseLazyFunction( tokenizer_->seek(firstOffset); // For now, only function declarations and function expression are supported. - RootedFunction func(cx_, lazyScript_->functionNonDelazifying()); + RootedFunction func(cx_, lazyScript_->function()); bool isExpr = func->isLambda(); MOZ_ASSERT(func->kind() == FunctionFlags::FunctionKind::NormalFunction); @@ -266,7 +266,7 @@ JS::Result BinASTParserPerTokenizer::buildFunctionBox( BINJS_TRY_VAR(fun, AllocNewFunction(cx_, fcd)); MOZ_ASSERT(fun->explicitName() == atom); } else { - BINJS_TRY_VAR(fun, lazyScript_->functionNonDelazifying()); + BINJS_TRY_VAR(fun, lazyScript_->function()); } mozilla::Maybe directives; @@ -321,8 +321,7 @@ JS::Result BinASTParserPerTokenizer::finishEagerFunction( FunctionBox* funbox, uint32_t nargs) { // If this is delazification of a canonical function, the JSFunction object // already has correct `nargs_`. - if (!lazyScript_ || - lazyScript_->functionNonDelazifying() != funbox->function()) { + if (!lazyScript_ || lazyScript_->function() != funbox->function()) { funbox->setArgCount(nargs); funbox->synchronizeArgCount(); } else { diff --git a/js/src/frontend/BytecodeCompiler.cpp b/js/src/frontend/BytecodeCompiler.cpp index 2878a3b4ca84..1ef62f7e66e2 100644 --- a/js/src/frontend/BytecodeCompiler.cpp +++ b/js/src/frontend/BytecodeCompiler.cpp @@ -932,8 +932,7 @@ class MOZ_STACK_CLASS AutoAssertFunctionDelazificationCompletion { template static bool CompileLazyFunctionImpl(JSContext* cx, Handle lazy, const Unit* units, size_t length) { - MOZ_ASSERT(cx->compartment() == - lazy->functionNonDelazifying()->compartment()); + MOZ_ASSERT(cx->compartment() == lazy->compartment()); // We can only compile functions whose parents have previously been // compiled, because compilation requires full information about the @@ -943,7 +942,7 @@ static bool CompileLazyFunctionImpl(JSContext* cx, Handle lazy, MOZ_ASSERT(!lazy->isBinAST()); AutoAssertReportedException assertException(cx); - Rooted fun(cx, lazy->functionNonDelazifying()); + Rooted fun(cx, lazy->function()); AutoAssertFunctionDelazificationCompletion delazificationCompletion(cx, fun); JS::CompileOptions options(cx); @@ -1045,8 +1044,7 @@ bool frontend::CompileLazyFunction(JSContext* cx, Handle lazy, bool frontend::CompileLazyBinASTFunction(JSContext* cx, Handle lazy, const uint8_t* buf, size_t length) { - MOZ_ASSERT(cx->compartment() == - lazy->functionNonDelazifying()->compartment()); + MOZ_ASSERT(cx->compartment() == lazy->compartment()); // We can only compile functions whose parents have previously been // compiled, because compilation requires full information about the @@ -1055,7 +1053,7 @@ bool frontend::CompileLazyBinASTFunction(JSContext* cx, MOZ_ASSERT(lazy->isBinAST()); AutoAssertReportedException assertException(cx); - Rooted fun(cx, lazy->functionNonDelazifying()); + Rooted fun(cx, lazy->function()); AutoAssertFunctionDelazificationCompletion delazificationCompletion(cx, fun); CompileOptions options(cx); diff --git a/js/src/gc/PublicIterators.cpp b/js/src/gc/PublicIterators.cpp index 7b2c86c221a6..cdb2b4e987d6 100644 --- a/js/src/gc/PublicIterators.cpp +++ b/js/src/gc/PublicIterators.cpp @@ -90,7 +90,7 @@ static void TraverseInnerLazyScriptsForLazyScript( // LazyScript::CreateForXDR temporarily initializes innerFunctions with // its own function, but it should be overwritten with correct // inner functions before getting inserted into parent's innerFunctions. - MOZ_ASSERT(fun != enclosingLazyScript->functionNonDelazifying()); + MOZ_ASSERT(fun != enclosingLazyScript->function()); if (!fun->isInterpretedLazy()) { return; diff --git a/js/src/vm/JSFunction.cpp b/js/src/vm/JSFunction.cpp index 614c2151a6cc..9599ea996c3b 100644 --- a/js/src/vm/JSFunction.cpp +++ b/js/src/vm/JSFunction.cpp @@ -1538,7 +1538,7 @@ static bool DelazifyCanonicalScriptedFunction(JSContext* cx, Rooted lazy(cx, fun->lazyScript()); MOZ_ASSERT(!lazy->maybeScript(), "Script is already compiled!"); - MOZ_ASSERT(lazy->functionNonDelazifying() == fun); + MOZ_ASSERT(lazy->function() == fun); ScriptSource* ss = lazy->scriptSource(); size_t sourceStart = lazy->sourceStart(); @@ -1646,7 +1646,7 @@ bool JSFunction::delazifyLazilyInterpretedFunction(JSContext* cx, if (fun->hasLazyScript()) { Rooted lazy(cx, fun->lazyScript()); - RootedFunction canonicalFun(cx, lazy->functionNonDelazifying()); + RootedFunction canonicalFun(cx, lazy->function()); // If this function is non-canonical, then use the canonical function first // to get the delazified script. This may result in calling this method diff --git a/js/src/vm/JSFunction.h b/js/src/vm/JSFunction.h index 4ef735cc338f..3acac11d4853 100644 --- a/js/src/vm/JSFunction.h +++ b/js/src/vm/JSFunction.h @@ -702,7 +702,7 @@ class JSFunction : public js::NativeObject { // use lazyScript->script_ here as it may be null in some cases, // see bug 976536. js::LazyScript* lazy = lazyScript(); - JSFunction* fun = lazy->functionNonDelazifying(); + JSFunction* fun = lazy->function(); MOZ_ASSERT(fun); return fun->nonLazyScript(); } @@ -731,7 +731,7 @@ class JSFunction : public js::NativeObject { return nonLazyScript()->function(); } if (hasLazyScript()) { - return lazyScript()->functionNonDelazifying(); + return lazyScript()->function(); } return nullptr; } diff --git a/js/src/vm/JSScript.cpp b/js/src/vm/JSScript.cpp index 631cd22df5a8..9c774628ea18 100644 --- a/js/src/vm/JSScript.cpp +++ b/js/src/vm/JSScript.cpp @@ -1250,7 +1250,7 @@ XDRResult js::XDRLazyScript(XDRState* xdr, HandleScope enclosingScope, // to a JSScript. We don't encode it: we can just delazify the // lazy script. - MOZ_ASSERT(fun == lazy->functionNonDelazifying()); + MOZ_ASSERT(fun == lazy->function()); sourceStart = lazy->sourceStart(); sourceEnd = lazy->sourceEnd(); @@ -3905,7 +3905,7 @@ JSScript* JSScript::Create(JSContext* cx, HandleObject functionOrGlobal, /* static */ JSScript* JSScript::CreateFromLazy(JSContext* cx, Handle lazy) { RootedScriptSourceObject sourceObject(cx, lazy->sourceObject()); - RootedObject fun(cx, lazy->functionNonDelazifying()); + RootedObject fun(cx, lazy->function()); RootedScript script(cx, JSScript::New(cx, fun, sourceObject, lazy->sourceStart(), lazy->sourceEnd(), lazy->toStringStart(), diff --git a/js/src/vm/JSScript.h b/js/src/vm/JSScript.h index 0f10645d0848..81a4c2571b0a 100644 --- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -3328,9 +3328,7 @@ class LazyScript : public BaseScript { uint32_t sourceStart, uint32_t sourceEnd, uint32_t toStringStart, uint32_t toStringEnd, uint32_t lineno, uint32_t column); - JSFunction* functionNonDelazifying() const { - return &functionOrGlobal_->as(); - } + JSFunction* function() const { return &functionOrGlobal_->as(); } bool canRelazify() const { // Only functions without inner functions or direct eval are re-lazified.