Bug 1673553 part 17 - Remove ObjectGroup interpreted function addendum. r=iain
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 18 Nov 2020 15:47:31 +0000
changeset 557818 d6cdc2a48fa7a24765684fe82771632cc6f59b79
parent 557817 aa3d200b6f98f4013cc23c1c13bc1b9504c96e5f
child 557819 66c92d861375bcf2e5d21b7e406b0fc742c0e689
push id37962
push userapavel@mozilla.com
push dateWed, 18 Nov 2020 21:51:58 +0000
treeherdermozilla-central@9d797387f57c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersiain
bugs1673553
milestone85.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 1673553 part 17 - Remove ObjectGroup interpreted function addendum. r=iain Differential Revision: https://phabricator.services.mozilla.com/D97297
js/src/gc/Marking.cpp
js/src/vm/JSFunction.cpp
js/src/vm/JSObject.cpp
js/src/vm/ObjectGroup.cpp
js/src/vm/ObjectGroup.h
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -1539,39 +1539,31 @@ void js::ObjectGroup::traceChildren(JSTr
     TraceManuallyBarrieredEdge(trc, &global, "group_global");
   }
 
   if (JSObject* descr = maybeTypeDescr()) {
     TraceManuallyBarrieredEdge(trc, &descr, "group_type_descr");
     MOZ_ASSERT(js::IsTypeDescrClass(MaybeForwardedObjectClass(descr)));
     setTypeDescr(static_cast<TypeDescr*>(descr));
   }
-
-  if (JSObject* fun = maybeInterpretedFunction()) {
-    TraceManuallyBarrieredEdge(trc, &fun, "group_function");
-    setInterpretedFunction(&MaybeForwardedObjectAs<JSFunction>(fun));
-  }
 }
+
 void js::GCMarker::lazilyMarkChildren(ObjectGroup* group) {
   if (group->proto().isObject()) {
     traverseEdge(group, group->proto().toObject());
   }
 
   // Note: the realm's global can be nullptr if we GC while creating the global.
   if (GlobalObject* global = group->realm()->unsafeUnbarrieredMaybeGlobal()) {
     traverseEdge(group, static_cast<JSObject*>(global));
   }
 
   if (TypeDescr* descr = group->maybeTypeDescr()) {
     traverseEdge(group, static_cast<JSObject*>(descr));
   }
-
-  if (JSFunction* fun = group->maybeInterpretedFunction()) {
-    traverseEdge(group, static_cast<JSObject*>(fun));
-  }
 }
 
 void JS::BigInt::traceChildren(JSTracer* trc) {}
 
 // Call the trace hook set on the object, if present.
 static inline void CallTraceHook(JSTracer* trc, JSObject* obj) {
   const JSClass* clasp = obj->getClass();
   MOZ_ASSERT(clasp);
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -2197,26 +2197,17 @@ JSFunction* js::CloneFunctionReuseScript
                                          gc::AllocKind allocKind,
                                          HandleObject proto) {
   MOZ_ASSERT(cx->realm() == fun->realm());
   MOZ_ASSERT(NewFunctionEnvironmentIsWellFormed(cx, enclosingEnv));
   MOZ_ASSERT(fun->isInterpreted());
   MOZ_ASSERT(!fun->isBoundFunction());
   MOZ_ASSERT(CanReuseScriptForClone(cx->realm(), fun, enclosingEnv));
 
-  // If an explicit prototype is present and this prototype doesn't match the
-  // original function's prototype and furthermore the original function's group
-  // has a type, then also create a type for the cloned function. This ensures
-  // derived class constructors will have a type assigned.
-  bool setTypeForFunction = proto && fun->staticPrototype() != proto &&
-                            fun->group()->maybeInterpretedFunction();
-
-  // The function needs to be tenured when used as an object group addendum.
-  NewObjectKind newKind = setTypeForFunction ? TenuredObject : GenericObject;
-
+  NewObjectKind newKind = GenericObject;
   RootedFunction clone(cx,
                        NewFunctionClone(cx, fun, newKind, allocKind, proto));
   if (!clone) {
     return nullptr;
   }
 
   if (fun->hasBaseScript()) {
     BaseScript* base = fun->baseScript();
@@ -2224,25 +2215,16 @@ JSFunction* js::CloneFunctionReuseScript
     clone->initEnvironment(enclosingEnv);
   } else {
     MOZ_ASSERT(fun->hasSelfHostedLazyScript());
     SelfHostedLazyScript* lazy = fun->selfHostedLazyScript();
     clone->initSelfHostedLazyScript(lazy);
     clone->initEnvironment(enclosingEnv);
   }
 
-  MOZ_RELEASE_ASSERT(!IsTypeInferenceEnabled());
-
-  /*
-   * Clone the function, reusing its script. We can use the same group as
-   * the original function provided that its prototype is correct.
-   */
-  if (fun->staticPrototype() == clone->staticPrototype()) {
-    clone->setGroup(fun->group());
-  }
   return clone;
 }
 
 JSFunction* js::CloneFunctionAndScript(JSContext* cx, HandleFunction fun,
                                        HandleObject enclosingEnv,
                                        HandleScope newScope,
                                        Handle<ScriptSourceObject*> sourceObject,
                                        gc::AllocKind allocKind,
--- a/js/src/vm/JSObject.cpp
+++ b/js/src/vm/JSObject.cpp
@@ -1955,28 +1955,17 @@ static bool SetProto(JSContext* cx, Hand
     }
     MarkObjectGroupUnknownProperties(cx, obj->group());
     return true;
   }
 
   RootedObjectGroup oldGroup(cx, obj->group());
 
   ObjectGroup* newGroup;
-  if (oldGroup->maybeInterpretedFunction()) {
-    // We're changing the group/proto of a scripted function. Create a new
-    // group so we can keep track of the interpreted function for Ion
-    // inlining.
-    MOZ_ASSERT(obj->is<JSFunction>());
-    newGroup = ObjectGroupRealm::makeGroup(cx, oldGroup->realm(),
-                                           &JSFunction::class_, proto);
-    if (!newGroup) {
-      return false;
-    }
-    newGroup->setInterpretedFunction(oldGroup->maybeInterpretedFunction());
-  } else {
+  {
     AutoRealm ar(cx, oldGroup);
     newGroup = ObjectGroup::defaultNewGroup(cx, obj->getClass(), proto);
     if (!newGroup) {
       return false;
     }
   }
 
   obj->setGroup(newGroup);
--- a/js/src/vm/ObjectGroup.cpp
+++ b/js/src/vm/ObjectGroup.cpp
@@ -175,22 +175,16 @@ ObjectGroup* JSObject::makeLazyGroup(JSC
   ObjectGroup* group = ObjectGroupRealm::makeGroup(
       cx, obj->nonCCWRealm(), obj->getClass(), proto, initialFlags);
   if (!group) {
     return nullptr;
   }
 
   AutoEnterAnalysis enter(cx);
 
-  /* Fill in the type according to the state of this object. */
-
-  if (obj->is<JSFunction>() && obj->as<JSFunction>().isInterpreted()) {
-    group->setInterpretedFunction(&obj->as<JSFunction>());
-  }
-
   obj->setGroupRaw(group);
 
   return group;
 }
 
 /* static */
 bool JSObject::setNewGroupUnknown(JSContext* cx, ObjectGroupRealm& realm,
                                   const JSClass* clasp, JS::HandleObject obj) {
--- a/js/src/vm/ObjectGroup.h
+++ b/js/src/vm/ObjectGroup.h
@@ -158,20 +158,16 @@ class ObjectGroup : public gc::TenuredCe
   JS::Compartment* maybeCompartment() const { return compartment(); }
   JS::Realm* realm() const { return realm_; }
 
  public:
   // Kinds of addendums which can be attached to ObjectGroups.
   enum AddendumKind {
     Addendum_None,
 
-    // When used by interpreted function, the addendum stores the
-    // canonical JSFunction object.
-    Addendum_InterpretedFunction,
-
     // When used by typed objects, the addendum stores a TypeDescr.
     Addendum_TypeDescr
   };
 
  private:
   void setAddendum(AddendumKind kind, void* addendum, bool isSweeping = false);
 
   AddendumKind addendumKind() const {
@@ -199,30 +195,16 @@ class ObjectGroup : public gc::TenuredCe
     MOZ_ASSERT(addendumKind() == Addendum_TypeDescr);
     return *reinterpret_cast<TypeDescr*>(addendum_);
   }
 
   void setTypeDescr(TypeDescr* descr) {
     setAddendum(Addendum_TypeDescr, descr);
   }
 
-  JSFunction* maybeInterpretedFunction() {
-    // Note: as with type descriptors, there is no need to sweep when
-    // accessing the interpreted function associated with an object.
-    if (addendumKind() == Addendum_InterpretedFunction) {
-      return reinterpret_cast<JSFunction*>(addendum_);
-    }
-    return nullptr;
-  }
-
-  void setInterpretedFunction(JSFunction* fun) {
-    MOZ_ASSERT(!gc::IsInsideNursery(reinterpret_cast<gc::Cell*>(fun)));
-    setAddendum(Addendum_InterpretedFunction, fun);
-  }
-
  public:
   inline ObjectGroup(const JSClass* clasp, TaggedProto proto, JS::Realm* realm,
                      ObjectGroupFlags initialFlags);
 
   inline bool hasAnyFlags(const AutoSweepObjectGroup& sweep,
                           ObjectGroupFlags flags);
   inline bool hasAllFlags(const AutoSweepObjectGroup& sweep,
                           ObjectGroupFlags flags);