Bug 836524 - Zone renaming part 1 (r=terrence)
authorBill McCloskey <wmccloskey@mozilla.com>
Wed, 06 Feb 2013 18:08:10 -0800
changeset 130993 4fec5623f2918acad99422bc53fd017352760a34
parent 130992 4b47185f48f8ab06d1abaff5ecde31cc209dade1
child 130994 8794e665403743ef1b1dc2bb106b03b62b5816ad
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs836524
milestone21.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 836524 - Zone renaming part 1 (r=terrence)
js/src/gc/Marking.cpp
js/src/jscompartment.cpp
js/src/jsfriendapi.cpp
js/src/vm/ObjectImpl-inl.h
js/src/vm/String.cpp
--- a/js/src/gc/Marking.cpp
+++ b/js/src/gc/Marking.cpp
@@ -124,21 +124,21 @@ CheckMarkedThing(JSTracer *trc, T *thing
 #endif
 
     JS_ASSERT_IF(thing->zone()->requireGCTracer(), IS_GC_MARKING_TRACER(trc));
 
     JS_ASSERT(thing->isAligned());
 
     JS_ASSERT_IF(rt->gcStrictCompartmentChecking,
                  thing->zone()->isCollecting() ||
-                 thing->compartment() == rt->atomsCompartment);
+                 thing->zone() == rt->atomsCompartment->zone());
 
     JS_ASSERT_IF(IS_GC_MARKING_TRACER(trc) && ((GCMarker *)trc)->getMarkColor() == GRAY,
                  thing->zone()->isGCMarkingGray() ||
-                 thing->compartment() == rt->atomsCompartment);
+                 thing->zone() == rt->atomsCompartment->zone());
 
     /*
      * Try to assert that the thing is allocated.  This is complicated by the
      * fact that allocated things may still contain the poison pattern if that
      * part has not been overwritten, and that the free span list head in the
      * ArenaHeader may not be synced with the real one in ArenaLists.
      */
     JS_ASSERT_IF(IsThingPoisoned(thing) && rt->isHeapBusy(),
@@ -711,17 +711,17 @@ gc::IsCellAboutToBeFinalized(Cell **thin
 
 /*** Push Mark Stack ***/
 
 #define JS_COMPARTMENT_ASSERT(rt, thing)                                \
     JS_ASSERT((thing)->zone()->isGCMarking())
 
 #define JS_COMPARTMENT_ASSERT_STR(rt, thing)                            \
     JS_ASSERT((thing)->zone()->isGCMarking() ||                         \
-              (thing)->compartment() == (rt)->atomsCompartment);
+              (thing)->zone() == (rt)->atomsCompartment->zone());
 
 static void
 PushMarkStack(GCMarker *gcmarker, JSObject *thing)
 {
     JS_COMPARTMENT_ASSERT(gcmarker->runtime, thing);
 
     if (thing->markIfUnmarked(gcmarker->getMarkColor()))
         gcmarker->pushObject(thing);
@@ -1325,18 +1325,18 @@ GCMarker::processMarkStackTop(SliceBudge
 
   scan_value_array:
     JS_ASSERT(vp <= end);
     while (vp != end) {
         const Value &v = *vp++;
         if (v.isString()) {
             JSString *str = v.toString();
             JS_COMPARTMENT_ASSERT_STR(runtime, str);
-            JS_ASSERT(str->compartment() == runtime->atomsCompartment ||
-                      str->compartment() == obj->compartment());
+            JS_ASSERT(str->zone() == runtime->atomsCompartment->zone() ||
+                      str->zone() == obj->zone());
             if (str->markIfUnmarked())
                 ScanString(this, str);
         } else if (v.isObject()) {
             JSObject *obj2 = &v.toObject();
             JS_COMPARTMENT_ASSERT(runtime, obj2);
             JS_ASSERT(obj->compartment() == obj2->compartment());
             if (obj2->markIfUnmarked(getMarkColor())) {
                 pushValueArray(obj, vp, end);
@@ -1609,12 +1609,12 @@ JS::UnmarkGrayGCThingRecursively(void *t
 {
     JS_ASSERT(kind != JSTRACE_SHAPE);
 
     if (!GCThingIsMarkedGray(thing))
         return;
 
     UnmarkGrayGCThing(thing);
 
-    JSRuntime *rt = static_cast<Cell *>(thing)->compartment()->rt;
+    JSRuntime *rt = static_cast<Cell *>(thing)->zone()->rt;
     UnmarkGrayTracer trc(rt);
     JS_TraceChildren(&trc, thing, kind);
 }
--- a/js/src/jscompartment.cpp
+++ b/js/src/jscompartment.cpp
@@ -265,22 +265,22 @@ JSCompartment::wrap(JSContext *cx, Value
     /* Only GC things have to be wrapped or copied. */
     if (!vp->isMarkable())
         return true;
 
     if (vp->isString()) {
         JSString *str = vp->toString();
 
         /* If the string is already in this compartment, we are done. */
-        if (str->compartment() == this)
+        if (str->zone() == zone())
             return true;
 
         /* If the string is an atom, we don't have to copy. */
         if (str->isAtom()) {
-            JS_ASSERT(str->compartment() == cx->runtime->atomsCompartment);
+            JS_ASSERT(str->zone() == cx->runtime->atomsCompartment->zone());
             return true;
         }
     }
 
     /*
      * Wrappers should really be parented to the wrapped parent of the wrapped
      * object, but in that case a wrapped global object would have a NULL
      * parent without being a proper global object (JSCLASS_IS_GLOBAL). Instead,
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -870,21 +870,21 @@ JS::IncrementalObjectBarrier(JSObject *o
 
 JS_FRIEND_API(void)
 JS::IncrementalReferenceBarrier(void *ptr, JSGCTraceKind kind)
 {
     if (!ptr)
         return;
 
     gc::Cell *cell = static_cast<gc::Cell *>(ptr);
-    JSCompartment *comp = cell->compartment();
+    Zone *zone = cell->zone();
 
-    JS_ASSERT(!comp->rt->isHeapBusy());
+    JS_ASSERT(!zone->rt->isHeapBusy());
 
-    AutoMarkInDeadCompartment amn(comp);
+    AutoMarkInDeadCompartment amn(zone);
 
     if (kind == JSTRACE_OBJECT)
         JSObject::writeBarrierPre(static_cast<JSObject*>(cell));
     else if (kind == JSTRACE_STRING)
         JSString::writeBarrierPre(static_cast<JSString*>(cell));
     else if (kind == JSTRACE_SCRIPT)
         JSScript::writeBarrierPre(static_cast<JSScript*>(cell));
     else if (kind == JSTRACE_SHAPE)
--- a/js/src/vm/ObjectImpl-inl.h
+++ b/js/src/vm/ObjectImpl-inl.h
@@ -186,55 +186,47 @@ js::ObjectImpl::nativeGetSlotRef(uint32_
 inline const js::Value &
 js::ObjectImpl::nativeGetSlot(uint32_t slot) const
 {
     MOZ_ASSERT(isNative());
     MOZ_ASSERT(slot < slotSpan());
     return getSlot(slot);
 }
 
-static JS_ALWAYS_INLINE JSCompartment *
-ValueCompartment(const js::Value &value)
-{
-    JS_ASSERT(value.isMarkable());
-    return static_cast<js::gc::Cell *>(value.toGCThing())->compartment();
-}
-
 #ifdef DEBUG
 inline bool
-IsValueInCompartment(js::Value v, JSCompartment *comp)
+IsObjectValueInCompartment(js::Value v, JSCompartment *comp)
 {
-    if (!v.isMarkable())
+    if (!v.isObject())
         return true;
-    JSCompartment *vcomp = ValueCompartment(v);
-    return vcomp == comp->rt->atomsCompartment || vcomp == comp;
+    return v.toObject().compartment() == comp;
 }
 #endif
 
 inline void
 js::ObjectImpl::setSlot(uint32_t slot, const js::Value &value)
 {
     MOZ_ASSERT(slotInRange(slot));
-    MOZ_ASSERT(IsValueInCompartment(value, compartment()));
+    MOZ_ASSERT(IsObjectValueInCompartment(value, compartment()));
     getSlotRef(slot).set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
 }
 
 inline void
 js::ObjectImpl::setCrossCompartmentSlot(uint32_t slot, const js::Value &value)
 {
     MOZ_ASSERT(slotInRange(slot));
     getSlotRef(slot).set(this->asObjectPtr(), HeapSlot::Slot, slot, value);
 }
 
 inline void
 js::ObjectImpl::initSlot(uint32_t slot, const js::Value &value)
 {
     MOZ_ASSERT(getSlot(slot).isUndefined());
     MOZ_ASSERT(slotInRange(slot));
-    MOZ_ASSERT(IsValueInCompartment(value, compartment()));
+    MOZ_ASSERT(IsObjectValueInCompartment(value, asObjectPtr()->compartment()));
     initSlotUnchecked(slot, value);
 }
 
 inline void
 js::ObjectImpl::initCrossCompartmentSlot(uint32_t slot, const js::Value &value)
 {
     MOZ_ASSERT(getSlot(slot).isUndefined());
     MOZ_ASSERT(slotInRange(slot));
--- a/js/src/vm/String.cpp
+++ b/js/src/vm/String.cpp
@@ -297,18 +297,18 @@ JSRope::flatten(JSContext *maybecx)
 }
 
 template <AllowGC allowGC>
 JSString *
 js::ConcatStrings(JSContext *cx,
                   typename MaybeRooted<JSString*, allowGC>::HandleType left,
                   typename MaybeRooted<JSString*, allowGC>::HandleType right)
 {
-    JS_ASSERT_IF(!left->isAtom(), left->compartment() == cx->compartment);
-    JS_ASSERT_IF(!right->isAtom(), right->compartment() == cx->compartment);
+    JS_ASSERT_IF(!left->isAtom(), left->zone() == cx->zone());
+    JS_ASSERT_IF(!right->isAtom(), right->zone() == cx->zone());
 
     size_t leftLen = left->length();
     if (leftLen == 0)
         return right;
 
     size_t rightLen = right->length();
     if (rightLen == 0)
         return left;