Bug 1589904 - Remove JSScript::ensureNonLazyCanonicalFunction() r=jandem
authorTed Campbell <tcampbell@mozilla.com>
Fri, 25 Oct 2019 06:09:10 +0000
changeset 499017 fa30ee7c72cd711eba7515d4961dec27747b2bc3
parent 499016 9b4e44680b99bdb0a758fbccc5abd82ead08af09
child 499018 327dacef5a0798007456cf20a9277384f57792ca
push id36734
push userncsoregi@mozilla.com
push dateSat, 26 Oct 2019 09:45:46 +0000
treeherdermozilla-central@0b9d0a86ebfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1589904
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1589904 - Remove JSScript::ensureNonLazyCanonicalFunction() r=jandem When a function is delazified, we always delazify the canonical function first. As a result, when we have the active JSScript, the JSFunction is already non-lazy. Differential Revision: https://phabricator.services.mozilla.com/D49836
js/src/jit/BaselineJIT.cpp
js/src/jit/Ion.cpp
js/src/jsapi.cpp
js/src/vm/Interpreter.cpp
js/src/vm/JSScript-inl.h
js/src/vm/JSScript.h
js/src/vm/Stack-inl.h
--- a/js/src/jit/BaselineJIT.cpp
+++ b/js/src/jit/BaselineJIT.cpp
@@ -195,18 +195,16 @@ MethodStatus jit::BaselineCompile(JSCont
   cx->check(script);
   MOZ_ASSERT(!script->hasBaselineScript());
   MOZ_ASSERT(script->canBaselineCompile());
   MOZ_ASSERT(IsBaselineJitEnabled());
   AutoGeckoProfilerEntry pseudoFrame(
       cx, "Baseline script compilation",
       JS::ProfilingCategoryPair::JS_BaselineCompilation);
 
-  script->ensureNonLazyCanonicalFunction();
-
   TempAllocator temp(&cx->tempLifoAlloc());
   JitContext jctx(cx, nullptr);
 
   BaselineCompiler compiler(cx, temp, script);
   if (!compiler.init()) {
     ReportOutOfMemory(cx);
     return Method_Error;
   }
--- a/js/src/jit/Ion.cpp
+++ b/js/src/jit/Ion.cpp
@@ -1741,20 +1741,16 @@ static AbortReason IonCompile(JSContext*
                               OptimizationLevel optimizationLevel) {
   TraceLoggerThread* logger = TraceLoggerForCurrentThread(cx);
   TraceLoggerEvent event(TraceLogger_AnnotateScripts, script);
   AutoTraceLog logScript(logger, event);
   AutoTraceLog logCompile(logger, TraceLogger_IonCompilation);
 
   cx->check(script);
 
-  // Make sure the script's canonical function isn't lazy. We can't de-lazify
-  // it in a helper thread.
-  script->ensureNonLazyCanonicalFunction();
-
   auto alloc =
       cx->make_unique<LifoAlloc>(TempAllocator::PreferredLifoChunkSize);
   if (!alloc) {
     return AbortReason::Alloc;
   }
 
   TempAllocator* temp = alloc->new_<TempAllocator>(alloc.get());
   if (!temp) {
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3714,17 +3714,16 @@ JS_PUBLIC_API JSScript* JS_GetFunctionSc
   return fun->nonLazyScript();
 }
 
 JS_PUBLIC_API JSString* JS_DecompileScript(JSContext* cx, HandleScript script) {
   MOZ_ASSERT(!cx->zone()->isAtomsZone());
 
   AssertHeapIsIdle();
   CHECK_THREAD(cx);
-  script->ensureNonLazyCanonicalFunction();
   RootedFunction fun(cx, script->functionNonDelazifying());
   if (fun) {
     return JS_DecompileFunction(cx, fun);
   }
   bool haveSource;
   if (!ScriptSource::loadSource(cx, script->scriptSource(), &haveSource)) {
     return nullptr;
   }
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -400,18 +400,16 @@ bool js::RunScript(JSContext* cx, RunSta
   MOZ_ASSERT(!cx->enableAccessValidation || cx->realm()->isAccessValid());
 
   if (!DebugAPI::checkNoExecute(cx, state.script())) {
     return false;
   }
 
   GeckoProfilerEntryMarker marker(cx, state.script());
 
-  state.script()->ensureNonLazyCanonicalFunction();
-
   jit::EnterJitStatus status = jit::MaybeEnterJit(cx, state);
   switch (status) {
     case jit::EnterJitStatus::Error:
       return false;
     case jit::EnterJitStatus::Ok:
       return true;
     case jit::EnterJitStatus::NotEntered:
       break;
--- a/js/src/vm/JSScript-inl.h
+++ b/js/src/vm/JSScript-inl.h
@@ -77,24 +77,16 @@ inline JSFunction* JSScript::functionDel
     // reference to the script when delazifying its canonical function.
     if (lazyScript && !lazyScript->maybeScript()) {
       lazyScript->initScript(const_cast<JSScript*>(this));
     }
   }
   return fun;
 }
 
-inline void JSScript::ensureNonLazyCanonicalFunction() {
-  // Infallibly delazify the canonical script.
-  JSFunction* fun = function();
-  if (fun && fun->isInterpretedLazy()) {
-    functionDelazifying();
-  }
-}
-
 inline JSFunction* JSScript::getFunction(size_t index) {
   JSObject* obj = getObject(index);
   MOZ_RELEASE_ASSERT(obj->is<JSFunction>(), "Script object is not JSFunction");
   JSFunction* fun = &obj->as<JSFunction>();
   MOZ_ASSERT_IF(fun->isNative(), IsAsmJSModuleNative(fun->native()));
   return fun;
 }
 
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -2739,21 +2739,16 @@ class JSScript : public js::BaseScript {
    */
   inline JSFunction* functionDelazifying() const;
   JSFunction* functionNonDelazifying() const {
     if (bodyScope()->is<js::FunctionScope>()) {
       return bodyScope()->as<js::FunctionScope>().canonicalFunction();
     }
     return nullptr;
   }
-  /*
-   * De-lazifies the canonical function. Must be called before entering code
-   * that expects the function to be non-lazy.
-   */
-  inline void ensureNonLazyCanonicalFunction();
 
   bool isModule() const {
     MOZ_ASSERT(hasFlag(ImmutableFlags::IsModule) ==
                bodyScope()->is<js::ModuleScope>());
     return hasFlag(ImmutableFlags::IsModule);
   }
   js::ModuleObject* module() const {
     if (isModule()) {
--- a/js/src/vm/Stack-inl.h
+++ b/js/src/vm/Stack-inl.h
@@ -260,18 +260,16 @@ MOZ_ALWAYS_INLINE InterpreterFrame* Inte
 
 MOZ_ALWAYS_INLINE bool InterpreterStack::pushInlineFrame(
     JSContext* cx, InterpreterRegs& regs, const CallArgs& args,
     HandleScript script, MaybeConstruct constructing) {
   RootedFunction callee(cx, &args.callee().as<JSFunction>());
   MOZ_ASSERT(regs.sp == args.end());
   MOZ_ASSERT(callee->nonLazyScript() == script);
 
-  script->ensureNonLazyCanonicalFunction();
-
   InterpreterFrame* prev = regs.fp();
   jsbytecode* prevpc = regs.pc;
   Value* prevsp = regs.sp;
   MOZ_ASSERT(prev);
 
   LifoAlloc::Mark mark = allocator_.mark();
 
   Value* argv;
@@ -295,18 +293,16 @@ MOZ_ALWAYS_INLINE bool InterpreterStack:
     HandleObject envChain) {
   MOZ_ASSERT(callee->isGenerator() || callee->isAsync());
   RootedScript script(cx, callee->nonLazyScript());
   InterpreterFrame* prev = regs.fp();
   jsbytecode* prevpc = regs.pc;
   Value* prevsp = regs.sp;
   MOZ_ASSERT(prev);
 
-  script->ensureNonLazyCanonicalFunction();
-
   LifoAlloc::Mark mark = allocator_.mark();
 
   // (Async) generators and async functions are not constructors.
   MOZ_ASSERT(!callee->isConstructor());
 
   // Include callee, |this|, and maybe |new.target|
   unsigned nformal = callee->nargs();
   unsigned nvals = 2 + nformal + script->nslots();