Bug 972712 (part 5) - Add BaseShape::clasp(). r=till.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 26 Feb 2014 18:34:02 -0800
changeset 171479 753376a55f0fc5380970da5245795a24dfea5636
parent 171478 655050f4a7467edcea8894b51f3734970d832876
child 171480 519787a56627716989a4cfb294ba1b2607199efa
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerstill
bugs972712
milestone30.0a1
Bug 972712 (part 5) - Add BaseShape::clasp(). r=till.
js/src/jsfriendapi.h
js/src/vm/Shape.cpp
js/src/vm/Shape.h
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -546,17 +546,17 @@ GetAnyCompartmentInZone(JS::Zone *zone);
 namespace shadow {
 
 struct TypeObject {
     const Class *clasp;
     JSObject    *proto;
 };
 
 struct BaseShape {
-    const js::Class *clasp;
+    const js::Class *clasp_;
     JSObject *parent;
     JSObject *_1;
     JSCompartment *compartment;
 };
 
 class Shape {
 public:
     shadow::BaseShape *base;
--- a/js/src/vm/Shape.cpp
+++ b/js/src/vm/Shape.cpp
@@ -1433,17 +1433,17 @@ StackBaseShape::hash(const StackBaseShap
     hash = RotateLeft(hash, 4) ^ uintptr_t(base->rawSetter);
     return hash;
 }
 
 /* static */ inline bool
 StackBaseShape::match(UnownedBaseShape *key, const StackBaseShape *lookup)
 {
     return key->flags == lookup->flags
-        && key->clasp == lookup->clasp
+        && key->clasp_ == lookup->clasp
         && key->parent == lookup->parent
         && key->metadata == lookup->metadata
         && key->rawGetter == lookup->rawGetter
         && key->rawSetter == lookup->rawSetter;
 }
 
 void
 StackBaseShape::trace(JSTracer *trc)
--- a/js/src/vm/Shape.h
+++ b/js/src/vm/Shape.h
@@ -576,17 +576,17 @@ class BaseShape : public gc::BarrieredCe
         NEW_TYPE_UNKNOWN    =  0x400,
         UNCACHEABLE_PROTO   =  0x800,
         HAD_ELEMENTS_ACCESS = 0x1000,
 
         OBJECT_FLAG_MASK    = 0x1ff8
     };
 
   private:
-    const Class         *clasp;         /* Class of referring object. */
+    const Class         *clasp_;        /* Class of referring object. */
     HeapPtrObject       parent;         /* Parent of referring object. */
     HeapPtrObject       metadata;       /* Optional holder of metadata about
                                          * the referring object. */
     JSCompartment       *compartment_;  /* Compartment shape belongs to. */
     uint32_t            flags;          /* Vector of above flags. */
     uint32_t            slotSpan_;      /* Object slot span for BaseShapes at
                                          * dictionary last properties. */
 
@@ -613,30 +613,30 @@ class BaseShape : public gc::BarrieredCe
   public:
     void finalize(FreeOp *fop);
 
     BaseShape(JSCompartment *comp, const Class *clasp, JSObject *parent, JSObject *metadata,
               uint32_t objectFlags)
     {
         JS_ASSERT(!(objectFlags & ~OBJECT_FLAG_MASK));
         mozilla::PodZero(this);
-        this->clasp = clasp;
+        this->clasp_ = clasp;
         this->parent = parent;
         this->metadata = metadata;
         this->flags = objectFlags;
         this->compartment_ = comp;
     }
 
     BaseShape(JSCompartment *comp, const Class *clasp, JSObject *parent, JSObject *metadata,
               uint32_t objectFlags, uint8_t attrs,
               PropertyOp rawGetter, StrictPropertyOp rawSetter)
     {
         JS_ASSERT(!(objectFlags & ~OBJECT_FLAG_MASK));
         mozilla::PodZero(this);
-        this->clasp = clasp;
+        this->clasp_ = clasp;
         this->parent = parent;
         this->metadata = metadata;
         this->flags = objectFlags;
         this->rawGetter = rawGetter;
         this->rawSetter = rawSetter;
         if ((attrs & JSPROP_GETTER) && rawGetter) {
             this->flags |= HAS_GETTER_OBJECT;
             GetterSetterWriteBarrierPost(runtimeFromMainThread(), &this->getterObj);
@@ -649,17 +649,17 @@ class BaseShape : public gc::BarrieredCe
     }
 
     inline BaseShape(const StackBaseShape &base);
 
     /* Not defined: BaseShapes must not be stack allocated. */
     ~BaseShape();
 
     BaseShape &operator=(const BaseShape &other) {
-        clasp = other.clasp;
+        clasp_ = other.clasp_;
         parent = other.parent;
         metadata = other.metadata;
         flags = other.flags;
         slotSpan_ = other.slotSpan_;
         if (flags & HAS_GETTER_OBJECT) {
             getterObj = other.getterObj;
             GetterSetterWriteBarrierPost(runtimeFromMainThread(), &getterObj);
         } else {
@@ -674,16 +674,18 @@ class BaseShape : public gc::BarrieredCe
             if (rawSetter)
                 GetterSetterWriteBarrierPostRemove(runtimeFromMainThread(), &setterObj);
             rawSetter = other.rawSetter;
         }
         compartment_ = other.compartment_;
         return *this;
     }
 
+    const Class *clasp() const { return clasp_; }
+
     bool isOwned() const { return !!(flags & OWNED_SHAPE); }
 
     bool matchesGetterSetter(PropertyOp rawGetter, StrictPropertyOp rawSetter) const {
         return rawGetter == this->rawGetter && rawSetter == this->rawSetter;
     }
 
     inline void adoptUnowned(UnownedBaseShape *other);
 
@@ -755,17 +757,17 @@ class BaseShape : public gc::BarrieredCe
             gc::MarkObject(trc, &parent, "parent");
 
         if (metadata)
             gc::MarkObject(trc, &metadata, "metadata");
     }
 
   private:
     static void staticAsserts() {
-        JS_STATIC_ASSERT(offsetof(BaseShape, clasp) == offsetof(js::shadow::BaseShape, clasp));
+        JS_STATIC_ASSERT(offsetof(BaseShape, clasp_) == offsetof(js::shadow::BaseShape, clasp_));
     }
 };
 
 class UnownedBaseShape : public BaseShape {};
 
 inline void
 BaseShape::adoptUnowned(UnownedBaseShape *other)
 {
@@ -812,17 +814,17 @@ struct StackBaseShape
     JSObject *parent;
     JSObject *metadata;
     PropertyOp rawGetter;
     StrictPropertyOp rawSetter;
     JSCompartment *compartment;
 
     explicit StackBaseShape(BaseShape *base)
       : flags(base->flags & BaseShape::OBJECT_FLAG_MASK),
-        clasp(base->clasp),
+        clasp(base->clasp_),
         parent(base->parent),
         metadata(base->metadata),
         rawGetter(nullptr),
         rawSetter(nullptr),
         compartment(base->compartment())
     {}
 
     inline StackBaseShape(ThreadSafeContext *cx, const Class *clasp,
@@ -851,17 +853,17 @@ struct StackBaseShape
     static inline js::ThingRootKind rootKind() { return js::THING_ROOT_CUSTOM; }
     void trace(JSTracer *trc);
 };
 
 inline
 BaseShape::BaseShape(const StackBaseShape &base)
 {
     mozilla::PodZero(this);
-    this->clasp = base.clasp;
+    this->clasp_ = base.clasp;
     this->parent = base.parent;
     this->metadata = base.metadata;
     this->flags = base.flags;
     this->rawGetter = base.rawGetter;
     this->rawSetter = base.rawSetter;
     if ((base.flags & HAS_GETTER_OBJECT) && base.rawGetter)
         GetterSetterWriteBarrierPost(runtimeFromMainThread(), &this->getterObj);
     if ((base.flags & HAS_SETTER_OBJECT) && base.rawSetter)
@@ -1025,17 +1027,17 @@ class Shape : public gc::BarrieredCell<S
 
         void popFront() {
             JS_ASSERT(!empty());
             cursor = cursor->parent;
         }
     };
 
     const Class *getObjectClass() const {
-        return base()->clasp;
+        return base()->clasp_;
     }
     JSObject *getObjectParent() const { return base()->parent; }
     JSObject *getObjectMetadata() const { return base()->metadata; }
 
     static Shape *setObjectParent(ExclusiveContext *cx,
                                   JSObject *obj, TaggedProto proto, Shape *last);
     static Shape *setObjectMetadata(JSContext *cx,
                                     JSObject *metadata, TaggedProto proto, Shape *last);
@@ -1476,17 +1478,17 @@ struct StackShape
 
     bool hasSlot() const { return (attrs & JSPROP_SHARED) == 0; }
     bool hasMissingSlot() const { return maybeSlot() == SHAPE_INVALID_SLOT; }
 
     uint32_t slot() const { JS_ASSERT(hasSlot() && !hasMissingSlot()); return slot_; }
     uint32_t maybeSlot() const { return slot_; }
 
     uint32_t slotSpan() const {
-        uint32_t free = JSSLOT_FREE(base->clasp);
+        uint32_t free = JSSLOT_FREE(base->clasp_);
         return hasMissingSlot() ? free : (maybeSlot() + 1);
     }
 
     void setSlot(uint32_t slot) {
         JS_ASSERT(slot <= SHAPE_INVALID_SLOT);
         slot_ = slot;
     }