Bug 692277 - Part b: Remove js/src from xpconnect LOCAL_INCLUDES; r=luke
authorMs2ger <ms2ger@gmail.com>
Sat, 24 Dec 2011 09:27:51 +0100
changeset 84511 f4d8adba8d7494ff58e16b66c27512a87b44e210
parent 84510 53c2fc22835b43d2fe60a5fce7e2e9cec97ecc1d
child 84512 b14872f6fd555084a106c7aadb570bf5cd19d55a
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs692277
milestone12.0a1
Bug 692277 - Part b: Remove js/src from xpconnect LOCAL_INCLUDES; r=luke
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/jsgc.h
js/src/jsobj.h
js/xpconnect/src/Makefile.in
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/dombindings.cpp
js/xpconnect/src/dombindings.h
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/src/xpcpublic.h
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -180,16 +180,22 @@ AutoSwitchCompartment::AutoSwitchCompart
 
 AutoSwitchCompartment::~AutoSwitchCompartment()
 {
     /* The old compartment may have been destroyed, so we can't use cx->setCompartment. */
     cx->compartment = oldCompartment;
 }
 
 JS_FRIEND_API(bool)
+js::IsSystemCompartment(const JSCompartment *c)
+{
+    return c->isSystemCompartment;
+}
+
+JS_FRIEND_API(bool)
 js::IsScopeObject(const JSObject *obj)
 {
     return obj->isInternalScope();
 }
 
 JS_FRIEND_API(JSObject *)
 js::GetObjectParentMaybeScope(const JSObject *obj)
 {
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -185,16 +185,19 @@ class JS_FRIEND_API(AutoSwitchCompartmen
     JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 #ifdef OLD_GETTER_SETTER_METHODS
 JS_FRIEND_API(JSBool) obj_defineGetter(JSContext *cx, uintN argc, js::Value *vp);
 JS_FRIEND_API(JSBool) obj_defineSetter(JSContext *cx, uintN argc, js::Value *vp);
 #endif
 
+extern JS_FRIEND_API(bool)
+IsSystemCompartment(const JSCompartment *compartment);
+
 /*
  * Check whether it is OK to assign an undeclared property with name
  * propname of the global object in the current script on cx.  Reports
  * an error if one needs to be reported (in particular in all cases
  * when it returns false).
  */
 extern JS_FRIEND_API(bool)
 CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname);
@@ -433,11 +436,20 @@ GetPCCountScriptCount(JSContext *cx);
 
 JS_FRIEND_API(JSString *)
 GetPCCountScriptSummary(JSContext *cx, size_t script);
 
 JS_FRIEND_API(JSString *)
 GetPCCountScriptContents(JSContext *cx, size_t script);
 
 } /* namespace js */
+
+/*
+ * If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
+ * JSProto_Null, clasp must non-null.
+ */
+extern JS_FRIEND_API(JSBool)
+js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
+                     JSObject **protop, js::Class *clasp = NULL);
+
 #endif
 
 #endif /* jsfriendapi_h___ */
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -1225,16 +1225,22 @@ struct ArenaLists {
  * chunks with total capacity of 16MB to avoid buffer resizes during browser
  * startup.
  */
 const size_t INITIAL_CHUNK_CAPACITY = 16 * 1024 * 1024 / ChunkSize;
 
 /* The number of GC cycles an empty chunk can survive before been released. */
 const size_t MAX_EMPTY_CHUNK_AGE = 4;
 
+inline Cell *
+AsCell(JSObject *obj)
+{
+    return reinterpret_cast<Cell *>(obj);
+}
+
 } /* namespace gc */
 
 struct GCPtrHasher
 {
     typedef void *Lookup;
 
     static HashNumber hash(void *key) {
         return HashNumber(uintptr_t(key) >> JS_GCTHING_ZEROBITS);
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1897,24 +1897,16 @@ CheckAccess(JSContext *cx, JSObject *obj
             js::Value *vp, uintN *attrsp);
 
 } /* namespace js */
 
 extern bool
 js_IsDelegate(JSContext *cx, JSObject *obj, const js::Value &v);
 
 /*
- * If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
- * JSProto_Null, clasp must non-null.
- */
-extern JS_FRIEND_API(JSBool)
-js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
-                     JSObject **protop, js::Class *clasp = NULL);
-
-/*
  * Wrap boolean, number or string as Boolean, Number or String object.
  * *vp must not be an object, null or undefined.
  */
 extern JSBool
 js_PrimitiveToObject(JSContext *cx, js::Value *vp);
 
 /*
  * v and vp may alias. On successful return, vp->isObjectOrNull(). If vp is not
--- a/js/xpconnect/src/Makefile.in
+++ b/js/xpconnect/src/Makefile.in
@@ -89,17 +89,16 @@ CPPSRCS		= \
 		DictionaryHelpers.cpp \
 		$(NULL)
 
 include $(topsrcdir)/config/config.mk
 
 LOCAL_INCLUDES = \
 		-I$(srcdir)/../wrappers \
 		-I$(srcdir)/../loader \
-		-I$(topsrcdir)/js/src \
 		-I$(topsrcdir)/caps/include \
 		-I$(topsrcdir)/content/base/src \
 		-I$(topsrcdir)/content/html/content/src \
 		-I$(topsrcdir)/content/html/document/src \
 		-I$(topsrcdir)/content/svg/content/src \
 		-I$(topsrcdir)/layout/style \
 		-I$(topsrcdir)/layout/base \
 		-I$(topsrcdir)/dom/base \
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -43,17 +43,16 @@
 
 #include "mozilla/Util.h"
 
 #include "xpcprivate.h"
 #include "xpcpublic.h"
 #include "WrapperFactory.h"
 #include "dom_quickstubs.h"
 
-#include "jscompartment.h"
 #include "nsIMemoryReporter.h"
 #include "nsPrintfCString.h"
 #include "mozilla/FunctionTimer.h"
 #include "prsystem.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Telemetry.h"
 
 #include "nsContentUtils.h"
@@ -506,17 +505,17 @@ XPCJSRuntime::SuspectWrappedNative(JSCon
         return;
 
     NS_ASSERTION(NS_IsMainThread() || NS_IsCycleCollectorThread(),
                  "Suspecting wrapped natives from non-CC thread");
 
     // Only suspect wrappedJSObjects that are in a compartment that
     // participates in cycle collection.
     JSObject* obj = wrapper->GetFlatJSObjectPreserveColor();
-    if (!xpc::ParticipatesInCycleCollection(cx, obj))
+    if (!xpc::ParticipatesInCycleCollection(cx, js::gc::AsCell(obj)))
         return;
 
     // Only record objects that might be part of a cycle as roots, unless
     // the callback wants all traces (a debug feature).
     if (xpc_IsGrayGCThing(obj) || cb.WantAllTraces())
         cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT, obj,
                     nsXPConnect::GetXPConnect());
 }
@@ -583,17 +582,17 @@ XPCJSRuntime::AddXPConnectRoots(JSContex
         cb.NoteXPCOMRoot(static_cast<XPCTraceableVariant*>(e));
 
     for (XPCRootSetElem *e = mWrappedJSRoots; e ; e = e->GetNextRoot()) {
         nsXPCWrappedJS *wrappedJS = static_cast<nsXPCWrappedJS*>(e);
         JSObject *obj = wrappedJS->GetJSObjectPreserveColor();
 
         // Only suspect wrappedJSObjects that are in a compartment that
         // participates in cycle collection.
-        if (!xpc::ParticipatesInCycleCollection(cx, obj))
+        if (!xpc::ParticipatesInCycleCollection(cx, js::gc::AsCell(obj)))
             continue;
 
         cb.NoteXPCOMRoot(static_cast<nsIXPConnectWrappedJS *>(wrappedJS));
     }
 
     Closure closure = { cx, true, &cb };
     if (mJSHolders.ops) {
         JS_DHashTableEnumerate(&mJSHolders, NoteJSHolder, &closure);
@@ -1502,28 +1501,30 @@ namespace xpconnect {
 namespace memory {
 
 CompartmentStats::CompartmentStats(JSContext *cx, JSCompartment *c)
 {
     memset(this, 0, sizeof(*this));
 
     if (c == cx->runtime->atomsCompartment) {
         name.AssignLiteral("atoms");
-    } else if (c->principals) {
-        if (c->principals->codebase) {
-            name.Assign(c->principals->codebase);
+    } else if (JSPrincipals *principals = JS_GetCompartmentPrincipals(c)) {
+        if (principals->codebase) {
+            name.Assign(principals->codebase);
 
             // If it's the system compartment, append the address.
             // This means that multiple system compartments (and there
             // can be many) can be distinguished.
-            if (c->isSystemCompartment) {
-                if (c->data &&
-                    !((xpc::CompartmentPrivate*)c->data)->location.IsEmpty()) {
+            if (js::IsSystemCompartment(c)) {
+                xpc::CompartmentPrivate *compartmentPrivate =
+                        static_cast<xpc::CompartmentPrivate*>(JS_GetCompartmentPrivate(cx, c));
+                if (compartmentPrivate &&
+                    !compartmentPrivate->location.IsEmpty()) {
                     name.AppendLiteral(", ");
-                    name.Append(((xpc::CompartmentPrivate*)c->data)->location);
+                    name.Append(compartmentPrivate->location);
                 }
 
                 // ample; 64-bit address max is 18 chars
                 static const int maxLength = 31;
                 nsPrintfCString address(maxLength, ", 0x%llx", PRUint64(c));
                 name.Append(address);
             }
 
@@ -2142,22 +2143,22 @@ AccumulateTelemetryCallback(int id, uint
         break;
     }
 }
 
 bool XPCJSRuntime::gNewDOMBindingsEnabled;
 
 bool PreserveWrapper(JSContext *cx, JSObject *obj)
 {
-    JS_ASSERT(obj->getClass()->ext.isWrappedNative);
+    JS_ASSERT(IS_WRAPPER_CLASS(js::GetObjectClass(obj)));
     nsISupports *native = nsXPConnect::GetXPConnect()->GetNativeOfWrapper(cx, obj);
     if (!native)
         return false;
     nsresult rv;
-    nsCOMPtr<nsINode> node = nsQueryInterfaceWithError(native, &rv);
+    nsCOMPtr<nsINode> node = do_QueryInterface(native, &rv);
     if (NS_FAILED(rv))
         return false;
     nsContentUtils::PreserveWrapper(native, node);
     return true;
 }
 
 XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
  : mXPConnect(aXPConnect),
--- a/js/xpconnect/src/dombindings.cpp
+++ b/js/xpconnect/src/dombindings.cpp
@@ -42,20 +42,24 @@
 #include "dombindings.h"
 #include "xpcpublic.h"
 #include "xpcprivate.h"
 #include "XPCQuickStubs.h"
 #include "XPCWrapper.h"
 #include "WrapperFactory.h"
 #include "nsDOMClassInfo.h"
 #include "nsGlobalWindow.h"
-#include "jsiter.h"
 #include "nsWrapperCacheInlines.h"
 
-using namespace js;
+#include "jsapi.h"
+
+#include "jscntxt.h" // js::AutoIdVector
+
+using namespace JS;
+using js::AutoIdVector;
 
 namespace mozilla {
 namespace dom {
 namespace binding {
 
 
 static jsid s_constructor_id = JSID_VOID;
 static jsid s_prototype_id = JSID_VOID;
@@ -347,17 +351,17 @@ ListBase<LC>::namedItem(JSContext *cx, J
                                xpc_qsDOMString::eDefaultUndefinedBehavior);
     if (!nameString.IsValid())
         return false;
     *hasResult = getNamedItem(getListObject(obj), nameString, result);
     return true;
 }
 
 JSBool
-interface_hasInstance(JSContext *cx, JSObject *obj, const js::Value *vp, JSBool *bp)
+interface_hasInstance(JSContext *cx, JSObject *obj, const JS::Value *vp, JSBool *bp)
 {
     if (vp->isObject()) {
         jsval prototype;
         if (!JS_GetPropertyById(cx, obj, s_prototype_id, &prototype) ||
             JSVAL_IS_PRIMITIVE(prototype)) {
             JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL,
                                          JSMSG_THROW_TYPE_ERROR);
             return false;
@@ -546,30 +550,30 @@ GetArrayIndexFromId(JSContext *cx, jsid 
 
         jsuint i;
         return js::StringIsArrayIndex(JSID_TO_ATOM(id), &i) ? i : -1;
     }
     return IdToInt32(cx, id);
 }
 
 static void
-FillPropertyDescriptor(PropertyDescriptor *desc, JSObject *obj, jsval v, bool readonly)
+FillPropertyDescriptor(JSPropertyDescriptor *desc, JSObject *obj, jsval v, bool readonly)
 {
     desc->obj = obj;
     desc->value = v;
     desc->attrs = (readonly ? JSPROP_READONLY : 0) | JSPROP_ENUMERATE;
     desc->getter = NULL;
     desc->setter = NULL;
     desc->shortid = 0;
 }
 
 template<class LC>
 bool
 ListBase<LC>::getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                       PropertyDescriptor *desc)
+                                       JSPropertyDescriptor *desc)
 {
     if (set) {
         if (hasIndexSetter) {
             int32_t index = GetArrayIndexFromId(cx, id);
             if (index >= 0) {
                 FillPropertyDescriptor(desc, proxy, JSVAL_VOID, false);
                 return true;
             }
@@ -625,17 +629,17 @@ ListBase<LC>::getOwnPropertyDescriptor(J
 
     desc->obj = NULL;
     return true;
 }
 
 template<class LC>
 bool
 ListBase<LC>::getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                    PropertyDescriptor *desc)
+                                    JSPropertyDescriptor *desc)
 {
     if (!getOwnPropertyDescriptor(cx, proxy, id, set, desc))
         return false;
     if (desc->obj)
         return true;
     if (xpc::WrapperFactory::IsXrayWrapper(proxy))
         return resolveNativeName(cx, proxy, id, desc);
     JSObject *proto = js::GetObjectProto(proxy);
@@ -679,17 +683,17 @@ ListBase<LC>::ensureExpandoObject(JSCont
         js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));
         JS_SetPrivate(cx, expando, js::GetProxyPrivate(obj).toPrivate());
     }
     return expando;
 }
 
 template<class LC>
 bool
-ListBase<LC>::defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc)
+ListBase<LC>::defineProperty(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
 {
     if (hasIndexSetter) {
         int32_t index = GetArrayIndexFromId(cx, id);
         if (index >= 0) {
             nsCOMPtr<nsISupports> ref;
             IndexSetterType value;
             jsval v;
             return Unwrap(cx, desc->value, &value, getter_AddRefs(ref), &v) &&
@@ -869,17 +873,17 @@ ListBase<LC>::shouldCacheProtoShape(JSCo
         return true;
     }
 
     return Base::shouldCacheProtoShape(cx, protoProto, shouldCache);
 }
 
 template<class LC>
 bool
-ListBase<LC>::resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc)
+ListBase<LC>::resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
 {
     JS_ASSERT(xpc::WrapperFactory::IsXrayWrapper(proxy));
 
     for (size_t n = 0; n < ArrayLength(sProtoProperties); ++n) {
         if (id == sProtoProperties[n].id) {
             desc->attrs = JSPROP_ENUMERATE | JSPROP_SHARED;
             if (!sProtoProperties[n].setter)
                 desc->attrs |= JSPROP_READONLY;
@@ -946,17 +950,17 @@ ListBase<LC>::nativeGet(JSContext *cx, J
     }
 
     return Base::nativeGet(cx, proxy, protoProto, id, found, vp);
 }
 
 template<class LC>
 bool
 ListBase<LC>::getPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id, bool *found,
-                                     js::Value *vp)
+                                     JS::Value *vp)
 {
     JSObject *proto = js::GetObjectProto(proxy);
     if (!proto)
         return true;
 
     bool hit;
     if (getProtoShape(proxy) != js::GetObjectShape(proto)) {
         if (!shouldCacheProtoShape(cx, proto, &hit))
--- a/js/xpconnect/src/dombindings.h
+++ b/js/xpconnect/src/dombindings.h
@@ -127,22 +127,22 @@ public:
 class NoBase {
 public:
     static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope);
     static bool shouldCacheProtoShape(JSContext *cx, JSObject *proto, bool *shouldCache)
     {
         *shouldCache = true;
         return true;
     }
-    static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, js::PropertyDescriptor *desc)
+    static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
     {
         return true;
     }
     static bool nativeGet(JSContext *cx, JSObject *proxy, JSObject *proto, jsid id, bool *found,
-                          js::Value *vp)
+                          JS::Value *vp)
     {
         *found = false;
         return true;
     }
 };
 
 template<class ListType, class IndexOps, class NameOps=NoOps>
 class ListClass : public DerivedListClass<ListType, NoBase, IndexOps, NameOps> {
@@ -198,48 +198,48 @@ private:
     static inline bool namedItem(JSContext *cx, JSObject *obj, jsval *name, NameGetterType &result,
                                  bool *hasResult);
 
     static inline bool getNamedItem(ListType *list, const nsAString& aName, NameGetterType &item);
     static inline bool setNamedItem(JSContext *cx, ListType *list, const nsAString& aName,
                                     NameSetterType item);
 
     static bool getPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id, bool *found,
-                                       js::Value *vp);
+                                       JS::Value *vp);
     static bool hasPropertyOnPrototype(JSContext *cx, JSObject *proxy, jsid id);
 
 public:
     static JSObject *create(JSContext *cx, XPCWrappedNativeScope *scope, ListType *list,
                             nsWrapperCache* cache, bool *triedToWrap);
 
     static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, bool *enabled);
 
     bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                               js::PropertyDescriptor *desc);
+                               JSPropertyDescriptor *desc);
     bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
-                                  js::PropertyDescriptor *desc);
+                                  JSPropertyDescriptor *desc);
     bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
-                        js::PropertyDescriptor *desc);
+                        JSPropertyDescriptor *desc);
     bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
     bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
     bool enumerate(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
-    bool fix(JSContext *cx, JSObject *proxy, js::Value *vp);
+    bool fix(JSContext *cx, JSObject *proxy, JS::Value *vp);
 
     bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
     bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
-    bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, js::Value *vp);
+    bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, JS::Value *vp);
     bool getElementIfPresent(JSContext *cx, JSObject *proxy, JSObject *receiver,
-                             uint32 index, js::Value *vp, bool *present);
+                             uint32 index, JS::Value *vp, bool *present);
     bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
-             js::Value *vp);
+             JS::Value *vp);
     bool keys(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
-    bool iterate(JSContext *cx, JSObject *proxy, uintN flags, js::Value *vp);
+    bool iterate(JSContext *cx, JSObject *proxy, uintN flags, JS::Value *vp);
 
     /* Spidermonkey extensions. */
-    bool hasInstance(JSContext *cx, JSObject *proxy, const js::Value *vp, bool *bp);
+    bool hasInstance(JSContext *cx, JSObject *proxy, const JS::Value *vp, bool *bp);
     JSString *obj_toString(JSContext *cx, JSObject *proxy);
     void finalize(JSContext *cx, JSObject *proxy);
 
     static bool proxyHandlerIsList(js::ProxyHandler *handler) {
         return handler == &instance;
     }
     static bool objIsList(JSObject *obj) {
         return js::IsProxy(obj) && proxyHandlerIsList(js::GetProxyHandler(obj));
@@ -249,19 +249,19 @@ public:
     {
         return js::GetObjectClass(prototype) == &sInterfaceClass;
     }
     static ListType *getListObject(JSObject *obj);
 
     static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope);
     static bool shouldCacheProtoShape(JSContext *cx, JSObject *proto, bool *shouldCache);
     static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id,
-                                  js::PropertyDescriptor *desc);
+                                  JSPropertyDescriptor *desc);
     static bool nativeGet(JSContext *cx, JSObject *proxy, JSObject *proto, jsid id, bool *found,
-                          js::Value *vp);
+                          JS::Value *vp);
     static ListType *getNative(JSObject *proxy);
 };
 
 struct nsISupportsResult
 {
     nsISupportsResult()
     {
     }
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -42,21 +42,18 @@
 
 /* High level class and public functions implementation. */
 
 #include "xpcprivate.h"
 #include "XPCWrapper.h"
 #include "nsBaseHashtable.h"
 #include "nsHashKeys.h"
 #include "jsatom.h"
-#include "jsobj.h"
 #include "jsfriendapi.h"
-#include "jsfun.h"
 #include "jsgc.h"
-#include "jsscript.h"
 #include "nsThreadUtilsInternal.h"
 #include "dom_quickstubs.h"
 #include "nsNullPrincipal.h"
 #include "nsIURI.h"
 #include "nsJSEnvironment.h"
 #include "plbase64.h"
 
 #include "XrayWrapper.h"
@@ -733,17 +730,17 @@ UnmarkGrayChildren(JSTracer *trc, void *
 }
 
 void
 xpc_UnmarkGrayObjectRecursive(JSObject *obj)
 {
     NS_ASSERTION(obj, "Don't pass me null!");
 
     // Unmark.
-    obj->unmark(js::gc::GRAY);
+    js::gc::AsCell(obj)->unmark(js::gc::GRAY);
 
     // Tracing requires a JSContext...
     JSContext *cx;
     nsXPConnect* xpc = nsXPConnect::GetXPConnect();
     if (!xpc || NS_FAILED(xpc->GetSafeJSContext(&cx)) || !cx) {
         NS_ERROR("Failed to get safe JSContext!");
         return;
     }
@@ -914,19 +911,19 @@ nsXPConnect::Traverse(void *p, nsCycleCo
                 "BaseShape",
                 "TypeObject",
             };
             JS_STATIC_ASSERT(NS_ARRAY_LENGTH(trace_types) == JSTRACE_LAST + 1);
             JS_snprintf(name, sizeof(name), "JS %s", trace_types[traceKind]);
         }
 
         // Disable printing global for objects while we figure out ObjShrink fallout.
-        cb.DescribeGCedNode(isMarked, sizeof(JSObject), name);
+        cb.DescribeGCedNode(isMarked, sizeof(js::shadow::Object), name);
     } else {
-        cb.DescribeGCedNode(isMarked, sizeof(JSObject), "JS Object");
+        cb.DescribeGCedNode(isMarked, sizeof(js::shadow::Object), "JS Object");
     }
 
     // There's no need to trace objects that have already been marked by the JS
     // GC. Any JS objects hanging from them will already be marked. Only do this
     // if DEBUG_CC is not defined, else we do want to know about all JS objects
     // to get better graphs and explanations.
     if (!cb.WantAllTraces() && isMarked)
         return NS_OK;
@@ -1110,17 +1107,17 @@ CreateNewCompartment(JSContext *cx, JSCl
     JSObject *tempGlobal = JS_NewCompartmentAndGlobalObject(cx, clasp, principals);
     if (principals)
         JSPRINCIPALS_DROP(cx, principals);
 
     if (!tempGlobal)
         return false;
 
     *global = tempGlobal;
-    *compartment = tempGlobal->compartment();
+    *compartment = js::GetObjectCompartment(tempGlobal);
 
     js::AutoSwitchCompartment sc(cx, *compartment);
     JS_SetCompartmentPrivate(cx, *compartment, priv_holder.forget());
     return true;
 }
 
 #ifdef DEBUG
 struct VerifyTraceXPCGlobalCalledTracer
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1480,21 +1480,23 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JS
         nsnull, /* fix            */                                          \
         XPC_WN_JSOp_ThisObject,                                               \
         XPC_WN_JSOp_Clear                                                     \
     }
 
 // Maybe this macro should check for class->enumerate ==
 // XPC_WN_Shared_Proto_Enumerate or something rather than checking for
 // 4 classes?
-#define IS_PROTO_CLASS(clazz)                                                 \
-    ((clazz) == &XPC_WN_NoMods_WithCall_Proto_JSClass ||                      \
-     (clazz) == &XPC_WN_NoMods_NoCall_Proto_JSClass ||                        \
-     (clazz) == &XPC_WN_ModsAllowed_WithCall_Proto_JSClass ||                 \
-     (clazz) == &XPC_WN_ModsAllowed_NoCall_Proto_JSClass)
+static inline bool IS_PROTO_CLASS(js::Class *clazz)
+{
+    return clazz == &XPC_WN_NoMods_WithCall_Proto_JSClass ||
+           clazz == &XPC_WN_NoMods_NoCall_Proto_JSClass ||
+           clazz == &XPC_WN_ModsAllowed_WithCall_Proto_JSClass ||
+           clazz == &XPC_WN_ModsAllowed_NoCall_Proto_JSClass;
+}
 
 /***************************************************************************/
 
 namespace XPCWrapper {
 
 enum WrapperType {
     UNKNOWN         = 0,
     NONE            = 0,
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -81,18 +81,20 @@ TraceXPCGlobal(JSTracer *trc, JSObject *
 
 // XXX where should this live?
 NS_EXPORT_(void)
 xpc_LocalizeContext(JSContext *cx);
 
 nsresult
 xpc_MorphSlimWrapper(JSContext *cx, nsISupports *tomorph);
 
-#define IS_WRAPPER_CLASS(clazz)                                               \
-    ((clazz)->ext.isWrappedNative)
+static inline bool IS_WRAPPER_CLASS(js::Class* clazz)
+{
+    return clazz->ext.isWrappedNative;
+}
 
 inline JSBool
 DebugCheckWrapperClass(JSObject* obj)
 {
     NS_ASSERTION(IS_WRAPPER_CLASS(js::GetObjectClass(obj)),
                  "Forgot to check if this is a wrapper?");
     return true;
 }