Bug 1620495 - Remove various uses of LazyScript r=mgaudet
authorTed Campbell <tcampbell@mozilla.com>
Mon, 16 Mar 2020 19:42:57 +0000
changeset 519026 1bf4fb5973f8681e49cf8fe051d7a92b79c6cb28
parent 519025 17f0784ab346b5a6cda72984d0b72c804b1fac7f
child 519027 40d56eb71cdd804a90b6253d4b7a98bae1ac4d6d
push id37220
push useraiakab@mozilla.com
push dateTue, 17 Mar 2020 05:13:41 +0000
treeherdermozilla-central@17adc9cb1db9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1620495
milestone76.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 1620495 - Remove various uses of LazyScript r=mgaudet Remove miscelaneous uses of LazyScript type. Also move XDRScriptData from LazyScript to BaseScript. Also remove JSFunction::lazyScript(). Differential Revision: https://phabricator.services.mozilla.com/D66849
js/src/gc/GCRuntime.h
js/src/vm/JSFunction.cpp
js/src/vm/JSFunction.h
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -720,17 +720,16 @@ class GCRuntime {
   void markIncomingCrossCompartmentPointers(MarkColor color);
   IncrementalProgress beginSweepingSweepGroup(JSFreeOp* fop,
                                               SliceBudget& budget);
   void updateAtomsBitmap();
   void sweepCCWrappers();
   void sweepObjectGroups();
   void sweepMisc();
   void sweepCompressionTasks();
-  void sweepLazyScripts();
   void sweepWeakMaps();
   void sweepUniqueIds();
   void sweepDebuggerOnMainThread(JSFreeOp* fop);
   void sweepJitDataOnMainThread(JSFreeOp* fop);
   void sweepFinalizationRegistriesOnMainThread();
   void sweepFinalizationRegistries(Zone* zone);
   void queueFinalizationRegistryForCleanup(
       FinalizationRegistryObject* registry);
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -555,17 +555,17 @@ XDRResult js::XDRInterpretedFunction(XDR
   uint8_t xdrFlags = 0; /* bitmask of FirstWordFlag */
 
   uint16_t nargs = 0;
   uint16_t flags = 0;
 
   RootedFunction fun(cx);
   RootedAtom atom(cx);
   RootedScript script(cx);
-  Rooted<LazyScript*> lazy(cx);
+  Rooted<BaseScript*> lazy(cx);
 
   if (mode == XDR_ENCODE) {
     fun = objp;
     if (!fun->isInterpreted() || fun->isBoundFunction()) {
       return xdr->fail(JS::TranscodeResult_Failure_NotInterpretedFun);
     }
 
     if (fun->isSingleton()) {
@@ -580,17 +580,17 @@ XDRResult js::XDRInterpretedFunction(XDR
     }
 
     if (fun->hasBytecode()) {
       // Encode the script.
       script = fun->nonLazyScript();
     } else {
       // Encode a lazy script.
       xdrFlags |= IsLazy;
-      lazy = fun->lazyScript();
+      lazy = fun->baseScript();
     }
 
     if (fun->displayAtom()) {
       xdrFlags |= HasAtom;
     }
 
     nargs = fun->nargs();
     flags = (fun->flags().toRaw() & ~FunctionFlags::MUTABLE_FLAGS);
@@ -1539,17 +1539,17 @@ bool JSFunction::finishBoundFunctionInit
     }
   }
 
   return true;
 }
 
 static bool DelazifyCanonicalScriptedFunction(JSContext* cx,
                                               HandleFunction fun) {
-  Rooted<LazyScript*> lazy(cx, fun->lazyScript());
+  Rooted<BaseScript*> lazy(cx, fun->baseScript());
 
   MOZ_ASSERT(lazy->isLazyScript(), "Script is already compiled!");
   MOZ_ASSERT(lazy->function() == fun);
 
   ScriptSource* ss = lazy->scriptSource();
   size_t sourceStart = lazy->sourceStart();
   size_t sourceLength = lazy->sourceEnd() - lazy->sourceStart();
   bool hadLazyScriptData = lazy->hasPrivateScriptData();
@@ -1630,17 +1630,17 @@ bool JSFunction::delazifyLazilyInterpret
                                                    HandleFunction fun) {
   MOZ_ASSERT(fun->hasBaseScript());
   MOZ_ASSERT(cx->compartment() == fun->compartment());
 
   // The function must be same-compartment but might be cross-realm. Make sure
   // the script is created in the function's realm.
   AutoRealm ar(cx, fun);
 
-  Rooted<LazyScript*> lazy(cx, fun->lazyScript());
+  Rooted<BaseScript*> lazy(cx, fun->baseScript());
   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
   // again on the canonical function. This ensures the canonical function is
   // always non-lazy if any of the clones are non-lazy.
   if (fun != canonicalFun) {
     JSScript* script = JSFunction::getOrCreateScript(cx, canonicalFun);
--- a/js/src/vm/JSFunction.h
+++ b/js/src/vm/JSFunction.h
@@ -738,22 +738,16 @@ class JSFunction : public js::NativeObje
   bool isIncomplete() const { return isInterpreted() && !u.scripted.s.script_; }
 
   JSScript* nonLazyScript() const {
     MOZ_ASSERT(hasBaseScript());
     MOZ_ASSERT(u.scripted.s.script_);
     return static_cast<JSScript*>(u.scripted.s.script_);
   }
 
-  js::LazyScript* lazyScript() const {
-    MOZ_ASSERT(hasBaseScript());
-    MOZ_ASSERT(u.scripted.s.script_);
-    return static_cast<js::LazyScript*>(u.scripted.s.script_);
-  }
-
   js::SelfHostedLazyScript* selfHostedLazyScript() const {
     MOZ_ASSERT(hasSelfHostedLazyScript());
     MOZ_ASSERT(u.scripted.s.selfHostedLazy_);
     return u.scripted.s.selfHostedLazy_;
   }
 
   // Access fields defined on both lazy and non-lazy scripts.
   js::BaseScript* baseScript() const {
@@ -805,17 +799,17 @@ class JSFunction : public js::NativeObje
 
   void initLazyScript(js::BaseScript* lazy) {
     MOZ_ASSERT(isInterpreted());
     u.scripted.s.script_ = lazy;
   }
 
   // Release the lazyScript() pointer while triggering barriers.
   void clearLazyScript() {
-    js::BaseScript::writeBarrierPre(lazyScript());
+    js::BaseScript::writeBarrierPre(baseScript());
     u.scripted.s.script_ = nullptr;
     MOZ_ASSERT(isIncomplete());
   }
 
   void initSelfHostedLazyScript(js::SelfHostedLazyScript* lazy) {
     MOZ_ASSERT(isSelfHostedBuiltin());
     MOZ_ASSERT(isInterpreted());
     flags_.clearBaseScript();
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -238,20 +238,20 @@ template XDRResult js::XDRScriptConst(XD
                                       MutableHandleValue);
 
 template XDRResult js::XDRScriptConst(XDRState<XDR_DECODE>*,
                                       MutableHandleValue);
 
 // Code LazyScript's closed over bindings.
 template <XDRMode mode>
 /* static */
-XDRResult LazyScript::XDRScriptData(XDRState<mode>* xdr,
-                                    HandleScriptSourceObject sourceObject,
-                                    Handle<LazyScript*> lazy,
-                                    bool hasFieldInitializers) {
+XDRResult BaseScript::XDRLazyScriptData(XDRState<mode>* xdr,
+                                        HandleScriptSourceObject sourceObject,
+                                        Handle<BaseScript*> lazy,
+                                        bool hasFieldInitializers) {
   JSContext* cx = xdr->cx();
 
   RootedAtom atom(cx);
   RootedFunction func(cx);
 
   if (hasFieldInitializers) {
     uint32_t numFieldInitializers;
     if (mode == XDR_ENCODE) {
@@ -1292,17 +1292,17 @@ template XDRResult js::XDRScript(XDRStat
 template XDRResult js::XDRScript(XDRState<XDR_DECODE>*, HandleScope,
                                  HandleScriptSourceObject, HandleObject,
                                  MutableHandleScript);
 
 template <XDRMode mode>
 XDRResult js::XDRLazyScript(XDRState<mode>* xdr, HandleScope enclosingScope,
                             HandleScriptSourceObject sourceObject,
                             HandleFunction fun,
-                            MutableHandle<LazyScript*> lazy) {
+                            MutableHandle<BaseScript*> lazy) {
   MOZ_ASSERT_IF(mode == XDR_DECODE, sourceObject);
 
   JSContext* cx = xdr->cx();
 
   {
     SourceExtent extent;
     uint32_t immutableFlags;
     uint32_t ngcthings;
@@ -1343,29 +1343,29 @@ XDRResult js::XDRLazyScript(XDRState<mod
       }
 
       fun->initLazyScript(lazy);
     }
   }
 
   bool hasFieldInitializers = fun->isClassConstructor();
 
-  MOZ_TRY(
-      LazyScript::XDRScriptData(xdr, sourceObject, lazy, hasFieldInitializers));
+  MOZ_TRY(BaseScript::XDRLazyScriptData(xdr, sourceObject, lazy,
+                                        hasFieldInitializers));
 
   return Ok();
 }
 
 template XDRResult js::XDRLazyScript(XDRState<XDR_ENCODE>*, HandleScope,
                                      HandleScriptSourceObject, HandleFunction,
-                                     MutableHandle<LazyScript*>);
+                                     MutableHandle<BaseScript*>);
 
 template XDRResult js::XDRLazyScript(XDRState<XDR_DECODE>*, HandleScope,
                                      HandleScriptSourceObject, HandleFunction,
-                                     MutableHandle<LazyScript*>);
+                                     MutableHandle<BaseScript*>);
 
 void JSScript::setDefaultClassConstructorSpan(
     js::ScriptSourceObject* sourceObject, uint32_t start, uint32_t end,
     unsigned line, unsigned column) {
   MOZ_ASSERT(compartment() == sourceObject->compartment());
   sourceObject_ = sourceObject;
   extent_.toStringStart = start;
   extent_.toStringEnd = end;
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -2379,16 +2379,22 @@ setterLevel:                            
   void finalize(JSFreeOp* fop);
 
   size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) {
     return mallocSizeOf(data_);
   }
 
   inline JSScript* asJSScript();
 
+  template <XDRMode mode>
+  static XDRResult XDRLazyScriptData(XDRState<mode>* xdr,
+                                     HandleScriptSourceObject sourceObject,
+                                     Handle<BaseScript*> lazy,
+                                     bool hasFieldInitializer);
+
   // JIT accessors
   static constexpr size_t offsetOfJitCodeRaw() {
     return offsetof(BaseScript, jitCodeRaw_);
   }
   static constexpr size_t offsetOfPrivateData() {
     return offsetof(BaseScript, data_);
   }
   static constexpr size_t offsetOfSharedData() {
@@ -2415,17 +2421,17 @@ setterLevel:                            
 template <XDRMode mode>
 XDRResult XDRScript(XDRState<mode>* xdr, HandleScope enclosingScope,
                     HandleScriptSourceObject sourceObject,
                     HandleObject funOrMod, MutableHandleScript scriptp);
 
 template <XDRMode mode>
 XDRResult XDRLazyScript(XDRState<mode>* xdr, HandleScope enclosingScope,
                         HandleScriptSourceObject sourceObject,
-                        HandleFunction fun, MutableHandle<LazyScript*> lazy);
+                        HandleFunction fun, MutableHandle<BaseScript*> lazy);
 
 /*
  * Code any constant value.
  */
 template <XDRMode mode>
 XDRResult XDRScriptConst(XDRState<mode>* xdr, MutableHandleValue vp);
 
 extern void SweepScriptData(JSRuntime* rt);
@@ -3163,22 +3169,16 @@ class LazyScript : public BaseScript {
   // Create a LazyScript and initialize closedOverBindings and innerFunctions
   // with the provided vectors.
   static LazyScript* Create(
       JSContext* cx, const frontend::CompilationInfo& compilationInfo,
       HandleFunction fun, HandleScriptSourceObject sourceObject,
       const frontend::AtomVector& closedOverBindings,
       const Vector<frontend::FunctionIndex>& innerFunctionIndexes,
       const SourceExtent& extent);
-
-  template <XDRMode mode>
-  static XDRResult XDRScriptData(XDRState<mode>* xdr,
-                                 HandleScriptSourceObject sourceObject,
-                                 Handle<LazyScript*> lazy,
-                                 bool hasFieldInitializer);
 };
 
 struct ScriptAndCounts {
   /* This structure is stored and marked from the JSRuntime. */
   JSScript* script;
   ScriptCounts scriptCounts;
 
   inline explicit ScriptAndCounts(JSScript* script);