Bug 989414 - Rename BarrieredPtr to BarrieredBase to match new usage; r=jonco
authorTerrence Cole <terrence@mozilla.com>
Mon, 28 Apr 2014 11:38:54 -0700
changeset 180804 57292971f11018f5f690abf59e82454e48c70082
parent 180803 7165d1b0097ab84362be2a5cbf03173eee54f27f
child 180805 a71ab94278556083224dcf8b6d0f77603720ec2b
push id42875
push usertcole@mozilla.com
push dateTue, 29 Apr 2014 19:39:44 +0000
treeherdermozilla-inbound@57292971f110 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs989414
milestone32.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 989414 - Rename BarrieredPtr to BarrieredBase to match new usage; r=jonco
js/src/gc/Barrier.h
js/src/gc/Marking.cpp
js/src/gc/Marking.h
--- a/js/src/gc/Barrier.h
+++ b/js/src/gc/Barrier.h
@@ -132,17 +132,17 @@
  * newly allocated objects do not need a pre-barrier.  In these cases, we use
  * the "obj->field.init(value)" method instead of "obj->field = value". We use
  * the init naming idiom in many places to signify that a field is being
  * assigned for the first time.
  *
  * For each of pointers, Values and jsids this file implements four classes,
  * illustrated here for the pointer (Ptr) classes:
  *
- * BarrieredPtr           abstract base class which provides common operations
+ * BarrieredBase          abstract base class which provides common operations
  *  |  |  |
  *  |  | PreBarriered     provides pre-barriers only
  *  |  |
  *  | HeapPtr             provides pre- and post-barriers
  *  |
  * RelocatablePtr         provides pre- and post-barriers and is relocatable
  *
  * These classes are designed to be used by the internals of the JS engine.
@@ -406,23 +406,23 @@ struct InternalGCMethods<jsid>
     static void postBarrierRelocate(jsid *idp) {}
     static void postBarrierRemove(jsid *idp) {}
 };
 
 /*
  * Base class for barriered pointer types.
  */
 template <class T>
-class BarrieredPtr : public HeapBase<T>
+class BarrieredBase : public HeapBase<T>
 {
   protected:
     T value;
 
-    BarrieredPtr(T v) : value(v) {}
-    ~BarrieredPtr() { pre(); }
+    BarrieredBase(T v) : value(v) {}
+    ~BarrieredBase() { pre(); }
 
   public:
     void init(T v) {
         JS_ASSERT(!GCMethods<T>::poisoned(v));
         this->value = v;
     }
 
     bool operator==(const T &other) const { return value == other; }
@@ -453,23 +453,23 @@ class BarrieredPtr : public HeapBase<T>
 
 /*
  * PreBarriered only automatically handles pre-barriers. Post-barriers must
  * be manually implemented when using this class. HeapPtr and RelocatablePtr
  * should be used in all cases that do not require explicit low-level control
  * of moving behavior, e.g. for HashMap keys.
  */
 template <class T>
-class PreBarriered : public BarrieredPtr<T>
+class PreBarriered : public BarrieredBase<T>
 {
   public:
-    PreBarriered() : BarrieredPtr<T>(GCMethods<T>::initial()) {}
-    PreBarriered(T v) : BarrieredPtr<T>(v) {}
+    PreBarriered() : BarrieredBase<T>(GCMethods<T>::initial()) {}
+    PreBarriered(T v) : BarrieredBase<T>(v) {}
     explicit PreBarriered(const PreBarriered<T> &v)
-      : BarrieredPtr<T>(v.value) {}
+      : BarrieredBase<T>(v.value) {}
 
     /* Use to set the pointer to nullptr. */
     void clear() {
         this->pre();
         this->value = nullptr;
     }
 
     PreBarriered<T> &operator=(T v) {
@@ -495,22 +495,22 @@ class PreBarriered : public BarrieredPtr
  *
  * The post-barriers implemented by this class are faster than those
  * implemented by RelocatablePtr<T> or JS::Heap<T> at the cost of not
  * automatically handling deletion or movement. It should generally only be
  * stored in memory that has GC lifetime. HeapPtr must not be used in contexts
  * where it may be implicitly moved or deleted, e.g. most containers.
  */
 template <class T>
-class HeapPtr : public BarrieredPtr<T>
+class HeapPtr : public BarrieredBase<T>
 {
   public:
-    HeapPtr() : BarrieredPtr<T>(GCMethods<T>::initial()) {}
-    explicit HeapPtr(T v) : BarrieredPtr<T>(v) { post(); }
-    explicit HeapPtr(const HeapPtr<T> &v) : BarrieredPtr<T>(v) { post(); }
+    HeapPtr() : BarrieredBase<T>(GCMethods<T>::initial()) {}
+    explicit HeapPtr(T v) : BarrieredBase<T>(v) { post(); }
+    explicit HeapPtr(const HeapPtr<T> &v) : BarrieredBase<T>(v) { post(); }
 
     void init(T v) {
         JS_ASSERT(!GCMethods<T>::poisoned(v));
         this->value = v;
         post();
     }
 
     HeapPtr<T> &operator=(T v) {
@@ -585,32 +585,32 @@ class ImmutableTenuredPtr
 /*
  * A pre- and post-barriered heap pointer, for use inside the JS engine.
  *
  * Unlike HeapPtr<T>, it can be used in memory that is not managed by the GC,
  * i.e. in C++ containers.  It is, however, somewhat slower, so should only be
  * used in contexts where this ability is necessary.
  */
 template <class T>
-class RelocatablePtr : public BarrieredPtr<T>
+class RelocatablePtr : public BarrieredBase<T>
 {
   public:
-    RelocatablePtr() : BarrieredPtr<T>(GCMethods<T>::initial()) {}
-    explicit RelocatablePtr(T v) : BarrieredPtr<T>(v) {
+    RelocatablePtr() : BarrieredBase<T>(GCMethods<T>::initial()) {}
+    explicit RelocatablePtr(T v) : BarrieredBase<T>(v) {
         if (isMarkable(v))
             post();
     }
 
     /*
      * For RelocatablePtr, move semantics are equivalent to copy semantics. In
      * C++, a copy constructor taking const-ref is the way to get a single
      * function that will be used for both lvalue and rvalue copies, so we can
      * simply omit the rvalue variant.
      */
-    RelocatablePtr(const RelocatablePtr<T> &v) : BarrieredPtr<T>(v) {
+    RelocatablePtr(const RelocatablePtr<T> &v) : BarrieredBase<T>(v) {
         if (isMarkable(this->value))
             post();
     }
 
     ~RelocatablePtr() {
         if (isMarkable(this->value))
             relocate();
     }
@@ -764,19 +764,16 @@ class UnownedBaseShape;
 namespace jit {
 class JitCode;
 }
 namespace types {
 struct TypeObject;
 struct TypeObjectAddendum;
 }
 
-typedef BarrieredPtr<JSObject*> BarrieredPtrObject;
-typedef BarrieredPtr<JSScript*> BarrieredPtrScript;
-
 typedef PreBarriered<JSObject*> PreBarrieredObject;
 typedef PreBarriered<JSScript*> PreBarrieredScript;
 typedef PreBarriered<jit::JitCode*> PreBarrieredJitCode;
 
 typedef RelocatablePtr<JSObject*> RelocatablePtrObject;
 typedef RelocatablePtr<JSScript*> RelocatablePtrScript;
 typedef RelocatablePtr<NestedScopeObject*> RelocatablePtrNestedScopeObject;
 
@@ -791,22 +788,20 @@ typedef HeapPtr<JSScript*> HeapPtrScript
 typedef HeapPtr<JSString*> HeapPtrString;
 typedef HeapPtr<PropertyName*> HeapPtrPropertyName;
 typedef HeapPtr<Shape*> HeapPtrShape;
 typedef HeapPtr<UnownedBaseShape*> HeapPtrUnownedBaseShape;
 typedef HeapPtr<jit::JitCode*> HeapPtrJitCode;
 typedef HeapPtr<types::TypeObject*> HeapPtrTypeObject;
 typedef HeapPtr<types::TypeObjectAddendum*> HeapPtrTypeObjectAddendum;
 
-typedef BarrieredPtr<Value> BarrieredValue;
 typedef PreBarriered<Value> PreBarrieredValue;
 typedef RelocatablePtr<Value> RelocatableValue;
 typedef HeapPtr<Value> HeapValue;
 
-typedef BarrieredPtr<jsid> BarrieredId;
 typedef PreBarriered<jsid> PreBarrieredId;
 typedef RelocatablePtr<jsid> RelocatableId;
 typedef HeapPtr<jsid> HeapId;
 
 typedef ImmutableTenuredPtr<PropertyName*> ImmutablePropertyNamePtr;
 
 typedef ReadBarriered<DebugScopeObject*> ReadBarrieredDebugScopeObject;
 typedef ReadBarriered<GlobalObject*> ReadBarrieredGlobalObject;
@@ -818,35 +813,35 @@ typedef ReadBarriered<UnownedBaseShape*>
 typedef ReadBarriered<jit::JitCode*> ReadBarrieredJitCode;
 typedef ReadBarriered<types::TypeObject*> ReadBarrieredTypeObject;
 
 typedef ReadBarriered<Value> ReadBarrieredValue;
 
 // A pre- and post-barriered Value that is specialized to be aware that it
 // resides in a slots or elements vector. This allows it to be relocated in
 // memory, but with substantially less overhead than a RelocatablePtr.
-class HeapSlot : public BarrieredValue
+class HeapSlot : public BarrieredBase<Value>
 {
   public:
     enum Kind {
         Slot = 0,
         Element = 1
     };
 
     explicit HeapSlot() MOZ_DELETE;
 
     explicit HeapSlot(JSObject *obj, Kind kind, uint32_t slot, const Value &v)
-      : BarrieredValue(v)
+      : BarrieredBase<Value>(v)
     {
         JS_ASSERT(!IsPoisonedValue(v));
         post(obj, kind, slot, v);
     }
 
     explicit HeapSlot(JSObject *obj, Kind kind, uint32_t slot, const HeapSlot &s)
-      : BarrieredValue(s.value)
+      : BarrieredBase<Value>(s.value)
     {
         JS_ASSERT(!IsPoisonedValue(s.value));
         post(obj, kind, slot, s);
     }
 
     ~HeapSlot() {
         pre();
     }
@@ -913,17 +908,17 @@ class HeapSlot : public BarrieredValue
     }
 
     void post(JSRuntime *rt, JSObject *owner, Kind kind, uint32_t slot, Value target) {
         HeapSlot::writeBarrierPost(rt, owner, kind, slot, target);
     }
 };
 
 static inline const Value *
-Valueify(const BarrieredValue *array)
+Valueify(const BarrieredBase<Value> *array)
 {
     JS_STATIC_ASSERT(sizeof(HeapValue) == sizeof(Value));
     JS_STATIC_ASSERT(sizeof(HeapSlot) == sizeof(Value));
     return (const Value *)array;
 }
 
 static inline HeapValue *
 HeapValueify(Value *v)
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -258,17 +258,17 @@ void
 MarkUnbarriered(JSTracer *trc, T **thingp, const char *name)
 {
     trc->setTracingName(name);
     MarkInternal(trc, thingp);
 }
 
 template <typename T>
 static void
-Mark(JSTracer *trc, BarrieredPtr<T*> *thing, const char *name)
+Mark(JSTracer *trc, BarrieredBase<T*> *thing, const char *name)
 {
     trc->setTracingName(name);
     MarkInternal(trc, thing->unsafeGet());
 }
 
 void
 MarkPermanentAtom(JSTracer *trc, JSAtom *atom, const char *name)
 {
@@ -397,17 +397,17 @@ UpdateIfRelocated(JSRuntime *rt, T **thi
     if (*thingp && rt->isHeapMinorCollecting() && rt->gcNursery.isInside(*thingp))
         rt->gcNursery.getForwardedPointer(thingp);
 #endif
     return *thingp;
 }
 
 #define DeclMarkerImpl(base, type)                                                                \
 void                                                                                              \
-Mark##base(JSTracer *trc, BarrieredPtr<type*> *thing, const char *name)                           \
+Mark##base(JSTracer *trc, BarrieredBase<type*> *thing, const char *name)                          \
 {                                                                                                 \
     Mark<type>(trc, thing, name);                                                                 \
 }                                                                                                 \
                                                                                                   \
 void                                                                                              \
 Mark##base##Root(JSTracer *trc, type **thingp, const char *name)                                  \
 {                                                                                                 \
     MarkRoot<type>(trc, thingp, name);                                                            \
@@ -438,35 +438,35 @@ Mark##base##RootRange(JSTracer *trc, siz
                                                                                                   \
 bool                                                                                              \
 Is##base##Marked(type **thingp)                                                                   \
 {                                                                                                 \
     return IsMarked<type>(thingp);                                                                \
 }                                                                                                 \
                                                                                                   \
 bool                                                                                              \
-Is##base##Marked(BarrieredPtr<type*> *thingp)                                                     \
+Is##base##Marked(BarrieredBase<type*> *thingp)                                                    \
 {                                                                                                 \
     return IsMarked<type>(thingp->unsafeGet());                                                   \
 }                                                                                                 \
                                                                                                   \
 bool                                                                                              \
 Is##base##AboutToBeFinalized(type **thingp)                                                       \
 {                                                                                                 \
     return IsAboutToBeFinalized<type>(thingp);                                                    \
 }                                                                                                 \
                                                                                                   \
 bool                                                                                              \
-Is##base##AboutToBeFinalized(BarrieredPtr<type*> *thingp)                                         \
+Is##base##AboutToBeFinalized(BarrieredBase<type*> *thingp)                                        \
 {                                                                                                 \
     return IsAboutToBeFinalized<type>(thingp->unsafeGet());                                       \
 }                                                                                                 \
                                                                                                   \
 type *                                                                                            \
-Update##base##IfRelocated(JSRuntime *rt, BarrieredPtr<type*> *thingp)                             \
+Update##base##IfRelocated(JSRuntime *rt, BarrieredBase<type*> *thingp)                            \
 {                                                                                                 \
     return UpdateIfRelocated<type>(rt, thingp->unsafeGet());                                      \
 }                                                                                                 \
                                                                                                   \
 type *                                                                                            \
 Update##base##IfRelocated(JSRuntime *rt, type **thingp)                                           \
 {                                                                                                 \
     return UpdateIfRelocated<type>(rt, thingp);                                                   \
@@ -576,17 +576,17 @@ MarkIdInternal(JSTracer *trc, jsid *id)
         *id = OBJECT_TO_JSID(obj);
     } else {
         /* Unset realLocation manually if we do not call MarkInternal. */
         trc->unsetTracingLocation();
     }
 }
 
 void
-gc::MarkId(JSTracer *trc, BarrieredId *id, const char *name)
+gc::MarkId(JSTracer *trc, BarrieredBase<jsid> *id, const char *name)
 {
     trc->setTracingName(name);
     MarkIdInternal(trc, id->unsafeGet());
 }
 
 void
 gc::MarkIdRoot(JSTracer *trc, jsid *id, const char *name)
 {
@@ -637,17 +637,17 @@ MarkValueInternal(JSTracer *trc, Value *
             v->setObjectOrNull((JSObject *)thing);
     } else {
         /* Unset realLocation manually if we do not call MarkInternal. */
         trc->unsetTracingLocation();
     }
 }
 
 void
-gc::MarkValue(JSTracer *trc, BarrieredValue *v, const char *name)
+gc::MarkValue(JSTracer *trc, BarrieredBase<Value> *v, const char *name)
 {
     trc->setTracingName(name);
     MarkValueInternal(trc, v->unsafeGet());
 }
 
 void
 gc::MarkValueRoot(JSTracer *trc, Value *v, const char *name)
 {
@@ -668,17 +668,17 @@ gc::MarkTypeRoot(JSTracer *trc, types::T
     } else if (v->isTypeObject()) {
         types::TypeObject *typeObj = v->typeObject();
         MarkInternal(trc, &typeObj);
         *v = types::Type::ObjectType(typeObj);
     }
 }
 
 void
-gc::MarkValueRange(JSTracer *trc, size_t len, BarrieredValue *vec, const char *name)
+gc::MarkValueRange(JSTracer *trc, size_t len, BarrieredBase<Value> *vec, const char *name)
 {
     for (size_t i = 0; i < len; ++i) {
         trc->setTracingIndex(name, i);
         MarkValueInternal(trc, vec[i].unsafeGet());
     }
 }
 
 void
@@ -970,17 +970,17 @@ PushMarkStack(GCMarker *gcmarker, BaseSh
 }
 
 static void
 ScanShape(GCMarker *gcmarker, Shape *shape)
 {
   restart:
     PushMarkStack(gcmarker, shape->base());
 
-    const BarrieredId &id = shape->propidRef();
+    const BarrieredBase<jsid> &id = shape->propidRef();
     if (JSID_IS_STRING(id))
         PushMarkStack(gcmarker, JSID_TO_STRING(id));
     else if (MOZ_UNLIKELY(JSID_IS_OBJECT(id)))
         PushMarkStack(gcmarker, JSID_TO_OBJECT(id));
 
     shape = shape->previous();
     if (shape && shape->markIfUnmarked(gcmarker->getMarkColor()))
         goto restart;
--- a/js/src/gc/Marking.h
+++ b/js/src/gc/Marking.h
@@ -83,26 +83,26 @@ namespace gc {
  *
  * UpdateObjectIfRelocated(JSObject **thingp);
  *     In some circumstances -- e.g. optional weak marking -- it is necessary
  *     to look at the pointer before marking it strongly or weakly. In these
  *     cases, the following must be called to update the pointer before use.
  */
 
 #define DeclMarker(base, type)                                                                    \
-void Mark##base(JSTracer *trc, BarrieredPtr<type*> *thing, const char *name);                     \
+void Mark##base(JSTracer *trc, BarrieredBase<type*> *thing, const char *name);                    \
 void Mark##base##Root(JSTracer *trc, type **thingp, const char *name);                            \
 void Mark##base##Unbarriered(JSTracer *trc, type **thingp, const char *name);                     \
 void Mark##base##Range(JSTracer *trc, size_t len, HeapPtr<type*> *thing, const char *name);       \
 void Mark##base##RootRange(JSTracer *trc, size_t len, type **thing, const char *name);            \
 bool Is##base##Marked(type **thingp);                                                             \
-bool Is##base##Marked(BarrieredPtr<type*> *thingp);                                               \
+bool Is##base##Marked(BarrieredBase<type*> *thingp);                                              \
 bool Is##base##AboutToBeFinalized(type **thingp);                                                 \
-bool Is##base##AboutToBeFinalized(BarrieredPtr<type*> *thingp);                                   \
-type *Update##base##IfRelocated(JSRuntime *rt, BarrieredPtr<type*> *thingp);                      \
+bool Is##base##AboutToBeFinalized(BarrieredBase<type*> *thingp);                                  \
+type *Update##base##IfRelocated(JSRuntime *rt, BarrieredBase<type*> *thingp);                     \
 type *Update##base##IfRelocated(JSRuntime *rt, type **thingp);
 
 DeclMarker(BaseShape, BaseShape)
 DeclMarker(BaseShape, UnownedBaseShape)
 DeclMarker(JitCode, jit::JitCode)
 DeclMarker(Object, ArgumentsObject)
 DeclMarker(Object, ArrayBufferObject)
 DeclMarker(Object, ArrayBufferViewObject)
@@ -150,37 +150,37 @@ void
 MarkGCThingRoot(JSTracer *trc, void **thingp, const char *name);
 
 void
 MarkGCThingUnbarriered(JSTracer *trc, void **thingp, const char *name);
 
 /*** ID Marking ***/
 
 void
-MarkId(JSTracer *trc, BarrieredId *id, const char *name);
+MarkId(JSTracer *trc, BarrieredBase<jsid> *id, const char *name);
 
 void
 MarkIdRoot(JSTracer *trc, jsid *id, const char *name);
 
 void
 MarkIdUnbarriered(JSTracer *trc, jsid *id, const char *name);
 
 void
 MarkIdRange(JSTracer *trc, size_t len, HeapId *vec, const char *name);
 
 void
 MarkIdRootRange(JSTracer *trc, size_t len, jsid *vec, const char *name);
 
 /*** Value Marking ***/
 
 void
-MarkValue(JSTracer *trc, BarrieredValue *v, const char *name);
+MarkValue(JSTracer *trc, BarrieredBase<Value> *v, const char *name);
 
 void
-MarkValueRange(JSTracer *trc, size_t len, BarrieredValue *vec, const char *name);
+MarkValueRange(JSTracer *trc, size_t len, BarrieredBase<Value> *vec, const char *name);
 
 inline void
 MarkValueRange(JSTracer *trc, HeapValue *begin, HeapValue *end, const char *name)
 {
     return MarkValueRange(trc, end - begin, begin, name);
 }
 
 void
@@ -260,29 +260,29 @@ PushArena(GCMarker *gcmarker, ArenaHeade
 /*** Generic ***/
 
 /*
  * The Mark() functions interface should only be used by code that must be
  * templated.  Other uses should use the more specific, type-named functions.
  */
 
 inline void
-Mark(JSTracer *trc, BarrieredValue *v, const char *name)
+Mark(JSTracer *trc, BarrieredBase<Value> *v, const char *name)
 {
     MarkValue(trc, v, name);
 }
 
 inline void
-Mark(JSTracer *trc, BarrieredPtrObject *o, const char *name)
+Mark(JSTracer *trc, BarrieredBase<JSObject*> *o, const char *name)
 {
     MarkObject(trc, o, name);
 }
 
 inline void
-Mark(JSTracer *trc, BarrieredPtrScript *o, const char *name)
+Mark(JSTracer *trc, BarrieredBase<JSScript*> *o, const char *name)
 {
     MarkScript(trc, o, name);
 }
 
 inline void
 Mark(JSTracer *trc, HeapPtrJitCode *code, const char *name)
 {
     MarkJitCode(trc, code, name);
@@ -304,51 +304,51 @@ Mark(JSTracer *trc, ScopeObject **obj, c
 
 bool
 IsCellMarked(Cell **thingp);
 
 bool
 IsCellAboutToBeFinalized(Cell **thing);
 
 inline bool
-IsMarked(BarrieredValue *v)
+IsMarked(BarrieredBase<Value> *v)
 {
     if (!v->isMarkable())
         return true;
     return IsValueMarked(v->unsafeGet());
 }
 
 inline bool
-IsMarked(BarrieredPtrObject *objp)
+IsMarked(BarrieredBase<JSObject*> *objp)
 {
     return IsObjectMarked(objp);
 }
 
 inline bool
-IsMarked(BarrieredPtrScript *scriptp)
+IsMarked(BarrieredBase<JSScript*> *scriptp)
 {
     return IsScriptMarked(scriptp);
 }
 
 inline bool
-IsAboutToBeFinalized(BarrieredValue *v)
+IsAboutToBeFinalized(BarrieredBase<Value> *v)
 {
     if (!v->isMarkable())
         return false;
     return IsValueAboutToBeFinalized(v->unsafeGet());
 }
 
 inline bool
-IsAboutToBeFinalized(BarrieredPtrObject *objp)
+IsAboutToBeFinalized(BarrieredBase<JSObject*> *objp)
 {
     return IsObjectAboutToBeFinalized(objp);
 }
 
 inline bool
-IsAboutToBeFinalized(BarrieredPtrScript *scriptp)
+IsAboutToBeFinalized(BarrieredBase<JSScript*> *scriptp)
 {
     return IsScriptAboutToBeFinalized(scriptp);
 }
 
 #ifdef JS_ION
 /* Nonsense to get WeakCache to work with new Marking semantics. */
 
 inline bool