bug 723517 - drop cx argument from JSObject field and fixed slots infallible API. r=:Waldo
☠☠ backed out by ae2812a649fe ☠ ☠
authorIgor Bukanov <igor@mir2.org>
Sun, 05 Feb 2012 21:07:23 +0100
changeset 89816 223f74353f637f14f88059d62444763d6ced4e1c
parent 89815 b8d16f5bbceb4208b906c3c5b475dda21214005b
child 89817 bb8e2ee240719b413df888e28a3b371832931e63
child 89822 ae2812a649fe1a0a89bff9fc7f068bb0eeff0d7f
push id136
push userlsblakk@mozilla.com
push dateFri, 01 Jun 2012 02:39:32 +0000
treeherdermozilla-release@7ebf7352c959 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs723517
milestone13.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 723517 - drop cx argument from JSObject field and fixed slots infallible API. r=:Waldo
caps/src/nsSecurityManagerFactory.cpp
content/xbl/src/nsXBLBinding.cpp
content/xbl/src/nsXBLDocumentInfo.cpp
content/xul/document/src/nsXULPrototypeDocument.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
dom/base/nsJSUtils.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/workers/ChromeWorkerScope.cpp
dom/workers/EventTarget.cpp
dom/workers/EventTarget.h
dom/workers/Events.cpp
dom/workers/Events.h
dom/workers/Exceptions.cpp
dom/workers/File.cpp
dom/workers/File.h
dom/workers/FileReaderSync.cpp
dom/workers/ListenerManager.cpp
dom/workers/Location.cpp
dom/workers/Navigator.cpp
dom/workers/Worker.cpp
dom/workers/WorkerInlines.h
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerScope.cpp
dom/workers/XMLHttpRequest.cpp
dom/workers/XMLHttpRequestPrivate.cpp
js/ipc/ObjectWrapperChild.cpp
js/ipc/ObjectWrapperParent.cpp
js/ipc/ObjectWrapperParent.h
js/jsd/jsd_val.c
js/src/ctypes/CTypes.cpp
js/src/ctypes/CTypes.h
js/src/ctypes/Library.cpp
js/src/ctypes/Library.h
js/src/jsapi-tests/selfTest.cpp
js/src/jsapi-tests/testResolveRecursion.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsgcinlines.h
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsxml.cpp
js/src/perf/jsperf.cpp
js/src/shell/js.cpp
js/src/shell/jsworkers.cpp
js/src/vm/Debugger.cpp
js/xpconnect/shell/xpcshell.cpp
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCQuickStubs.cpp
js/xpconnect/src/XPCThreadContext.cpp
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
js/xpconnect/src/XPCWrappedNativeProto.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/dombindings.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/wrappers/WrapperFactory.cpp
security/manager/ssl/src/nsCrypto.cpp
toolkit/components/ctypes/ctypes.cpp
toolkit/components/telemetry/Telemetry.cpp
--- a/caps/src/nsSecurityManagerFactory.cpp
+++ b/caps/src/nsSecurityManagerFactory.cpp
@@ -332,17 +332,17 @@ nsSecurityNameSet::InitializeNameSet(nsI
 
     /*
      * Find Object.prototype's class by walking up the global object's
      * prototype chain.
      */
     JSObject *obj = global;
     JSObject *proto;
     JSAutoRequest ar(cx);
-    while ((proto = JS_GetPrototype(cx, obj)) != nsnull)
+    while ((proto = JS_GetPrototype(obj)) != nsnull)
         obj = proto;
     JSClass *objectClass = JS_GetClass(obj);
 
     jsval v;
     if (!JS_GetProperty(cx, global, "netscape", &v))
         return NS_ERROR_FAILURE;
     JSObject *securityObj;
     if (JSVAL_IS_OBJECT(v)) {
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -103,17 +103,17 @@
 /***********************************************************************/
 //
 // The JS class for XBLBinding
 //
 static void
 XBLFinalize(JSContext *cx, JSObject *obj)
 {
   nsXBLDocumentInfo* docInfo =
-    static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(cx, obj));
+    static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(obj));
   NS_RELEASE(docInfo);
   
   nsXBLJSClass* c = static_cast<nsXBLJSClass*>(::JS_GetClass(obj));
   c->Drop();
 }
 
 static JSBool
 XBLResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
@@ -130,18 +130,17 @@ XBLResolve(JSContext *cx, JSObject *obj,
   *objp = NULL;
 
   if (!JSID_IS_STRING(id)) {
     return JS_TRUE;
   }
 
   nsDependentJSString fieldName(id);
 
-  jsval slotVal;
-  ::JS_GetReservedSlot(cx, obj, 0, &slotVal);
+  jsval slotVal = ::JS_GetReservedSlot(obj, 0);
   NS_ASSERTION(!JSVAL_IS_VOID(slotVal), "How did that happen?");
     
   nsXBLPrototypeBinding* protoBinding =
     static_cast<nsXBLPrototypeBinding*>(JSVAL_TO_PRIVATE(slotVal));
   NS_ASSERTION(protoBinding, "Must have prototype binding!");
 
   nsXBLProtoImplField* field = protoBinding->FindField(fieldName);
   if (!field) {
@@ -156,17 +155,17 @@ XBLResolve(JSContext *cx, JSObject *obj,
   
   if (~nodeClass->flags &
       (JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS)) {
     nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
     return JS_FALSE;
   }
 
   nsCOMPtr<nsIXPConnectWrappedNative> xpcWrapper =
-    do_QueryInterface(static_cast<nsISupports*>(::JS_GetPrivate(cx, origObj)));
+    do_QueryInterface(static_cast<nsISupports*>(::JS_GetPrivate(origObj)));
   if (!xpcWrapper) {
     // Looks like whatever |origObj| is it's not our nsIContent.  It might well
     // be the proto our binding installed, however, where the private is the
     // nsXBLDocumentInfo, so just baul out quietly.  Do NOT throw an exception
     // here.
     // We could make this stricter by checking the class maybe, but whatever
     return JS_TRUE;
   }
@@ -1083,53 +1082,49 @@ nsXBLBinding::ChangeDocument(nsIDocument
               JSObject* proto;
               JSAutoRequest ar(cx);
               JSAutoEnterCompartment ac;
               if (!ac.enter(cx, scriptObject)) {
                 return;
               }
 
               for ( ; true; base = proto) { // Will break out on null proto
-                proto = ::JS_GetPrototype(cx, base);
+                proto = ::JS_GetPrototype(base);
                 if (!proto) {
                   break;
                 }
 
                 JSClass* clazz = ::JS_GetClass(proto);
                 if (!clazz ||
                     (~clazz->flags &
                      (JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS)) ||
                     JSCLASS_RESERVED_SLOTS(clazz) != 1 ||
                     clazz->resolve != (JSResolveOp)XBLResolve ||
                     clazz->finalize != XBLFinalize) {
                   // Clearly not the right class
                   continue;
                 }
 
                 nsRefPtr<nsXBLDocumentInfo> docInfo =
-                  static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(cx, proto));
+                  static_cast<nsXBLDocumentInfo*>(::JS_GetPrivate(proto));
                 if (!docInfo) {
                   // Not the proto we seek
                   continue;
                 }
 
-                jsval protoBinding;
-                if (!::JS_GetReservedSlot(cx, proto, 0, &protoBinding)) {
-                  NS_ERROR("Really shouldn't happen");
-                  continue;
-                }
+                jsval protoBinding = ::JS_GetReservedSlot(proto, 0);
 
                 if (JSVAL_TO_PRIVATE(protoBinding) != mPrototypeBinding) {
                   // Not the right binding
                   continue;
                 }
 
                 // Alright!  This is the right prototype.  Pull it out of the
                 // proto chain.
-                JSObject* grandProto = ::JS_GetPrototype(cx, proto);
+                JSObject* grandProto = ::JS_GetPrototype(proto);
                 ::JS_SetPrototype(cx, base, grandProto);
                 break;
               }
 
               mPrototypeBinding->UndefineFields(cx, scriptObject);
 
               // Don't remove the reference from the document to the
               // wrapper here since it'll be removed by the element
@@ -1219,17 +1214,17 @@ nsXBLBinding::DoInitJSClass(JSContext *c
 
   JSAutoEnterCompartment ac;
   if (!ac.enter(cx, global)) {
     return NS_ERROR_FAILURE;
   }
 
   if (obj) {
     // Retrieve the current prototype of obj.
-    parent_proto = ::JS_GetPrototype(cx, obj);
+    parent_proto = ::JS_GetPrototype(obj);
     if (parent_proto) {
       // We need to create a unique classname based on aClassName and
       // parent_proto.  Append a space (an invalid URI character) to ensure that
       // we don't have accidental collisions with the case when parent_proto is
       // null and aClassName ends in some bizarre numbers (yeah, it's unlikely).
       jsid parent_proto_id;
       if (!::JS_GetObjectId(cx, parent_proto, &parent_proto_id)) {
         // Probably OOM
@@ -1322,26 +1317,20 @@ nsXBLBinding::DoInitJSClass(JSContext *c
 
     // Keep this proto binding alive while we're alive.  Do this first so that
     // we can guarantee that in XBLFinalize this will be non-null.
     // Note that we can't just store aProtoBinding in the private and
     // addref/release the nsXBLDocumentInfo through it, because cycle
     // collection doesn't seem to work right if the private is not an
     // nsISupports.
     nsXBLDocumentInfo* docInfo = aProtoBinding->XBLDocumentInfo();
-    ::JS_SetPrivate(cx, proto, docInfo);
+    ::JS_SetPrivate(proto, docInfo);
     NS_ADDREF(docInfo);
 
-    if (!::JS_SetReservedSlot(cx, proto, 0, PRIVATE_TO_JSVAL(aProtoBinding))) {
-      (nsXBLService::gClassTable)->Remove(&key);
-
-      // |c| will get dropped when |proto| is finalized
-
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    ::JS_SetReservedSlot(proto, 0, PRIVATE_TO_JSVAL(aProtoBinding));
 
     *aClassObject = proto;
   }
   else {
     proto = JSVAL_TO_OBJECT(val);
   }
 
   if (obj) {
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -117,17 +117,17 @@ nsXBLDocGlobalObject::doCheckAccess(JSCo
   if (!ssm) {
     ::JS_ReportError(cx, "Unable to verify access to a global object property.");
     return JS_FALSE;
   }
 
   // Make sure to actually operate on our object, and not some object further
   // down on the proto chain.
   while (JS_GetClass(obj) != &nsXBLDocGlobalObject::gSharedGlobalClass) {
-    obj = ::JS_GetPrototype(cx, obj);
+    obj = ::JS_GetPrototype(obj);
     if (!obj) {
       ::JS_ReportError(cx, "Invalid access to a global object property.");
       return JS_FALSE;
     }
   }
 
   nsresult rv = ssm->CheckPropertyAccess(cx, obj, JS_GetClass(obj)->name,
                                          id, accessType);
@@ -163,17 +163,17 @@ nsXBLDocGlobalObject_checkAccess(JSConte
 
   return nsXBLDocGlobalObject::
     doCheckAccess(cx, obj, id, translated);
 }
 
 static void
 nsXBLDocGlobalObject_finalize(JSContext *cx, JSObject *obj)
 {
-  nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(cx, obj);
+  nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(obj);
 
   nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeThis));
 
   if (sgo)
     sgo->OnFinalize(obj);
 
   // The addref was part of JSObject construction
   NS_RELEASE(nativeThis);
@@ -329,17 +329,17 @@ nsXBLDocGlobalObject::EnsureScriptEnviro
   rv = xpc_CreateGlobalObject(cx, &gSharedGlobalClass, principal, nsnull,
                               false, &mJSObject, &compartment);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   ::JS_SetGlobalObject(cx, mJSObject);
 
   // Add an owning reference from JS back to us. This'll be
   // released when the JSObject is finalized.
-  ::JS_SetPrivate(cx, mJSObject, this);
+  ::JS_SetPrivate(mJSObject, this);
   NS_ADDREF(this);
   return NS_OK;
 }
 
 nsIScriptContext *
 nsXBLDocGlobalObject::GetContext()
 {
   // This whole fragile mess is predicated on the fact that
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp
+++ b/content/xul/document/src/nsXULPrototypeDocument.cpp
@@ -114,17 +114,17 @@ protected:
 nsIPrincipal* nsXULPrototypeDocument::gSystemPrincipal;
 nsXULPDGlobalObject* nsXULPrototypeDocument::gSystemGlobal;
 PRUint32 nsXULPrototypeDocument::gRefCnt;
 
 
 void
 nsXULPDGlobalObject_finalize(JSContext *cx, JSObject *obj)
 {
-    nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(cx, obj);
+    nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(obj);
 
     nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(nativeThis));
 
     if (sgo) {
         sgo->OnFinalize(obj);
     }
 
     // The addref was part of JSObject construction
@@ -742,17 +742,17 @@ nsXULPDGlobalObject::EnsureScriptEnviron
     rv = xpc_CreateGlobalObject(cx, &gSharedGlobalClass, principal, nsnull,
                                 false, &newGlob, &compartment);
     NS_ENSURE_SUCCESS(rv, NS_OK);
 
     ::JS_SetGlobalObject(cx, newGlob);
 
     // Add an owning reference from JS back to us. This'll be
     // released when the JSObject is finalized.
-    ::JS_SetPrivate(cx, newGlob, this);
+    ::JS_SetPrivate(newGlob, this);
     NS_ADDREF(this);
   }
 
   NS_ENSURE_SUCCESS(rv, NS_OK);
   rv = SetScriptContext(lang_id, ctxNew);
   NS_ENSURE_SUCCESS(rv, NS_OK);
   return NS_OK;
 }
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -4891,18 +4891,18 @@ nsDOMClassInfo::PostCreatePrototype(JSCo
   // sObjectClass, so compute it here. We assume that nobody has had a
   // chance to monkey around with proto's prototype chain before this.
   if (!sObjectClass) {
     FindObjectClass(proto);
     NS_ASSERTION(sObjectClass && !strcmp(sObjectClass->name, "Object"),
                  "Incorrect object class!");
   }
 
-  NS_ASSERTION(::JS_GetPrototype(cx, proto) &&
-               JS_GetClass(::JS_GetPrototype(cx, proto)) == sObjectClass,
+  NS_ASSERTION(::JS_GetPrototype(proto) &&
+               JS_GetClass(::JS_GetPrototype(proto)) == sObjectClass,
                "Hmm, somebody did something evil?");
 
 #ifdef DEBUG
   if (mData->mHasClassInterface && mData->mProtoChainInterface &&
       mData->mProtoChainInterface != &NS_GET_IID(nsISupports)) {
     nsCOMPtr<nsIInterfaceInfoManager>
       iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
 
@@ -5199,20 +5199,20 @@ nsWindowSH::SecurityCheckOnAddDelProp(JS
 JSBool
 nsWindowSH::SecurityCheckOnSetProp(JSContext *cx, JSObject *obj, jsid id, JSBool strict,
                                    jsval *vp)
 {
   return SecurityCheckOnAddDelProp(cx, obj, id, vp);
 }
 
 static nsHTMLDocument*
-GetDocument(JSContext *cx, JSObject *obj)
+GetDocument(JSObject *obj)
 {
   return static_cast<nsHTMLDocument*>(
-    static_cast<nsIHTMLDocument*>(::JS_GetPrivate(cx, obj)));
+    static_cast<nsIHTMLDocument*>(::JS_GetPrivate(obj)));
 }
 
 // static
 JSBool
 nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSObject *obj,
                                           jsid id, uintN flags,
                                           JSObject **objp)
 {
@@ -5221,27 +5221,27 @@ nsWindowSH::GlobalScopePolluterNewResolv
       !JSID_IS_STRING(id)) {
     // Nothing to do here if we're either assigning or declaring,
     // resolving a class name, doing a qualified resolve, or
     // resolving a number.
 
     return JS_TRUE;
   }
 
-  nsHTMLDocument *document = GetDocument(cx, obj);
+  nsHTMLDocument *document = GetDocument(obj);
 
   if (!document ||
       document->GetCompatibilityMode() != eCompatibility_NavQuirks) {
     // If we don't have a document, or if the document is not in
     // quirks mode, return early.
 
     return JS_TRUE;
   }
 
-  JSObject *proto = ::JS_GetPrototype(cx, obj);
+  JSObject *proto = ::JS_GetPrototype(obj);
   JSBool hasProp;
 
   if (!proto || !::JS_HasPropertyById(cx, proto, id, &hasProp) ||
       hasProp) {
     // No prototype, or the property exists on the prototype. Do
     // nothing.
 
     return JS_TRUE;
@@ -5281,27 +5281,27 @@ nsWindowSH::GlobalScopePolluterNewResolv
 // static
 void
 nsWindowSH::InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj)
 {
   JSObject *proto;
 
   JSAutoRequest ar(cx);
 
-  while ((proto = ::JS_GetPrototype(cx, obj))) {
+  while ((proto = ::JS_GetPrototype(obj))) {
     if (JS_GetClass(proto) == &sGlobalScopePolluterClass) {
-      nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(cx, proto);
+      nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(proto);
 
       NS_IF_RELEASE(doc);
 
-      ::JS_SetPrivate(cx, proto, nsnull);
+      ::JS_SetPrivate(proto, nsnull);
 
       // Pull the global scope polluter out of the prototype chain so
       // that it can be freed.
-      ::JS_SplicePrototype(cx, obj, ::JS_GetPrototype(cx, proto));
+      ::JS_SplicePrototype(cx, obj, ::JS_GetPrototype(proto));
 
       break;
     }
 
     obj = proto;
   }
 }
 
@@ -5323,34 +5323,32 @@ nsWindowSH::InstallGlobalScopePolluter(J
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   JSObject *o = obj, *proto;
 
   // Find the place in the prototype chain where we want this global
   // scope polluter (right before Object.prototype).
 
-  while ((proto = ::JS_GetPrototype(cx, o))) {
+  while ((proto = ::JS_GetPrototype(o))) {
     if (JS_GetClass(proto) == sObjectClass) {
       // Set the global scope polluters prototype to Object.prototype
       ::JS_SplicePrototype(cx, gsp, proto);
 
       break;
     }
 
     o = proto;
   }
 
   // And then set the prototype of the object whose prototype was
   // Object.prototype to be the global scope polluter.
   ::JS_SplicePrototype(cx, o, gsp);
 
-  if (!::JS_SetPrivate(cx, gsp, doc)) {
-    return NS_ERROR_UNEXPECTED;
-  }
+  ::JS_SetPrivate(gsp, doc);
 
   // The global scope polluter will release doc on destruction (or
   // invalidation).
   NS_ADDREF(doc);
 
   return NS_OK;
 }
 
@@ -5923,18 +5921,18 @@ nsDOMConstructor::HasInstance(nsIXPConne
     jsval val;
     if (!JS_GetProperty(cx, obj, "prototype", &val)) {
       return NS_ERROR_UNEXPECTED;
     }
 
     JS_ASSERT(!JSVAL_IS_PRIMITIVE(val));
     JSObject *dot_prototype = JSVAL_TO_OBJECT(val);
 
-    JSObject *proto = JS_GetPrototype(cx, dom_obj);
-    for ( ; proto; proto = JS_GetPrototype(cx, proto)) {
+    JSObject *proto = JS_GetPrototype(dom_obj);
+    for ( ; proto; proto = JS_GetPrototype(proto)) {
       if (proto == dot_prototype) {
         *bp = true;
         break;
       }
     }
 
     return NS_OK;
   }
@@ -6295,17 +6293,17 @@ ResolvePrototype(nsIXPConnect *aXPConnec
     }
 
     if (dot_prototype) {
       JSAutoEnterCompartment ac;
       if (!ac.enter(cx, dot_prototype)) {
         return NS_ERROR_UNEXPECTED;
       }
 
-      JSObject *xpc_proto_proto = ::JS_GetPrototype(cx, dot_prototype);
+      JSObject *xpc_proto_proto = ::JS_GetPrototype(dot_prototype);
 
       if (proto &&
           (!xpc_proto_proto ||
            JS_GetClass(xpc_proto_proto) == sObjectClass)) {
         if (!JS_WrapObject(cx, &proto) ||
             !JS_SetPrototype(cx, dot_prototype, proto)) {
           return NS_ERROR_UNEXPECTED;
         }
@@ -8145,17 +8143,17 @@ nsNamedArraySH::NewResolve(nsIXPConnectW
 
       JSAutoEnterCompartment ac;
 
       if (!ac.enter(cx, realObj)) {
         *_retval = false;
         return NS_ERROR_FAILURE;
       }
 
-      JSObject *proto = ::JS_GetPrototype(cx, realObj);
+      JSObject *proto = ::JS_GetPrototype(realObj);
 
       if (proto) {
         JSBool hasProp;
         if (!::JS_HasPropertyById(cx, proto, id, &hasProp)) {
           *_retval = false;
           return NS_ERROR_FAILURE;
         }
 
@@ -8722,22 +8720,19 @@ nsHTMLDocumentSH::GetDocumentAllNodeList
                                          nsContentList **nodeList)
 {
   // The document.all object is a mix of the node list returned by
   // document.getElementsByTagName("*") and a map of elements in the
   // document exposed by their id and/or name. To make access to the
   // node list part (i.e. access to elements by index) not walk the
   // document each time, we create a nsContentList and hold on to it
   // in a reserved slot (0) on the document.all JSObject.
-  jsval collection;
   nsresult rv = NS_OK;
 
-  if (!JS_GetReservedSlot(cx, obj, 0, &collection)) {
-    return JS_FALSE;
-  }
+  jsval collection = JS_GetReservedSlot(obj, 0);
 
   if (!JSVAL_IS_PRIMITIVE(collection)) {
     // We already have a node list in our reserved slot, use it.
     JSObject *obj = JSVAL_TO_OBJECT(collection);
     if (mozilla::dom::binding::HTMLCollection::objIsWrapper(obj)) {
       nsIHTMLCollection *native =
         mozilla::dom::binding::HTMLCollection::getNative(obj);
       NS_ADDREF(*nodeList = static_cast<nsContentList*>(native));
@@ -8763,19 +8758,17 @@ nsHTMLDocumentSH::GetDocumentAllNodeList
     nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
     rv |= WrapNative(cx, JS_GetGlobalForScopeChain(cx),
                      static_cast<nsINodeList*>(list), list, false,
                      &collection, getter_AddRefs(holder));
 
     list.forget(nodeList);
 
     // ... and store it in our reserved slot.
-    if (!JS_SetReservedSlot(cx, obj, 0, collection)) {
-      return JS_FALSE;
-    }
+    JS_SetReservedSlot(obj, 0, collection);
   }
 
   if (NS_FAILED(rv)) {
     nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);
 
     return JS_FALSE;
   }
 
@@ -8799,17 +8792,17 @@ nsHTMLDocumentSH::DocumentAllGetProperty
 
     if (!obj) {
       NS_ERROR("The JS engine lies!");
 
       return JS_TRUE;
     }
   }
 
-  nsHTMLDocument *doc = GetDocument(cx, obj);
+  nsHTMLDocument *doc = GetDocument(obj);
   nsISupports *result;
   nsWrapperCache *cache;
   nsresult rv = NS_OK;
 
   if (JSID_IS_STRING(id)) {
     if (id == sLength_id) {
       // Map document.all.length to the length of the collection
       // document.getElementsByTagName("*"), and make sure <div
@@ -8904,27 +8897,25 @@ nsHTMLDocumentSH::DocumentAllNewResolve(
   if (id == sLength_id) {
     // document.all.length. Any jsval other than undefined would do
     // here, all we need is to get into the code below that defines
     // this propery on obj, the rest happens in
     // DocumentAllGetProperty().
 
     v = JSVAL_ONE;
   } else if (id == sTags_id) {
-    nsHTMLDocument *doc = GetDocument(cx, obj);
+    nsHTMLDocument *doc = GetDocument(obj);
 
     JSObject *tags = ::JS_NewObject(cx, &sHTMLDocumentAllTagsClass, nsnull,
                                     ::JS_GetGlobalForObject(cx, obj));
     if (!tags) {
       return JS_FALSE;
     }
 
-    if (!::JS_SetPrivate(cx, tags, doc)) {
-      return JS_FALSE;
-    }
+    ::JS_SetPrivate(tags, doc);
 
     // The "tags" JSObject now also owns doc.
     NS_ADDREF(doc);
 
     v = OBJECT_TO_JSVAL(tags);
   } else {
     if (!DocumentAllGetProperty(cx, obj, id, &v)) {
       return JS_FALSE;
@@ -8942,17 +8933,17 @@ nsHTMLDocumentSH::DocumentAllNewResolve(
 }
 
 // Finalize hook used by document related JS objects, but also by
 // sGlobalScopePolluterClass!
 
 void
 nsHTMLDocumentSH::ReleaseDocument(JSContext *cx, JSObject *obj)
 {
-  nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(cx, obj);
+  nsIHTMLDocument *doc = (nsIHTMLDocument *)::JS_GetPrivate(obj);
 
   NS_IF_RELEASE(doc);
 }
 
 JSBool
 nsHTMLDocumentSH::CallToGetPropMapper(JSContext *cx, uintN argc, jsval *vp)
 {
   // Handle document.all("foo") style access to document.all.
@@ -8990,20 +8981,20 @@ nsHTMLDocumentSH::CallToGetPropMapper(JS
     return JS_FALSE;
   }
 
   return ::JS_GetUCProperty(cx, self, chars, length, vp);
 }
 
 
 static inline JSObject *
-GetDocumentAllHelper(JSContext *cx, JSObject *obj)
+GetDocumentAllHelper(JSObject *obj)
 {
   while (obj && JS_GetClass(obj) != &sHTMLDocumentAllHelperClass) {
-    obj = ::JS_GetPrototype(cx, obj);
+    obj = ::JS_GetPrototype(obj);
   }
 
   return obj;
 }
 
 static inline void *
 FlagsToPrivate(PRUint32 flags)
 {
@@ -9021,27 +9012,27 @@ PrivateToFlags(void *priv)
 JSBool
 nsHTMLDocumentSH::DocumentAllHelperGetProperty(JSContext *cx, JSObject *obj,
                                                jsid id, jsval *vp)
 {
   if (id != nsDOMClassInfo::sAll_id) {
     return JS_TRUE;
   }
 
-  JSObject *helper = GetDocumentAllHelper(cx, obj);
+  JSObject *helper = GetDocumentAllHelper(obj);
 
   if (!helper) {
     NS_ERROR("Uh, how'd we get here?");
 
     // Let scripts continue, if we somehow did get here...
 
     return JS_TRUE;
   }
 
-  PRUint32 flags = PrivateToFlags(::JS_GetPrivate(cx, helper));
+  PRUint32 flags = PrivateToFlags(::JS_GetPrivate(helper));
 
   if (flags & JSRESOLVE_DETECTING || !(flags & JSRESOLVE_QUALIFIED)) {
     // document.all is either being detected, e.g. if (document.all),
     // or it was not being resolved with a qualified name. Claim that
     // document.all is undefined.
 
     *vp = JSVAL_VOID;
   } else {
@@ -9061,19 +9052,17 @@ nsHTMLDocumentSH::DocumentAllHelperGetPr
 
       JSObject *all = ::JS_NewObject(cx, &sHTMLDocumentAllClass, nsnull,
                                      ::JS_GetGlobalForObject(cx, obj));
       if (!all) {
         return JS_FALSE;
       }
 
       // Let the JSObject take over ownership of doc.
-      if (!::JS_SetPrivate(cx, all, doc)) {
-        return JS_FALSE;
-      }
+      ::JS_SetPrivate(all, doc);
 
       doc.forget();
 
       *vp = OBJECT_TO_JSVAL(all);
     }
   }
 
   return JS_TRUE;
@@ -9081,17 +9070,17 @@ nsHTMLDocumentSH::DocumentAllHelperGetPr
 
 JSBool
 nsHTMLDocumentSH::DocumentAllHelperNewResolve(JSContext *cx, JSObject *obj,
                                               jsid id, uintN flags,
                                               JSObject **objp)
 {
   if (id == nsDOMClassInfo::sAll_id) {
     // document.all is resolved for the first time. Define it.
-    JSObject *helper = GetDocumentAllHelper(cx, obj);
+    JSObject *helper = GetDocumentAllHelper(obj);
 
     if (helper) {
       if (!::JS_DefineProperty(cx, helper, "all", JSVAL_VOID, nsnull, nsnull,
                                JSPROP_ENUMERATE)) {
         return JS_FALSE;
       }
 
       *objp = helper;
@@ -9103,19 +9092,19 @@ nsHTMLDocumentSH::DocumentAllHelperNewRe
 
 
 JSBool
 nsHTMLDocumentSH::DocumentAllTagsNewResolve(JSContext *cx, JSObject *obj,
                                             jsid id, uintN flags,
                                             JSObject **objp)
 {
   if (JSID_IS_STRING(id)) {
-    nsDocument *doc = GetDocument(cx, obj);
-
-    JSObject *proto = ::JS_GetPrototype(cx, obj);
+    nsDocument *doc = GetDocument(obj);
+
+    JSObject *proto = ::JS_GetPrototype(obj);
     if (NS_UNLIKELY(!proto)) {
       return JS_TRUE;
     }
 
     JSBool found;
     if (!::JS_HasPropertyById(cx, proto, id, &found)) {
       return JS_FALSE;
     }
@@ -9183,54 +9172,53 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnec
       }
     }
 
     if (id == sAll_id && !sDisableDocumentAllSupport &&
         !ObjectIsNativeWrapper(cx, obj)) {
       nsIDocument *doc = static_cast<nsIDocument*>(wrapper->Native());
 
       if (doc->GetCompatibilityMode() == eCompatibility_NavQuirks) {
-        JSObject *helper =
-          GetDocumentAllHelper(cx, ::JS_GetPrototype(cx, obj));
-
-        JSObject *proto = ::JS_GetPrototype(cx, helper ? helper : obj);
+        JSObject *helper = GetDocumentAllHelper(::JS_GetPrototype(obj));
+
+        JSObject *proto = ::JS_GetPrototype(helper ? helper : obj);
 
         // Check if the property all is defined on obj's (or helper's
         // if obj doesn't exist) prototype, if it is, don't expose our
         // document.all helper.
 
         JSBool hasAll = JS_FALSE;
         if (proto && !JS_HasProperty(cx, proto, "all", &hasAll)) {
           return NS_ERROR_UNEXPECTED;
         }
 
         if (hasAll && helper) {
           // Our helper's prototype now has an "all" property, remove
           // the helper out of the prototype chain to prevent
           // shadowing of the now defined "all" property.
           JSObject *tmp = obj, *tmpProto;
 
-          while ((tmpProto = ::JS_GetPrototype(cx, tmp)) != helper) {
+          while ((tmpProto = ::JS_GetPrototype(tmp)) != helper) {
             tmp = tmpProto;
           }
 
           ::JS_SetPrototype(cx, tmp, proto);
         }
 
         // If we don't already have a helper, and we're resolving
         // document.all qualified, and we're *not* detecting
         // document.all, e.g. if (document.all), and "all" isn't
         // already defined on our prototype, create a helper.
         if (!helper && flags & JSRESOLVE_QUALIFIED &&
             !(flags & JSRESOLVE_DETECTING) && !hasAll) {
           // Print a warning so developers can stop using document.all
           PrintWarningOnConsole(cx, "DocumentAllUsed");
 
           helper = ::JS_NewObject(cx, &sHTMLDocumentAllHelperClass,
-                                  ::JS_GetPrototype(cx, obj),
+                                  ::JS_GetPrototype(obj),
                                   ::JS_GetGlobalForObject(cx, obj));
 
           if (!helper) {
             return NS_ERROR_OUT_OF_MEMORY;
           }
 
           // Insert the helper into our prototype chain. helper's prototype
           // is already obj's current prototype.
@@ -9238,20 +9226,18 @@ nsHTMLDocumentSH::NewResolve(nsIXPConnec
             nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
 
             return NS_ERROR_UNEXPECTED;
           }
         }
 
         // If we have (or just created) a helper, pass the resolve flags
         // to the helper as its private data.
-        if (helper && !::JS_SetPrivate(cx, helper, FlagsToPrivate(flags))) {
-          nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);
-
-          return NS_ERROR_UNEXPECTED;
+        if (helper) {
+          ::JS_SetPrivate(helper, FlagsToPrivate(flags));
         }
       }
 
       return NS_OK;
     }
   }
 
   return nsDocumentSH::NewResolve(wrapper, cx, obj, id, flags, objp, _retval);
@@ -9786,17 +9772,17 @@ nsHTMLPluginObjElementSH::PostCreate(nsI
 
 NS_IMETHODIMP
 nsHTMLPluginObjElementSH::GetProperty(nsIXPConnectWrappedNative *wrapper,
                                       JSContext *cx, JSObject *obj, jsid id,
                                       jsval *vp, bool *_retval)
 {
   JSAutoRequest ar(cx);
 
-  JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
+  JSObject *pi_obj = ::JS_GetPrototype(obj);
   if (NS_UNLIKELY(!pi_obj)) {
     return NS_OK;
   }
 
   JSBool found = false;
 
   if (!ObjectIsNativeWrapper(cx, obj)) {
     *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
@@ -9815,17 +9801,17 @@ nsHTMLPluginObjElementSH::GetProperty(ns
 
 NS_IMETHODIMP
 nsHTMLPluginObjElementSH::SetProperty(nsIXPConnectWrappedNative *wrapper,
                                       JSContext *cx, JSObject *obj, jsid id,
                                       jsval *vp, bool *_retval)
 {
   JSAutoRequest ar(cx);
 
-  JSObject *pi_obj = ::JS_GetPrototype(cx, obj);
+  JSObject *pi_obj = ::JS_GetPrototype(obj);
   if (NS_UNLIKELY(!pi_obj)) {
     return NS_OK;
   }
 
   JSBool found = false;
 
   if (!ObjectIsNativeWrapper(cx, obj)) {
     *_retval = ::JS_HasPropertyById(cx, pi_obj, id, &found);
@@ -9894,17 +9880,17 @@ nsHTMLPluginObjElementSH::GetPluginJSObj
   JSAutoEnterCompartment ac;
   if (!ac.enter(cx, obj)) {
     return NS_ERROR_UNEXPECTED;
   }
 
   if (plugin_inst) {
     plugin_inst->GetJSObject(cx, plugin_obj);
     if (*plugin_obj) {
-      *plugin_proto = ::JS_GetPrototype(cx, *plugin_obj);
+      *plugin_proto = ::JS_GetPrototype(*plugin_obj);
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLPluginObjElementSH::NewResolve(nsIXPConnectWrappedNative *wrapper,
@@ -10293,17 +10279,17 @@ nsStorageSH::NewResolve(nsIXPConnectWrap
   JSAutoEnterCompartment ac;
   if (!ac.enter(cx, realObj)) {
     *_retval = false;
     return NS_ERROR_FAILURE;
   }
 
   // First check to see if the property is defined on our prototype.
 
-  JSObject *proto = ::JS_GetPrototype(cx, realObj);
+  JSObject *proto = ::JS_GetPrototype(realObj);
   JSBool hasProp;
 
   if (proto &&
       (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
        hasProp)) {
     // We found the property we're resolving on the prototype,
     // nothing left to do here then.
 
@@ -10479,17 +10465,17 @@ nsStorage2SH::NewResolve(nsIXPConnectWra
   // First check to see if the property is defined on our prototype,
   // after converting id to a string if it's an integer.
 
   JSString *jsstr = IdToString(cx, id);
   if (!jsstr) {
     return JS_FALSE;
   }
 
-  JSObject *proto = ::JS_GetPrototype(cx, realObj);
+  JSObject *proto = ::JS_GetPrototype(realObj);
   JSBool hasProp;
 
   if (proto &&
       (::JS_HasPropertyById(cx, proto, id, &hasProp) &&
        hasProp)) {
     // We found the property we're resolving on the prototype,
     // nothing left to do here then.
 
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1601,17 +1601,17 @@ nsDOMWindowUtils::GetParent(const JS::Va
     return NS_ERROR_DOM_SECURITY_ERR;
   }
 
   // First argument must be an object.
   if (JSVAL_IS_PRIMITIVE(aObject)) {
     return NS_ERROR_XPC_BAD_CONVERT_JS;
   }
 
-  JSObject* parent = JS_GetParent(aCx, JSVAL_TO_OBJECT(aObject));
+  JSObject* parent = JS_GetParent(JSVAL_TO_OBJECT(aObject));
   *aParent = OBJECT_TO_JSVAL(parent);
 
   // Outerize if necessary.
   if (parent) {
     if (JSObjectOp outerize = js::GetObjectClass(parent)->ext.outerObject) {
       *aParent = OBJECT_TO_JSVAL(outerize(aCx, parent));
     }
   }
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1865,17 +1865,17 @@ static JSDHashOperator
 ReparentWaiverWrappers(JSDHashTable *table, JSDHashEntryHdr *hdr,
                        uint32 number, void *arg)
 {
     ReparentWaiverClosure *closure = static_cast<ReparentWaiverClosure*>(arg);
     JSObject *value = static_cast<JSObject2JSObjectMap::Entry *>(hdr)->value;
 
     // We reparent wrappers that have as their parent an inner window whose
     // outer has the new inner window as its current inner.
-    JSObject *parent = JS_GetParent(closure->mCx, value);
+    JSObject *parent = JS_GetParent(value);
     JSObject *outer = JS_ObjectToOuterObject(closure->mCx, parent);
     if (outer) {
       JSObject *inner = JS_ObjectToInnerObject(closure->mCx, outer);
       if (inner == closure->mNewInner && inner != parent)
         JS_SetParent(closure->mCx, value, closure->mNewInner);
     } else {
       JS_ClearPendingException(closure->mCx);
     }
@@ -9970,17 +9970,17 @@ nsGlobalWindow::SaveWindowState(nsISuppo
 
   nsCOMPtr<nsIClassInfo> ci =
     do_QueryInterface((nsIScriptGlobalObject *)this);
   nsCOMPtr<nsIXPConnectJSObjectHolder> proto;
   nsresult rv = xpc->GetWrappedNativePrototype(cx, mJSObject, ci,
                                                getter_AddRefs(proto));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  JSObject *realProto = JS_GetPrototype(cx, mJSObject);
+  JSObject *realProto = JS_GetPrototype(mJSObject);
   nsCOMPtr<nsIXPConnectJSObjectHolder> realProtoHolder;
   if (realProto) {
     rv = xpc->HoldObject(cx, realProto, getter_AddRefs(realProtoHolder));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCOMPtr<nsISupports> state = new WindowStateHolder(inner,
                                                       mInnerWindowHolder,
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1896,17 +1896,17 @@ nsJSContext::CallEventHandler(nsISupport
     return NS_OK;
   }
 
 #ifdef NS_FUNCTION_TIMER
   {
     JSObject *obj = aHandler;
     if (js::IsFunctionProxy(obj))
       obj = js::UnwrapObject(obj);
-    JSString *id = JS_GetFunctionId(static_cast<JSFunction *>(JS_GetPrivate(mContext, obj)));
+    JSString *id = JS_GetFunctionId(static_cast<JSFunction *>(JS_GetPrivate(obj)));
     JSAutoByteString bytes;
     const char *name = !id ? "anonymous" : bytes.encode(mContext, id) ? bytes.ptr() : "<error>";
     NS_TIME_FUNCTION_FMT(1.0, "%s (line %d) (function: %s)", MOZ_FUNCTION_NAME, __LINE__, name);
   }
 #endif
   SAMPLE_LABEL("JS", "CallEventHandler");
 
   JSAutoRequest ar(mContext);
@@ -2267,18 +2267,18 @@ nsJSContext::ConnectToInner(nsIScriptGlo
   JSObject *newInnerJSObject = aNewInner->GetGlobalJSObject();
 #endif
 
   // Now that we're connecting the outer global to the inner one,
   // we must have transplanted it. The JS engine tries to maintain
   // the global object's compartment as its default compartment,
   // so update that now since it might have changed.
   JS_SetGlobalObject(mContext, aOuterGlobal);
-  NS_ASSERTION(JS_GetPrototype(mContext, aOuterGlobal) ==
-               JS_GetPrototype(mContext, newInnerJSObject),
+  NS_ASSERTION(JS_GetPrototype(aOuterGlobal) ==
+               JS_GetPrototype(newInnerJSObject),
                "outer and inner globals should have the same prototype");
 
   return NS_OK;
 }
 
 JSContext*
 nsJSContext::GetNativeContext()
 {
@@ -2329,27 +2329,27 @@ nsJSContext::CreateOuterObject(nsIScript
 
 nsresult
 nsJSContext::SetOuterObject(JSObject* aOuterObject)
 {
   // Force our context's global object to be the outer.
   JS_SetGlobalObject(mContext, aOuterObject);
 
   // NB: JS_SetGlobalObject sets mContext->compartment.
-  JSObject *inner = JS_GetParent(mContext, aOuterObject);
+  JSObject *inner = JS_GetParent(aOuterObject);
 
   nsIXPConnect *xpc = nsContentUtils::XPConnect();
   nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
   nsresult rv = xpc->GetWrappedNativeOfJSObject(mContext, inner,
                                                 getter_AddRefs(wrapper));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
 
   wrapper->RefreshPrototype();
-  JS_SetPrototype(mContext, aOuterObject, JS_GetPrototype(mContext, inner));
+  JS_SetPrototype(mContext, aOuterObject, JS_GetPrototype(inner));
 
   return NS_OK;
 }
 
 nsresult
 nsJSContext::InitOuterWindow()
 {
   JSObject *global = JS_ObjectToInnerObject(mContext, JS_GetGlobalObject(mContext));
@@ -3094,18 +3094,18 @@ nsJSContext::ClearScope(void *aGlobalObj
     // Since the prototype chain is shared between inner and outer (and
     // stays with the inner), we don't clear things from the prototype
     // chain when we're clearing an outer window whose current inner we
     // still want.
     if (aClearFromProtoChain) {
       nsWindowSH::InvalidateGlobalScopePolluter(mContext, obj);
 
       // Clear up obj's prototype chain, but not Object.prototype.
-      for (JSObject *o = ::JS_GetPrototype(mContext, obj), *next;
-           o && (next = ::JS_GetPrototype(mContext, o)); o = next)
+      for (JSObject *o = ::JS_GetPrototype(obj), *next;
+           o && (next = ::JS_GetPrototype(o)); o = next)
         ::JS_ClearScope(mContext, o);
     }
   }
 
   if (stack) {
     stack->Pop(nsnull);
   }
 }
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -109,17 +109,17 @@ nsJSUtils::GetStaticScriptGlobal(JSConte
   glob = JS_GetGlobalForObject(aContext, glob);
   NS_ABORT_IF_FALSE(glob, "Infallible returns null");
 
   clazz = JS_GetClass(glob);
 
   if (!clazz ||
       !(clazz->flags & JSCLASS_HAS_PRIVATE) ||
       !(clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS) ||
-      !(supports = (nsISupports*)::JS_GetPrivate(aContext, glob))) {
+      !(supports = (nsISupports*)::JS_GetPrivate(glob))) {
     return nsnull;
   }
 
   // We might either have a window directly (e.g. if the global is a
   // sandbox whose script object principal pointer is a window), or an
   // XPCWrappedNative for a window.  We could also have other
   // sandbox-related script object principals, but we can't do much
   // about those short of trying to walk the proto chain of |glob|
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -1068,17 +1068,17 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS
   // compartments.
 
   JSClass *clazz = JS_GetClass(obj);
 
   if (clazz == &sNPObjectJSWrapperClass) {
     // obj is one of our own, its private data is the NPObject we're
     // looking for.
 
-    NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
+    NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
 
     if (LookupNPP(npobj) == npp)
       return _retainobject(npobj);
   }
 
   if (!sJSObjWrappers.ops) {
     // No hash yet (or any more), initialize it.
 
@@ -1149,36 +1149,36 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS
 
     return nsnull;
   }
 
   return wrapper;
 }
 
 static NPObject *
-GetNPObject(JSContext *cx, JSObject *obj)
+GetNPObject(JSObject *obj)
 {
   while (obj && JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
-    obj = ::JS_GetPrototype(cx, obj);
+    obj = ::JS_GetPrototype(obj);
   }
 
   if (!obj) {
     return nsnull;
   }
 
-  return (NPObject *)::JS_GetPrivate(cx, obj);
+  return (NPObject *)::JS_GetPrivate(obj);
 }
 
 
 // Does not actually add a property because this is always followed by a
 // SetProperty call.
 static JSBool
 NPObjWrapper_AddProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
 {
-  NPObject *npobj = GetNPObject(cx, obj);
+  NPObject *npobj = GetNPObject(obj);
 
   if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
       !npobj->_class->hasMethod) {
     ThrowJSException(cx, "Bad NPObject as private data!");
 
     return JS_FALSE;
   }
 
@@ -1209,17 +1209,17 @@ NPObjWrapper_AddProperty(JSContext *cx, 
   }
 
   return JS_TRUE;
 }
 
 static JSBool
 NPObjWrapper_DelProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
 {
-  NPObject *npobj = GetNPObject(cx, obj);
+  NPObject *npobj = GetNPObject(obj);
 
   if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
       !npobj->_class->removeProperty) {
     ThrowJSException(cx, "Bad NPObject as private data!");
 
     return JS_FALSE;
   }
 
@@ -1240,17 +1240,17 @@ NPObjWrapper_DelProperty(JSContext *cx, 
     *vp = JSVAL_FALSE;
 
   return ReportExceptionIfPending(cx);
 }
 
 static JSBool
 NPObjWrapper_SetProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
 {
-  NPObject *npobj = GetNPObject(cx, obj);
+  NPObject *npobj = GetNPObject(obj);
 
   if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
       !npobj->_class->setProperty) {
     ThrowJSException(cx, "Bad NPObject as private data!");
 
     return JS_FALSE;
   }
 
@@ -1299,17 +1299,17 @@ NPObjWrapper_SetProperty(JSContext *cx, 
   }
 
   return JS_TRUE;
 }
 
 static JSBool
 NPObjWrapper_GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
 {
-  NPObject *npobj = GetNPObject(cx, obj);
+  NPObject *npobj = GetNPObject(obj);
 
   if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
       !npobj->_class->hasMethod || !npobj->_class->getProperty) {
     ThrowJSException(cx, "Bad NPObject as private data!");
 
     return JS_FALSE;
   }
 
@@ -1388,26 +1388,26 @@ NPObjWrapper_GetProperty(JSContext *cx, 
   return JS_TRUE;
 }
 
 static JSBool
 CallNPMethodInternal(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
                      jsval *rval, bool ctorCall)
 {
   while (obj && JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
-    obj = ::JS_GetPrototype(cx, obj);
+    obj = ::JS_GetPrototype(obj);
   }
 
   if (!obj) {
     ThrowJSException(cx, "NPMethod called on non-NPObject wrapped JSObject!");
 
     return JS_FALSE;
   }
 
-  NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
+  NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
 
   if (!npobj || !npobj->_class) {
     ThrowJSException(cx, "Bad NPObject as private data!");
 
     return JS_FALSE;
   }
 
   // Find out what plugin (NPP) is the owner of the object we're
@@ -1540,17 +1540,17 @@ struct NPObjectEnumerateState {
   PRUint32     length;
   NPIdentifier *value;
 };
 
 static JSBool
 NPObjWrapper_newEnumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
                           jsval *statep, jsid *idp)
 {
-  NPObject *npobj = GetNPObject(cx, obj);
+  NPObject *npobj = GetNPObject(obj);
   NPIdentifier *enum_value;
   uint32_t length;
   NPObjectEnumerateState *state;
 
   if (!npobj || !npobj->_class) {
     ThrowJSException(cx, "Bad NPObject as private data!");
     return JS_FALSE;
   }
@@ -1620,17 +1620,17 @@ NPObjWrapper_newEnumerate(JSContext *cx,
 
   return JS_TRUE;
 }
 
 static JSBool
 NPObjWrapper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
                         JSObject **objp)
 {
-  NPObject *npobj = GetNPObject(cx, obj);
+  NPObject *npobj = GetNPObject(obj);
 
   if (!npobj || !npobj->_class || !npobj->_class->hasProperty ||
       !npobj->_class->hasMethod) {
     ThrowJSException(cx, "Bad NPObject as private data!");
 
     return JS_FALSE;
   }
 
@@ -1709,17 +1709,17 @@ NPObjWrapper_Convert(JSContext *cx, JSOb
                        ? "number"
                        : "string");
   return false;
 }
 
 static void
 NPObjWrapper_Finalize(JSContext *cx, JSObject *obj)
 {
-  NPObject *npobj = (NPObject *)::JS_GetPrivate(cx, obj);
+  NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
   if (npobj) {
     if (sNPObjWrappers.ops) {
       PL_DHashTableOperate(&sNPObjWrappers, npobj, PL_DHASH_REMOVE);
     }
   }
 
   if (!sDelayedReleases)
     sDelayedReleases = new nsTArray<NPObject*>;
@@ -1775,21 +1775,17 @@ nsNPObjWrapper::OnDestroy(NPObject *npob
 
   NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
     (PL_DHashTableOperate(&sNPObjWrappers, npobj, PL_DHASH_LOOKUP));
 
   if (PL_DHASH_ENTRY_IS_BUSY(entry) && entry->mJSObj) {
     // Found a live NPObject wrapper, null out its JSObjects' private
     // data.
 
-    JSContext *cx = GetJSContext(entry->mNpp);
-
-    if (cx) {
-      ::JS_SetPrivate(cx, entry->mJSObj, nsnull);
-    }
+    ::JS_SetPrivate(entry->mJSObj, nsnull);
 
     // Remove the npobj from the hash now that it went away.
     PL_DHashTableRawRemove(&sNPObjWrappers, entry);
 
     OnWrapperDestroyed();
   }
 }
 
@@ -1871,18 +1867,17 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
 
     return nsnull;
   }
 
   OnWrapperCreated();
 
   entry->mJSObj = obj;
 
-  // JS_SetPrivate() never fails.
-  ::JS_SetPrivate(cx, obj, npobj);
+  ::JS_SetPrivate(obj, npobj);
 
   // The new JSObject now holds on to npobj
   _retainobject(npobj);
 
   return obj;
 }
 
 
@@ -1955,20 +1950,17 @@ NPObjWrapperPluginDestroyedCallback(PLDH
     // Force deallocation of plugin objects since the plugin they came
     // from is being torn down.
     if (npobj->_class && npobj->_class->deallocate) {
       npobj->_class->deallocate(npobj);
     } else {
       PR_Free(npobj);
     }
 
-    JSAutoEnterCompartment ac;
-    if (ac.enter(nppcx->cx, entry->mJSObj)) {
-      ::JS_SetPrivate(nppcx->cx, entry->mJSObj, nsnull);
-    }
+    ::JS_SetPrivate(entry->mJSObj, nsnull);
 
     table->ops = ops;    
 
     return PL_DHASH_REMOVE;
   }
 
   return PL_DHASH_NEXT;
 }
@@ -2069,20 +2061,20 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
     return;
   }
 
   // Loop over the DOM element's JS object prototype chain and remove
   // all JS objects of the class sNPObjectJSWrapperClass (there should
   // be only one, but remove all instances found in case the page put
   // more than one of the plugin's scriptable objects on the prototype
   // chain).
-  while (obj && (proto = ::JS_GetPrototype(cx, obj))) {
+  while (obj && (proto = ::JS_GetPrototype(obj))) {
     if (JS_GetClass(proto) == &sNPObjectJSWrapperClass) {
       // We found an NPObject on the proto chain, get its prototype...
-      proto = ::JS_GetPrototype(cx, proto);
+      proto = ::JS_GetPrototype(proto);
 
       // ... and pull it out of the chain.
       ::JS_SetPrototype(cx, obj, proto);
     }
 
     obj = proto;
   }
 }
@@ -2135,17 +2127,17 @@ CreateNPObjectMember(NPP npp, JSContext 
   if (!memobj) {
     PR_Free(memberPrivate);
     return JS_FALSE;
   }
 
   *vp = OBJECT_TO_JSVAL(memobj);
   ::JS_AddValueRoot(cx, vp);
 
-  ::JS_SetPrivate(cx, memobj, (void *)memberPrivate);
+  ::JS_SetPrivate(memobj, (void *)memberPrivate);
 
   NPIdentifier identifier = JSIdToNPIdentifier(id);
 
   jsval fieldValue;
   NPVariant npv;
 
   if (getPropertyResult) {
     // Plugin has already handed us the value we want here.
@@ -2168,17 +2160,17 @@ CreateNPObjectMember(NPP npp, JSContext 
   }
 
   fieldValue = NPVariantToJSVal(npp, cx, &npv);
 
   // npobjWrapper is the JSObject through which we make sure we don't
   // outlive the underlying NPObject, so make sure it points to the
   // real JSObject wrapper for the NPObject.
   while (JS_GetClass(obj) != &sNPObjectJSWrapperClass) {
-    obj = ::JS_GetPrototype(cx, obj);
+    obj = ::JS_GetPrototype(obj);
   }
 
   memberPrivate->npobjWrapper = obj;
 
   memberPrivate->fieldValue = fieldValue;
   memberPrivate->methodName = identifier;
   memberPrivate->npp = npp;
 
@@ -2221,17 +2213,17 @@ NPObjectMember_Convert(JSContext *cx, JS
   }
 }
 
 static void
 NPObjectMember_Finalize(JSContext *cx, JSObject *obj)
 {
   NPObjectMemberPrivate *memberPrivate;
 
-  memberPrivate = (NPObjectMemberPrivate *)::JS_GetPrivate(cx, obj);
+  memberPrivate = (NPObjectMemberPrivate *)::JS_GetPrivate(obj);
   if (!memberPrivate)
     return;
 
   PR_Free(memberPrivate);
 }
 
 static JSBool
 NPObjectMember_Call(JSContext *cx, uintN argc, jsval *vp)
@@ -2241,17 +2233,17 @@ NPObjectMember_Call(JSContext *cx, uintN
 
   NPObjectMemberPrivate *memberPrivate =
     (NPObjectMemberPrivate *)::JS_GetInstancePrivate(cx, memobj,
                                                      &sNPObjectMemberClass,
                                                      JS_ARGV(cx, vp));
   if (!memberPrivate || !memberPrivate->npobjWrapper)
     return JS_FALSE;
 
-  NPObject *npobj = GetNPObject(cx, memberPrivate->npobjWrapper);
+  NPObject *npobj = GetNPObject(memberPrivate->npobjWrapper);
   if (!npobj) {
     ThrowJSException(cx, "Call on invalid member object");
 
     return JS_FALSE;
   }
 
   NPVariant npargs_buf[8];
   NPVariant *npargs = npargs_buf;
@@ -2314,17 +2306,17 @@ NPObjectMember_Call(JSContext *cx, uintN
 
   return ReportExceptionIfPending(cx);
 }
 
 static void
 NPObjectMember_Trace(JSTracer *trc, JSObject *obj)
 {
   NPObjectMemberPrivate *memberPrivate =
-    (NPObjectMemberPrivate *)::JS_GetPrivate(trc->context, obj);
+    (NPObjectMemberPrivate *)::JS_GetPrivate(obj);
   if (!memberPrivate)
     return;
 
   // Our NPIdentifier is not always interned, so we must root it explicitly.
   jsid id = NPIdentifierToJSId(memberPrivate->methodName);
   if (JSID_IS_STRING(id))
     JS_CALL_STRING_TRACER(trc, JSID_TO_STRING(id), "NPObjectMemberPrivate.methodName");
 
--- a/dom/workers/ChromeWorkerScope.cpp
+++ b/dom/workers/ChromeWorkerScope.cpp
@@ -89,22 +89,23 @@ CTypesLazyGetter(JSContext* aCx, JSObjec
   WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx);
   NS_ASSERTION(worker->IsChromeWorker(), "This should always be true!");
 
   if (!worker->DisableMemoryReporter()) {
     return false;
   }
 
   jsval ctypes;
-  return JS_DeletePropertyById(aCx, aObj, aId) &&
-         JS_InitCTypesClass(aCx, aObj) &&
-         JS_GetPropertyById(aCx, aObj, aId, &ctypes) &&
-         JS_SetCTypesCallbacks(aCx, JSVAL_TO_OBJECT(ctypes),
-                               &gCTypesCallbacks) &&
-         JS_GetPropertyById(aCx, aObj, aId, aVp);
+  if (!JS_DeletePropertyById(aCx, aObj, aId) ||
+      !JS_InitCTypesClass(aCx, aObj) ||
+      !JS_GetPropertyById(aCx, aObj, aId, &ctypes)) {
+    return false;
+  }
+  JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &gCTypesCallbacks);
+  return JS_GetPropertyById(aCx, aObj, aId, aVp);
 }
 #endif
 
 inline bool
 DefineCTypesLazyGetter(JSContext* aCx, JSObject* aGlobal)
 {
 #ifdef BUILD_CTYPES
   {
--- a/dom/workers/EventTarget.cpp
+++ b/dom/workers/EventTarget.cpp
@@ -80,19 +80,19 @@ EnsureObjectIsEventTarget(JSContext* aCx
 
   JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                        "EventTarget", aFunctionName, classPtr->name);
   return false;
 }
 
 inline
 EventTarget*
-GetPrivate(JSContext* aCx, JSObject* aObj)
+GetPrivate(JSObject* aObj)
 {
-  return GetJSPrivateSafeish<EventTarget>(aCx, aObj);
+  return GetJSPrivateSafeish<EventTarget>(aObj);
 }
 
 JSBool
 Construct(JSContext* aCx, uintN aArgc, jsval* aVp)
 {
   JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_WRONG_CONSTRUCTOR,
                        gClass.name);
   return false;
@@ -144,35 +144,35 @@ EventTarget::SetEventListenerOnEventTarg
     return false;
   }
 
   return mListenerManager.SetEventListener(aCx, type, *aVp);
 }
 
 // static
 EventTarget*
-EventTarget::FromJSObject(JSContext* aCx, JSObject* aObj)
+EventTarget::FromJSObject(JSObject* aObj)
 {
-  return GetPrivate(aCx, aObj);
+  return GetPrivate(aObj);
 }
 
 // static
 JSBool
 EventTarget::AddEventListener(JSContext* aCx, uintN aArgc, jsval* aVp)
 {
   JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
   if (!obj) {
     return true;
   }
 
   if (!EnsureObjectIsEventTarget(aCx, obj, "AddEventListener")) {
     return false;
   }
 
-  EventTarget* self = GetPrivate(aCx, obj);
+  EventTarget* self = GetPrivate(obj);
   if (!self) {
     return true;
   }
 
   JSString* type;
   JSObject* listener;
   JSBool capturing = false, wantsUntrusted = false;
   if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "So/bb", &type,
@@ -197,17 +197,17 @@ EventTarget::RemoveEventListener(JSConte
   if (!obj) {
     return true;
   }
 
   if (!EnsureObjectIsEventTarget(aCx, obj, "RemoveEventListener")) {
     return false;
   }
 
-  EventTarget* self = GetPrivate(aCx, obj);
+  EventTarget* self = GetPrivate(obj);
   if (!self) {
     return true;
   }
 
   JSString* type;
   JSObject* listener;
   JSBool capturing = false;
   if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "So/b", &type,
@@ -232,17 +232,17 @@ EventTarget::DispatchEvent(JSContext* aC
   if (!obj) {
     return true;
   }
 
   if (!EnsureObjectIsEventTarget(aCx, obj, "DispatchEvent")) {
     return false;
   }
 
-  EventTarget* self = GetPrivate(aCx, obj);
+  EventTarget* self = GetPrivate(obj);
   if (!self) {
     return true;
   }
 
   JSObject* event;
   if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "o", &event)) {
     return false;
   }
--- a/dom/workers/EventTarget.h
+++ b/dom/workers/EventTarget.h
@@ -72,17 +72,17 @@ protected:
   bool
   GetEventListenerOnEventTarget(JSContext* aCx, const char* aType, jsval* aVp);
 
   bool
   SetEventListenerOnEventTarget(JSContext* aCx, const char* aType, jsval* aVp);
 
 public:
   static EventTarget*
-  FromJSObject(JSContext* aCx, JSObject* aObj);
+  FromJSObject(JSObject* aObj);
 
   static JSBool
   AddEventListener(JSContext* aCx, uintN aArgc, jsval* aVp);
 
   static JSBool
   RemoveEventListener(JSContext* aCx, uintN aArgc, jsval* aVp);
 
   static JSBool
--- a/dom/workers/Events.cpp
+++ b/dom/workers/Events.cpp
@@ -123,60 +123,51 @@ public:
   Create(JSContext* aCx, JSObject* aParent, JSString* aType, bool aBubbles,
          bool aCancelable, bool aMainRuntime)
   {
     JSClass* clasp = aMainRuntime ? &sMainRuntimeClass : &sClass;
 
     JSObject* obj = JS_NewObject(aCx, clasp, NULL, aParent);
     if (obj) {
       Event* priv = new Event();
-      if (!SetJSPrivateSafeish(aCx, obj, priv) ||
-          !InitEventCommon(aCx, obj, priv, aType, aBubbles, aCancelable,
-                           true)) {
-        SetJSPrivateSafeish(aCx, obj, NULL);
-        delete priv;
-        return NULL;
-      }
+      SetJSPrivateSafeish(obj, priv);
+      InitEventCommon(obj, priv, aType, aBubbles, aCancelable, true);
     }
     return obj;
   }
 
   static bool
-  IsSupportedClass(JSContext* aCx, JSObject* aEvent)
+  IsSupportedClass(JSObject* aEvent)
   {
-    return !!GetPrivate(aCx, aEvent);
+    return !!GetPrivate(aEvent);
+  }
+
+  static void
+  SetTarget(JSObject* aEvent, JSObject* aTarget)
+  {
+    JS_ASSERT(IsSupportedClass(aEvent));
+
+    jsval target = OBJECT_TO_JSVAL(aTarget);
+    JS_SetReservedSlot(aEvent, SLOT_target, target);
+    JS_SetReservedSlot(aEvent, SLOT_currentTarget, target);
   }
 
   static bool
-  SetTarget(JSContext* aCx, JSObject* aEvent, JSObject* aTarget)
+  WasCanceled(JSObject* aEvent)
   {
-    JS_ASSERT(IsSupportedClass(aCx, aEvent));
-
-    jsval target = OBJECT_TO_JSVAL(aTarget);
-    return JS_SetReservedSlot(aCx, aEvent, SLOT_target, target) &&
-           JS_SetReservedSlot(aCx, aEvent, SLOT_currentTarget, target);
-  }
+    JS_ASSERT(IsSupportedClass(aEvent));
 
-  static bool
-  WasCanceled(JSContext* aCx, JSObject* aEvent)
-  {
-    JS_ASSERT(IsSupportedClass(aCx, aEvent));
-
-    jsval canceled;
-    if (!GetPropertyCommon(aCx, aEvent, SLOT_defaultPrevented, &canceled)) {
-      return false;
-    }
-
+    jsval canceled = JS_GetReservedSlot(aEvent, SLOT_defaultPrevented);
     return JSVAL_TO_BOOLEAN(canceled);
   }
 
   static bool
-  ImmediatePropagationStopped(JSContext* aCx, JSObject* aEvent)
+  ImmediatePropagationStopped(JSObject* aEvent)
   {
-    Event* event = GetPrivate(aCx, aEvent);
+    Event* event = GetPrivate(aEvent);
     return event ? event->mStopImmediatePropagationCalled : false;
   }
 
 protected:
   Event()
   : mStopPropagationCalled(false), mStopImmediatePropagationCalled(false)
   {
     MOZ_COUNT_CTOR(mozilla::dom::workers::Event);
@@ -204,99 +195,82 @@ protected:
     SLOT_defaultPrevented,
     SLOT_isTrusted,
 
     SLOT_COUNT,
     SLOT_FIRST = SLOT_type
   };
 
   static Event*
-  GetPrivate(JSContext* aCx, JSObject* aEvent);
+  GetPrivate(JSObject* aEvent);
 
   static Event*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
-    Event* priv = GetPrivate(aCx, aObj);
+    Event* priv = GetPrivate(aObj);
     if (priv) {
       return priv;
     }
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          JS_GetClass(aObj)->name);
     return NULL;
   }
 
-  static JSBool
-  InitEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
-                  JSString* aType, JSBool aBubbles, JSBool aCancelable,
-                  bool aIsTrusted)
+  static void
+  InitEventCommon(JSObject* aObj, Event* aEvent, JSString* aType,
+                  JSBool aBubbles, JSBool aCancelable, bool aIsTrusted)
   {
     aEvent->mStopPropagationCalled = false;
     aEvent->mStopImmediatePropagationCalled = false;
 
-    jsval now;
-    if (!JS_NewNumberValue(aCx, JS_Now(), &now)) {
-      return false;
-    }
-
-    if (!JS_SetReservedSlot(aCx, aObj, SLOT_type, STRING_TO_JSVAL(aType)) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_target, JSVAL_NULL) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_currentTarget, JSVAL_NULL) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_eventPhase,
-                            INT_TO_JSVAL(CAPTURING_PHASE)) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_bubbles,
-                            aBubbles ? JSVAL_TRUE : JSVAL_FALSE) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_cancelable,
-                            aCancelable ? JSVAL_TRUE : JSVAL_FALSE) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_timeStamp, now) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_defaultPrevented, JSVAL_FALSE) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_isTrusted,
-                            aIsTrusted ? JSVAL_TRUE : JSVAL_FALSE)) {
-      return false;
-    }
-
-    return true;
-  }
-
-  static JSBool
-  GetPropertyCommon(JSContext* aCx, JSObject* aObj, int32 aSlot, jsval* aVp)
-  {
-    JS_ASSERT(aSlot >= 0 && aSlot < SLOT_COUNT);
-    return JS_GetReservedSlot(aCx, aObj, aSlot, aVp);
+    JS_SetReservedSlot(aObj, SLOT_type, STRING_TO_JSVAL(aType));
+    JS_SetReservedSlot(aObj, SLOT_target, JSVAL_NULL);
+    JS_SetReservedSlot(aObj, SLOT_currentTarget, JSVAL_NULL);
+    JS_SetReservedSlot(aObj, SLOT_eventPhase, INT_TO_JSVAL(CAPTURING_PHASE));
+    JS_SetReservedSlot(aObj, SLOT_bubbles,
+                       aBubbles ? JSVAL_TRUE : JSVAL_FALSE);
+    JS_SetReservedSlot(aObj, SLOT_cancelable,
+                       aCancelable ? JSVAL_TRUE : JSVAL_FALSE);
+    JS_SetReservedSlot(aObj, SLOT_timeStamp, JS::NumberValue(double(JS_Now())));
+    JS_SetReservedSlot(aObj, SLOT_defaultPrevented, JSVAL_FALSE);
+    JS_SetReservedSlot(aObj, SLOT_isTrusted,
+                       aIsTrusted ? JSVAL_TRUE : JSVAL_FALSE);
   }
 
 private:
   static JSBool
   Construct(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_WRONG_CONSTRUCTOR,
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
-    delete GetJSPrivateSafeish<Event>(aCx, aObj);
+    delete GetJSPrivateSafeish<Event>(aObj);
   }
 
   static JSBool
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(aIdval));
 
     int32 slot = JSID_TO_INT(aIdval);
 
     const char*& name = sProperties[slot - SLOT_FIRST].name;
     if (!GetInstancePrivate(aCx, aObj, name)) {
       return false;
     }
 
-    return GetPropertyCommon(aCx, aObj, slot, aVp);
+    *aVp = JS_GetReservedSlot(aObj, slot);
+    return true;
   }
 
   static JSBool
   GetConstant(JSContext* aCx, JSObject* aObj, jsid idval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(idval));
     JS_ASSERT(JSID_TO_INT(idval) >= CAPTURING_PHASE &&
               JSID_TO_INT(idval) <= BUBBLING_PHASE);
@@ -349,24 +323,21 @@ private:
       return false;
     }
 
     Event* event = GetInstancePrivate(aCx, obj, sFunctions[1].name);
     if (!event) {
       return false;
     }
 
-    jsval cancelableVal;
-    if (!GetPropertyCommon(aCx, obj, SLOT_cancelable, &cancelableVal)) {
-      return false;
-    }
+    jsval cancelableVal = JS_GetReservedSlot(obj, SLOT_cancelable);
 
-    return JSVAL_TO_BOOLEAN(cancelableVal) ?
-           JS_SetReservedSlot(aCx, obj, SLOT_defaultPrevented, cancelableVal) :
-           true;
+    if (JSVAL_TO_BOOLEAN(cancelableVal))
+      JS_SetReservedSlot(obj, SLOT_defaultPrevented, cancelableVal);
+    return true;
   }
 
   static JSBool
   InitEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
     if (!obj) {
       return false;
@@ -379,17 +350,18 @@ private:
 
     JSString* type;
     JSBool bubbles, cancelable;
     if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "Sbb", &type,
                              &bubbles, &cancelable)) {
       return false;
     }
 
-    return InitEventCommon(aCx, obj, event, type, bubbles, cancelable, false);
+    InitEventCommon(obj, event, type, bubbles, cancelable, false);
+    return true;
   }
 };
 
 #define DECL_EVENT_CLASS(_varname, _name) \
   JSClass _varname = { \
     _name, \
     JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), \
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, \
@@ -481,24 +453,19 @@ public:
     JSClass* clasp = aMainRuntime ? &sMainRuntimeClass : &sClass;
 
     JSObject* obj = JS_NewObject(aCx, clasp, NULL, aParent);
     if (!obj) {
       return NULL;
     }
 
     MessageEvent* priv = new MessageEvent(aMainRuntime);
-    if (!SetJSPrivateSafeish(aCx, obj, priv) ||
-        !InitMessageEventCommon(aCx, obj, priv, type, false, false, NULL, NULL,
-                                NULL, true)) {
-      SetJSPrivateSafeish(aCx, obj, NULL);
-      delete priv;
-      return NULL;
-    }
-
+    SetJSPrivateSafeish(obj, priv);
+    InitMessageEventCommon(aCx, obj, priv, type, false, false, NULL, NULL, NULL,
+                           true);
     aData.steal(&priv->mData, &priv->mDataByteCount);
     priv->mClonedObjects.SwapElements(aClonedObjects);
 
     return obj;
   }
 
 protected:
   MessageEvent(bool aMainRuntime)
@@ -523,58 +490,55 @@ protected:
   };
 
 private:
   static MessageEvent*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
     JSClass* classPtr = JS_GetClass(aObj);
     if (IsThisClass(classPtr)) {
-      return GetJSPrivateSafeish<MessageEvent>(aCx, aObj);
+      return GetJSPrivateSafeish<MessageEvent>(aObj);
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          classPtr->name);
     return NULL;
   }
 
-  static JSBool
+  static void
   InitMessageEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
                          JSString* aType, JSBool aBubbles, JSBool aCancelable,
                          JSString* aData, JSString* aOrigin, JSObject* aSource,
                          bool aIsTrusted)
   {
     jsval emptyString = JS_GetEmptyStringValue(aCx);
 
-    if (!Event::InitEventCommon(aCx, aObj, aEvent, aType, aBubbles,
-                                aCancelable, aIsTrusted) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_data,
-                            aData ? STRING_TO_JSVAL(aData) : emptyString) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_origin,
-                            aOrigin ? STRING_TO_JSVAL(aOrigin) : emptyString) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_source, OBJECT_TO_JSVAL(aSource))) {
-      return false;
-    }
-    return true;
+    Event::InitEventCommon(aObj, aEvent, aType, aBubbles, aCancelable,
+                           aIsTrusted);
+    JS_SetReservedSlot(aObj, SLOT_data,
+                       aData ? STRING_TO_JSVAL(aData) : emptyString);
+    JS_SetReservedSlot(aObj, SLOT_origin,
+                       aOrigin ? STRING_TO_JSVAL(aOrigin) : emptyString);
+    JS_SetReservedSlot(aObj, SLOT_source, OBJECT_TO_JSVAL(aSource));
   }
 
   static JSBool
   Construct(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_WRONG_CONSTRUCTOR,
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
-    MessageEvent* priv = GetJSPrivateSafeish<MessageEvent>(aCx, aObj);
+    MessageEvent* priv = GetJSPrivateSafeish<MessageEvent>(aObj);
     if (priv) {
       JS_free(aCx, priv->mData);
 #ifdef DEBUG
       priv->mData = NULL;
 #endif
       delete priv;
     }
   }
@@ -604,26 +568,27 @@ private:
 
       // Release reference to objects that were AddRef'd for
       // cloning into worker when array goes out of scope.
       nsTArray<nsCOMPtr<nsISupports> > clonedObjects;
       clonedObjects.SwapElements(event->mClonedObjects);
 
       jsval data;
       if (!buffer.read(aCx, &data,
-                       WorkerStructuredCloneCallbacks(event->mMainRuntime)) ||
-          !JS_SetReservedSlot(aCx, aObj, slot, data)) {
+                       WorkerStructuredCloneCallbacks(event->mMainRuntime))) {
         return false;
       }
+      JS_SetReservedSlot(aObj, slot, data);
 
       *aVp = data;
       return true;
     }
 
-    return JS_GetReservedSlot(aCx, aObj, slot, aVp);
+    *aVp = JS_GetReservedSlot(aObj, slot);
+    return true;
   }
 
   static JSBool
   InitMessageEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
     if (!obj) {
       return false;
@@ -637,18 +602,19 @@ private:
     JSString* type, *data, *origin;
     JSBool bubbles, cancelable;
     JSObject* source;
     if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "SbbSSo", &type,
                              &bubbles, &cancelable, &data, &origin, &source)) {
       return false;
     }
 
-    return InitMessageEventCommon(aCx, obj, event, type, bubbles, cancelable,
-                                  data, origin, source, false);
+    InitMessageEventCommon(aCx, obj, event, type, bubbles, cancelable,
+                           data, origin, source, false);
+    return true;
   }
 };
 
 #define DECL_MESSAGEEVENT_CLASS(_varname, _name) \
   JSClass _varname = { \
     _name, \
     JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), \
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, \
@@ -712,23 +678,19 @@ public:
     JSClass* clasp = aMainRuntime ? &sMainRuntimeClass : &sClass;
 
     JSObject* obj = JS_NewObject(aCx, clasp, NULL, aParent);
     if (!obj) {
       return NULL;
     }
 
     ErrorEvent* priv = new ErrorEvent();
-    if (!SetJSPrivateSafeish(aCx, obj, priv) ||
-        !InitErrorEventCommon(aCx, obj, priv, type, false, true, aMessage,
-                              aFilename, aLineNumber, true)) {
-      SetJSPrivateSafeish(aCx, obj, NULL);
-      delete priv;
-      return NULL;
-    }
+    SetJSPrivateSafeish(obj, priv);
+    InitErrorEventCommon(obj, priv, type, false, true, aMessage, aFilename,
+                         aLineNumber, true);
     return obj;
   }
 
 protected:
   ErrorEvent()
   {
     MOZ_COUNT_CTOR(mozilla::dom::workers::ErrorEvent);
   }
@@ -748,57 +710,51 @@ protected:
   };
 
 private:
   static ErrorEvent*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
     JSClass* classPtr = JS_GetClass(aObj);
     if (IsThisClass(classPtr)) {
-      return GetJSPrivateSafeish<ErrorEvent>(aCx, aObj);
+      return GetJSPrivateSafeish<ErrorEvent>(aObj);
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          classPtr->name);
     return NULL;
   }
 
-  static JSBool
-  InitErrorEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
-                       JSString* aType, JSBool aBubbles, JSBool aCancelable,
+  static void
+  InitErrorEventCommon(JSObject* aObj, Event* aEvent, JSString* aType,
+                       JSBool aBubbles, JSBool aCancelable,
                        JSString* aMessage, JSString* aFilename,
                        uint32 aLineNumber, bool aIsTrusted)
   {
-    if (!Event::InitEventCommon(aCx, aObj, aEvent, aType, aBubbles,
-                                aCancelable, aIsTrusted) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_message,
-                            STRING_TO_JSVAL(aMessage)) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_filename,
-                            STRING_TO_JSVAL(aFilename)) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_lineno,
-                            INT_TO_JSVAL(aLineNumber))) {
-      return false;
-    }
-    return true;
+    Event::InitEventCommon(aObj, aEvent, aType, aBubbles, aCancelable,
+                           aIsTrusted);
+    JS_SetReservedSlot(aObj, SLOT_message, STRING_TO_JSVAL(aMessage));
+    JS_SetReservedSlot(aObj, SLOT_filename, STRING_TO_JSVAL(aFilename));
+    JS_SetReservedSlot(aObj, SLOT_lineno, INT_TO_JSVAL(aLineNumber));
   }
 
   static JSBool
   Construct(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_WRONG_CONSTRUCTOR,
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(IsThisClass(JS_GetClass(aObj)));
-    delete GetJSPrivateSafeish<ErrorEvent>(aCx, aObj);
+    delete GetJSPrivateSafeish<ErrorEvent>(aObj);
   }
 
   static JSBool
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(aIdval));
 
     int32 slot = JSID_TO_INT(aIdval);
@@ -806,17 +762,18 @@ private:
     JS_ASSERT(slot >= SLOT_message && slot < SLOT_COUNT);
 
     const char*& name = sProperties[slot - SLOT_FIRST].name;
     ErrorEvent* event = GetInstancePrivate(aCx, aObj, name);
     if (!event) {
       return false;
     }
 
-    return JS_GetReservedSlot(aCx, aObj, slot, aVp);
+    *aVp = JS_GetReservedSlot(aObj, slot);
+    return true;
   }
 
   static JSBool
   InitErrorEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
     if (!obj) {
       return false;
@@ -831,18 +788,19 @@ private:
     JSBool bubbles, cancelable;
     uint32_t lineNumber;
     if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "SbbSSu", &type,
                              &bubbles, &cancelable, &message, &filename,
                              &lineNumber)) {
       return false;
     }
 
-    return InitErrorEventCommon(aCx, obj, event, type, bubbles, cancelable,
-                                message, filename, lineNumber, false);
+    InitErrorEventCommon(obj, event, type, bubbles, cancelable, message,
+                         filename, lineNumber, false);
+    return true;
   }
 };
 
 #define DECL_ERROREVENT_CLASS(_varname, _name) \
   JSClass _varname = { \
     _name, \
     JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT), \
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, \
@@ -900,23 +858,19 @@ public:
     }
 
     JSObject* obj = JS_NewObject(aCx, &sClass, NULL, aParent);
     if (!obj) {
       return NULL;
     }
 
     ProgressEvent* priv = new ProgressEvent();
-    if (!SetJSPrivateSafeish(aCx, obj, priv) ||
-        !InitProgressEventCommon(aCx, obj, priv, type, false, false,
-                                 aLengthComputable, aLoaded, aTotal, true)) {
-      SetJSPrivateSafeish(aCx, obj, NULL);
-      delete priv;
-      return NULL;
-    }
+    SetJSPrivateSafeish(obj, priv);
+    InitProgressEventCommon(obj, priv, type, false, false, aLengthComputable,
+                            aLoaded, aTotal, true);
     return obj;
   }
 
 protected:
   ProgressEvent()
   {
     MOZ_COUNT_CTOR(mozilla::dom::workers::ProgressEvent);
   }
@@ -936,55 +890,52 @@ protected:
   };
 
 private:
   static ProgressEvent*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
     JSClass* classPtr = JS_GetClass(aObj);
     if (classPtr == &sClass) {
-      return GetJSPrivateSafeish<ProgressEvent>(aCx, aObj);
+      return GetJSPrivateSafeish<ProgressEvent>(aObj);
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          classPtr->name);
     return NULL;
   }
 
-  static JSBool
-  InitProgressEventCommon(JSContext* aCx, JSObject* aObj, Event* aEvent,
-                          JSString* aType, JSBool aBubbles, JSBool aCancelable,
+  static void
+  InitProgressEventCommon(JSObject* aObj, Event* aEvent, JSString* aType,
+                          JSBool aBubbles, JSBool aCancelable,
                           JSBool aLengthComputable, jsdouble aLoaded,
                           jsdouble aTotal, bool aIsTrusted)
   {
-    if (!Event::InitEventCommon(aCx, aObj, aEvent, aType, aBubbles,
-                                aCancelable, aIsTrusted) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_lengthComputable,
-                            aLengthComputable ? JSVAL_TRUE : JSVAL_FALSE) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_loaded, DOUBLE_TO_JSVAL(aLoaded)) ||
-        !JS_SetReservedSlot(aCx, aObj, SLOT_total, DOUBLE_TO_JSVAL(aTotal))) {
-      return false;
-    }
-    return true;
+    Event::InitEventCommon(aObj, aEvent, aType, aBubbles, aCancelable,
+                           aIsTrusted);
+    JS_SetReservedSlot(aObj, SLOT_lengthComputable,
+                       aLengthComputable ? JSVAL_TRUE : JSVAL_FALSE);
+    JS_SetReservedSlot(aObj, SLOT_loaded, DOUBLE_TO_JSVAL(aLoaded));
+    JS_SetReservedSlot(aObj, SLOT_total, DOUBLE_TO_JSVAL(aTotal));
   }
 
   static JSBool
   Construct(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_WRONG_CONSTRUCTOR,
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    delete GetJSPrivateSafeish<ProgressEvent>(aCx, aObj);
+    delete GetJSPrivateSafeish<ProgressEvent>(aObj);
   }
 
   static JSBool
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(aIdval));
 
     int32 slot = JSID_TO_INT(aIdval);
@@ -992,17 +943,18 @@ private:
     JS_ASSERT(slot >= SLOT_lengthComputable && slot < SLOT_COUNT);
 
     const char*& name = sProperties[slot - SLOT_FIRST].name;
     ProgressEvent* event = GetInstancePrivate(aCx, aObj, name);
     if (!event) {
       return false;
     }
 
-    return JS_GetReservedSlot(aCx, aObj, slot, aVp);
+    *aVp = JS_GetReservedSlot(aObj, slot);
+    return true;
   }
 
   static JSBool
   InitProgressEvent(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
     if (!obj) {
       return false;
@@ -1017,18 +969,19 @@ private:
     JSBool bubbles, cancelable, lengthComputable;
     jsdouble loaded, total;
     if (!JS_ConvertArguments(aCx, aArgc, JS_ARGV(aCx, aVp), "Sbbbdd", &type,
                              &bubbles, &cancelable, &lengthComputable, &loaded,
                              &total)) {
       return false;
     }
 
-    return InitProgressEventCommon(aCx, obj, event, type, bubbles, cancelable,
-                                   lengthComputable, loaded, total, false);
+    InitProgressEventCommon(obj, event, type, bubbles, cancelable,
+                            lengthComputable, loaded, total, false);
+    return true;
   }
 };
 
 JSClass ProgressEvent::sClass = {
   "ProgressEvent",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
   JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
@@ -1046,25 +999,25 @@ JSPropertySpec ProgressEvent::sPropertie
 };
 
 JSFunctionSpec ProgressEvent::sFunctions[] = {
   JS_FN("initProgressEvent", InitProgressEvent, 6, FUNCTION_FLAGS),
   JS_FS_END
 };
 
 Event*
-Event::GetPrivate(JSContext* aCx, JSObject* aObj)
+Event::GetPrivate(JSObject* aObj)
 {
   if (aObj) {
     JSClass* classPtr = JS_GetClass(aObj);
     if (IsThisClass(classPtr) ||
         MessageEvent::IsThisClass(classPtr) ||
         ErrorEvent::IsThisClass(classPtr) ||
         classPtr == ProgressEvent::Class()) {
-      return GetJSPrivateSafeish<Event>(aCx, aObj);
+      return GetJSPrivateSafeish<Event>(aObj);
     }
   }
   return NULL;
 }
 
 } /* anonymous namespace */
 
 BEGIN_WORKERS_NAMESPACE
@@ -1115,37 +1068,37 @@ CreateProgressEvent(JSContext* aCx, JSSt
                     jsdouble aLoaded, jsdouble aTotal)
 {
   JSObject* global = JS_GetGlobalForScopeChain(aCx);
   return ProgressEvent::Create(aCx, global, aType, aLengthComputable, aLoaded,
                                aTotal);
 }
 
 bool
-IsSupportedEventClass(JSContext* aCx, JSObject* aEvent)
+IsSupportedEventClass(JSObject* aEvent)
 {
-  return Event::IsSupportedClass(aCx, aEvent);
+  return Event::IsSupportedClass(aEvent);
+}
+
+void
+SetEventTarget(JSObject* aEvent, JSObject* aTarget)
+{
+  Event::SetTarget(aEvent, aTarget);
 }
 
 bool
-SetEventTarget(JSContext* aCx, JSObject* aEvent, JSObject* aTarget)
+EventWasCanceled(JSObject* aEvent)
 {
-  return Event::SetTarget(aCx, aEvent, aTarget);
+  return Event::WasCanceled(aEvent);
 }
 
 bool
-EventWasCanceled(JSContext* aCx, JSObject* aEvent)
+EventImmediatePropagationStopped(JSObject* aEvent)
 {
-  return Event::WasCanceled(aCx, aEvent);
-}
-
-bool
-EventImmediatePropagationStopped(JSContext* aCx, JSObject* aEvent)
-{
-  return Event::ImmediatePropagationStopped(aCx, aEvent);
+  return Event::ImmediatePropagationStopped(aEvent);
 }
 
 bool
 DispatchEventToTarget(JSContext* aCx, JSObject* aTarget, JSObject* aEvent,
                       bool* aPreventDefaultCalled)
 {
   static const char kFunctionName[] = "dispatchEvent";
   JSBool hasProperty;
--- a/dom/workers/Events.h
+++ b/dom/workers/Events.h
@@ -67,26 +67,26 @@ JSObject*
 CreateErrorEvent(JSContext* aCx, JSString* aMessage, JSString* aFilename,
                  uint32 aLineNumber, bool aMainRuntime);
 
 JSObject*
 CreateProgressEvent(JSContext* aCx, JSString* aType, bool aLengthComputable,
                     jsdouble aLoaded, jsdouble aTotal);
 
 bool
-IsSupportedEventClass(JSContext* aCx, JSObject* aEvent);
+IsSupportedEventClass(JSObject* aEvent);
+
+void
+SetEventTarget(JSObject* aEvent, JSObject* aTarget);
 
 bool
-SetEventTarget(JSContext* aCx, JSObject* aEvent, JSObject* aTarget);
+EventWasCanceled(JSObject* aEvent);
 
 bool
-EventWasCanceled(JSContext* aCx, JSObject* aEvent);
-
-bool
-EventImmediatePropagationStopped(JSContext* aCx, JSObject* aEvent);
+EventImmediatePropagationStopped(JSObject* aEvent);
 
 bool
 DispatchEventToTarget(JSContext* aCx, JSObject* aTarget, JSObject* aEvent,
                       bool* aPreventDefaultCalled);
 
 } // namespace events
 
 END_WORKERS_NAMESPACE
--- a/dom/workers/Exceptions.cpp
+++ b/dom/workers/Exceptions.cpp
@@ -109,17 +109,17 @@ private:
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    delete GetJSPrivateSafeish<DOMException>(aCx, aObj);
+    delete GetJSPrivateSafeish<DOMException>(aObj);
   }
 
   static JSBool
   ToString(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
     if (!obj) {
       return false;
@@ -136,21 +136,17 @@ private:
     char buf[100];
     JS_snprintf(buf, sizeof(buf), "%s: ", sClass.name);
 
     JSString* classString = JS_NewStringCopyZ(aCx, buf);
     if (!classString) {
       return false;
     }
 
-    jsval name;
-    if (!JS_GetReservedSlot(aCx, obj, SLOT_name, &name)) {
-      return false;
-    }
-
+    jsval name = JS_GetReservedSlot(obj, SLOT_name);
     JS_ASSERT(JSVAL_IS_STRING(name));
 
     JSString* out = JS_ConcatStrings(aCx, classString, JSVAL_TO_STRING(name));
     if (!out) {
       return false;
     }
 
     JS_SET_RVAL(aCx, aVp, STRING_TO_JSVAL(out));
@@ -161,24 +157,25 @@ private:
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(aIdval));
 
     int32 slot = JSID_TO_INT(aIdval);
 
     JSClass* classPtr = JS_GetClass(aObj);
 
-    if (classPtr != &sClass || !GetJSPrivateSafeish<DOMException>(aCx, aObj)) {
+    if (classPtr != &sClass || !GetJSPrivateSafeish<DOMException>(aObj)) {
       JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                            JSMSG_INCOMPATIBLE_PROTO, sClass.name,
                            sProperties[slot].name, classPtr->name);
       return false;
     }
 
-    return JS_GetReservedSlot(aCx, aObj, slot, aVp);
+    *aVp = JS_GetReservedSlot(aObj, slot);
+    return true;
   }
 
   static JSBool
   GetConstant(JSContext* aCx, JSObject* aObj, jsid idval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(idval));
     *aVp = INT_TO_JSVAL(JSID_TO_INT(idval));
     return true;
@@ -264,26 +261,21 @@ DOMException::Create(JSContext* aCx, int
     foundIndex = 0;
   }
 
   JSString* name = JS_NewStringCopyZ(aCx, sStaticProperties[foundIndex].name);
   if (!name) {
     return NULL;
   }
 
-  if (!JS_SetReservedSlot(aCx, obj, SLOT_code, INT_TO_JSVAL(aCode)) ||
-      !JS_SetReservedSlot(aCx, obj, SLOT_name, STRING_TO_JSVAL(name))) {
-    return NULL;
-  }
+  JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(aCode));
+  JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(name));
 
   DOMException* priv = new DOMException();
-  if (!SetJSPrivateSafeish(aCx, obj, priv)) {
-    delete priv;
-    return NULL;
-  }
+  SetJSPrivateSafeish(obj, priv);
 
   return obj;
 }
 
 class FileException : public PrivatizableBase
 {
   static JSClass sClass;
   static JSPropertySpec sProperties[];
@@ -325,36 +317,37 @@ private:
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    delete GetJSPrivateSafeish<FileException>(aCx, aObj);
+    delete GetJSPrivateSafeish<FileException>(aObj);
   }
 
   static JSBool
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(aIdval));
 
     int32 slot = JSID_TO_INT(aIdval);
 
     JSClass* classPtr = JS_GetClass(aObj);
 
-    if (classPtr != &sClass || !GetJSPrivateSafeish<FileException>(aCx, aObj)) {
+    if (classPtr != &sClass || !GetJSPrivateSafeish<FileException>(aObj)) {
       JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                            JSMSG_INCOMPATIBLE_PROTO, sClass.name,
                            sProperties[slot].name, classPtr->name);
       return false;
     }
 
-    return JS_GetReservedSlot(aCx, aObj, slot, aVp);
+    *aVp = JS_GetReservedSlot(aObj, slot);
+    return true;
   }
 
   static JSBool
   GetConstant(JSContext* aCx, JSObject* aObj, jsid idval, jsval* aVp)
   {
     JS_ASSERT(JSID_IS_INT(idval));
     *aVp = INT_TO_JSVAL(JSID_TO_INT(idval));
     return true;
@@ -410,26 +403,21 @@ FileException::Create(JSContext* aCx, in
 
   JS_ASSERT(foundIndex != size_t(-1));
 
   JSString* name = JS_NewStringCopyZ(aCx, sStaticProperties[foundIndex].name);
   if (!name) {
     return NULL;
   }
 
-  if (!JS_SetReservedSlot(aCx, obj, SLOT_code, INT_TO_JSVAL(aCode)) ||
-      !JS_SetReservedSlot(aCx, obj, SLOT_name, STRING_TO_JSVAL(name))) {
-    return NULL;
-  }
+  JS_SetReservedSlot(obj, SLOT_code, INT_TO_JSVAL(aCode));
+  JS_SetReservedSlot(obj, SLOT_name, STRING_TO_JSVAL(name));
 
   FileException* priv = new FileException();
-  if (!SetJSPrivateSafeish(aCx, obj, priv)) {
-    delete priv;
-    return NULL;
-  }
+  SetJSPrivateSafeish(obj, priv);
 
   return obj;
 }
 
 } // anonymous namespace
 
 BEGIN_WORKERS_NAMESPACE
 
--- a/dom/workers/File.cpp
+++ b/dom/workers/File.cpp
@@ -81,32 +81,30 @@ public:
 
   static JSObject*
   Create(JSContext* aCx, nsIDOMBlob* aBlob)
   {
     JS_ASSERT(SameCOMIdentity(static_cast<nsISupports*>(aBlob), aBlob));
 
     JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
     if (obj) {
-      if (!JS_SetPrivate(aCx, obj, aBlob)) {
-        return NULL;
-      }
+      JS_SetPrivate(obj, aBlob);
       NS_ADDREF(aBlob);
     }
     return obj;
   }
 
   static nsIDOMBlob*
-  GetPrivate(JSContext* aCx, JSObject* aObj);
+  GetPrivate(JSObject* aObj);
 
 private:
   static nsIDOMBlob*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
-    nsIDOMBlob* blob = GetPrivate(aCx, aObj);
+    nsIDOMBlob* blob = GetPrivate(aObj);
     if (blob) {
       return blob;
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          JS_GetClass(aObj)->name);
     return NULL;
@@ -120,17 +118,17 @@ private:
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
 
-    nsIDOMBlob* blob = GetPrivate(aCx, aObj);
+    nsIDOMBlob* blob = GetPrivate(aObj);
     NS_IF_RELEASE(blob);
   }
 
   static JSBool
   GetSize(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     nsIDOMBlob* blob = GetInstancePrivate(aCx, aObj, "size");
     if (!blob) {
@@ -255,31 +253,29 @@ public:
 
   static JSObject*
   Create(JSContext* aCx, nsIDOMFile* aFile)
   {
     JS_ASSERT(SameCOMIdentity(static_cast<nsISupports*>(aFile), aFile));
 
     JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
     if (obj) {
-      if (!JS_SetPrivate(aCx, obj, aFile)) {
-        return NULL;
-      }
+      JS_SetPrivate(obj, aFile);
       NS_ADDREF(aFile);
     }
     return obj;
   }
 
   static nsIDOMFile*
-  GetPrivate(JSContext* aCx, JSObject* aObj)
+  GetPrivate(JSObject* aObj)
   {
     if (aObj) {
       JSClass* classPtr = JS_GetClass(aObj);
       if (classPtr == &sClass) {
-        nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aCx, aObj));
+        nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aObj));
         nsCOMPtr<nsIDOMFile> file = do_QueryInterface(priv);
         JS_ASSERT_IF(priv, file);
         return file;
       }
     }
     return NULL;
   }
 
@@ -288,17 +284,17 @@ public:
   {
     return &sClass;
   }
 
 private:
   static nsIDOMFile*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
-    nsIDOMFile* file = GetPrivate(aCx, aObj);
+    nsIDOMFile* file = GetPrivate(aObj);
     if (file) {
       return file;
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          JS_GetClass(aObj)->name);
     return NULL;
@@ -312,17 +308,17 @@ private:
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
 
-    nsIDOMFile* file = GetPrivate(aCx, aObj);
+    nsIDOMFile* file = GetPrivate(aObj);
     NS_IF_RELEASE(file);
   }
 
   static JSBool
   GetMozFullPath(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     nsIDOMFile* file = GetInstancePrivate(aCx, aObj, "mozFullPath");
     if (!file) {
@@ -381,22 +377,22 @@ JSClass File::sClass = {
 JSPropertySpec File::sProperties[] = {
   { "name", 0, PROPERTY_FLAGS, GetName, js_GetterOnlyPropertyStub },
   { "mozFullPath", 0, PROPERTY_FLAGS, GetMozFullPath,
     js_GetterOnlyPropertyStub },
   { 0, 0, 0, NULL, NULL }
 };
 
 nsIDOMBlob*
-Blob::GetPrivate(JSContext* aCx, JSObject* aObj)
+Blob::GetPrivate(JSObject* aObj)
 {
   if (aObj) {
     JSClass* classPtr = JS_GetClass(aObj);
     if (classPtr == &sClass || classPtr == File::Class()) {
-      nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aCx, aObj));
+      nsISupports* priv = static_cast<nsISupports*>(JS_GetPrivate(aObj));
       nsCOMPtr<nsIDOMBlob> blob = do_QueryInterface(priv);
       JS_ASSERT_IF(priv, blob);
       return blob;
     }
   }
   return NULL;
 }
 
@@ -415,28 +411,28 @@ CreateBlob(JSContext* aCx, nsIDOMBlob* a
 bool
 InitClasses(JSContext* aCx, JSObject* aGlobal)
 {
   JSObject* blobProto = Blob::InitClass(aCx, aGlobal);
   return blobProto && File::InitClass(aCx, aGlobal, blobProto);
 }
 
 nsIDOMBlob*
-GetDOMBlobFromJSObject(JSContext* aCx, JSObject* aObj)
+GetDOMBlobFromJSObject(JSObject* aObj)
 {
-  return Blob::GetPrivate(aCx, aObj);
+  return Blob::GetPrivate(aObj);
 }
 
 JSObject*
 CreateFile(JSContext* aCx, nsIDOMFile* aFile)
 {
   return File::Create(aCx, aFile);
 }
 
 nsIDOMFile*
-GetDOMFileFromJSObject(JSContext* aCx, JSObject* aObj)
+GetDOMFileFromJSObject(JSObject* aObj)
 {
-  return File::GetPrivate(aCx, aObj);
+  return File::GetPrivate(aObj);
 }
 
 } // namespace file
 
 END_WORKERS_NAMESPACE
--- a/dom/workers/File.h
+++ b/dom/workers/File.h
@@ -53,21 +53,21 @@ namespace file {
 
 bool
 InitClasses(JSContext* aCx, JSObject* aGlobal);
 
 JSObject*
 CreateBlob(JSContext* aCx, nsIDOMBlob* aBlob);
 
 nsIDOMBlob*
-GetDOMBlobFromJSObject(JSContext* aCx, JSObject* aObj);
+GetDOMBlobFromJSObject(JSObject* aObj);
 
 JSObject*
 CreateFile(JSContext* aCx, nsIDOMFile* aFile);
 
 nsIDOMFile*
-GetDOMFileFromJSObject(JSContext* aCx, JSObject* aObj);
+GetDOMFileFromJSObject(JSObject* aObj);
 
 } // namespace file
 
 END_WORKERS_NAMESPACE
 
 #endif /* mozilla_dom_workers_file_h__ */
--- a/dom/workers/FileReaderSync.cpp
+++ b/dom/workers/FileReaderSync.cpp
@@ -76,17 +76,17 @@ EnsureSucceededOrThrow(JSContext* aCx, n
   return false;
 }
 
 inline nsIDOMBlob*
 GetDOMBlobFromJSObject(JSContext* aCx, JSObject* aObj) {
   // aObj can be null as JS_ConvertArguments("o") successfully converts JS
   // null to a null pointer to JSObject 
   if (aObj) {
-    nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aCx, aObj);
+    nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aObj);
     if (blob) {
       return blob;
     }
   }
 
   JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_UNEXPECTED_TYPE,
                        aObj ? JS_GetClass(aObj)->name : "Object", "not a Blob.");
   return NULL;
@@ -105,34 +105,34 @@ public:
   static JSObject*
   InitClass(JSContext* aCx, JSObject* aObj)
   {
     return JS_InitClass(aCx, aObj, NULL, &sClass, Construct, 0,
                         NULL, sFunctions, NULL, NULL);
   }
 
   static FileReaderSyncPrivate*
-  GetPrivate(JSContext* aCx, JSObject* aObj)
+  GetPrivate(JSObject* aObj)
   {
     if (aObj) {
       JSClass* classPtr = JS_GetClass(aObj);
       if (classPtr == &sClass) {
         FileReaderSyncPrivate* fileReader =
-          GetJSPrivateSafeish<FileReaderSyncPrivate>(aCx, aObj);
+          GetJSPrivateSafeish<FileReaderSyncPrivate>(aObj);
         return fileReader;
       }
     }
     return NULL;
   }
 
 private:
   static FileReaderSyncPrivate*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
-    FileReaderSyncPrivate* fileReader = GetPrivate(aCx, aObj);
+    FileReaderSyncPrivate* fileReader = GetPrivate(aObj);
     if (fileReader) {
       return fileReader;
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          JS_GetClass(aObj)->name);
     return NULL;
@@ -144,31 +144,28 @@ private:
     JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
     if (!obj) {
       return false;
     }
 
     FileReaderSyncPrivate* fileReader = new FileReaderSyncPrivate();
     NS_ADDREF(fileReader);
 
-    if (!SetJSPrivateSafeish(aCx, obj, fileReader)) {
-      NS_RELEASE(fileReader);
-      return false;
-    }
+    SetJSPrivateSafeish(obj, fileReader);
 
     JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(obj));
     return true;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
     FileReaderSyncPrivate* fileReader =
-      GetJSPrivateSafeish<FileReaderSyncPrivate>(aCx, aObj);
+      GetJSPrivateSafeish<FileReaderSyncPrivate>(aObj);
     NS_IF_RELEASE(fileReader);
   }
 
   static JSBool
   ReadAsArrayBuffer(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
     if (!obj) {
--- a/dom/workers/ListenerManager.cpp
+++ b/dom/workers/ListenerManager.cpp
@@ -335,17 +335,17 @@ class ExternallyUsableContextAllocPolicy
     void free_(void *p) { JS_free(cx, p); }
     void reportAllocOverflow() const { JS_ReportAllocationOverflow(cx); }
 };
 
 bool
 ListenerManager::DispatchEvent(JSContext* aCx, JSObject* aTarget,
                                JSObject* aEvent, bool* aPreventDefaultCalled)
 {
-  if (!events::IsSupportedEventClass(aCx, aEvent)) {
+  if (!events::IsSupportedEventClass(aEvent)) {
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_METHOD,
                          "EventTarget", "dispatchEvent", "Event object");
     return false;
   }
 
   jsval val;
   if (!JS_GetProperty(aCx, aEvent, "target", &val)) {
@@ -402,22 +402,20 @@ ListenerManager::DispatchEvent(JSContext
       return false;
     }
   }
 
   if (listeners.empty()) {
     return true;
   }
 
-  if (!events::SetEventTarget(aCx, aEvent, aTarget)) {
-    return false;
-  }
+  events::SetEventTarget(aEvent, aTarget);
 
   for (size_t index = 0; index < listeners.length(); index++) {
-    if (events::EventImmediatePropagationStopped(aCx, aEvent)) {
+    if (events::EventImmediatePropagationStopped(aEvent)) {
       break;
     }
 
     // If anything fails in here we want to report the exception and continue on
     // to the next listener rather than bailing out. If something fails and
     // does not set an exception then we bail out entirely as we've either run
     // out of memory or the operation callback has indicated that we should
     // stop running.
@@ -457,21 +455,19 @@ ListenerManager::DispatchEvent(JSContext
                               argv, &rval)) {
       if (!JS_ReportPendingException(aCx)) {
         return false;
       }
       continue;
     }
   }
 
-  if (!events::SetEventTarget(aCx, aEvent, NULL)) {
-    return false;
-  }
+  events::SetEventTarget(aEvent, NULL);
 
-  *aPreventDefaultCalled = events::EventWasCanceled(aCx, aEvent);
+  *aPreventDefaultCalled = events::EventWasCanceled(aEvent);
   return true;
 }
 
 bool
 ListenerManager::HasListenersForTypeInternal(JSContext* aCx, JSString* aType)
 {
   JS_ASSERT(!PR_CLIST_IS_EMPTY(&mCollectionHead));
 
--- a/dom/workers/Location.cpp
+++ b/dom/workers/Location.cpp
@@ -84,41 +84,35 @@ public:
   {
     JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
     if (!obj) {
       return NULL;
     }
 
     jsval empty = JS_GetEmptyStringValue(aCx);
 
-    if (!JS_SetReservedSlot(aCx, obj, SLOT_href,
-                            aHref ? STRING_TO_JSVAL(aHref) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_protocol,
-                            aProtocol ? STRING_TO_JSVAL(aProtocol) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_host,
-                            aHost ? STRING_TO_JSVAL(aHost) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_hostname,
-                            aHostname ? STRING_TO_JSVAL(aHostname) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_port,
-                            aPort ? STRING_TO_JSVAL(aPort) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_pathname,
-                            aPathname ? STRING_TO_JSVAL(aPathname) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_search,
-                            aSearch ? STRING_TO_JSVAL(aSearch) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_hash,
-                            aHash ? STRING_TO_JSVAL(aHash) : empty)) {
-      return NULL;
-    }
+    JS_SetReservedSlot(obj, SLOT_href,
+                       aHref ? STRING_TO_JSVAL(aHref) : empty);
+    JS_SetReservedSlot(obj, SLOT_protocol,
+                       aProtocol ? STRING_TO_JSVAL(aProtocol) : empty);
+    JS_SetReservedSlot(obj, SLOT_host,
+                       aHost ? STRING_TO_JSVAL(aHost) : empty);
+    JS_SetReservedSlot(obj, SLOT_hostname,
+                       aHostname ? STRING_TO_JSVAL(aHostname) : empty);
+    JS_SetReservedSlot(obj, SLOT_port,
+                       aPort ? STRING_TO_JSVAL(aPort) : empty);
+    JS_SetReservedSlot(obj, SLOT_pathname,
+                       aPathname ? STRING_TO_JSVAL(aPathname) : empty);
+    JS_SetReservedSlot(obj, SLOT_search,
+                       aSearch ? STRING_TO_JSVAL(aSearch) : empty);
+    JS_SetReservedSlot(obj, SLOT_hash,
+                       aHash ? STRING_TO_JSVAL(aHash) : empty);
 
     Location* priv = new Location();
-
-    if (!JS_SetPrivate(aCx, obj, priv)) {
-      delete priv;
-      return NULL;
-    }
+    JS_SetPrivate(obj, priv);
 
     return obj;
   }
 
 private:
   Location()
   {
     MOZ_COUNT_CTOR(mozilla::dom::workers::Location);
@@ -136,17 +130,17 @@ private:
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    delete static_cast<Location*>(JS_GetPrivate(aCx, aObj));
+    delete static_cast<Location*>(JS_GetPrivate(aObj));
   }
 
   static JSBool
   ToString(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     JSObject* obj = JS_THIS_OBJECT(aCx, aVp);
     if (!obj) {
       return false;
@@ -155,21 +149,17 @@ private:
     JSClass* classPtr = JS_GetClass(obj);
     if (classPtr != &sClass) {
       JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                            JSMSG_INCOMPATIBLE_PROTO, sClass.name, "toString",
                            classPtr);
       return false;
     }
 
-
-    jsval href;
-    if (!JS_GetReservedSlot(aCx, obj, SLOT_href, &href)) {
-      return false;
-    }
+    jsval href = JS_GetReservedSlot(obj, SLOT_href);
 
     JS_SET_RVAL(aCx, aVp, href);
     return true;
   }
 
   static JSBool
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
@@ -179,17 +169,18 @@ private:
                            JSMSG_INCOMPATIBLE_PROTO, sClass.name, "GetProperty",
                            classPtr->name);
       return false;
     }
 
     JS_ASSERT(JSID_IS_INT(aIdval));
     JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < SLOT_COUNT);
 
-    return JS_GetReservedSlot(aCx, aObj, JSID_TO_INT(aIdval), aVp);
+    *aVp = JS_GetReservedSlot(aObj, JSID_TO_INT(aIdval));
+    return true;
   }
 };
 
 JSClass Location::sClass = {
   "WorkerLocation",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
   JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
--- a/dom/workers/Navigator.cpp
+++ b/dom/workers/Navigator.cpp
@@ -103,33 +103,27 @@ public:
 
     JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
     if (!obj) {
       return NULL;
     }
 
     jsval empty = JS_GetEmptyStringValue(aCx);
 
-    if (!JS_SetReservedSlot(aCx, obj, SLOT_appName,
-                            appName ? STRING_TO_JSVAL(appName) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_appVersion,
-                            version ? STRING_TO_JSVAL(version) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_platform,
-                            platform ? STRING_TO_JSVAL(platform) : empty) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_userAgent,
-                            userAgent ? STRING_TO_JSVAL(userAgent) : empty)) {
-      return NULL;
-    }
+    JS_SetReservedSlot(obj, SLOT_appName,
+                       appName ? STRING_TO_JSVAL(appName) : empty);
+    JS_SetReservedSlot(obj, SLOT_appVersion,
+                       version ? STRING_TO_JSVAL(version) : empty);
+    JS_SetReservedSlot(obj, SLOT_platform,
+                       platform ? STRING_TO_JSVAL(platform) : empty);
+    JS_SetReservedSlot(obj, SLOT_userAgent,
+                       userAgent ? STRING_TO_JSVAL(userAgent) : empty);
 
     Navigator* priv = new Navigator();
-
-    if (!JS_SetPrivate(aCx, obj, priv)) {
-      delete priv;
-      return NULL;
-    }
+    JS_SetPrivate(obj, priv);
 
     return obj;
   }
 
 private:
   Navigator()
   {
     MOZ_COUNT_CTOR(mozilla::dom::workers::Navigator);
@@ -147,34 +141,35 @@ private:
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    delete static_cast<Navigator*>(JS_GetPrivate(aCx, aObj));
+    delete static_cast<Navigator*>(JS_GetPrivate(aObj));
   }
 
   static JSBool
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
     JSClass* classPtr = JS_GetClass(aObj);
     if (classPtr != &sClass) {
       JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                            JSMSG_INCOMPATIBLE_PROTO, sClass.name, "GetProperty",
                            classPtr->name);
       return false;
     }
 
     JS_ASSERT(JSID_IS_INT(aIdval));
     JS_ASSERT(JSID_TO_INT(aIdval) >= 0 && JSID_TO_INT(aIdval) < SLOT_COUNT);
 
-    return JS_GetReservedSlot(aCx, aObj, JSID_TO_INT(aIdval), aVp);
+    *aVp = JS_GetReservedSlot(aObj, JSID_TO_INT(aIdval));
+    return true;
   }
 };
 
 JSClass Navigator::sClass = {
   "WorkerNavigator",
   JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(SLOT_COUNT),
   JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
   JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Finalize,
--- a/dom/workers/Worker.cpp
+++ b/dom/workers/Worker.cpp
@@ -111,32 +111,32 @@ public:
     return proto;
   }
 
   static void
   ClearPrivateSlot(JSContext* aCx, JSObject* aObj, bool aSaveEventHandlers)
   {
     JS_ASSERT(!JS_IsExceptionPending(aCx));
 
-    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
+    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
     JS_ASSERT(worker);
 
     if (aSaveEventHandlers) {
       for (int index = 0; index < STRING_COUNT; index++) {
         const char* name = sEventStrings[index];
         jsval listener;
         if (!worker->GetEventListenerOnEventTarget(aCx, name + 2, &listener) ||
             !JS_DefineProperty(aCx, aObj, name, listener, NULL, NULL,
                                (PROPERTY_FLAGS & ~JSPROP_SHARED))) {
           JS_ClearPendingException(aCx);
         }
       }
     }
 
-    SetJSPrivateSafeish(aCx, aObj, NULL);
+    SetJSPrivateSafeish(aObj, NULL);
   }
 
   static WorkerPrivate*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName);
 
 protected:
   static JSBool
   ConstructInternal(JSContext* aCx, uintN aArgc, jsval* aVp,
@@ -179,17 +179,17 @@ protected:
 
     WorkerPrivate* worker = WorkerPrivate::Create(aCx, obj, parent, scriptURL,
                                                   aIsChromeWorker);
     if (!worker) {
       return false;
     }
 
     // Worker now owned by the JS object.
-    SetJSPrivateSafeish(aCx, obj, worker);
+    SetJSPrivateSafeish(obj, worker);
 
     if (!runtimeService->RegisterWorker(aCx, worker)) {
       return false;
     }
 
     JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(obj));
     return true;
   }
@@ -237,28 +237,27 @@ private:
   {
     return ConstructInternal(aCx, aArgc, aVp, false);
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
+    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
     if (worker) {
       worker->FinalizeInstance(aCx, true);
     }
   }
 
   static void
   Trace(JSTracer* aTrc, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    WorkerPrivate* worker =
-      GetJSPrivateSafeish<WorkerPrivate>(aTrc->context, aObj);
+    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
     if (worker) {
       worker->TraceInstance(aTrc);
     }
   }
 
   static JSBool
   Terminate(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
@@ -375,45 +374,44 @@ private:
   ~ChromeWorker();
 
   static WorkerPrivate*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
     if (aObj) {
       JSClass* classPtr = JS_GetClass(aObj);
       if (classPtr == &sClass) {
-        return GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
+        return GetJSPrivateSafeish<WorkerPrivate>(aObj);
       }
     }
 
     return Worker::GetInstancePrivate(aCx, aObj, aFunctionName);
   }
 
   static JSBool
   Construct(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
     return ConstructInternal(aCx, aArgc, aVp, true);
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
+    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
     if (worker) {
       worker->FinalizeInstance(aCx, true);
     }
   }
 
   static void
   Trace(JSTracer* aTrc, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    WorkerPrivate* worker =
-      GetJSPrivateSafeish<WorkerPrivate>(aTrc->context, aObj);
+    WorkerPrivate* worker = GetJSPrivateSafeish<WorkerPrivate>(aObj);
     if (worker) {
       worker->TraceInstance(aTrc);
     }
   }
 };
 
 JSClass ChromeWorker::sClass = {
   "ChromeWorker",
@@ -424,17 +422,17 @@ JSClass ChromeWorker::sClass = {
 };
 
 WorkerPrivate*
 Worker::GetInstancePrivate(JSContext* aCx, JSObject* aObj,
                            const char* aFunctionName)
 {
   JSClass* classPtr = JS_GetClass(aObj);
   if (classPtr == &sClass || classPtr == ChromeWorker::Class()) {
-    return GetJSPrivateSafeish<WorkerPrivate>(aCx, aObj);
+    return GetJSPrivateSafeish<WorkerPrivate>(aObj);
   }
 
   JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                        sClass.name, aFunctionName, classPtr->name);
   return NULL;
 }
 
 } // anonymous namespace
--- a/dom/workers/WorkerInlines.h
+++ b/dom/workers/WorkerInlines.h
@@ -34,24 +34,24 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 BEGIN_WORKERS_NAMESPACE
 
 inline
-JSBool
-SetJSPrivateSafeish(JSContext* aCx, JSObject* aObj, PrivatizableBase* aBase)
+void
+SetJSPrivateSafeish(JSObject* aObj, PrivatizableBase* aBase)
 {
-  return JS_SetPrivate(aCx, aObj, aBase);
+  JS_SetPrivate(aObj, aBase);
 }
 
 template <class Derived>
 inline
 Derived*
-GetJSPrivateSafeish(JSContext* aCx, JSObject* aObj)
+GetJSPrivateSafeish(JSObject* aObj)
 {
   return static_cast<Derived*>(
-    static_cast<PrivatizableBase*>(JS_GetPrivate(aCx, aObj)));
+    static_cast<PrivatizableBase*>(JS_GetPrivate(aObj)));
 }
 
 END_WORKERS_NAMESPACE
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -333,29 +333,29 @@ struct WorkerStructuredCloneCallbacks
     NS_ASSERTION(aClosure, "Null pointer!");
 
     // We'll stash any nsISupports pointers that need to be AddRef'd here.
     nsTArray<nsCOMPtr<nsISupports> >* clonedObjects =
       static_cast<nsTArray<nsCOMPtr<nsISupports> >*>(aClosure);
 
     // See if this is a File object.
     {
-      nsIDOMFile* file = file::GetDOMFileFromJSObject(aCx, aObj);
+      nsIDOMFile* file = file::GetDOMFileFromJSObject(aObj);
       if (file) {
         if (JS_WriteUint32Pair(aWriter, DOMWORKER_SCTAG_FILE, 0) &&
             JS_WriteBytes(aWriter, &file, sizeof(file))) {
           clonedObjects->AppendElement(file);
           return true;
         }
       }
     }
 
     // See if this is a Blob object.
     {
-      nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aCx, aObj);
+      nsIDOMBlob* blob = file::GetDOMBlobFromJSObject(aObj);
       if (blob) {
         nsCOMPtr<nsIMutable> mutableBlob = do_QueryInterface(blob);
         if (mutableBlob && NS_SUCCEEDED(mutableBlob->SetMutable(false)) &&
             JS_WriteUint32Pair(aWriter, DOMWORKER_SCTAG_BLOB, 0) &&
             JS_WriteBytes(aWriter, &blob, sizeof(blob))) {
           clonedObjects->AppendElement(blob);
           return true;
         }
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -655,24 +655,21 @@ public:
     return JS_InitClass(aCx, aObj, aParentProto, &sClass, Construct, 0,
                         sProperties, sFunctions, NULL, NULL);
   }
 
   static JSBool
   InitPrivate(JSContext* aCx, JSObject* aObj, WorkerPrivate* aWorkerPrivate)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    JS_ASSERT(!GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aCx, aObj));
+    JS_ASSERT(!GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj));
 
     DedicatedWorkerGlobalScope* priv =
       new DedicatedWorkerGlobalScope(aWorkerPrivate);
-    if (!SetJSPrivateSafeish(aCx, aObj, priv)) {
-      delete priv;
-      return false;
-    }
+    SetJSPrivateSafeish(aObj, priv);
 
     return true;
   }
 
 protected:
   DedicatedWorkerGlobalScope(WorkerPrivate* aWorker)
   : WorkerGlobalScope(aWorker)
   {
@@ -719,17 +716,17 @@ private:
     return scope->SetEventListenerOnEventTarget(aCx, name + 2, aVp);
   }
 
   static DedicatedWorkerGlobalScope*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
     JSClass* classPtr = JS_GetClass(aObj);
     if (classPtr == &sClass) {
-      return GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aCx, aObj);
+      return GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj);
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          classPtr->name);
     return NULL;
   }
 
@@ -754,29 +751,29 @@ private:
     return true;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
     DedicatedWorkerGlobalScope* scope =
-      GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aCx, aObj);
+      GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj);
     if (scope) {
       scope->FinalizeInstance(aCx);
       delete scope;
     }
   }
 
   static void
   Trace(JSTracer* aTrc, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
     DedicatedWorkerGlobalScope* scope =
-      GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aTrc->context, aObj);
+      GetJSPrivateSafeish<DedicatedWorkerGlobalScope>(aObj);
     if (scope) {
       scope->TraceInstance(aTrc);
     }
   }
 
   static JSBool
   PostMessage(JSContext* aCx, uintN aArgc, jsval* aVp)
   {
@@ -824,17 +821,17 @@ const char* const DedicatedWorkerGlobalS
 };
 
 WorkerGlobalScope*
 WorkerGlobalScope::GetInstancePrivate(JSContext* aCx, JSObject* aObj,
                                       const char* aFunctionName)
 {
   JSClass* classPtr = JS_GetClass(aObj);
   if (classPtr == &sClass || classPtr == DedicatedWorkerGlobalScope::Class()) {
-    return GetJSPrivateSafeish<WorkerGlobalScope>(aCx, aObj);
+    return GetJSPrivateSafeish<WorkerGlobalScope>(aObj);
   }
 
   JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                        sClass.name, aFunctionName, classPtr->name);
   return NULL;
 }
 
 } /* anonymous namespace */
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -103,23 +103,19 @@ public:
 
   static JSObject*
   Create(JSContext* aCx, JSObject* aParentObj)
   {
     JS_ASSERT(aParentObj);
 
     JSObject* obj = JS_NewObject(aCx, &sClass, NULL, NULL);
     if (obj) {
+      JS_SetReservedSlot(obj, SLOT_xhrParent, OBJECT_TO_JSVAL(aParentObj));
       XMLHttpRequestUpload* priv = new XMLHttpRequestUpload();
-      if (!JS_SetReservedSlot(aCx, obj, SLOT_xhrParent,
-                              OBJECT_TO_JSVAL(aParentObj)) ||
-          !SetJSPrivateSafeish(aCx, obj, priv)) {
-        delete priv;
-        return NULL;
-      }
+      SetJSPrivateSafeish(obj, priv);
     }
     return obj;
   }
 
   static bool
   UpdateState(JSContext* aCx, JSObject* aObj, const xhr::StateData& aNewState);
 
 private:
@@ -129,31 +125,31 @@ private:
   }
 
   ~XMLHttpRequestUpload()
   {
     MOZ_COUNT_DTOR(mozilla::dom::workers::xhr::XMLHttpRequestUpload);
   }
 
   static XMLHttpRequestUpload*
-  GetPrivate(JSContext* aCx, JSObject* aObj)
+  GetPrivate(JSObject* aObj)
   {
     if (aObj) {
       JSClass* classPtr = JS_GetClass(aObj);
       if (classPtr == &sClass) {
-        return GetJSPrivateSafeish<XMLHttpRequestUpload>(aCx, aObj);
+        return GetJSPrivateSafeish<XMLHttpRequestUpload>(aObj);
       }
     }
     return NULL;
   }
 
   static XMLHttpRequestUpload*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
-    XMLHttpRequestUpload* priv = GetPrivate(aCx, aObj);
+    XMLHttpRequestUpload* priv = GetPrivate(aObj);
     if (priv) {
       return priv;
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          JS_GetClass(aObj)->name);
     return NULL;
@@ -166,28 +162,28 @@ private:
                          sClass.name);
     return false;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    XMLHttpRequestUpload* priv = GetPrivate(aCx, aObj);
+    XMLHttpRequestUpload* priv = GetPrivate(aObj);
     if (priv) {
       priv->FinalizeInstance(aCx);
       delete priv;
     }
   }
 
   static void
   Trace(JSTracer* aTrc, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    XMLHttpRequestUpload* priv = GetPrivate(aTrc->context, aObj);
+    XMLHttpRequestUpload* priv = GetPrivate(aObj);
     if (priv) {
       priv->TraceInstance(aTrc);
     }
   }
 
   static JSBool
   GetEventListener(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
@@ -320,23 +316,21 @@ public:
     }
 
     return proto;
   }
 
   static bool
   UpdateState(JSContext* aCx, JSObject* aObj, const xhr::StateData& aNewState)
   {
-    JS_ASSERT(GetPrivate(aCx, aObj));
+    JS_ASSERT(GetPrivate(aObj));
 
 #define HANDLE_STATE_VALUE(_member, _slot) \
   if (aNewState. _member##Exception || !JSVAL_IS_VOID(aNewState. _member)) { \
-    if (!JS_SetReservedSlot(aCx, aObj, _slot, aNewState. _member)) { \
-      return false; \
-    } \
+    JS_SetReservedSlot(aObj, _slot, aNewState. _member);                     \
   }
 
     HANDLE_STATE_VALUE(mResponseText, SLOT_responseText)
     HANDLE_STATE_VALUE(mStatus, SLOT_status)
     HANDLE_STATE_VALUE(mStatusText, SLOT_statusText)
     HANDLE_STATE_VALUE(mReadyState, SLOT_readyState)
     HANDLE_STATE_VALUE(mResponse, SLOT_response)
 
@@ -348,31 +342,31 @@ public:
 private:
   // No instance of this class should ever be created so these are explicitly
   // left without an implementation to prevent linking in case someone tries to
   // make one.
   XMLHttpRequest();
   ~XMLHttpRequest();
 
   static XMLHttpRequestPrivate*
-  GetPrivate(JSContext* aCx, JSObject* aObj)
+  GetPrivate(JSObject* aObj)
   {
     if (aObj) {
       JSClass* classPtr = JS_GetClass(aObj);
       if (classPtr == &sClass) {
-        return GetJSPrivateSafeish<XMLHttpRequestPrivate>(aCx, aObj);
+        return GetJSPrivateSafeish<XMLHttpRequestPrivate>(aObj);
       }
     }
     return NULL;
   }
 
   static XMLHttpRequestPrivate*
   GetInstancePrivate(JSContext* aCx, JSObject* aObj, const char* aFunctionName)
   {
-    XMLHttpRequestPrivate* priv = GetPrivate(aCx, aObj);
+    XMLHttpRequestPrivate* priv = GetPrivate(aObj);
     if (priv) {
       return priv;
     }
 
     JS_ReportErrorNumber(aCx, js_GetErrorMessage, NULL,
                          JSMSG_INCOMPATIBLE_PROTO, sClass.name, aFunctionName,
                          JS_GetClass(aObj)->name);
     return NULL;
@@ -389,58 +383,52 @@ private:
     JSString* textStr = JS_NewStringCopyN(aCx, "text", 4);
     if (!textStr) {
       return false;
     }
 
     jsval emptyString = JS_GetEmptyStringValue(aCx);
     jsval zero = INT_TO_JSVAL(0);
 
-    if (!JS_SetReservedSlot(aCx, obj, SLOT_channel, JSVAL_NULL) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_responseXML, JSVAL_NULL) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_responseText, emptyString) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_status, zero) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_statusText, emptyString) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_readyState, zero) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_multipart, JSVAL_FALSE) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_mozBackgroundRequest, JSVAL_FALSE) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_withCredentials, JSVAL_FALSE) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_upload, JSVAL_NULL) ||
-        !JS_SetReservedSlot(aCx, obj, SLOT_responseType,
-                            STRING_TO_JSVAL(textStr))) {
-      return false;
-    }
+    JS_SetReservedSlot(obj, SLOT_channel, JSVAL_NULL);
+    JS_SetReservedSlot(obj, SLOT_responseXML, JSVAL_NULL);
+    JS_SetReservedSlot(obj, SLOT_responseText, emptyString);
+    JS_SetReservedSlot(obj, SLOT_status, zero);
+    JS_SetReservedSlot(obj, SLOT_statusText, emptyString);
+    JS_SetReservedSlot(obj, SLOT_readyState, zero);
+    JS_SetReservedSlot(obj, SLOT_multipart, JSVAL_FALSE);
+    JS_SetReservedSlot(obj, SLOT_mozBackgroundRequest, JSVAL_FALSE);
+    JS_SetReservedSlot(obj, SLOT_withCredentials, JSVAL_FALSE);
+    JS_SetReservedSlot(obj, SLOT_upload, JSVAL_NULL);
+    JS_SetReservedSlot(obj, SLOT_responseType, STRING_TO_JSVAL(textStr));
 
     WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
     XMLHttpRequestPrivate* priv = new XMLHttpRequestPrivate(obj, workerPrivate);
-    if (!SetJSPrivateSafeish(aCx, obj, priv)) {
-      delete priv;
-      return false;
-    }
+    SetJSPrivateSafeish(obj, priv);
 
     JS_SET_RVAL(aCx, aVp, OBJECT_TO_JSVAL(obj));
     return true;
   }
 
   static void
   Finalize(JSContext* aCx, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    XMLHttpRequestPrivate* priv = GetPrivate(aCx, aObj);
+    XMLHttpRequestPrivate* priv = GetPrivate(aObj);
     if (priv) {
       priv->FinalizeInstance(aCx);
       delete priv;
     }
   }
 
   static void
   Trace(JSTracer* aTrc, JSObject* aObj)
   {
     JS_ASSERT(JS_GetClass(aObj) == &sClass);
-    XMLHttpRequestPrivate* priv = GetPrivate(aTrc->context, aObj);
+    XMLHttpRequestPrivate* priv = GetPrivate(aObj);
     if (priv) {
       priv->TraceInstance(aTrc);
     }
   }
 
   static JSBool
   GetProperty(JSContext* aCx, JSObject* aObj, jsid aIdval, jsval* aVp)
   {
@@ -448,20 +436,17 @@ private:
 
     int32 slot = JSID_TO_INT(aIdval);
     const char*& name = sProperties[slot].name;
 
     if (!GetInstancePrivate(aCx, aObj, name)) {
       return false;
     }
 
-    jsval rval;
-    if (!JS_GetReservedSlot(aCx, aObj, slot, &rval)) {
-      return false;
-    }
+    jsval rval = JS_GetReservedSlot(aObj, slot);
 
     if (JSVAL_IS_VOID(rval)) {
       // Throw an exception.
       exceptions::ThrowDOMExceptionForCode(aCx, INVALID_STATE_ERR);
       return false;
     }
 
     *aVp = rval;
@@ -487,32 +472,27 @@ private:
     int32 slot = JSID_TO_INT(aIdval);
 
     XMLHttpRequestPrivate* priv =
       GetInstancePrivate(aCx, aObj, sProperties[slot].name);
     if (!priv) {
       return false;
     }
 
-    jsval uploadVal;
-    if (!JS_GetReservedSlot(aCx, aObj, slot, &uploadVal)) {
-      return false;
-    }
+    jsval uploadVal = JS_GetReservedSlot(aObj, slot);
 
     if (JSVAL_IS_NULL(uploadVal)) {
       JSObject* uploadObj = XMLHttpRequestUpload::Create(aCx, aObj);
       if (!uploadObj) {
         return false;
       }
 
       uploadVal = OBJECT_TO_JSVAL(uploadObj);
 
-      if (!JS_SetReservedSlot(aCx, aObj, slot, uploadVal)) {
-        return false;
-      }
+      JS_SetReservedSlot(aObj, slot, uploadVal);
 
       priv->SetUploadObject(uploadObj);
     }
 
     JS_ASSERT(!JSVAL_IS_PRIMITIVE(uploadVal));
 
     *aVp = uploadVal;
     return true;
@@ -528,26 +508,22 @@ private:
     int32 slot = JSID_TO_INT(aIdval);                                          \
                                                                                \
     XMLHttpRequestPrivate* priv =                                              \
       GetInstancePrivate(aCx, aObj, sProperties[slot].name);                   \
     if (!priv) {                                                               \
       return false;                                                            \
     }                                                                          \
                                                                                \
-    jsval oldVal;                                                              \
-    if (!JS_GetReservedSlot(aCx, aObj, slot, &oldVal)) {                       \
-      return false;                                                            \
-    }                                                                          \
+    jsval oldVal = JS_GetReservedSlot(aObj, slot);                             \
                                                                                \
     jsval rval = *aVp;                                                         \
-    if (!priv->Set##_name (aCx, oldVal, &rval) ||                              \
-        !JS_SetReservedSlot(aCx, aObj, slot, rval)) {                          \
+    if (!priv->Set##_name (aCx, oldVal, &rval))                                \
       return false;                                                            \
-    }                                                                          \
+    JS_SetReservedSlot(aObj, slot, rval);                                      \
                                                                                \
     *aVp = rval;                                                               \
     return true;                                                               \
   }
 
   IMPL_SETTER(Multipart)
   IMPL_SETTER(MozBackgroundRequest)
   IMPL_SETTER(WithCredentials)
@@ -875,20 +851,17 @@ const char* const XMLHttpRequest::sEvent
 
 // static
 bool
 XMLHttpRequestUpload::UpdateState(JSContext* aCx, JSObject* aObj,
                                   const xhr::StateData& aNewState)
 {
   JS_ASSERT(JS_GetClass(aObj) == &sClass);
 
-  jsval parentVal;
-  if (!JS_GetReservedSlot(aCx, aObj, SLOT_xhrParent, &parentVal)) {
-    return false;
-  }
+  jsval parentVal = JS_GetReservedSlot(aObj, SLOT_xhrParent);
 
   if (!JSVAL_IS_PRIMITIVE(parentVal)) {
     return XMLHttpRequest::UpdateState(aCx, JSVAL_TO_OBJECT(parentVal),
                                        aNewState);
   }
 
   return true;
 }
--- a/dom/workers/XMLHttpRequestPrivate.cpp
+++ b/dom/workers/XMLHttpRequestPrivate.cpp
@@ -1689,17 +1689,17 @@ XMLHttpRequestPrivate::Send(JSContext* a
   if (!mProxy) {
     ThrowDOMExceptionForCode(aCx, INVALID_STATE_ERR);
     return false;
   }
 
   bool hasUploadListeners = false;
   if (mUploadJSObject) {
     events::EventTarget* target =
-      events::EventTarget::FromJSObject(aCx, mUploadJSObject);
+      events::EventTarget::FromJSObject(mUploadJSObject);
     NS_ASSERTION(target, "This should never be null!");
     hasUploadListeners = target->HasListeners();
   }
 
   if (!RootJSObject(aCx)) {
     return false;
   }
 
@@ -1749,17 +1749,17 @@ XMLHttpRequestPrivate::SendAsBinary(JSCo
   nsDependentJSString body;
   if (!body.init(aCx, aBody)) {
     return false;
   }
 
   bool hasUploadListeners = false;
   if (mUploadJSObject) {
     events::EventTarget* target =
-      events::EventTarget::FromJSObject(aCx, mUploadJSObject);
+      events::EventTarget::FromJSObject(mUploadJSObject);
     NS_ASSERTION(target, "This should never be null!");
     hasUploadListeners = target->HasListeners();
   }
 
   if (!RootJSObject(aCx)) {
     return false;
   }
 
--- a/js/ipc/ObjectWrapperChild.cpp
+++ b/js/ipc/ObjectWrapperChild.cpp
@@ -409,21 +409,21 @@ ObjectWrapperChild::AnswerDelProperty(co
 
 static const PRUint32 sNextIdIndexSlot = 0;
 static const PRUint32 sNumNewEnumerateStateSlots = 1;
 
 static void
 CPOW_NewEnumerateState_Finalize(JSContext* cx, JSObject* state)
 {
     nsTArray<nsString>* strIds =
-        static_cast<nsTArray<nsString>*>(JS_GetPrivate(cx, state));
+        static_cast<nsTArray<nsString>*>(JS_GetPrivate(state));
 
     if (strIds) {
         delete strIds;
-        JS_SetPrivate(cx, state, NULL);
+        JS_SetPrivate(state, NULL);
     }
 }
 
 // Similar to IteratorClass in XPCWrapper.cpp
 static const JSClass sCPOW_NewEnumerateState_JSClass = {
     "CPOW NewEnumerate State",
     JSCLASS_HAS_PRIVATE |
     JSCLASS_HAS_RESERVED_SLOTS(sNumNewEnumerateStateSlots),
@@ -447,17 +447,17 @@ ObjectWrapperChild::AnswerNewEnumerateIn
     JSClass* clasp = const_cast<JSClass*>(&sCPOW_NewEnumerateState_JSClass);
     JSObject* state = JS_NewObjectWithGivenProto(cx, clasp, NULL, NULL);
     if (!state)
         return false;
     AutoObjectRooter tvr(cx, state);
 
     for (JSObject* proto = mObj;
          proto;
-         proto = JS_GetPrototype(cx, proto))
+         proto = JS_GetPrototype(proto))
     {
         AutoIdArray ids(cx, JS_Enumerate(cx, proto));
         for (size_t i = 0; i < ids.length(); ++i)
             JS_DefinePropertyById(cx, state, ids[i], JSVAL_VOID,
                                   NULL, NULL, JSPROP_ENUMERATE | JSPROP_SHARED);
     }
 
     InfallibleTArray<nsString>* strIds;
@@ -469,59 +469,60 @@ ObjectWrapperChild::AnswerNewEnumerateIn
         for (size_t i = 0; i < ids.length(); ++i)
             if (!jsid_to_nsString(cx, ids[i], strIds->AppendElement())) {
                 delete strIds;
                 return false;
             }
     }
     *idp = strIds->Length();
 
-    *status = (JS_SetPrivate(cx, state, strIds) &&
-               JS_SetReservedSlot(cx, state, sNextIdIndexSlot,
-                                  JSVAL_ZERO) &&
-               JSObject_to_JSVariant(cx, state, statep));
+    JS_SetPrivate(state, strIds);
+    JS_SetReservedSlot(state, sNextIdIndexSlot, JSVAL_ZERO);
+               
+    *status = JSObject_to_JSVariant(cx, state, statep);
 
     return true;
 }
 
 bool
 ObjectWrapperChild::AnswerNewEnumerateNext(const JSVariant& in_state,
                                            OperationStatus* status, JSVariant* statep, nsString* idp)
 {
     JSObject* state;
-    jsval v;
 
     *statep = in_state;
     idp->Truncate();
     
     JSContext* cx = Manager()->GetContext();
     AutoContextPusher acp(cx);
     AutoCheckOperation aco(this, status);
 
     if (!JSObject_from_JSVariant(cx, in_state, &state))
         return false;
 
     InfallibleTArray<nsString>* strIds =
-        static_cast<InfallibleTArray<nsString>*>(JS_GetPrivate(cx, state));
+        static_cast<InfallibleTArray<nsString>*>(JS_GetPrivate(state));
 
-    if (!strIds || !JS_GetReservedSlot(cx, state, sNextIdIndexSlot, &v))
+    if (!strIds)
         return false;
 
+    jsval v = JS_GetReservedSlot(state, sNextIdIndexSlot);
+
     jsuint i = JSVAL_TO_INT(v);
     NS_ASSERTION(i >= 0, "Index of next jsid negative?");
     NS_ASSERTION(i <= strIds->Length(), "Index of next jsid too large?");
 
     if (jsuint(i) == strIds->Length()) {
         *status = JS_TRUE;
         return JSObject_to_JSVariant(cx, NULL, statep);
     }
 
     *idp = strIds->ElementAt(i);
-    *status = JS_SetReservedSlot(cx, state, sNextIdIndexSlot,
-                                 INT_TO_JSVAL(i + 1));
+    JS_SetReservedSlot(state, sNextIdIndexSlot, INT_TO_JSVAL(i + 1));
+    *status = JS_TRUE;
     return true;
 }
     
 bool
 ObjectWrapperChild::RecvNewEnumerateDestroy(const JSVariant& in_state)
 {
     JSObject* state;
 
--- a/js/ipc/ObjectWrapperParent.cpp
+++ b/js/ipc/ObjectWrapperParent.cpp
@@ -54,57 +54,48 @@ namespace {
     // Only need one reserved slot because the ObjectWrapperParent* is
     // stored in the private slot.
     static const uintN sFlagsSlot = 0;
     static const uintN sNumSlots = 1;
     static const uintN CPOW_FLAG_RESOLVING = 1 << 0;
 
     class AutoResolveFlag
     {
-        JSContext* mContext;
         JSObject* mObj;
         uintN mOldFlags;
         JS_DECL_USE_GUARD_OBJECT_NOTIFIER
 
-        static uintN GetFlags(JSContext* cx, JSObject* obj) {
-            jsval v;
-#ifdef DEBUG
-            JSBool ok =
-#endif
-                JS_GetReservedSlot(cx, obj, sFlagsSlot, &v);
-            NS_ASSERTION(ok, "Failed to get CPOW flags");
+        static uintN GetFlags(JSObject* obj) {
+            jsval v = JS_GetReservedSlot(obj, sFlagsSlot);
             return JSVAL_TO_INT(v);
         }
 
-        static uintN SetFlags(JSContext* cx, JSObject* obj, uintN flags) {
-            uintN oldFlags = GetFlags(cx, obj);
+        static uintN SetFlags(JSObject* obj, uintN flags) {
+            uintN oldFlags = GetFlags(obj);
             if (oldFlags != flags)
-                JS_SetReservedSlot(cx, obj, sFlagsSlot, INT_TO_JSVAL(flags));
+                JS_SetReservedSlot(obj, sFlagsSlot, INT_TO_JSVAL(flags));
             return oldFlags;
         }
 
     public:
 
-        AutoResolveFlag(JSContext* cx,
-                        JSObject* obj
+        AutoResolveFlag(JSObject* obj
                         JS_GUARD_OBJECT_NOTIFIER_PARAM)
-            : mContext(cx)
-            , mObj(obj)
-            , mOldFlags(SetFlags(cx, obj,
-                                 GetFlags(cx, obj) | CPOW_FLAG_RESOLVING))
+            : mObj(obj)
+            , mOldFlags(SetFlags(obj, GetFlags(obj) | CPOW_FLAG_RESOLVING))
         {
             JS_GUARD_OBJECT_NOTIFIER_INIT;
         }
 
         ~AutoResolveFlag() {
-            SetFlags(mContext, mObj, mOldFlags);
+            SetFlags(mObj, mOldFlags);
         }
 
-        static JSBool IsSet(JSContext* cx, JSObject* obj) {
-            return GetFlags(cx, obj) & CPOW_FLAG_RESOLVING;
+        static JSBool IsSet(JSObject* obj) {
+            return GetFlags(obj) & CPOW_FLAG_RESOLVING;
         }
 
     };
 
     class StatusMemberOwner
     {
         OperationStatus mStatus;
     public:
@@ -196,50 +187,53 @@ const js::Class ObjectWrapperParent::sCP
           nsnull, // wrappedObject
     }
 };
 
 void
 ObjectWrapperParent::ActorDestroy(ActorDestroyReason)
 {
     if (mObj) {
-        JS_SetPrivate(NULL, mObj, NULL);
+        JS_SetPrivate(mObj, NULL);
         mObj = NULL;
     }
 }
 
 ContextWrapperParent*
 ObjectWrapperParent::Manager()
 {
     PContextWrapperParent* pcwp = PObjectWrapperParent::Manager();
     return static_cast<ContextWrapperParent*>(pcwp);
 }
 
 JSObject*
 ObjectWrapperParent::GetJSObject(JSContext* cx) const
 {
-    js::Class *clasp = const_cast<js::Class *>(&ObjectWrapperParent::sCPOW_JSClass);
-    if (!mObj && (mObj = JS_NewObject(cx, js::Jsvalify(clasp), NULL, NULL))) {
-        JS_SetPrivate(cx, mObj, (void*)this);
-        JS_SetReservedSlot(cx, mObj, sFlagsSlot, JSVAL_ZERO);
+    if (!mObj) {
+        js::Class *clasp = const_cast<js::Class *>(&ObjectWrapperParent::sCPOW_JSClass);
+        mObj = JS_NewObject(cx, js::Jsvalify(clasp), NULL, NULL);
+        if (mObj) {
+            JS_SetPrivate(mObj, (void*)this);
+            JS_SetReservedSlot(mObj, sFlagsSlot, JSVAL_ZERO);
+        }
     }
     return mObj;
 }
 
 static ObjectWrapperParent*
-Unwrap(JSContext* cx, JSObject* obj)
+Unwrap(JSObject* obj)
 {
     while (js::GetObjectClass(obj) != &ObjectWrapperParent::sCPOW_JSClass)
         if (!(obj = js::GetObjectProto(obj)))
             return NULL;
     
     ObjectWrapperParent* self =
-        static_cast<ObjectWrapperParent*>(JS_GetPrivate(cx, obj));
+        static_cast<ObjectWrapperParent*>(JS_GetPrivate(obj));
 
-    NS_ASSERTION(!self || self->GetJSObject(cx) == obj,
+    NS_ASSERTION(!self || self->GetJSObjectOrNull() == obj,
                  "Wrapper and wrapped object disagree?");
     
     return self;
 }
 
 /*static*/ bool
 ObjectWrapperParent::jsval_to_JSVariant(JSContext* cx, jsval from,
                                         JSVariant* to)
@@ -254,17 +248,17 @@ ObjectWrapperParent::jsval_to_JSVariant(
         // fall through
     case JSTYPE_FUNCTION:
         // CPOWs can fool JS_TypeOfValue into returning JSTYPE_FUNCTION
         // because they have a call hook, but CPOWs are really objects, so
         // fall through to the JSTYPE_OBJECT case:
     case JSTYPE_OBJECT:
         {
             PObjectWrapperParent* powp;
-            if (!JSObject_to_PObjectWrapperParent(cx, JSVAL_TO_OBJECT(from), &powp))
+            if (!JSObject_to_PObjectWrapperParent(JSVAL_TO_OBJECT(from), &powp))
                 return with_error(cx, false, "Cannot pass parent-created object to child");
             *to = powp;
         }
         return true;
     case JSTYPE_STRING:
         {
             nsDependentJSString depStr;
             if (!depStr.init(cx, from))
@@ -317,24 +311,23 @@ ObjectWrapperParent::jsval_from_JSVarian
         return true;
     default:
         return false;
     }
 }
 
 /*static*/ bool
 ObjectWrapperParent::
-JSObject_to_PObjectWrapperParent(JSContext* cx, JSObject* from,
-                                 PObjectWrapperParent** to)
+JSObject_to_PObjectWrapperParent(JSObject* from, PObjectWrapperParent** to)
 {
     if (!from) {
         *to = NULL;
         return true;
     }
-    ObjectWrapperParent* owp = Unwrap(cx, from);
+    ObjectWrapperParent* owp = Unwrap(from);
     if (!owp)
         return false;
     *to = owp;
     return true;
 }
 
 /*static*/ bool
 ObjectWrapperParent::
@@ -396,21 +389,21 @@ jsval_to_nsString(JSContext* cx, jsid fr
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_AddProperty(JSContext *cx, JSObject *obj, jsid id,
                                       jsval *vp)
 {
     CPOW_LOG(("Calling CPOW_AddProperty (%s)...",
               JSVAL_TO_CSTR(cx, id)));
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_AddProperty");
 
-    if (AutoResolveFlag::IsSet(cx, obj))
+    if (AutoResolveFlag::IsSet(obj))
         return JS_TRUE;
 
     AutoCheckOperation aco(cx, self);
 
     nsString in_id;
 
     if (!jsval_to_nsString(cx, id, &in_id))
         return JS_FALSE;
@@ -423,17 +416,17 @@ ObjectWrapperParent::CPOW_AddProperty(JS
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_GetProperty(JSContext *cx, JSObject *obj, jsid id,
                                       jsval *vp)
 {
     CPOW_LOG(("Calling CPOW_GetProperty (%s)...",
               JSVAL_TO_CSTR(cx, id)));
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_GetProperty");
 
     AutoCheckOperation aco(cx, self);
 
     nsString in_id;
 
     if (!jsval_to_nsString(cx, id, &in_id))
@@ -450,17 +443,17 @@ ObjectWrapperParent::CPOW_GetProperty(JS
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_SetProperty(JSContext *cx, JSObject *obj, jsid id, 
                                       JSBool strict, jsval *vp)
 {
     CPOW_LOG(("Calling CPOW_SetProperty (%s)...",
               JSVAL_TO_CSTR(cx, id)));
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_SetProperty");
 
     AutoCheckOperation aco(cx, self);
 
     nsString in_id;
     JSVariant in_v;
 
@@ -479,17 +472,17 @@ ObjectWrapperParent::CPOW_SetProperty(JS
     
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_DelProperty(JSContext *cx, JSObject *obj, jsid id,
                                       jsval *vp)
 {
     CPOW_LOG(("Calling CPOW_DelProperty (%s)...",
               JSVAL_TO_CSTR(cx, id)));
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_DelProperty");
 
     AutoCheckOperation aco(cx, self);
 
     nsString in_id;
 
     if (!jsval_to_nsString(cx, id, &in_id))
@@ -533,17 +526,17 @@ ObjectWrapperParent::NewEnumerateNext(JS
 
     if (CallNewEnumerateNext(in_state,
                              aco.StatusPtr(), &out_state, &out_id) &&
         aco.Ok() &&
         jsval_from_JSVariant(cx, out_state, statep) &&
         jsid_from_nsString(cx, out_id, idp))
     {
         JSObject* obj = GetJSObject(cx);
-        AutoResolveFlag arf(cx, obj);
+        AutoResolveFlag arf(obj);
         return JS_DefinePropertyById(cx, obj, *idp, JSVAL_VOID, NULL, NULL,
                                      JSPROP_ENUMERATE);
     }
     return JS_FALSE;
 }
 
 JSBool
 ObjectWrapperParent::NewEnumerateDestroy(JSContext* cx, jsval state)
@@ -560,17 +553,17 @@ ObjectWrapperParent::NewEnumerateDestroy
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_NewEnumerate(JSContext *cx, JSObject *obj,
                                        JSIterateOp enum_op, jsval *statep,
                                        jsid *idp)
 {
     CPOW_LOG(("Calling CPOW_NewEnumerate..."));
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_NewEnumerate");
 
     switch (enum_op) {
     case JSENUMERATE_INIT:
     case JSENUMERATE_INIT_ALL:
         self->Manager()->RequestRunToCompletion();
         return self->NewEnumerateInit(cx, statep, idp);
@@ -586,17 +579,17 @@ ObjectWrapperParent::CPOW_NewEnumerate(J
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_NewResolve(JSContext *cx, JSObject *obj, jsid id,
                                      uintN flags, JSObject **objp)
 {
     CPOW_LOG(("Calling CPOW_NewResolve (%s)...",
               JSVAL_TO_CSTR(cx, id)));
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_NewResolve");
 
     AutoCheckOperation aco(cx, self);
 
     nsString in_id;
 
     if (!jsval_to_nsString(cx, id, &in_id))
@@ -607,68 +600,68 @@ ObjectWrapperParent::CPOW_NewResolve(JSC
     if (!self->Manager()->RequestRunToCompletion() ||
         !self->CallNewResolve(in_id, flags,
                               aco.StatusPtr(), &out_pobj) ||
         !aco.Ok() ||
         !JSObject_from_PObjectWrapperParent(cx, out_pobj, objp))
         return JS_FALSE;
 
     if (*objp) {
-        AutoResolveFlag arf(cx, *objp);
+        AutoResolveFlag arf(*objp);
         JS_DefinePropertyById(cx, *objp, id, JSVAL_VOID, NULL, NULL,
                               JSPROP_ENUMERATE);
     }
     return JS_TRUE;
 }
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_Convert(JSContext *cx, JSObject *obj, JSType type,
                                   jsval *vp)
 {
     CPOW_LOG(("Calling CPOW_Convert (to %s)...",
               JS_GetTypeName(cx, type)));
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Convert");
 
     *vp = OBJECT_TO_JSVAL(obj);
 
     return JS_TRUE;
 }
 
 /*static*/ void
 ObjectWrapperParent::CPOW_Finalize(JSContext* cx, JSObject* obj)
 {
     CPOW_LOG(("Calling CPOW_Finalize..."));
     
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (self) {
         self->mObj = NULL;
         unused << ObjectWrapperParent::Send__delete__(self);
     }
 }
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_Call(JSContext* cx, uintN argc, jsval* vp)
 {
     CPOW_LOG(("Calling CPOW_Call..."));
 
     JSObject* thisobj = JS_THIS_OBJECT(cx, vp);
     if (!thisobj)
         return JS_FALSE;
 
     ObjectWrapperParent* function =
-        Unwrap(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
+        Unwrap(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
     if (!function)
         return with_error(cx, JS_FALSE, "Could not unwrap CPOW function");
 
     AutoCheckOperation aco(cx, function);
 
-    ObjectWrapperParent* receiver = Unwrap(cx, thisobj);
+    ObjectWrapperParent* receiver = Unwrap(thisobj);
     if (!receiver) {
         // Substitute child global for parent global object.
         // TODO First make sure we're really replacing the global object?
         ContextWrapperParent* manager =
             static_cast<ContextWrapperParent*>(function->Manager());
         receiver = manager->GetGlobalObjectWrapper();
     }
 
@@ -687,17 +680,17 @@ ObjectWrapperParent::CPOW_Call(JSContext
             jsval_from_JSVariant(cx, out_rval, vp));
 }
 
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_Construct(JSContext* cx, uintN argc, jsval* vp)
 {
     CPOW_LOG(("Calling CPOW_Construct..."));
     
-    ObjectWrapperParent* constructor = Unwrap(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
+    ObjectWrapperParent* constructor = Unwrap(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
     if (!constructor)
         return with_error(cx, JS_FALSE, "Could not unwrap CPOW constructor function");
 
     AutoCheckOperation aco(cx, constructor);
 
     InfallibleTArray<JSVariant> in_argv(argc);
     jsval* argv = JS_ARGV(cx, vp);
     for (uintN i = 0; i < argc; i++)
@@ -715,17 +708,17 @@ ObjectWrapperParent::CPOW_Construct(JSCo
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_HasInstance(JSContext *cx, JSObject *obj, const jsval *v,
                                       JSBool *bp)
 {
     CPOW_LOG(("Calling CPOW_HasInstance..."));
 
     *bp = JS_FALSE;
 
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_HasInstance");
 
     AutoCheckOperation aco(cx, self);
 
     JSVariant in_v;
 
     if (!jsval_to_JSVariant(cx, *v, &in_v))
@@ -740,23 +733,23 @@ ObjectWrapperParent::CPOW_HasInstance(JS
 /*static*/ JSBool
 ObjectWrapperParent::CPOW_Equality(JSContext *cx, JSObject *obj, const jsval *v,
                                    JSBool *bp)
 {
     CPOW_LOG(("Calling CPOW_Equality..."));
 
     *bp = JS_FALSE;
     
-    ObjectWrapperParent* self = Unwrap(cx, obj);
+    ObjectWrapperParent* self = Unwrap(obj);
     if (!self)
         return with_error(cx, JS_FALSE, "Unwrapping failed in CPOW_Equality");
 
     if (JSVAL_IS_PRIMITIVE(*v))
         return JS_TRUE;
 
-    ObjectWrapperParent* other = Unwrap(cx, JSVAL_TO_OBJECT(*v));
+    ObjectWrapperParent* other = Unwrap(JSVAL_TO_OBJECT(*v));
     if (!other)
         return JS_TRUE;
 
     *bp = (self == other);
     
     return JS_TRUE;
 }
--- a/js/ipc/ObjectWrapperParent.h
+++ b/js/ipc/ObjectWrapperParent.h
@@ -64,16 +64,20 @@ class ObjectWrapperParent
 public:
 
     ObjectWrapperParent()
         : mObj(NULL)
     {}
 
     JSObject* GetJSObject(JSContext* cx) const;
 
+    JSObject* GetJSObjectOrNull() const {
+        return mObj;
+    }
+
     jsval GetJSVal(JSContext* cx) const {
         return OBJECT_TO_JSVAL(GetJSObject(cx));
     }
 
     void CheckOperation(JSContext* cx,
                         OperationStatus* status);
 
     static const js::Class sCPOW_JSClass;
@@ -128,18 +132,17 @@ private:
 
     static JSBool
     CPOW_Equality(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
 
     static bool jsval_to_JSVariant(JSContext* cx, jsval from, JSVariant* to);
     static bool jsval_from_JSVariant(JSContext* cx, const JSVariant& from,
                                      jsval* to);
     static bool
-    JSObject_to_PObjectWrapperParent(JSContext* cx, JSObject* from,
-                                     PObjectWrapperParent** to);
+    JSObject_to_PObjectWrapperParent(JSObject* from, PObjectWrapperParent** to);
     static bool
     JSObject_from_PObjectWrapperParent(JSContext* cx,
                                        const PObjectWrapperParent* from,
                                        JSObject** to);
     static bool
     jsval_from_PObjectWrapperParent(JSContext* cx,
                                     const PObjectWrapperParent* from,
                                     jsval* to);
--- a/js/jsd/jsd_val.c
+++ b/js/jsd/jsd_val.c
@@ -701,26 +701,17 @@ jsd_GetValuePrototype(JSDContext* jsdc, 
         JSObject* obj;
         JSObject* proto;
         JS_ASSERT(!jsdval->proto);
         SET_BIT_FLAG(jsdval->flags, GOT_PROTO);
         if(!JSVAL_IS_OBJECT(jsdval->val))
             return NULL;
         if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
             return NULL;
-        JS_BeginRequest(jsdc->dumbContext);
-        call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
-        if(!call) {
-            JS_EndRequest(jsdc->dumbContext);
-
-            return NULL;
-        }
-        proto = JS_GetPrototype(jsdc->dumbContext, obj);
-        JS_LeaveCrossCompartmentCall(call);
-        JS_EndRequest(jsdc->dumbContext);
+        proto = JS_GetPrototype(obj);
         if(!proto)
             return NULL;
         jsdval->proto = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(proto));
     }
     if(jsdval->proto)
         jsdval->proto->nref++;
     return jsdval->proto;
 }
@@ -770,30 +761,26 @@ jsd_GetValueConstructor(JSDContext* jsdc
         JSObject* proto;
         JSObject* ctor;
         JS_ASSERT(!jsdval->ctor);
         SET_BIT_FLAG(jsdval->flags, GOT_CTOR);
         if(!JSVAL_IS_OBJECT(jsdval->val))
             return NULL;
         if(!(obj = JSVAL_TO_OBJECT(jsdval->val)))
             return NULL;
+        proto = JS_GetPrototype(obj);
+        if(!proto)
+            return NULL;
         JS_BeginRequest(jsdc->dumbContext);
         call = JS_EnterCrossCompartmentCall(jsdc->dumbContext, obj);
         if(!call) {
             JS_EndRequest(jsdc->dumbContext);
 
             return NULL;
         }
-        proto = JS_GetPrototype(jsdc->dumbContext,obj);
-        if(!proto)
-        {
-            JS_LeaveCrossCompartmentCall(call);
-            JS_EndRequest(jsdc->dumbContext);
-            return NULL;
-        }
         ctor = JS_GetConstructor(jsdc->dumbContext,proto);
         JS_LeaveCrossCompartmentCall(call);
         JS_EndRequest(jsdc->dumbContext);
         if(!ctor)
             return NULL;
         jsdval->ctor = jsd_NewValue(jsdc, OBJECT_TO_JSVAL(ctor));
     }
     if(jsdval->ctor)
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -170,17 +170,17 @@ namespace CData {
   static JSBool ToSource(JSContext* cx, uintN argc, jsval* vp);
 }
 
 // Int64Base provides functions common to Int64 and UInt64.
 namespace Int64Base {
   JSObject* Construct(JSContext* cx, JSObject* proto, uint64_t data,
     bool isUnsigned);
 
-  uint64_t GetInt(JSContext* cx, JSObject* obj);
+  uint64_t GetInt(JSObject* obj);
 
   JSBool ToString(JSContext* cx, JSObject* obj, uintN argc, jsval* vp,
     bool isUnsigned);
 
   JSBool ToSource(JSContext* cx, JSObject* obj, uintN argc, jsval* vp,
     bool isUnsigned);
 
   static void Finalize(JSContext* cx, JSObject* obj);
@@ -473,26 +473,24 @@ NewUCString(JSContext* cx, const AutoStr
 
 JS_ALWAYS_INLINE size_t
 Align(size_t val, size_t align)
 {
   return ((val - 1) | (align - 1)) + 1;
 }
 
 static ABICode
-GetABICode(JSContext* cx, JSObject* obj)
+GetABICode(JSObject* obj)
 {
   // make sure we have an object representing a CABI class,
   // and extract the enumerated class type from the reserved slot.
   if (JS_GetClass(obj) != &sCABIClass)
     return INVALID_ABI;
 
-  jsval result;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_ABICODE, &result));
-
+  jsval result = JS_GetReservedSlot(obj, SLOT_ABICODE);
   return ABICode(JSVAL_TO_INT(result));
 }
 
 JSErrorFormatString ErrorFormatString[CTYPESERR_LIMIT] = {
 #define MSG_DEF(name, number, count, exception, format) \
   { format, count, exception } ,
 #include "ctypes.msg"
 #undef MSG_DEF
@@ -530,17 +528,17 @@ static JSObject*
 InitCTypeClass(JSContext* cx, JSObject* parent)
 {
   JSFunction* fun = JS_DefineFunction(cx, parent, "CType", ConstructAbstract, 0,
                       CTYPESCTOR_FLAGS);
   if (!fun)
     return NULL;
 
   JSObject* ctor = JS_GetFunctionObject(fun);
-  JSObject* fnproto = JS_GetPrototype(cx, ctor);
+  JSObject* fnproto = JS_GetPrototype(ctor);
   JS_ASSERT(ctor);
   JS_ASSERT(fnproto);
 
   // Set up ctypes.CType.prototype.
   JSObject* prototype = JS_NewObject(cx, &sCTypeProtoClass, fnproto, parent);
   if (!prototype)
     return NULL;
 
@@ -610,18 +608,17 @@ DefineABIConstant(JSContext* cx,
                   JSObject* parent,
                   const char* name,
                   ABICode code)
 {
   JSObject* obj = JS_DefineObject(cx, parent, name, &sCABIClass, NULL,
                     JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
   if (!obj)
     return false;
-  if (!JS_SetReservedSlot(cx, obj, SLOT_ABICODE, INT_TO_JSVAL(code)))
-    return false;
+  JS_SetReservedSlot(obj, SLOT_ABICODE, INT_TO_JSVAL(code));
   return JS_FreezeObject(cx, obj);
 }
 
 // Set up a single type constructor for
 // ctypes.{Pointer,Array,Struct,Function}Type.
 static JSBool
 InitTypeConstructor(JSContext* cx,
                     JSObject* parent,
@@ -682,18 +679,17 @@ InitTypeConstructor(JSContext* cx,
   // become functions and properties on CData objects created from this type.)
   if (instanceFns && !JS_DefineFunctions(cx, dataProto, instanceFns))
     return false;
 
   if (instanceProps && !JS_DefineProperties(cx, dataProto, instanceProps))
     return false;
 
   // Link the type prototype to the data prototype.
-  if (!JS_SetReservedSlot(cx, typeProto, SLOT_OURDATAPROTO, OBJECT_TO_JSVAL(dataProto)))
-    return false;
+  JS_SetReservedSlot(typeProto, SLOT_OURDATAPROTO, OBJECT_TO_JSVAL(dataProto));
 
   if (!JS_FreezeObject(cx, obj) ||
       //!JS_FreezeObject(cx, dataProto) || // XXX fixme - see bug 541212!
       !JS_FreezeObject(cx, typeProto))
     return false;
 
   return true;
 }
@@ -731,28 +727,24 @@ InitInt64Class(JSContext* cx,
     OBJECT_TO_JSVAL(prototype));
 
   if (!JS_FreezeObject(cx, prototype))
     return NULL;
 
   return prototype;
 }
 
-static JSBool
-AttachProtos(JSContext* cx, JSObject* proto, JSObject** protos)
+static void
+AttachProtos(JSObject* proto, JSObject** protos)
 {
   // For a given 'proto' of [[Class]] "CTypeProto", attach each of the 'protos'
   // to the appropriate CTypeProtoSlot. (SLOT_UINT64PROTO is the last slot
   // of [[Class]] "CTypeProto" that we fill in this automated manner.)
-  for (uint32_t i = 0; i <= SLOT_UINT64PROTO; ++i) {
-    if (!JS_SetReservedSlot(cx, proto, i, OBJECT_TO_JSVAL(protos[i])))
-      return false;
-  }
-
-  return true;
+  for (uint32_t i = 0; i <= SLOT_UINT64PROTO; ++i)
+    JS_SetReservedSlot(proto, i, OBJECT_TO_JSVAL(protos[i]));
 }
 
 JSBool
 InitTypeClasses(JSContext* cx, JSObject* parent)
 {
   // Initialize the ctypes.CType class. This acts as an abstract base class for
   // the various types, and provides the common API functions. It has:
   //   * [[Class]] "Function"
@@ -781,19 +773,18 @@ InitTypeClasses(JSContext* cx, JSObject*
   //     * [[Class]] "CDataProto"
   //     * 'constructor' property === ctypes.CData
   //     * Provides properties and functions common to all CDatas.
   JSObject* CDataProto = InitCDataClass(cx, parent, CTypeProto);
   if (!CDataProto)
     return false;
 
   // Link CTypeProto to CDataProto.
-  if (!JS_SetReservedSlot(cx, CTypeProto, SLOT_OURDATAPROTO,
-                          OBJECT_TO_JSVAL(CDataProto)))
-    return false;
+  JS_SetReservedSlot(CTypeProto, SLOT_OURDATAPROTO,
+                     OBJECT_TO_JSVAL(CDataProto));
 
   // Create and attach the special class constructors: ctypes.PointerType,
   // ctypes.ArrayType, ctypes.StructType, and ctypes.FunctionType.
   // Each of these constructors 'c' has, respectively:
   //   * [[Class]] "Function"
   //   * __proto__ === Function.prototype
   //   * A constructor that creates a user-defined type.
   //   * 'prototype' property:
@@ -861,22 +852,21 @@ InitTypeClasses(JSContext* cx, JSObject*
   protos[SLOT_UINT64PROTO] = InitInt64Class(cx, parent, &sUInt64ProtoClass,
     UInt64::Construct, sUInt64Functions, sUInt64StaticFunctions);
   if (!protos[SLOT_UINT64PROTO])
     return false;
 
   // Attach the prototypes just created to each of ctypes.CType.prototype,
   // and the special type constructors, so we can access them when constructing
   // instances of those types. 
-  if (!AttachProtos(cx, CTypeProto, protos) ||
-      !AttachProtos(cx, protos[SLOT_POINTERPROTO], protos) ||
-      !AttachProtos(cx, protos[SLOT_ARRAYPROTO], protos) ||
-      !AttachProtos(cx, protos[SLOT_STRUCTPROTO], protos) ||
-      !AttachProtos(cx, protos[SLOT_FUNCTIONPROTO], protos))
-     return false;
+  AttachProtos(CTypeProto, protos);
+  AttachProtos(protos[SLOT_POINTERPROTO], protos);
+  AttachProtos(protos[SLOT_ARRAYPROTO], protos);
+  AttachProtos(protos[SLOT_STRUCTPROTO], protos);
+  AttachProtos(protos[SLOT_FUNCTIONPROTO], protos);
 
   // Attach objects representing ABI constants.
   if (!DefineABIConstant(cx, parent, "default_abi", ABI_DEFAULT) ||
       !DefineABIConstant(cx, parent, "stdcall_abi", ABI_STDCALL) ||
       !DefineABIConstant(cx, parent, "winapi_abi", ABI_WINAPI))
     return false;
 
   // Create objects representing the builtin types, and attach them to the
@@ -925,22 +915,21 @@ InitTypeClasses(JSContext* cx, JSObject*
 bool
 IsCTypesGlobal(JSObject* obj)
 {
   return JS_GetClass(obj) == &sCTypesGlobalClass;
 }
 
 // Get the JSCTypesCallbacks struct from the 'ctypes' object 'obj'.
 JSCTypesCallbacks*
-GetCallbacks(JSContext* cx, JSObject* obj)
+GetCallbacks(JSObject* obj)
 {
   JS_ASSERT(IsCTypesGlobal(obj));
 
-  jsval result;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_CALLBACKS, &result));
+  jsval result = JS_GetReservedSlot(obj, SLOT_CALLBACKS);
   if (JSVAL_IS_VOID(result))
     return NULL;
 
   return static_cast<JSCTypesCallbacks*>(JSVAL_TO_PRIVATE(result));
 }
 
 JS_BEGIN_EXTERN_C
 
@@ -963,27 +952,25 @@ JS_InitCTypesClass(JSContext* cx, JSObje
   // attach API functions
   if (!JS_DefineFunctions(cx, ctypes, sModuleFunctions))
     return false;
 
   // Seal the ctypes object, to prevent modification.
   return JS_FreezeObject(cx, ctypes);
 }
 
-JS_PUBLIC_API(JSBool)
-JS_SetCTypesCallbacks(JSContext* cx,
-                      JSObject* ctypesObj,
+JS_PUBLIC_API(void)
+JS_SetCTypesCallbacks(JSObject* ctypesObj,
                       JSCTypesCallbacks* callbacks)
 {
   JS_ASSERT(callbacks);
   JS_ASSERT(IsCTypesGlobal(ctypesObj));
 
   // Set the callbacks on a reserved slot.
-  return JS_SetReservedSlot(cx, ctypesObj, SLOT_CALLBACKS,
-    PRIVATE_TO_JSVAL(callbacks));
+  JS_SetReservedSlot(ctypesObj, SLOT_CALLBACKS, PRIVATE_TO_JSVAL(callbacks));
 }
 
 JS_END_EXTERN_C
 
 /*******************************************************************************
 ** Type conversion functions
 *******************************************************************************/
 
@@ -1197,22 +1184,22 @@ jsvalToInteger(JSContext* cx, jsval val,
     // Don't silently lose bits here -- check that val really is an
     // integer value, and has the right sign.
     jsdouble d = JSVAL_TO_DOUBLE(val);
     return ConvertExact(d, result);
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     JSObject* obj = JSVAL_TO_OBJECT(val);
     if (CData::IsCData(obj)) {
-      JSObject* typeObj = CData::GetCType(cx, obj);
-      void* data = CData::GetData(cx, obj);
+      JSObject* typeObj = CData::GetCType(obj);
+      void* data = CData::GetData(obj);
 
       // Check whether the source type is always representable, with exact
       // precision, by the target type. If it is, convert the value.
-      switch (CType::GetTypeCode(cx, typeObj)) {
+      switch (CType::GetTypeCode(typeObj)) {
 #define DEFINE_INT_TYPE(name, fromType, ffiType)                               \
       case TYPE_##name:                                                        \
         if (!IsAlwaysExact<IntegerType, fromType>())                           \
           return false;                                                        \
         *result = IntegerType(*static_cast<fromType*>(data));                  \
         return true;
 #define DEFINE_WRAPPED_INT_TYPE(x, y, z) DEFINE_INT_TYPE(x, y, z)
 #include "typedefs.h"
@@ -1232,23 +1219,23 @@ jsvalToInteger(JSContext* cx, jsval val,
       case TYPE_struct:
         // Not a compatible number type.
         return false;
       }
     }
 
     if (Int64::IsInt64(obj)) {
       // Make sure the integer fits in IntegerType.
-      int64_t i = Int64Base::GetInt(cx, obj);
+      int64_t i = Int64Base::GetInt(obj);
       return ConvertExact(i, result);
     }
 
     if (UInt64::IsUInt64(obj)) {
       // Make sure the integer fits in IntegerType.
-      uint64_t i = Int64Base::GetInt(cx, obj);
+      uint64_t i = Int64Base::GetInt(obj);
       return ConvertExact(i, result);
     }
 
     return false; 
   }
   if (JSVAL_IS_BOOLEAN(val)) {
     // Implicitly promote boolean values to 0 or 1, like C.
     *result = JSVAL_TO_BOOLEAN(val);
@@ -1278,22 +1265,22 @@ jsvalToFloat(JSContext *cx, jsval val, F
   }
   if (JSVAL_IS_DOUBLE(val)) {
     *result = FloatType(JSVAL_TO_DOUBLE(val));
     return true;
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     JSObject* obj = JSVAL_TO_OBJECT(val);
     if (CData::IsCData(obj)) {
-      JSObject* typeObj = CData::GetCType(cx, obj);
-      void* data = CData::GetData(cx, obj);
+      JSObject* typeObj = CData::GetCType(obj);
+      void* data = CData::GetData(obj);
 
       // Check whether the source type is always representable, with exact
       // precision, by the target type. If it is, convert the value.
-      switch (CType::GetTypeCode(cx, typeObj)) {
+      switch (CType::GetTypeCode(typeObj)) {
 #define DEFINE_FLOAT_TYPE(name, fromType, ffiType)                             \
       case TYPE_##name:                                                        \
         if (!IsAlwaysExact<FloatType, fromType>())                             \
           return false;                                                        \
         *result = FloatType(*static_cast<fromType*>(data));                    \
         return true;
 #define DEFINE_INT_TYPE(x, y, z) DEFINE_FLOAT_TYPE(x, y, z)
 #define DEFINE_WRAPPED_INT_TYPE(x, y, z) DEFINE_INT_TYPE(x, y, z)
@@ -1404,23 +1391,23 @@ jsvalToBigInteger(JSContext* cx,
     return StringToInteger(cx, JSVAL_TO_STRING(val), result);
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     // Allow conversion from an Int64 or UInt64 object directly.
     JSObject* obj = JSVAL_TO_OBJECT(val);
 
     if (UInt64::IsUInt64(obj)) {
       // Make sure the integer fits in IntegerType.
-      uint64_t i = Int64Base::GetInt(cx, obj);
+      uint64_t i = Int64Base::GetInt(obj);
       return ConvertExact(i, result);
     }
 
     if (Int64::IsInt64(obj)) {
       // Make sure the integer fits in IntegerType.
-      int64_t i = Int64Base::GetInt(cx, obj);
+      int64_t i = Int64Base::GetInt(obj);
       return ConvertExact(i, result);
     }
   }
   return false;
 }
 
 // Implicitly convert val to a size value, where the size value is represented
 // by size_t but must also fit in a jsdouble.
@@ -1460,23 +1447,23 @@ jsidToBigInteger(JSContext* cx,
     return StringToInteger(cx, JSID_TO_STRING(val), result);
   }
   if (JSID_IS_OBJECT(val)) {
     // Allow conversion from an Int64 or UInt64 object directly.
     JSObject* obj = JSID_TO_OBJECT(val);
 
     if (UInt64::IsUInt64(obj)) {
       // Make sure the integer fits in IntegerType.
-      uint64_t i = Int64Base::GetInt(cx, obj);
+      uint64_t i = Int64Base::GetInt(obj);
       return ConvertExact(i, result);
     }
 
     if (Int64::IsInt64(obj)) {
       // Make sure the integer fits in IntegerType.
-      int64_t i = Int64Base::GetInt(cx, obj);
+      int64_t i = Int64Base::GetInt(obj);
       return ConvertExact(i, result);
     }
   }
   return false;
 }
 
 // Implicitly convert val to a size value, where the size value is represented
 // by size_t but must also fit in a jsdouble.
@@ -1501,36 +1488,36 @@ SizeTojsval(JSContext* cx, size_t size, 
   }
 
   return JS_NewNumberValue(cx, jsdouble(size), result);
 }
 
 // Forcefully convert val to IntegerType when explicitly requested.
 template<class IntegerType>
 static bool
-jsvalToIntegerExplicit(JSContext* cx, jsval val, IntegerType* result)
+jsvalToIntegerExplicit(jsval val, IntegerType* result)
 {
   JS_STATIC_ASSERT(numeric_limits<IntegerType>::is_exact);
 
   if (JSVAL_IS_DOUBLE(val)) {
     // Convert -Inf, Inf, and NaN to 0; otherwise, convert by C-style cast.
     jsdouble d = JSVAL_TO_DOUBLE(val);
     *result = FloatIsFinite(d) ? IntegerType(d) : 0;
     return true;
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     // Convert Int64 and UInt64 values by C-style cast.
     JSObject* obj = JSVAL_TO_OBJECT(val);
     if (Int64::IsInt64(obj)) {
-      int64_t i = Int64Base::GetInt(cx, obj);
+      int64_t i = Int64Base::GetInt(obj);
       *result = IntegerType(i);
       return true;
     }
     if (UInt64::IsUInt64(obj)) {
-      uint64_t i = Int64Base::GetInt(cx, obj);
+      uint64_t i = Int64Base::GetInt(obj);
       *result = IntegerType(i);
       return true;
     }
   }
   return false;
 }
 
 // Forcefully convert val to a pointer value when explicitly requested.
@@ -1559,28 +1546,28 @@ jsvalToPtrExplicit(JSContext* cx, jsval 
     // Don't silently lose bits here -- check that val really is an
     // integer value, and has the right sign.
     *result = Convert<uintptr_t>(d);
     return jsdouble(*result) == d;
   }
   if (!JSVAL_IS_PRIMITIVE(val)) {
     JSObject* obj = JSVAL_TO_OBJECT(val);
     if (Int64::IsInt64(obj)) {
-      int64_t i = Int64Base::GetInt(cx, obj);
+      int64_t i = Int64Base::GetInt(obj);
       intptr_t p = intptr_t(i);
 
       // Make sure the integer fits in the alotted precision.
       if (int64_t(p) != i)
         return false;
       *result = uintptr_t(p);
       return true;
     }
 
     if (UInt64::IsUInt64(obj)) {
-      uint64_t i = Int64Base::GetInt(cx, obj);
+      uint64_t i = Int64Base::GetInt(obj);
 
       // Make sure the integer fits in the alotted precision.
       *result = uintptr_t(i);
       return uint64_t(*result) == i;
     }
   }
   return false;
 }
@@ -1645,17 +1632,17 @@ ConvertToJS(JSContext* cx,
             bool wantPrimitive,
             bool ownResult,
             jsval* result)
 {
   JS_ASSERT(!parentObj || CData::IsCData(parentObj));
   JS_ASSERT(!parentObj || !ownResult);
   JS_ASSERT(!wantPrimitive || !ownResult);
 
-  TypeCode typeCode = CType::GetTypeCode(cx, typeObj);
+  TypeCode typeCode = CType::GetTypeCode(typeObj);
 
   switch (typeCode) {
   case TYPE_void_t:
     *result = JSVAL_VOID;
     break;
   case TYPE_bool:
     *result = *static_cast<bool*>(data) ? JSVAL_TRUE : JSVAL_FALSE;
     break;
@@ -1671,21 +1658,21 @@ ConvertToJS(JSContext* cx,
 #define DEFINE_WRAPPED_INT_TYPE(name, type, ffiType)                           \
   case TYPE_##name: {                                                          \
     /* Return an Int64 or UInt64 object - do not convert to a JS number. */    \
     uint64_t value;                                                            \
     JSObject* proto;                                                           \
     if (!numeric_limits<type>::is_signed) {                                    \
       value = *static_cast<type*>(data);                                       \
       /* Get ctypes.UInt64.prototype from ctypes.CType.prototype. */           \
-      proto = CType::GetProtoFromType(cx, typeObj, SLOT_UINT64PROTO);          \
+      proto = CType::GetProtoFromType(typeObj, SLOT_UINT64PROTO);              \
     } else {                                                                   \
       value = int64_t(*static_cast<type*>(data));                              \
       /* Get ctypes.Int64.prototype from ctypes.CType.prototype. */            \
-      proto = CType::GetProtoFromType(cx, typeObj, SLOT_INT64PROTO);           \
+      proto = CType::GetProtoFromType(typeObj, SLOT_INT64PROTO);               \
     }                                                                          \
                                                                                \
     JSObject* obj = Int64Base::Construct(cx, proto, value,                     \
       !numeric_limits<type>::is_signed);                                       \
     if (!obj)                                                                  \
       return false;                                                            \
     *result = OBJECT_TO_JSVAL(obj);                                            \
     break;                                                                     \
@@ -1751,36 +1738,36 @@ ConvertToJS(JSContext* cx,
 JSBool
 ImplicitConvert(JSContext* cx,
                 jsval val,
                 JSObject* targetType,
                 void* buffer,
                 bool isArgument,
                 bool* freePointer)
 {
-  JS_ASSERT(CType::IsSizeDefined(cx, targetType));
+  JS_ASSERT(CType::IsSizeDefined(targetType));
 
   // First, check if val is a CData object of type targetType.
   JSObject* sourceData = NULL;
   JSObject* sourceType = NULL;
   if (!JSVAL_IS_PRIMITIVE(val) &&
       CData::IsCData(JSVAL_TO_OBJECT(val))) {
     sourceData = JSVAL_TO_OBJECT(val);
-    sourceType = CData::GetCType(cx, sourceData);
+    sourceType = CData::GetCType(sourceData);
 
     // If the types are equal, copy the buffer contained within the CData.
     // (Note that the buffers may overlap partially or completely.)
-    if (CType::TypesEqual(cx, sourceType, targetType)) {
-      size_t size = CType::GetSize(cx, sourceType);
-      memmove(buffer, CData::GetData(cx, sourceData), size);
+    if (CType::TypesEqual(sourceType, targetType)) {
+      size_t size = CType::GetSize(sourceType);
+      memmove(buffer, CData::GetData(sourceData), size);
       return true;
     }
   }
 
-  TypeCode targetCode = CType::GetTypeCode(cx, targetType);
+  TypeCode targetCode = CType::GetTypeCode(targetType);
 
   switch (targetCode) {
   case TYPE_bool: {
     // Do not implicitly lose bits, but allow the values 0, 1, and -0.
     // Programs can convert explicitly, if needed, using `Boolean(v)` or `!!v`.
     bool result;
     if (!jsvalToBool(cx, val, &result))
       return TypeError(cx, "boolean", val);
@@ -1828,49 +1815,49 @@ ImplicitConvert(JSContext* cx,
 #include "typedefs.h"
   case TYPE_pointer: {
     if (JSVAL_IS_NULL(val)) {
       // Convert to a null pointer.
       *static_cast<void**>(buffer) = NULL;
       break;
     }
 
-    JSObject* baseType = PointerType::GetBaseType(cx, targetType);
+    JSObject* baseType = PointerType::GetBaseType(targetType);
     if (sourceData) {
       // First, determine if the targetType is ctypes.void_t.ptr.
-      TypeCode sourceCode = CType::GetTypeCode(cx, sourceType);
-      void* sourceBuffer = CData::GetData(cx, sourceData);
-      bool voidptrTarget = CType::GetTypeCode(cx, baseType) == TYPE_void_t;
+      TypeCode sourceCode = CType::GetTypeCode(sourceType);
+      void* sourceBuffer = CData::GetData(sourceData);
+      bool voidptrTarget = CType::GetTypeCode(baseType) == TYPE_void_t;
 
       if (sourceCode == TYPE_pointer && voidptrTarget) {
         // Autoconvert if targetType is ctypes.voidptr_t.
         *static_cast<void**>(buffer) = *static_cast<void**>(sourceBuffer);
         break;
       }
       if (sourceCode == TYPE_array) {
         // Autoconvert an array to a ctypes.void_t.ptr or to
         // sourceType.elementType.ptr, just like C.
-        JSObject* elementType = ArrayType::GetBaseType(cx, sourceType);
-        if (voidptrTarget || CType::TypesEqual(cx, baseType, elementType)) {
+        JSObject* elementType = ArrayType::GetBaseType(sourceType);
+        if (voidptrTarget || CType::TypesEqual(baseType, elementType)) {
           *static_cast<void**>(buffer) = sourceBuffer;
           break;
         }
       }
 
     } else if (isArgument && JSVAL_IS_STRING(val)) {
       // Convert the string for the ffi call. This requires allocating space
       // which the caller assumes ownership of.
       // TODO: Extend this so we can safely convert strings at other times also.
       JSString* sourceString = JSVAL_TO_STRING(val);
       size_t sourceLength = sourceString->length();
       const jschar* sourceChars = sourceString->getChars(cx);
       if (!sourceChars)
         return false;
 
-      switch (CType::GetTypeCode(cx, baseType)) {
+      switch (CType::GetTypeCode(baseType)) {
       case TYPE_char:
       case TYPE_signed_char:
       case TYPE_unsigned_char: {
         // Convert from UTF-16 to UTF-8.
         size_t nbytes =
           GetDeflatedUTF8StringLength(cx, sourceChars, sourceLength);
         if (nbytes == (size_t) -1)
           return false;
@@ -1907,27 +1894,27 @@ ImplicitConvert(JSContext* cx,
       default:
         return TypeError(cx, "pointer", val);
       }
       break;
     }
     return TypeError(cx, "pointer", val);
   }
   case TYPE_array: {
-    JSObject* baseType = ArrayType::GetBaseType(cx, targetType);
-    size_t targetLength = ArrayType::GetLength(cx, targetType);
+    JSObject* baseType = ArrayType::GetBaseType(targetType);
+    size_t targetLength = ArrayType::GetLength(targetType);
 
     if (JSVAL_IS_STRING(val)) {
       JSString* sourceString = JSVAL_TO_STRING(val);
       size_t sourceLength = sourceString->length();
       const jschar* sourceChars = sourceString->getChars(cx);
       if (!sourceChars)
         return false;
 
-      switch (CType::GetTypeCode(cx, baseType)) {
+      switch (CType::GetTypeCode(baseType)) {
       case TYPE_char:
       case TYPE_signed_char:
       case TYPE_unsigned_char: {
         // Convert from UTF-16 to UTF-8.
         size_t nbytes =
           GetDeflatedUTF8StringLength(cx, sourceChars, sourceLength);
         if (nbytes == (size_t) -1)
           return false;
@@ -1971,17 +1958,17 @@ ImplicitConvert(JSContext* cx,
       jsuint sourceLength;
       if (!JS_GetArrayLength(cx, sourceArray, &sourceLength) ||
           targetLength != size_t(sourceLength)) {
         JS_ReportError(cx, "ArrayType length does not match source array length");
         return false;
       }
 
       // Convert into an intermediate, in case of failure.
-      size_t elementSize = CType::GetSize(cx, baseType);
+      size_t elementSize = CType::GetSize(baseType);
       size_t arraySize = elementSize * targetLength;
       AutoPtr<char>::Array intermediate(cx->array_new<char>(arraySize));
       if (!intermediate) {
         JS_ReportAllocationOverflow(cx);
         return false;
       }
 
       for (jsuint i = 0; i < sourceLength; ++i) {
@@ -2009,17 +1996,17 @@ ImplicitConvert(JSContext* cx,
       // specification, convert the fields.
       JSObject* obj = JSVAL_TO_OBJECT(val);
       JSObject* iter = JS_NewPropertyIterator(cx, obj);
       if (!iter)
         return false;
       js::AutoObjectRooter iterroot(cx, iter);
 
       // Convert into an intermediate, in case of failure.
-      size_t structSize = CType::GetSize(cx, targetType);
+      size_t structSize = CType::GetSize(targetType);
       AutoPtr<char>::Array intermediate(cx->array_new<char>(structSize));
       if (!intermediate) {
         JS_ReportAllocationOverflow(cx);
         return false;
       }
 
       jsid id;
       size_t i = 0;
@@ -2046,17 +2033,17 @@ ImplicitConvert(JSContext* cx,
         // Convert the field via ImplicitConvert().
         char* fieldData = intermediate.get() + field->mOffset;
         if (!ImplicitConvert(cx, prop.jsval_value(), field->mType, fieldData, false, NULL))
           return false;
 
         ++i;
       }
 
-      const FieldInfoHash* fields = StructType::GetFieldInfo(cx, targetType);
+      const FieldInfoHash* fields = StructType::GetFieldInfo(targetType);
       if (i != fields->count()) {
         JS_ReportError(cx, "missing fields");
         return false;
       }
 
       memcpy(buffer, intermediate.get(), structSize);
       break;
     }
@@ -2088,32 +2075,32 @@ ExplicitConvert(JSContext* cx, jsval val
   js::AutoValueRooter ex(cx);
   if (!JS_GetPendingException(cx, ex.jsval_addr()))
     return false;
 
   // Otherwise, assume soft failure. Clear the pending exception so that we
   // can throw a different one as required.
   JS_ClearPendingException(cx);
 
-  TypeCode type = CType::GetTypeCode(cx, targetType);
+  TypeCode type = CType::GetTypeCode(targetType);
 
   switch (type) {
   case TYPE_bool: {
     // Convert according to the ECMAScript ToBoolean() function.
     JSBool result;
     ASSERT_OK(JS_ValueToBoolean(cx, val, &result));
     *static_cast<bool*>(buffer) = result != JS_FALSE;
     break;
   }
 #define DEFINE_INT_TYPE(name, type, ffiType)                                   \
   case TYPE_##name: {                                                          \
     /* Convert numeric values with a C-style cast, and */                      \
     /* allow conversion from a base-10 or base-16 string. */                   \
     type result;                                                               \
-    if (!jsvalToIntegerExplicit(cx, val, &result) &&                           \
+    if (!jsvalToIntegerExplicit(val, &result) &&                               \
         (!JSVAL_IS_STRING(val) ||                                              \
          !StringToInteger(cx, JSVAL_TO_STRING(val), &result)))                 \
       return TypeError(cx, #name, val);                                        \
     *static_cast<type*>(buffer) = result;                                      \
     break;                                                                     \
   }
 #define DEFINE_WRAPPED_INT_TYPE(x, y, z) DEFINE_INT_TYPE(x, y, z)
 #define DEFINE_CHAR_TYPE(x, y, z) DEFINE_INT_TYPE(x, y, z)
@@ -2154,52 +2141,52 @@ BuildTypeName(JSContext* cx, JSObject* t
   AutoString result;
 
   // Walk the hierarchy of types, outermost to innermost, building up the type
   // string. This consists of the base type, which goes on the left.
   // Derived type modifiers (* and []) build from the inside outward, with
   // pointers on the left and arrays on the right. An excellent description
   // of the rules for building C type declarations can be found at:
   // http://unixwiz.net/techtips/reading-cdecl.html
-  TypeCode prevGrouping = CType::GetTypeCode(cx, typeObj), currentGrouping;
+  TypeCode prevGrouping = CType::GetTypeCode(typeObj), currentGrouping;
   while (1) {
-    currentGrouping = CType::GetTypeCode(cx, typeObj);
+    currentGrouping = CType::GetTypeCode(typeObj);
     switch (currentGrouping) {
     case TYPE_pointer: {
       // Pointer types go on the left.
       PrependString(result, "*");
 
-      typeObj = PointerType::GetBaseType(cx, typeObj);
+      typeObj = PointerType::GetBaseType(typeObj);
       prevGrouping = currentGrouping;
       continue;
     }
     case TYPE_array: {
       if (prevGrouping == TYPE_pointer) {
         // Outer type is pointer, inner type is array. Grouping is required.
         PrependString(result, "(");
         AppendString(result, ")");
       } 
 
       // Array types go on the right.
       AppendString(result, "[");
       size_t length;
-      if (ArrayType::GetSafeLength(cx, typeObj, &length))
+      if (ArrayType::GetSafeLength(typeObj, &length))
         IntegerToString(length, 10, result);
 
       AppendString(result, "]");
 
-      typeObj = ArrayType::GetBaseType(cx, typeObj);
+      typeObj = ArrayType::GetBaseType(typeObj);
       prevGrouping = currentGrouping;
       continue;
     }
     case TYPE_function: {
-      FunctionInfo* fninfo = FunctionType::GetFunctionInfo(cx, typeObj);
+      FunctionInfo* fninfo = FunctionType::GetFunctionInfo(typeObj);
 
       // Add in the calling convention, if it's not cdecl.
-      ABICode abi = GetABICode(cx, fninfo->mABI);
+      ABICode abi = GetABICode(fninfo->mABI);
       if (abi == ABI_STDCALL)
         PrependString(result, "__stdcall ");
       else if (abi == ABI_WINAPI)
         PrependString(result, "WINAPI ");
 
       // Wrap the entire expression so far with parens.
       PrependString(result, "(");
       AppendString(result, ")");
@@ -2245,47 +2232,47 @@ BuildTypeName(JSContext* cx, JSObject* t
 // equality is determined by strict JSObject pointer equality.)
 static void
 BuildTypeSource(JSContext* cx,
                 JSObject* typeObj, 
                 bool makeShort, 
                 AutoString& result)
 {
   // Walk the types, building up the toSource() string.
-  switch (CType::GetTypeCode(cx, typeObj)) {
+  switch (CType::GetTypeCode(typeObj)) {
   case TYPE_void_t:
 #define DEFINE_TYPE(name, type, ffiType)  \
   case TYPE_##name:
 #include "typedefs.h"
   {
     AppendString(result, "ctypes.");
     JSString* nameStr = CType::GetName(cx, typeObj);
     AppendString(result, nameStr);
     break;
   }
   case TYPE_pointer: {
-    JSObject* baseType = PointerType::GetBaseType(cx, typeObj);
+    JSObject* baseType = PointerType::GetBaseType(typeObj);
 
     // Specialcase ctypes.voidptr_t.
-    if (CType::GetTypeCode(cx, baseType) == TYPE_void_t) {
+    if (CType::GetTypeCode(baseType) == TYPE_void_t) {
       AppendString(result, "ctypes.voidptr_t");
       break;
     }
 
     // Recursively build the source string, and append '.ptr'.
     BuildTypeSource(cx, baseType, makeShort, result);
     AppendString(result, ".ptr");
     break;
   }
   case TYPE_function: {
-    FunctionInfo* fninfo = FunctionType::GetFunctionInfo(cx, typeObj);
+    FunctionInfo* fninfo = FunctionType::GetFunctionInfo(typeObj);
 
     AppendString(result, "ctypes.FunctionType(");
 
-    switch (GetABICode(cx, fninfo->mABI)) {
+    switch (GetABICode(fninfo->mABI)) {
     case ABI_DEFAULT:
       AppendString(result, "ctypes.default_abi, ");
       break;
     case ABI_STDCALL:
       AppendString(result, "ctypes.stdcall_abi, ");
       break;
     case ABI_WINAPI:
       AppendString(result, "ctypes.winapi_abi, ");
@@ -2314,22 +2301,22 @@ BuildTypeSource(JSContext* cx,
 
     AppendString(result, ")");
     break;
   }
   case TYPE_array: {
     // Recursively build the source string, and append '.array(n)',
     // where n is the array length, or the empty string if the array length
     // is undefined.
-    JSObject* baseType = ArrayType::GetBaseType(cx, typeObj);
+    JSObject* baseType = ArrayType::GetBaseType(typeObj);
     BuildTypeSource(cx, baseType, makeShort, result);
     AppendString(result, ".array(");
 
     size_t length;
-    if (ArrayType::GetSafeLength(cx, typeObj, &length))
+    if (ArrayType::GetSafeLength(typeObj, &length))
       IntegerToString(length, 10, result);
 
     AppendString(result, ")");
     break;
   }
   case TYPE_struct: {
     JSString* name = CType::GetName(cx, typeObj);
 
@@ -2341,24 +2328,24 @@ BuildTypeSource(JSContext* cx,
     }
 
     // Write the full struct declaration.
     AppendString(result, "ctypes.StructType(\"");
     AppendString(result, name);
     AppendString(result, "\"");
 
     // If it's an opaque struct, we're done.
-    if (!CType::IsSizeDefined(cx, typeObj)) {
+    if (!CType::IsSizeDefined(typeObj)) {
       AppendString(result, ")");
       break;
     }
 
     AppendString(result, ", [");
 
-    const FieldInfoHash* fields = StructType::GetFieldInfo(cx, typeObj);
+    const FieldInfoHash* fields = StructType::GetFieldInfo(typeObj);
     size_t length = fields->count();
     Array<const FieldInfoHash::Entry*, 64> fieldsArray;
     if (!fieldsArray.resize(length))
       break;
 
     for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront())
       fieldsArray[r.front().value.mIndex] = &r.front();
 
@@ -2391,17 +2378,17 @@ BuildTypeSource(JSContext* cx,
 // structs and arrays are converted with ImplicitConvert.)
 static JSBool
 BuildDataSource(JSContext* cx,
                 JSObject* typeObj, 
                 void* data, 
                 bool isImplicit, 
                 AutoString& result)
 {
-  TypeCode type = CType::GetTypeCode(cx, typeObj);
+  TypeCode type = CType::GetTypeCode(typeObj);
   switch (type) {
   case TYPE_bool:
     if (*static_cast<bool*>(data))
       AppendString(result, "true");
     else
       AppendString(result, "false");
     break;
 #define DEFINE_INT_TYPE(name, type, ffiType)                                   \
@@ -2472,21 +2459,21 @@ BuildDataSource(JSContext* cx,
     if (isImplicit)
       AppendString(result, ")");
 
     break;
   }
   case TYPE_array: {
     // Serialize each element of the array recursively. Each element must
     // be able to ImplicitConvert successfully.
-    JSObject* baseType = ArrayType::GetBaseType(cx, typeObj);
+    JSObject* baseType = ArrayType::GetBaseType(typeObj);
     AppendString(result, "[");
 
-    size_t length = ArrayType::GetLength(cx, typeObj);
-    size_t elementSize = CType::GetSize(cx, baseType);
+    size_t length = ArrayType::GetLength(typeObj);
+    size_t elementSize = CType::GetSize(baseType);
     for (size_t i = 0; i < length; ++i) {
       char* element = static_cast<char*>(data) + elementSize * i;
       if (!BuildDataSource(cx, baseType, element, true, result))
         return false;
 
       if (i + 1 < length)
         AppendString(result, ", ");
     }
@@ -2498,17 +2485,17 @@ BuildDataSource(JSContext* cx,
       // The result must be able to ImplicitConvert successfully.
       // Serialize the data as an object with properties, rather than
       // a sequence of arguments to the StructType constructor.
       AppendString(result, "{");
     }
 
     // Serialize each field of the struct recursively. Each field must
     // be able to ImplicitConvert successfully.
-    const FieldInfoHash* fields = StructType::GetFieldInfo(cx, typeObj);
+    const FieldInfoHash* fields = StructType::GetFieldInfo(typeObj);
     size_t length = fields->count();
     Array<const FieldInfoHash::Entry*, 64> fieldsArray;
     if (!fieldsArray.resize(length))
       return false;
 
     for (FieldInfoHash::Range r = fields->all(); !r.empty(); r.popFront())
       fieldsArray[r.front().value.mIndex] = &r.front();
 
@@ -2571,17 +2558,17 @@ CType::ConstructData(JSContext* cx,
     JS_ReportError(cx, "not a CType");
     return JS_FALSE;
   }
 
   // How we construct the CData object depends on what type we represent.
   // An instance 'd' of a CData object of type 't' has:
   //   * [[Class]] "CData"
   //   * __proto__ === t.prototype
-  switch (GetTypeCode(cx, obj)) {
+  switch (GetTypeCode(obj)) {
   case TYPE_void_t:
     JS_ReportError(cx, "cannot construct from void_t");
     return JS_FALSE;
   case TYPE_function:
     JS_ReportError(cx, "cannot construct from FunctionType; use FunctionType.ptr instead");
     return JS_FALSE;
   case TYPE_pointer:
     return PointerType::ConstructData(cx, obj, argc, vp);
@@ -2606,17 +2593,17 @@ CType::ConstructBasic(JSContext* cx,
   }
 
   // construct a CData object
   JSObject* result = CData::Create(cx, obj, NULL, NULL, true);
   if (!result)
     return JS_FALSE;
 
   if (argc == 1) {
-    if (!ExplicitConvert(cx, JS_ARGV(cx, vp)[0], obj, CData::GetData(cx, result)))
+    if (!ExplicitConvert(cx, JS_ARGV(cx, vp)[0], obj, CData::GetData(result)))
       return JS_FALSE;
   }
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
   return JS_TRUE;
 }
 
 JSObject*
@@ -2624,17 +2611,17 @@ CType::Create(JSContext* cx,
               JSObject* typeProto,
               JSObject* dataProto,
               TypeCode type,
               JSString* name,
               jsval size,
               jsval align,
               ffi_type* ffiType)
 {
-  JSObject* parent = JS_GetParent(cx, typeProto);
+  JSObject* parent = JS_GetParent(typeProto);
   JS_ASSERT(parent);
 
   // Create a CType object with the properties and slots common to all CTypes.
   // Each type object 't' has:
   //   * [[Class]] "CType"
   //   * __proto__ === 'typeProto'; one of ctypes.{CType,PointerType,ArrayType,
   //     StructType}.prototype
   //   * A constructor which creates and returns a CData object, containing
@@ -2649,47 +2636,48 @@ CType::Create(JSContext* cx,
   //     * Additional properties specified by 'ps', as appropriate for the
   //       specific type instance 't'.
   JSObject* typeObj = JS_NewObject(cx, &sCTypeClass, typeProto, parent);
   if (!typeObj)
     return NULL;
   js::AutoObjectRooter root(cx, typeObj);
 
   // Set up the reserved slots.
-  if (!JS_SetReservedSlot(cx, typeObj, SLOT_TYPECODE, INT_TO_JSVAL(type)) ||
-      (ffiType && !JS_SetReservedSlot(cx, typeObj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(ffiType))) ||
-      (name && !JS_SetReservedSlot(cx, typeObj, SLOT_NAME, STRING_TO_JSVAL(name))) ||
-      !JS_SetReservedSlot(cx, typeObj, SLOT_SIZE, size) ||
-      !JS_SetReservedSlot(cx, typeObj, SLOT_ALIGN, align))
-    return NULL;
+  JS_SetReservedSlot(typeObj, SLOT_TYPECODE, INT_TO_JSVAL(type));
+  if (ffiType)
+    JS_SetReservedSlot(typeObj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(ffiType));
+  if (name)
+    JS_SetReservedSlot(typeObj, SLOT_NAME, STRING_TO_JSVAL(name));
+  JS_SetReservedSlot(typeObj, SLOT_SIZE, size);
+  JS_SetReservedSlot(typeObj, SLOT_ALIGN, align);
 
   if (dataProto) {
     // Set up the 'prototype' and 'prototype.constructor' properties.
     JSObject* prototype = JS_NewObject(cx, &sCDataProtoClass, dataProto, parent);
     if (!prototype)
       return NULL;
     js::AutoObjectRooter protoroot(cx, prototype);
 
     if (!JS_DefineProperty(cx, prototype, "constructor", OBJECT_TO_JSVAL(typeObj),
            NULL, NULL, JSPROP_READONLY | JSPROP_PERMANENT))
       return NULL;
 
     // Set the 'prototype' object.
-    if (//!JS_FreezeObject(cx, prototype) || // XXX fixme - see bug 541212!
-        !JS_SetReservedSlot(cx, typeObj, SLOT_PROTO, OBJECT_TO_JSVAL(prototype)))
-      return NULL;
+    //if (!JS_FreezeObject(cx, prototype)) // XXX fixme - see bug 541212!
+    //  return NULL;
+    JS_SetReservedSlot(typeObj, SLOT_PROTO, OBJECT_TO_JSVAL(prototype));
   }
 
   if (!JS_FreezeObject(cx, typeObj))
     return NULL;
 
   // Assert a sanity check on size and alignment: size % alignment should always
   // be zero.
-  JS_ASSERT_IF(IsSizeDefined(cx, typeObj),
-               GetSize(cx, typeObj) % GetAlignment(cx, typeObj) == 0);
+  JS_ASSERT_IF(IsSizeDefined(typeObj),
+               GetSize(typeObj) % GetAlignment(typeObj) == 0);
 
   return typeObj;
 }
 
 JSObject*
 CType::DefineBuiltin(JSContext* cx,
                      JSObject* parent,
                      const char* propName,
@@ -2719,43 +2707,43 @@ CType::DefineBuiltin(JSContext* cx,
 
   return typeObj;
 }
 
 void
 CType::Finalize(JSContext* cx, JSObject* obj)
 {
   // Make sure our TypeCode slot is legit. If it's not, bail.
-  jsval slot;
-  if (!JS_GetReservedSlot(cx, obj, SLOT_TYPECODE, &slot) || JSVAL_IS_VOID(slot))
+  jsval slot = JS_GetReservedSlot(obj, SLOT_TYPECODE);
+  if (JSVAL_IS_VOID(slot))
     return;
 
   // The contents of our slots depends on what kind of type we are.
   switch (TypeCode(JSVAL_TO_INT(slot))) {
   case TYPE_function: {
     // Free the FunctionInfo.
-    ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_FNINFO, &slot));
+    slot = JS_GetReservedSlot(obj, SLOT_FNINFO);
     if (!JSVAL_IS_VOID(slot))
       cx->delete_(static_cast<FunctionInfo*>(JSVAL_TO_PRIVATE(slot)));
     break;
   }
 
   case TYPE_struct: {
     // Free the FieldInfoHash table.
-    ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_FIELDINFO, &slot));
+    slot = JS_GetReservedSlot(obj, SLOT_FIELDINFO);
     if (!JSVAL_IS_VOID(slot)) {
       void* info = JSVAL_TO_PRIVATE(slot);
       cx->delete_(static_cast<FieldInfoHash*>(info));
     }
   }
 
     // Fall through.
   case TYPE_array: {
     // Free the ffi_type info.
-    ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_FFITYPE, &slot));
+    slot = JS_GetReservedSlot(obj, SLOT_FFITYPE);
     if (!JSVAL_IS_VOID(slot)) {
       ffi_type* ffiType = static_cast<ffi_type*>(JSVAL_TO_PRIVATE(slot));
       cx->array_delete(ffiType->elements);
       cx->delete_(ffiType);
     }
 
     break;
   }
@@ -2768,18 +2756,18 @@ CType::Finalize(JSContext* cx, JSObject*
 void
 CType::FinalizeProtoClass(JSContext* cx, JSObject* obj)
 {
   // Finalize the CTypeProto class. The only important bit here is our
   // SLOT_CLOSURECX -- it contains the JSContext that was (lazily) instantiated
   // for use with FunctionType closures. And if we're here, in this finalizer,
   // we're guaranteed to not need it anymore. Note that this slot will only
   // be set for the object (of class CTypeProto) ctypes.FunctionType.prototype.
-  jsval slot;
-  if (!JS_GetReservedSlot(cx, obj, SLOT_CLOSURECX, &slot) || JSVAL_IS_VOID(slot))
+  jsval slot = JS_GetReservedSlot(obj, SLOT_CLOSURECX);
+  if (JSVAL_IS_VOID(slot))
     return;
 
   JSContext* closureCx = static_cast<JSContext*>(JSVAL_TO_PRIVATE(slot));
   JS_DestroyContextNoGC(closureCx);
 }
 
 void
 CType::Trace(JSTracer* trc, JSObject* obj)
@@ -2836,101 +2824,99 @@ CType::IsCType(JSObject* obj)
 
 bool
 CType::IsCTypeProto(JSObject* obj)
 {
   return JS_GetClass(obj) == &sCTypeProtoClass;
 }
 
 TypeCode
-CType::GetTypeCode(JSContext* cx, JSObject* typeObj)
+CType::GetTypeCode(JSObject* typeObj)
 {
   JS_ASSERT(IsCType(typeObj));
 
-  jsval result;
-  ASSERT_OK(JS_GetReservedSlot(cx, typeObj, SLOT_TYPECODE, &result));
+  jsval result = JS_GetReservedSlot(typeObj, SLOT_TYPECODE);
   return TypeCode(JSVAL_TO_INT(result));
 }
 
 bool
-CType::TypesEqual(JSContext* cx, JSObject* t1, JSObject* t2)
+CType::TypesEqual(JSObject* t1, JSObject* t2)
 {
   JS_ASSERT(IsCType(t1) && IsCType(t2));
 
   // Fast path: check for object equality.
   if (t1 == t2)
     return true;
 
   // First, perform shallow comparison.
-  TypeCode c1 = GetTypeCode(cx, t1);
-  TypeCode c2 = GetTypeCode(cx, t2);
+  TypeCode c1 = GetTypeCode(t1);
+  TypeCode c2 = GetTypeCode(t2);
   if (c1 != c2)
     return false;
 
   // Determine whether the types require shallow or deep comparison.
   switch (c1) {
   case TYPE_pointer: {
     // Compare base types.
-    JSObject* b1 = PointerType::GetBaseType(cx, t1);
-    JSObject* b2 = PointerType::GetBaseType(cx, t2);
-    return TypesEqual(cx, b1, b2);
+    JSObject* b1 = PointerType::GetBaseType(t1);
+    JSObject* b2 = PointerType::GetBaseType(t2);
+    return TypesEqual(b1, b2);
   }
   case TYPE_function: {
-    FunctionInfo* f1 = FunctionType::GetFunctionInfo(cx, t1);
-    FunctionInfo* f2 = FunctionType::GetFunctionInfo(cx, t2);
+    FunctionInfo* f1 = FunctionType::GetFunctionInfo(t1);
+    FunctionInfo* f2 = FunctionType::GetFunctionInfo(t2);
 
     // Compare abi, return type, and argument types.
     if (f1->mABI != f2->mABI)
       return false;
 
-    if (!TypesEqual(cx, f1->mReturnType, f2->mReturnType))
+    if (!TypesEqual(f1->mReturnType, f2->mReturnType))
       return false;
 
     if (f1->mArgTypes.length() != f2->mArgTypes.length())
       return false;
 
     if (f1->mIsVariadic != f2->mIsVariadic)
       return false;
 
     for (size_t i = 0; i < f1->mArgTypes.length(); ++i) {
-      if (!TypesEqual(cx, f1->mArgTypes[i], f2->mArgTypes[i]))
+      if (!TypesEqual(f1->mArgTypes[i], f2->mArgTypes[i]))
         return false;
     }
 
     return true;
   }
   case TYPE_array: {
     // Compare length, then base types.
     // An undefined length array matches other undefined length arrays.
     size_t s1 = 0, s2 = 0;
-    bool d1 = ArrayType::GetSafeLength(cx, t1, &s1);
-    bool d2 = ArrayType::GetSafeLength(cx, t2, &s2);
+    bool d1 = ArrayType::GetSafeLength(t1, &s1);
+    bool d2 = ArrayType::GetSafeLength(t2, &s2);
     if (d1 != d2 || (d1 && s1 != s2))
       return false;
 
-    JSObject* b1 = ArrayType::GetBaseType(cx, t1);
-    JSObject* b2 = ArrayType::GetBaseType(cx, t2);
-    return TypesEqual(cx, b1, b2);
+    JSObject* b1 = ArrayType::GetBaseType(t1);
+    JSObject* b2 = ArrayType::GetBaseType(t2);
+    return TypesEqual(b1, b2);
   }
   case TYPE_struct:
     // Require exact type object equality.
     return false;
   default:
     // Shallow comparison is sufficient.
     return true;
   }
 }
 
 bool
-CType::GetSafeSize(JSContext* cx, JSObject* obj, size_t* result)
+CType::GetSafeSize(JSObject* obj, size_t* result)
 {
   JS_ASSERT(CType::IsCType(obj));
 
-  jsval size;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_SIZE, &size));
+  jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
   // The "size" property can be a jsint, a jsdouble, or JSVAL_VOID
   // (for arrays of undefined length), and must always fit in a size_t.
   if (JSVAL_IS_INT(size)) {
     *result = JSVAL_TO_INT(size);
     return true;
   }
   if (JSVAL_IS_DOUBLE(size)) {
@@ -2938,152 +2924,144 @@ CType::GetSafeSize(JSContext* cx, JSObje
     return true;
   }
 
   JS_ASSERT(JSVAL_IS_VOID(size));
   return false;
 }
 
 size_t
-CType::GetSize(JSContext* cx, JSObject* obj)
+CType::GetSize(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
-  jsval size;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_SIZE, &size));
+  jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
   JS_ASSERT(!JSVAL_IS_VOID(size));
 
   // The "size" property can be a jsint, a jsdouble, or JSVAL_VOID
   // (for arrays of undefined length), and must always fit in a size_t.
   // For callers who know it can never be JSVAL_VOID, return a size_t directly.
   if (JSVAL_IS_INT(size))
     return JSVAL_TO_INT(size);
   return Convert<size_t>(JSVAL_TO_DOUBLE(size));
 }
 
 bool
-CType::IsSizeDefined(JSContext* cx, JSObject* obj)
+CType::IsSizeDefined(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
-  jsval size;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_SIZE, &size));
+  jsval size = JS_GetReservedSlot(obj, SLOT_SIZE);
 
   // The "size" property can be a jsint, a jsdouble, or JSVAL_VOID
   // (for arrays of undefined length), and must always fit in a size_t.
   JS_ASSERT(JSVAL_IS_INT(size) || JSVAL_IS_DOUBLE(size) || JSVAL_IS_VOID(size));
   return !JSVAL_IS_VOID(size);
 }
 
 size_t
-CType::GetAlignment(JSContext* cx, JSObject* obj)
+CType::GetAlignment(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_ALIGN, &slot));
+  jsval slot = JS_GetReservedSlot(obj, SLOT_ALIGN);
   return static_cast<size_t>(JSVAL_TO_INT(slot));
 }
 
 ffi_type*
 CType::GetFFIType(JSContext* cx, JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_FFITYPE, &slot));
+  jsval slot = JS_GetReservedSlot(obj, SLOT_FFITYPE);
 
   if (!JSVAL_IS_VOID(slot)) {
     return static_cast<ffi_type*>(JSVAL_TO_PRIVATE(slot));
   }
 
   AutoPtr<ffi_type> result;
-  switch (CType::GetTypeCode(cx, obj)) {
+  switch (CType::GetTypeCode(obj)) {
   case TYPE_array:
     result = ArrayType::BuildFFIType(cx, obj);
     break;
 
   case TYPE_struct:
     result = StructType::BuildFFIType(cx, obj);
     break;
 
   default:
     JS_NOT_REACHED("simple types must have an ffi_type");
   }
 
-  if (!result ||
-      !JS_SetReservedSlot(cx, obj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(result.get())))
+  if (!result)
     return NULL;
-
+  JS_SetReservedSlot(obj, SLOT_FFITYPE, PRIVATE_TO_JSVAL(result.get()));
   return result.forget();
 }
 
 JSString*
 CType::GetName(JSContext* cx, JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
 
-  jsval string;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_NAME, &string));
+  jsval string = JS_GetReservedSlot(obj, SLOT_NAME);
   if (JSVAL_IS_VOID(string)) {
     // Build the type name lazily.
     JSString* name = BuildTypeName(cx, obj);
-    if (!name || !JS_SetReservedSlot(cx, obj, SLOT_NAME, STRING_TO_JSVAL(name)))
+    if (!name)
       return NULL;
-
+    JS_SetReservedSlot(obj, SLOT_NAME, STRING_TO_JSVAL(name));
     return name;
   }
 
   return JSVAL_TO_STRING(string);
 }
 
 JSObject*
-CType::GetProtoFromCtor(JSContext* cx, JSObject* obj, CTypeProtoSlot slot)
+CType::GetProtoFromCtor(JSObject* obj, CTypeProtoSlot slot)
 {
   // Get ctypes.{Pointer,Array,Struct}Type.prototype from a reserved slot
   // on the type constructor.
   jsval protoslot = js::GetFunctionNativeReserved(obj, SLOT_FN_CTORPROTO);
   JSObject* proto = JSVAL_TO_OBJECT(protoslot);
   JS_ASSERT(proto);
   JS_ASSERT(CType::IsCTypeProto(proto));
 
   // Get the desired prototype.
-  jsval result;
-  ASSERT_OK(JS_GetReservedSlot(cx, proto, slot, &result));
+  jsval result = JS_GetReservedSlot(proto, slot);
   return JSVAL_TO_OBJECT(result);
 }
 
 JSObject*
-CType::GetProtoFromType(JSContext* cx, JSObject* obj, CTypeProtoSlot slot)
+CType::GetProtoFromType(JSObject* obj, CTypeProtoSlot slot)
 {
   JS_ASSERT(IsCType(obj));
 
   // Get the prototype of the type object.
-  JSObject* proto = JS_GetPrototype(cx, obj);
+  JSObject* proto = JS_GetPrototype(obj);
   JS_ASSERT(proto);
   JS_ASSERT(CType::IsCTypeProto(proto));
 
   // Get the requested ctypes.{Pointer,Array,Struct,Function}Type.prototype.
-  jsval result;
-  ASSERT_OK(JS_GetReservedSlot(cx, proto, slot, &result));
+  jsval result = JS_GetReservedSlot(proto, slot);
   return JSVAL_TO_OBJECT(result);
 }
 
 JSBool
 CType::PrototypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!(CType::IsCType(obj) || CType::IsCTypeProto(obj))) {
     JS_ReportError(cx, "not a CType or CTypeProto");
     return JS_FALSE;
   }
 
   unsigned slot = CType::IsCTypeProto(obj) ? (unsigned) SLOT_OURDATAPROTO
                                            : (unsigned) SLOT_PROTO;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, slot, vp));
+  *vp = JS_GetReservedSlot(obj, slot);
   JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp) || JSVAL_IS_VOID(*vp));
   return JS_TRUE;
 }
 
 JSBool
 CType::NameGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CType::IsCType(obj)) {
@@ -3102,17 +3080,17 @@ CType::NameGetter(JSContext* cx, JSObjec
 JSBool
 CType::SizeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CType::IsCType(obj)) {
     JS_ReportError(cx, "not a CType");
     return JS_FALSE;
   }
 
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_SIZE, vp));
+  *vp = JS_GetReservedSlot(obj, SLOT_SIZE);
   JS_ASSERT(JSVAL_IS_NUMBER(*vp) || JSVAL_IS_VOID(*vp));
   return JS_TRUE;
 }
 
 JSBool
 CType::PtrGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CType::IsCType(obj)) {
@@ -3215,28 +3193,27 @@ CType::ToSource(JSContext* cx, uintN arg
   return JS_TRUE;
 }
 
 JSBool
 CType::HasInstance(JSContext* cx, JSObject* obj, const jsval* v, JSBool* bp)
 {
   JS_ASSERT(CType::IsCType(obj));
 
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_PROTO, &slot));
+  jsval slot = JS_GetReservedSlot(obj, SLOT_PROTO);
   JSObject* prototype = JSVAL_TO_OBJECT(slot);
   JS_ASSERT(prototype);
   JS_ASSERT(CData::IsCDataProto(prototype));
 
   *bp = JS_FALSE;
   if (JSVAL_IS_PRIMITIVE(*v))
     return JS_TRUE;
 
   JSObject* proto = JSVAL_TO_OBJECT(*v);
-  while ((proto = JS_GetPrototype(cx, proto))) {
+  while ((proto = JS_GetPrototype(proto))) {
     if (proto == prototype) {
       *bp = JS_TRUE;
       break;
     }
   }
   return JS_TRUE;
 }
 
@@ -3266,55 +3243,51 @@ PointerType::Create(JSContext* cx, uintN
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
   return JS_TRUE;
 }
 
 JSObject*
 PointerType::CreateInternal(JSContext* cx, JSObject* baseType)
 {
   // check if we have a cached PointerType on our base CType.
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, baseType, SLOT_PTR, &slot));
+  jsval slot = JS_GetReservedSlot(baseType, SLOT_PTR);
   if (!JSVAL_IS_VOID(slot))
     return JSVAL_TO_OBJECT(slot);
 
   // Get ctypes.PointerType.prototype and the common prototype for CData objects
   // of this type.
   JSObject* typeProto;
   JSObject* dataProto;
-  typeProto = CType::GetProtoFromType(cx, baseType, SLOT_POINTERPROTO);
-  dataProto = CType::GetProtoFromType(cx, baseType, SLOT_POINTERDATAPROTO);
+  typeProto = CType::GetProtoFromType(baseType, SLOT_POINTERPROTO);
+  dataProto = CType::GetProtoFromType(baseType, SLOT_POINTERDATAPROTO);
 
   // Create a new CType object with the common properties and slots.
   JSObject* typeObj = CType::Create(cx, typeProto, dataProto, TYPE_pointer,
                         NULL, INT_TO_JSVAL(sizeof(void*)),
                         INT_TO_JSVAL(ffi_type_pointer.alignment),
                         &ffi_type_pointer);
   if (!typeObj)
     return NULL;
-  js::AutoObjectRooter root(cx, typeObj);
 
   // Set the target type. (This will be 'null' for an opaque pointer type.)
-  if (!JS_SetReservedSlot(cx, typeObj, SLOT_TARGET_T, OBJECT_TO_JSVAL(baseType)))
-    return NULL;
+  JS_SetReservedSlot(typeObj, SLOT_TARGET_T, OBJECT_TO_JSVAL(baseType));
 
   // Finally, cache our newly-created PointerType on our pointed-to CType.
-  if (!JS_SetReservedSlot(cx, baseType, SLOT_PTR, OBJECT_TO_JSVAL(typeObj)))
-    return NULL;
+  JS_SetReservedSlot(baseType, SLOT_PTR, OBJECT_TO_JSVAL(typeObj));
 
   return typeObj;
 }
 
 JSBool
 PointerType::ConstructData(JSContext* cx,
                            JSObject* obj,
                            uintN argc,
                            jsval* vp)
 {
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_pointer) {
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_pointer) {
     JS_ReportError(cx, "not a PointerType");
     return JS_FALSE;
   }
 
   if (argc > 3) {
     JS_ReportError(cx, "constructor takes 0, 1, 2, or 3 arguments");
     return JS_FALSE;
   }
@@ -3337,30 +3310,30 @@ PointerType::ConstructData(JSContext* cx
   //
   // Case 1 - Null pointer
   //
   if (argc == 0)
     return JS_TRUE;
 
   // Analyze the arguments a bit to decide what to do next.
   jsval* argv = JS_ARGV(cx, vp);
-  JSObject* baseObj = PointerType::GetBaseType(cx, obj);
-  bool looksLikeClosure = CType::GetTypeCode(cx, baseObj) == TYPE_function &&
+  JSObject* baseObj = PointerType::GetBaseType(obj);
+  bool looksLikeClosure = CType::GetTypeCode(baseObj) == TYPE_function &&
                           JSVAL_IS_OBJECT(argv[0]) &&
                           JS_ObjectIsCallable(cx, JSVAL_TO_OBJECT(argv[0]));
 
   //
   // Case 2 - Initialized pointer
   //
   if (!looksLikeClosure) {
     if (argc != 1) {
       JS_ReportError(cx, "first argument must be a function");
       return JS_FALSE;
     }
-    return ExplicitConvert(cx, argv[0], obj, CData::GetData(cx, result));
+    return ExplicitConvert(cx, argv[0], obj, CData::GetData(result));
   }
 
   //
   // Case 3 - Closure
   //
 
   // The second argument is an optional 'this' parameter with which to invoke
   // the given js function. Callers may leave this blank, or pass null if they
@@ -3381,87 +3354,86 @@ PointerType::ConstructData(JSContext* cx
   if (argc == 3)
     errVal = argv[2];
 
   JSObject* fnObj = JSVAL_TO_OBJECT(argv[0]);
   return FunctionType::ConstructData(cx, baseObj, result, fnObj, thisObj, errVal);
 }
 
 JSObject*
-PointerType::GetBaseType(JSContext* cx, JSObject* obj)
-{
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_pointer);
-
-  jsval type;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_TARGET_T, &type));
+PointerType::GetBaseType(JSObject* obj)
+{
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_pointer);
+
+  jsval type = JS_GetReservedSlot(obj, SLOT_TARGET_T);
   JS_ASSERT(!JSVAL_IS_NULL(type));
   return JSVAL_TO_OBJECT(type);
 }
 
 JSBool
 PointerType::TargetTypeGetter(JSContext* cx,
                               JSObject* obj,
                               jsid idval,
                               jsval* vp)
 {
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_pointer) {
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_pointer) {
     JS_ReportError(cx, "not a PointerType");
     return JS_FALSE;
   }
 
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_TARGET_T, vp));
+  *vp = JS_GetReservedSlot(obj, SLOT_TARGET_T);
   JS_ASSERT(JSVAL_IS_OBJECT(*vp));
   return JS_TRUE;
 }
 
 JSBool
 PointerType::IsNull(JSContext* cx, uintN argc, jsval* vp)
 {
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj || !CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   // Get pointer type and base type.
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_pointer) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_pointer) {
     JS_ReportError(cx, "not a PointerType");
     return JS_FALSE;
   }
 
-  void* data = *static_cast<void**>(CData::GetData(cx, obj));
+  void* data = *static_cast<void**>(CData::GetData(obj));
   jsval result = BOOLEAN_TO_JSVAL(data == NULL);
   JS_SET_RVAL(cx, vp, result);
   return JS_TRUE;
 }
 
 JSBool
 PointerType::OffsetBy(JSContext* cx, intN offset, jsval* vp)
 {
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj || !CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_pointer) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_pointer) {
     JS_ReportError(cx, "not a PointerType");
     return JS_FALSE;
   }
 
-  JSObject* baseType = PointerType::GetBaseType(cx, typeObj);
-  if (!CType::IsSizeDefined(cx, baseType)) {
+  JSObject* baseType = PointerType::GetBaseType(typeObj);
+  if (!CType::IsSizeDefined(baseType)) {
     JS_ReportError(cx, "cannot modify pointer of undefined size");
     return JS_FALSE;
   }
 
-  size_t elementSize = CType::GetSize(cx, baseType);
-  char* data = static_cast<char*>(*static_cast<void**>(CData::GetData(cx, obj)));
+  size_t elementSize = CType::GetSize(baseType);
+  char* data = static_cast<char*>(*static_cast<void**>(CData::GetData(obj)));
   void* address = data + offset * elementSize;
 
   // Create a PointerType CData object containing the new address.
   JSObject* result = CData::Create(cx, typeObj, NULL, &address, true);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
@@ -3487,29 +3459,29 @@ PointerType::ContentsGetter(JSContext* c
                             jsval* vp)
 {
   if (!CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   // Get pointer type and base type.
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_pointer) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_pointer) {
     JS_ReportError(cx, "not a PointerType");
     return JS_FALSE;
   }
 
-  JSObject* baseType = GetBaseType(cx, typeObj);
-  if (!CType::IsSizeDefined(cx, baseType)) {
+  JSObject* baseType = GetBaseType(typeObj);
+  if (!CType::IsSizeDefined(baseType)) {
     JS_ReportError(cx, "cannot get contents of undefined size");
     return JS_FALSE;
   }
 
-  void* data = *static_cast<void**>(CData::GetData(cx, obj));
+  void* data = *static_cast<void**>(CData::GetData(obj));
   if (data == NULL) {
     JS_ReportError(cx, "cannot read contents of null pointer");
     return JS_FALSE;
   }
 
   jsval result;
   if (!ConvertToJS(cx, baseType, NULL, data, false, false, &result))
     return JS_FALSE;
@@ -3526,29 +3498,29 @@ PointerType::ContentsSetter(JSContext* c
                             jsval* vp)
 {
   if (!CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   // Get pointer type and base type.
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_pointer) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_pointer) {
     JS_ReportError(cx, "not a PointerType");
     return JS_FALSE;
   }
 
-  JSObject* baseType = GetBaseType(cx, typeObj);
-  if (!CType::IsSizeDefined(cx, baseType)) {
+  JSObject* baseType = GetBaseType(typeObj);
+  if (!CType::IsSizeDefined(baseType)) {
     JS_ReportError(cx, "cannot set contents of undefined size");
     return JS_FALSE;
   }
 
-  void* data = *static_cast<void**>(CData::GetData(cx, obj));
+  void* data = *static_cast<void**>(CData::GetData(obj));
   if (data == NULL) {
     JS_ReportError(cx, "cannot write contents to null pointer");
     return JS_FALSE;
   }
 
   return ImplicitConvert(cx, *vp, baseType, data, false, NULL);
 }
 
@@ -3591,24 +3563,24 @@ ArrayType::Create(JSContext* cx, uintN a
 JSObject*
 ArrayType::CreateInternal(JSContext* cx,
                           JSObject* baseType,
                           size_t length,
                           bool lengthDefined)
 {
   // Get ctypes.ArrayType.prototype and the common prototype for CData objects
   // of this type, from ctypes.CType.prototype.
-  JSObject* typeProto = CType::GetProtoFromType(cx, baseType, SLOT_ARRAYPROTO);
-  JSObject* dataProto = CType::GetProtoFromType(cx, baseType, SLOT_ARRAYDATAPROTO);
+  JSObject* typeProto = CType::GetProtoFromType(baseType, SLOT_ARRAYPROTO);
+  JSObject* dataProto = CType::GetProtoFromType(baseType, SLOT_ARRAYDATAPROTO);
 
   // Determine the size of the array from the base type, if possible.
   // The size of the base type must be defined.
   // If our length is undefined, both our size and length will be undefined.
   size_t baseSize;
-  if (!CType::GetSafeSize(cx, baseType, &baseSize)) {
+  if (!CType::GetSafeSize(baseType, &baseSize)) {
     JS_ReportError(cx, "base size must be defined");
     return NULL;
   }
 
   jsval sizeVal = JSVAL_VOID;
   jsval lengthVal = JSVAL_VOID;
   if (lengthDefined) {
     // Check for overflow, and convert to a jsint or jsdouble as required.
@@ -3617,66 +3589,63 @@ ArrayType::CreateInternal(JSContext* cx,
       JS_ReportError(cx, "size overflow");
       return NULL;
     }
     if (!SizeTojsval(cx, size, &sizeVal) ||
         !SizeTojsval(cx, length, &lengthVal))
       return NULL;
   }
 
-  size_t align = CType::GetAlignment(cx, baseType);
+  size_t align = CType::GetAlignment(baseType);
 
   // Create a new CType object with the common properties and slots.
   JSObject* typeObj = CType::Create(cx, typeProto, dataProto, TYPE_array, NULL,
                         sizeVal, INT_TO_JSVAL(align), NULL);
   if (!typeObj)
     return NULL;
-  js::AutoObjectRooter root(cx, typeObj);
 
   // Set the element type.
-  if (!JS_SetReservedSlot(cx, typeObj, SLOT_ELEMENT_T, OBJECT_TO_JSVAL(baseType)))
-    return NULL;
+  JS_SetReservedSlot(typeObj, SLOT_ELEMENT_T, OBJECT_TO_JSVAL(baseType));
 
   // Set the length.
-  if (!JS_SetReservedSlot(cx, typeObj, SLOT_LENGTH, lengthVal))
-    return NULL;
+  JS_SetReservedSlot(typeObj, SLOT_LENGTH, lengthVal);
 
   return typeObj;
 }
 
 JSBool
 ArrayType::ConstructData(JSContext* cx,
                          JSObject* obj,
                          uintN argc,
                          jsval* vp)
 {
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_array) {
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) {
     JS_ReportError(cx, "not an ArrayType");
     return JS_FALSE;
   }
 
   // Decide whether we have an object to initialize from. We'll override this
   // if we get a length argument instead.
   bool convertObject = argc == 1;
 
   // Check if we're an array of undefined length. If we are, allow construction
   // with a length argument, or with an actual JS array.
-  if (CType::IsSizeDefined(cx, obj)) {
+  if (CType::IsSizeDefined(obj)) {
     if (argc > 1) {
       JS_ReportError(cx, "constructor takes zero or one argument");
       return JS_FALSE;
     }
 
   } else {
     if (argc != 1) {
       JS_ReportError(cx, "constructor takes one argument");
       return JS_FALSE;
     }
 
-    JSObject* baseType = GetBaseType(cx, obj);
+    JSObject* baseType = GetBaseType(obj);
 
     jsval* argv = JS_ARGV(cx, vp);
     size_t length;
     if (jsvalToSize(cx, argv[0], false, &length)) {
       // Have a length, rather than an object to initialize from.
       convertObject = false;
 
     } else if (!JSVAL_IS_PRIMITIVE(argv[0])) {
@@ -3694,17 +3663,17 @@ ArrayType::ConstructData(JSContext* cx,
       // We were given a string. Size the array to the appropriate length,
       // including space for the terminator.
       JSString* sourceString = JSVAL_TO_STRING(argv[0]);
       size_t sourceLength = sourceString->length();
       const jschar* sourceChars = sourceString->getChars(cx);
       if (!sourceChars)
         return false;
 
-      switch (CType::GetTypeCode(cx, baseType)) {
+      switch (CType::GetTypeCode(baseType)) {
       case TYPE_char:
       case TYPE_signed_char:
       case TYPE_unsigned_char: {
         // Determine the UTF-8 length.
         length = GetDeflatedUTF8StringLength(cx, sourceChars, sourceLength);
         if (length == (size_t) -1)
           return false;
 
@@ -3734,43 +3703,41 @@ ArrayType::ConstructData(JSContext* cx,
 
   JSObject* result = CData::Create(cx, obj, NULL, NULL, true);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
 
   if (convertObject) {
-    if (!ExplicitConvert(cx, JS_ARGV(cx, vp)[0], obj, CData::GetData(cx, result)))
+    if (!ExplicitConvert(cx, JS_ARGV(cx, vp)[0], obj, CData::GetData(result)))
       return JS_FALSE;
   }
 
   return JS_TRUE;
 }
 
 JSObject*
-ArrayType::GetBaseType(JSContext* cx, JSObject* obj)
+ArrayType::GetBaseType(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_array);
-
-  jsval type;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_ELEMENT_T, &type));
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_array);
+
+  jsval type = JS_GetReservedSlot(obj, SLOT_ELEMENT_T);
   JS_ASSERT(!JSVAL_IS_NULL(type));
   return JSVAL_TO_OBJECT(type);
 }
 
 bool
-ArrayType::GetSafeLength(JSContext* cx, JSObject* obj, size_t* result)
+ArrayType::GetSafeLength(JSObject* obj, size_t* result)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_array);
-
-  jsval length;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_LENGTH, &length));
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_array);
+
+  jsval length = JS_GetReservedSlot(obj, SLOT_LENGTH);
 
   // The "length" property can be a jsint, a jsdouble, or JSVAL_VOID
   // (for arrays of undefined length), and must always fit in a size_t.
   if (JSVAL_IS_INT(length)) {
     *result = JSVAL_TO_INT(length);
     return true;
   }
   if (JSVAL_IS_DOUBLE(length)) {
@@ -3778,224 +3745,223 @@ ArrayType::GetSafeLength(JSContext* cx, 
     return true;
   }
 
   JS_ASSERT(JSVAL_IS_VOID(length));
   return false;
 }
 
 size_t
-ArrayType::GetLength(JSContext* cx, JSObject* obj)
+ArrayType::GetLength(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_array);
-
-  jsval length;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_LENGTH, &length));
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_array);
+
+  jsval length = JS_GetReservedSlot(obj, SLOT_LENGTH);
 
   JS_ASSERT(!JSVAL_IS_VOID(length));
 
   // The "length" property can be a jsint, a jsdouble, or JSVAL_VOID
   // (for arrays of undefined length), and must always fit in a size_t.
   // For callers who know it can never be JSVAL_VOID, return a size_t directly.
   if (JSVAL_IS_INT(length))
     return JSVAL_TO_INT(length);
   return Convert<size_t>(JSVAL_TO_DOUBLE(length));
 }
 
 ffi_type*
 ArrayType::BuildFFIType(JSContext* cx, JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_array);
-  JS_ASSERT(CType::IsSizeDefined(cx, obj));
-
-  JSObject* baseType = ArrayType::GetBaseType(cx, obj);
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_array);
+  JS_ASSERT(CType::IsSizeDefined(obj));
+
+  JSObject* baseType = ArrayType::GetBaseType(obj);
   ffi_type* ffiBaseType = CType::GetFFIType(cx, baseType);
   if (!ffiBaseType)
     return NULL;
 
-  size_t length = ArrayType::GetLength(cx, obj);
+  size_t length = ArrayType::GetLength(obj);
 
   // Create an ffi_type to represent the array. This is necessary for the case
   // where the array is part of a struct. Since libffi has no intrinsic
   // support for array types, we approximate it by creating a struct type
   // with elements of type 'baseType' and with appropriate size and alignment
   // values. It would be nice to not do all the work of setting up 'elements',
   // but some libffi platforms currently require that it be meaningful. I'm
   // looking at you, x86_64.
   AutoPtr<ffi_type> ffiType(cx->new_<ffi_type>());
   if (!ffiType) {
     JS_ReportOutOfMemory(cx);
     return NULL;
   }
 
   ffiType->type = FFI_TYPE_STRUCT;
-  ffiType->size = CType::GetSize(cx, obj);
-  ffiType->alignment = CType::GetAlignment(cx, obj);
+  ffiType->size = CType::GetSize(obj);
+  ffiType->alignment = CType::GetAlignment(obj);
   ffiType->elements = cx->array_new<ffi_type*>(length + 1);
   if (!ffiType->elements) {
     JS_ReportAllocationOverflow(cx);
     return NULL;
   }
 
   for (size_t i = 0; i < length; ++i)
     ffiType->elements[i] = ffiBaseType;
   ffiType->elements[length] = NULL;
 
   return ffiType.forget();
 }
 
 JSBool
 ArrayType::ElementTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_array) {
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) {
     JS_ReportError(cx, "not an ArrayType");
     return JS_FALSE;
   }
 
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_ELEMENT_T, vp));
+  *vp = JS_GetReservedSlot(obj, SLOT_ELEMENT_T);
   JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
   return JS_TRUE;
 }
 
 JSBool
 ArrayType::LengthGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   // This getter exists for both CTypes and CDatas of the ArrayType persuasion.
   // If we're dealing with a CData, get the CType from it.
   if (CData::IsCData(obj))
-    obj = CData::GetCType(cx, obj);
-
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_array) {
+    obj = CData::GetCType(obj);
+
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_array) {
     JS_ReportError(cx, "not an ArrayType");
     return JS_FALSE;
   }
 
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_LENGTH, vp));
+  *vp = JS_GetReservedSlot(obj, SLOT_LENGTH);
   JS_ASSERT(JSVAL_IS_NUMBER(*vp) || JSVAL_IS_VOID(*vp));
   return JS_TRUE;
 }
 
 JSBool
 ArrayType::Getter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   // This should never happen, but we'll check to be safe.
   if (!CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   // Bail early if we're not an ArrayType. (This setter is present for all
   // CData, regardless of CType.)
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_array)
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_array)
     return JS_TRUE;
 
   // Convert the index to a size_t and bounds-check it.
   size_t index;
-  size_t length = GetLength(cx, typeObj);
+  size_t length = GetLength(typeObj);
   bool ok = jsidToSize(cx, idval, true, &index);
   if (!ok && JSID_IS_STRING(idval)) {
     // String either isn't a number, or doesn't fit in size_t.
     // Chances are it's a regular property lookup, so return.
     return JS_TRUE;
   }
   if (!ok || index >= length) {
     JS_ReportError(cx, "invalid index");
     return JS_FALSE;
   }
 
-  JSObject* baseType = GetBaseType(cx, typeObj);
-  size_t elementSize = CType::GetSize(cx, baseType);
-  char* data = static_cast<char*>(CData::GetData(cx, obj)) + elementSize * index;
+  JSObject* baseType = GetBaseType(typeObj);
+  size_t elementSize = CType::GetSize(baseType);
+  char* data = static_cast<char*>(CData::GetData(obj)) + elementSize * index;
   return ConvertToJS(cx, baseType, obj, data, false, false, vp);
 }
 
 JSBool
 ArrayType::Setter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict, jsval* vp)
 {
   // This should never happen, but we'll check to be safe.
   if (!CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   // Bail early if we're not an ArrayType. (This setter is present for all
   // CData, regardless of CType.)
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_array)
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_array)
     return JS_TRUE;
 
   // Convert the index to a size_t and bounds-check it.
   size_t index;
-  size_t length = GetLength(cx, typeObj);
+  size_t length = GetLength(typeObj);
   bool ok = jsidToSize(cx, idval, true, &index);
   if (!ok && JSID_IS_STRING(idval)) {
     // String either isn't a number, or doesn't fit in size_t.
     // Chances are it's a regular property lookup, so return.
     return JS_TRUE;
   }
   if (!ok || index >= length) {
     JS_ReportError(cx, "invalid index");
     return JS_FALSE;
   }
 
-  JSObject* baseType = GetBaseType(cx, typeObj);
-  size_t elementSize = CType::GetSize(cx, baseType);
-  char* data = static_cast<char*>(CData::GetData(cx, obj)) + elementSize * index;
+  JSObject* baseType = GetBaseType(typeObj);
+  size_t elementSize = CType::GetSize(baseType);
+  char* data = static_cast<char*>(CData::GetData(obj)) + elementSize * index;
   return ImplicitConvert(cx, *vp, baseType, data, false, NULL);
 }
 
 JSBool
 ArrayType::AddressOfElement(JSContext* cx, uintN argc, jsval* vp)
 {
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj || !CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_array) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_array) {
     JS_ReportError(cx, "not an ArrayType");
     return JS_FALSE;
   }
 
   if (argc != 1) {
     JS_ReportError(cx, "addressOfElement takes one argument");
     return JS_FALSE;
   }
 
-  JSObject* baseType = GetBaseType(cx, typeObj);
+  JSObject* baseType = GetBaseType(typeObj);
   JSObject* pointerType = PointerType::CreateInternal(cx, baseType);
   if (!pointerType)
     return JS_FALSE;
   js::AutoObjectRooter root(cx, pointerType);
 
   // Create a PointerType CData object containing null.
   JSObject* result = CData::Create(cx, pointerType, NULL, NULL, true);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
 
   // Convert the index to a size_t and bounds-check it.
   size_t index;
-  size_t length = GetLength(cx, typeObj);
+  size_t length = GetLength(typeObj);
   if (!jsvalToSize(cx, JS_ARGV(cx, vp)[0], false, &index) ||
       index >= length) {
     JS_ReportError(cx, "invalid index");
     return JS_FALSE;
   }
 
   // Manually set the pointer inside the object, so we skip the conversion step.
-  void** data = static_cast<void**>(CData::GetData(cx, result));
-  size_t elementSize = CType::GetSize(cx, baseType);
-  *data = static_cast<char*>(CData::GetData(cx, obj)) + elementSize * index;
+  void** data = static_cast<void**>(CData::GetData(result));
+  size_t elementSize = CType::GetSize(baseType);
+  *data = static_cast<char*>(CData::GetData(obj)) + elementSize * index;
   return JS_TRUE;
 }
 
 /*******************************************************************************
 ** StructType implementation
 *******************************************************************************/
 
 // For a struct field descriptor 'val' of the form { name : type }, extract
@@ -4046,17 +4012,17 @@ ExtractStructField(JSContext* cx, jsval 
     return NULL;
   }
 
   // Undefined size or zero size struct members are illegal.
   // (Zero-size arrays are legal as struct members in C++, but libffi will
   // choke on a zero-size struct, so we disallow them.)
   *typeObj = JSVAL_TO_OBJECT(propVal.jsval_value());
   size_t size;
-  if (!CType::GetSafeSize(cx, *typeObj, &size) || size == 0) {
+  if (!CType::GetSafeSize(*typeObj, &size) || size == 0) {
     JS_ReportError(cx, "struct field types must have defined and nonzero size");
     return NULL;
   }
 
   return JSID_TO_FLAT_STRING(nameid);
 }
 
 // For a struct field with 'name' and 'type', add an element of the form
@@ -4095,17 +4061,17 @@ StructType::Create(JSContext* cx, uintN 
   jsval name = argv[0];
   if (!JSVAL_IS_STRING(name)) {
     JS_ReportError(cx, "first argument must be a string");
     return JS_FALSE;
   }
 
   // Get ctypes.StructType.prototype from the ctypes.StructType constructor.
   JSObject* callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
-  JSObject* typeProto = CType::GetProtoFromCtor(cx, callee, SLOT_STRUCTPROTO);
+  JSObject* typeProto = CType::GetProtoFromCtor(callee, SLOT_STRUCTPROTO);
 
   // Create a simple StructType with no defined fields. The result will be
   // non-instantiable as CData, will have no 'prototype' property, and will
   // have undefined size and alignment and no ffi_type.
   JSObject* result = CType::Create(cx, typeProto, NULL, TYPE_struct,
                        JSVAL_TO_STRING(name), JSVAL_VOID, JSVAL_VOID, NULL);
   if (!result)
     return JS_FALSE;
@@ -4130,18 +4096,17 @@ StructType::Create(JSContext* cx, uintN 
 JSBool
 StructType::DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj)
 {
   jsuint len;
   ASSERT_OK(JS_GetArrayLength(cx, fieldsObj, &len));
 
   // Get the common prototype for CData objects of this type from
   // ctypes.CType.prototype.
-  JSObject* dataProto =
-    CType::GetProtoFromType(cx, typeObj, SLOT_STRUCTDATAPROTO);
+  JSObject* dataProto = CType::GetProtoFromType(typeObj, SLOT_STRUCTDATAPROTO);
 
   // Set up the 'prototype' and 'prototype.constructor' properties.
   // The prototype will reflect the struct fields as properties on CData objects
   // created from this type.
   JSObject* prototype = JS_NewObject(cx, &sCDataProtoClass, dataProto, NULL);
   if (!prototype)
     return JS_FALSE;
   js::AutoObjectRooter protoroot(cx, prototype);
@@ -4193,18 +4158,18 @@ StructType::DefineInternal(JSContext* cx
 
       // Add the field to the StructType's 'prototype' property.
       if (!JS_DefineUCProperty(cx, prototype,
              name->chars(), name->length(), JSVAL_VOID,
              StructType::FieldGetter, StructType::FieldSetter,
              JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT))
         return JS_FALSE;
 
-      size_t fieldSize = CType::GetSize(cx, fieldType);
-      size_t fieldAlign = CType::GetAlignment(cx, fieldType);
+      size_t fieldSize = CType::GetSize(fieldType);
+      size_t fieldAlign = CType::GetAlignment(fieldType);
       size_t fieldOffset = Align(structSize, fieldAlign);
       // Check for overflow. Since we hold invariant that fieldSize % fieldAlign
       // be zero, we can safely check fieldOffset + fieldSize without first
       // checking fieldOffset for overflow.
       if (fieldOffset + fieldSize < structSize) {
         JS_ReportError(cx, "size overflow");
         return JS_FALSE;
       }
@@ -4231,42 +4196,38 @@ StructType::DefineInternal(JSContext* cx
     structSize = 1;
     structAlign = 1;
   }
 
   jsval sizeVal;
   if (!SizeTojsval(cx, structSize, &sizeVal))
     return JS_FALSE;
 
-  if (!JS_SetReservedSlot(cx, typeObj, SLOT_FIELDINFO,
-         PRIVATE_TO_JSVAL(fields.get())))
-    return JS_FALSE;
-  fields.forget();
-
-  if (!JS_SetReservedSlot(cx, typeObj, SLOT_SIZE, sizeVal) ||
-      !JS_SetReservedSlot(cx, typeObj, SLOT_ALIGN, INT_TO_JSVAL(structAlign)) ||
-      //!JS_FreezeObject(cx, prototype) || // XXX fixme - see bug 541212!
-      !JS_SetReservedSlot(cx, typeObj, SLOT_PROTO, OBJECT_TO_JSVAL(prototype)))
-    return JS_FALSE;
-
+  JS_SetReservedSlot(typeObj, SLOT_FIELDINFO, PRIVATE_TO_JSVAL(fields.forget()));
+
+  JS_SetReservedSlot(typeObj, SLOT_SIZE, sizeVal);
+  JS_SetReservedSlot(typeObj, SLOT_ALIGN, INT_TO_JSVAL(structAlign));
+  //if (!JS_FreezeObject(cx, prototype)0 // XXX fixme - see bug 541212!
+  //  return false;
+  JS_SetReservedSlot(typeObj, SLOT_PROTO, OBJECT_TO_JSVAL(prototype));
   return JS_TRUE;
 }
 
 ffi_type*
 StructType::BuildFFIType(JSContext* cx, JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_struct);
-  JS_ASSERT(CType::IsSizeDefined(cx, obj));
-
-  const FieldInfoHash* fields = GetFieldInfo(cx, obj);
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct);
+  JS_ASSERT(CType::IsSizeDefined(obj));
+
+  const FieldInfoHash* fields = GetFieldInfo(obj);
   size_t len = fields->count();
 
-  size_t structSize = CType::GetSize(cx, obj);
-  size_t structAlign = CType::GetAlignment(cx, obj);
+  size_t structSize = CType::GetSize(obj);
+  size_t structAlign = CType::GetAlignment(obj);
 
   AutoPtr<ffi_type> ffiType(cx->new_<ffi_type>());
   if (!ffiType) {
     JS_ReportOutOfMemory(cx);
     return NULL;
   }
   ffiType->type = FFI_TYPE_STRUCT;
 
@@ -4327,22 +4288,22 @@ StructType::BuildFFIType(JSContext* cx, 
 }
 
 JSBool
 StructType::Define(JSContext* cx, uintN argc, jsval* vp)
 {
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj ||
       !CType::IsCType(obj) ||
-      CType::GetTypeCode(cx, obj) != TYPE_struct) {
+      CType::GetTypeCode(obj) != TYPE_struct) {
     JS_ReportError(cx, "not a StructType");
     return JS_FALSE;
   }
 
-  if (CType::IsSizeDefined(cx, obj)) {
+  if (CType::IsSizeDefined(obj)) {
     JS_ReportError(cx, "StructType has already been defined");
     return JS_FALSE;
   }
 
   if (argc != 1) {
     JS_ReportError(cx, "define takes one argument");
     return JS_FALSE;
   }
@@ -4358,37 +4319,37 @@ StructType::Define(JSContext* cx, uintN 
 }
 
 JSBool
 StructType::ConstructData(JSContext* cx,
                           JSObject* obj,
                           uintN argc,
                           jsval* vp)
 {
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_struct) {
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_struct) {
     JS_ReportError(cx, "not a StructType");
     return JS_FALSE;
   }
 
-  if (!CType::IsSizeDefined(cx, obj)) {
+  if (!CType::IsSizeDefined(obj)) {
     JS_ReportError(cx, "cannot construct an opaque StructType");
     return JS_FALSE;
   }
 
   JSObject* result = CData::Create(cx, obj, NULL, NULL, true);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
 
   if (argc == 0)
     return JS_TRUE;
 
-  char* buffer = static_cast<char*>(CData::GetData(cx, result));
-  const FieldInfoHash* fields = GetFieldInfo(cx, obj);
+  char* buffer = static_cast<char*>(CData::GetData(result));
+  const FieldInfoHash* fields = GetFieldInfo(obj);
 
   jsval* argv = JS_ARGV(cx, vp);
   if (argc == 1) {
     // There are two possible interpretations of the argument:
     // 1) It may be an object '{ ... }' with properties representing the
     //    struct fields intended to ExplicitConvert wholesale to our StructType.
     // 2) If the struct contains one field, the arg may be intended to
     //    ImplicitConvert directly to that arg's CType.
@@ -4430,54 +4391,53 @@ StructType::ConstructData(JSContext* cx,
   }
 
   JS_ReportError(cx, "constructor takes 0, 1, or %u arguments",
     fields->count());
   return JS_FALSE;
 }
 
 const FieldInfoHash*
-StructType::GetFieldInfo(JSContext* cx, JSObject* obj)
+StructType::GetFieldInfo(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_struct);
-
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_FIELDINFO, &slot));
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct);
+
+  jsval slot = JS_GetReservedSlot(obj, SLOT_FIELDINFO);
   JS_ASSERT(!JSVAL_IS_VOID(slot) && JSVAL_TO_PRIVATE(slot));
 
   return static_cast<const FieldInfoHash*>(JSVAL_TO_PRIVATE(slot));
 }
 
 const FieldInfo*
 StructType::LookupField(JSContext* cx, JSObject* obj, JSFlatString *name)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_struct);
-
-  FieldInfoHash::Ptr ptr = GetFieldInfo(cx, obj)->lookup(name);
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct);
+
+  FieldInfoHash::Ptr ptr = GetFieldInfo(obj)->lookup(name);
   if (ptr)
     return &ptr->value;
 
   JSAutoByteString bytes(cx, name);
   if (!bytes)
     return NULL;
 
   JS_ReportError(cx, "%s does not name a field", bytes.ptr());
   return NULL;
 }
 
 JSObject*
 StructType::BuildFieldsArray(JSContext* cx, JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_struct);
-  JS_ASSERT(CType::IsSizeDefined(cx, obj));
-
-  const FieldInfoHash* fields = GetFieldInfo(cx, obj);
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_struct);
+  JS_ASSERT(CType::IsSizeDefined(obj));
+
+  const FieldInfoHash* fields = GetFieldInfo(obj);
   size_t len = fields->count();
 
   // Prepare a new array for the 'fields' property of the StructType.
   Array<jsval, 16> fieldsVec;
   if (!fieldsVec.appendN(JSVAL_VOID, len))
     return NULL;
   js::AutoArrayRooter root(cx, fieldsVec.length(), fieldsVec.begin());
 
@@ -4498,34 +4458,34 @@ StructType::BuildFieldsArray(JSContext* 
     return NULL;
 
   return fieldsProp;
 }
 
 JSBool
 StructType::FieldsArrayGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_struct) {
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_struct) {
     JS_ReportError(cx, "not a StructType");
     return JS_FALSE;
   }
 
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_FIELDS, vp));
-
-  if (!CType::IsSizeDefined(cx, obj)) {
+  *vp = JS_GetReservedSlot(obj, SLOT_FIELDS);
+
+  if (!CType::IsSizeDefined(obj)) {
     JS_ASSERT(JSVAL_IS_VOID(*vp));
     return JS_TRUE;
   }
 
   if (JSVAL_IS_VOID(*vp)) {
     // Build the 'fields' array lazily.
     JSObject* fields = BuildFieldsArray(cx, obj);
-    if (!fields ||
-        !JS_SetReservedSlot(cx, obj, SLOT_FIELDS, OBJECT_TO_JSVAL(fields)))
+    if (!fields)
       return JS_FALSE;
+    JS_SetReservedSlot(obj, SLOT_FIELDS, OBJECT_TO_JSVAL(fields));
 
     *vp = OBJECT_TO_JSVAL(fields);
   }
 
   JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp) &&
             JS_IsArrayObject(cx, JSVAL_TO_OBJECT(*vp)));
   return JS_TRUE;
 }
@@ -4533,63 +4493,63 @@ StructType::FieldsArrayGetter(JSContext*
 JSBool
 StructType::FieldGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_struct) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_struct) {
     JS_ReportError(cx, "not a StructType");
     return JS_FALSE;
   }
 
   const FieldInfo* field = LookupField(cx, typeObj, JSID_TO_FLAT_STRING(idval));
   if (!field)
     return JS_FALSE;
 
-  char* data = static_cast<char*>(CData::GetData(cx, obj)) + field->mOffset;
+  char* data = static_cast<char*>(CData::GetData(obj)) + field->mOffset;
   return ConvertToJS(cx, field->mType, obj, data, false, false, vp);
 }
 
 JSBool
 StructType::FieldSetter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict, jsval* vp)
 {
   if (!CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_struct) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_struct) {
     JS_ReportError(cx, "not a StructType");
     return JS_FALSE;
   }
 
   const FieldInfo* field = LookupField(cx, typeObj, JSID_TO_FLAT_STRING(idval));
   if (!field)
     return JS_FALSE;
 
-  char* data = static_cast<char*>(CData::GetData(cx, obj)) + field->mOffset;
+  char* data = static_cast<char*>(CData::GetData(obj)) + field->mOffset;
   return ImplicitConvert(cx, *vp, field->mType, data, false, NULL);
 }
 
 JSBool
 StructType::AddressOfField(JSContext* cx, uintN argc, jsval* vp)
 {
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj || !CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_struct) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_struct) {
     JS_ReportError(cx, "not a StructType");
     return JS_FALSE;
   }
 
   if (argc != 1) {
     JS_ReportError(cx, "addressOfField takes one argument");
     return JS_FALSE;
   }
@@ -4611,18 +4571,18 @@ StructType::AddressOfField(JSContext* cx
   // Create a PointerType CData object containing null.
   JSObject* result = CData::Create(cx, pointerType, NULL, NULL, true);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
 
   // Manually set the pointer inside the object, so we skip the conversion step.
-  void** data = static_cast<void**>(CData::GetData(cx, result));
-  *data = static_cast<char*>(CData::GetData(cx, obj)) + field->mOffset;
+  void** data = static_cast<void**>(CData::GetData(result));
+  *data = static_cast<char*>(CData::GetData(obj)) + field->mOffset;
   return JS_TRUE;
 }
 
 /*******************************************************************************
 ** FunctionType implementation
 *******************************************************************************/
 
 // Helper class for handling allocation of function arguments.
@@ -4633,33 +4593,33 @@ struct AutoValue
   ~AutoValue()
   {
     UnwantedForeground::array_delete(static_cast<char*>(mData));
   }
 
   bool SizeToType(JSContext* cx, JSObject* type)
   {
     // Allocate a minimum of sizeof(ffi_arg) to handle small integers.
-    size_t size = Align(CType::GetSize(cx, type), sizeof(ffi_arg));
+    size_t size = Align(CType::GetSize(type), sizeof(ffi_arg));
     mData = cx->array_new<char>(size);
     if (mData)
       memset(mData, 0, size);
     return mData != NULL;
   }
 
   void* mData;
 };
 
 static bool
 GetABI(JSContext* cx, jsval abiType, ffi_abi* result)
 {
   if (JSVAL_IS_PRIMITIVE(abiType))
     return false;
 
-  ABICode abi = GetABICode(cx, JSVAL_TO_OBJECT(abiType));
+  ABICode abi = GetABICode(JSVAL_TO_OBJECT(abiType));
 
   // determine the ABI from the subset of those available on the
   // given platform. ABI_DEFAULT specifies the default
   // C calling convention (cdecl) on each platform.
   switch (abi) {
   case ABI_DEFAULT:
     *result = FFI_DEFAULT_ABI;
     return true;
@@ -4685,68 +4645,68 @@ PrepareType(JSContext* cx, jsval type)
 {
   if (JSVAL_IS_PRIMITIVE(type) ||
       !CType::IsCType(JSVAL_TO_OBJECT(type))) {
     JS_ReportError(cx, "not a ctypes type");
     return NULL;
   }
 
   JSObject* result = JSVAL_TO_OBJECT(type);
-  TypeCode typeCode = CType::GetTypeCode(cx, result);
+  TypeCode typeCode = CType::GetTypeCode(result);
 
   if (typeCode == TYPE_array) {
     // convert array argument types to pointers, just like C.
     // ImplicitConvert will do the same, when passing an array as data.
-    JSObject* baseType = ArrayType::GetBaseType(cx, result);
+    JSObject* baseType = ArrayType::GetBaseType(result);
     result = PointerType::CreateInternal(cx, baseType);
     if (!result)
       return NULL;
 
   } else if (typeCode == TYPE_void_t || typeCode == TYPE_function) {
     // disallow void or function argument types
     JS_ReportError(cx, "Cannot have void or function argument type");
     return NULL;
   }
 
-  if (!CType::IsSizeDefined(cx, result)) {
+  if (!CType::IsSizeDefined(result)) {
     JS_ReportError(cx, "Argument type must have defined size");
     return NULL;
   }
 
   // libffi cannot pass types of zero size by value.
-  JS_ASSERT(CType::GetSize(cx, result) != 0);
+  JS_ASSERT(CType::GetSize(result) != 0);
 
   return result;
 }
 
 static JSObject*
 PrepareReturnType(JSContext* cx, jsval type)
 {
   if (JSVAL_IS_PRIMITIVE(type) ||
       !CType::IsCType(JSVAL_TO_OBJECT(type))) {
     JS_ReportError(cx, "not a ctypes type");
     return NULL;
   }
 
   JSObject* result = JSVAL_TO_OBJECT(type);
-  TypeCode typeCode = CType::GetTypeCode(cx, result);
+  TypeCode typeCode = CType::GetTypeCode(result);
 
   // Arrays and functions can never be return types.
   if (typeCode == TYPE_array || typeCode == TYPE_function) {
     JS_ReportError(cx, "Return type cannot be an array or function");
     return NULL;
   }
 
-  if (typeCode != TYPE_void_t && !CType::IsSizeDefined(cx, result)) {
+  if (typeCode != TYPE_void_t && !CType::IsSizeDefined(result)) {
     JS_ReportError(cx, "Return type must have defined size");
     return NULL;
   }
 
   // libffi cannot pass types of zero size by value.
-  JS_ASSERT(typeCode == TYPE_void_t || CType::GetSize(cx, result) != 0);
+  JS_ASSERT(typeCode == TYPE_void_t || CType::GetSize(result) != 0);
 
   return result;
 }
 
 static JS_ALWAYS_INLINE JSBool
 IsEllipsis(JSContext* cx, jsval v, bool* isEllipsis)
 {
   *isEllipsis = false;
@@ -4797,24 +4757,23 @@ PrepareCIF(JSContext* cx,
     return false;
   default:
     JS_ReportError(cx, "Unknown libffi error");
     return false;
   }
 }
 
 void
-FunctionType::BuildSymbolName(JSContext* cx,
-                              JSString* name,
+FunctionType::BuildSymbolName(JSString* name,
                               JSObject* typeObj,
                               AutoCString& result)
 {
-  FunctionInfo* fninfo = GetFunctionInfo(cx, typeObj);
-
-  switch (GetABICode(cx, fninfo->mABI)) {
+  FunctionInfo* fninfo = GetFunctionInfo(typeObj);
+
+  switch (GetABICode(fninfo->mABI)) {
   case ABI_DEFAULT:
   case ABI_WINAPI:
     // For cdecl or WINAPI functions, no mangling is necessary.
     AppendString(result, name);
     break;
 
   case ABI_STDCALL: {
 #if (defined(_WIN32) && !defined(_WIN64)) || defined(_OS2)
@@ -4825,17 +4784,17 @@ FunctionType::BuildSymbolName(JSContext*
     AppendString(result, "_");
     AppendString(result, name);
     AppendString(result, "@");
 
     // Compute the suffix by aligning each argument to sizeof(ffi_arg).
     size_t size = 0;
     for (size_t i = 0; i < fninfo->mArgTypes.length(); ++i) {
       JSObject* argType = fninfo->mArgTypes[i];
-      size += Align(CType::GetSize(cx, argType), sizeof(ffi_arg));
+      size += Align(CType::GetSize(argType), sizeof(ffi_arg));
     }
 
     IntegerToString(size, 10, result);
 #elif defined(_WIN64)
     // On Win64, stdcall is an alias to the default ABI for compatibility, so no
     // mangling is done.
     AppendString(result, name);
 #endif
@@ -4893,17 +4852,17 @@ NewFunctionInfo(JSContext* cx,
                        "type of a variadic function declaration");
         return NULL;
       }
       if (i < argLength - 1) {
         JS_ReportError(cx, "\"...\" must be the last parameter type of a "
                        "variadic function declaration");
         return NULL;
       }
-      if (GetABICode(cx, fninfo->mABI) != ABI_DEFAULT) {
+      if (GetABICode(fninfo->mABI) != ABI_DEFAULT) {
         JS_ReportError(cx, "Variadic functions must use the __cdecl calling "
                        "convention");
         return NULL;
       }
       break;
     }
 
     JSObject* argType = PrepareType(cx, argTypes[i]);
@@ -4985,72 +4944,67 @@ FunctionType::CreateInternal(JSContext* 
 {
   // Determine and check the types, and prepare the function CIF.
   AutoPtr<FunctionInfo> fninfo(NewFunctionInfo(cx, abi, rtype, argtypes, arglen));
   if (!fninfo)
     return NULL;
 
   // Get ctypes.FunctionType.prototype and the common prototype for CData objects
   // of this type, from ctypes.CType.prototype.
-  JSObject* typeProto = CType::GetProtoFromType(cx, fninfo->mReturnType,
+  JSObject* typeProto = CType::GetProtoFromType(fninfo->mReturnType,
                                                 SLOT_FUNCTIONPROTO);
-  JSObject* dataProto = CType::GetProtoFromType(cx, fninfo->mReturnType,
+  JSObject* dataProto = CType::GetProtoFromType(fninfo->mReturnType,
                                                 SLOT_FUNCTIONDATAPROTO);
 
   // Create a new CType object with the common properties and slots.
   JSObject* typeObj = CType::Create(cx, typeProto, dataProto, TYPE_function,
                         NULL, JSVAL_VOID, JSVAL_VOID, NULL);
   if (!typeObj)
     return NULL;
   js::AutoObjectRooter root(cx, typeObj);
 
   // Stash the FunctionInfo in a reserved slot.
-  if (!JS_SetReservedSlot(cx, typeObj, SLOT_FNINFO,
-         PRIVATE_TO_JSVAL(fninfo.get())))
-    return NULL;
-  fninfo.forget();
+  JS_SetReservedSlot(typeObj, SLOT_FNINFO, PRIVATE_TO_JSVAL(fninfo.forget()));
 
   return typeObj;
 }
 
 // Construct a function pointer to a JS function (see CClosure::Create()).
 // Regular function pointers are constructed directly in
 // PointerType::ConstructData().
 JSBool
 FunctionType::ConstructData(JSContext* cx,
                             JSObject* typeObj,
                             JSObject* dataObj,
                             JSObject* fnObj,
                             JSObject* thisObj,
                             jsval errVal)
 {
-  JS_ASSERT(CType::GetTypeCode(cx, typeObj) == TYPE_function);
-
-  PRFuncPtr* data = static_cast<PRFuncPtr*>(CData::GetData(cx, dataObj));
-
-  FunctionInfo* fninfo = FunctionType::GetFunctionInfo(cx, typeObj);
+  JS_ASSERT(CType::GetTypeCode(typeObj) == TYPE_function);
+
+  PRFuncPtr* data = static_cast<PRFuncPtr*>(CData::GetData(dataObj));
+
+  FunctionInfo* fninfo = FunctionType::GetFunctionInfo(typeObj);
   if (fninfo->mIsVariadic) {
     JS_ReportError(cx, "Can't declare a variadic callback function");
     return JS_FALSE;
   }
-  if (GetABICode(cx, fninfo->mABI) == ABI_WINAPI) {
+  if (GetABICode(fninfo->mABI) == ABI_WINAPI) {
     JS_ReportError(cx, "Can't declare a ctypes.winapi_abi callback function, "
                    "use ctypes.stdcall_abi instead");
     return JS_FALSE;
   }
 
   JSObject* closureObj = CClosure::Create(cx, typeObj, fnObj, thisObj, errVal, data);
   if (!closureObj)
     return JS_FALSE;
   js::AutoObjectRooter root(cx, closureObj);
 
   // Set the closure object as the referent of the new CData object.
-  if (!JS_SetReservedSlot(cx, dataObj, SLOT_REFERENT,
-         OBJECT_TO_JSVAL(closureObj)))
-    return JS_FALSE;
+  JS_SetReservedSlot(dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(closureObj));
 
   // Seal the CData object, to prevent modification of the function pointer.
   // This permanently associates this object with the closure, and avoids
   // having to do things like reset SLOT_REFERENT when someone tries to
   // change the pointer value.
   // XXX This will need to change when bug 541212 is fixed -- CData::ValueSetter
   // could be called on a frozen object.
   return JS_FreezeObject(cx, dataObj);
@@ -5094,42 +5048,41 @@ FunctionType::Call(JSContext* cx,
 {
   // get the callee object...
   JSObject* obj = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
   if (!CData::IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return false;
   }
 
-  JSObject* typeObj = CData::GetCType(cx, obj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_pointer) {
+  JSObject* typeObj = CData::GetCType(obj);
+  if (CType::GetTypeCode(typeObj) != TYPE_pointer) {
     JS_ReportError(cx, "not a FunctionType.ptr");
     return false;
   }
 
-  typeObj = PointerType::GetBaseType(cx, typeObj);
-  if (CType::GetTypeCode(cx, typeObj) != TYPE_function) {
+  typeObj = PointerType::GetBaseType(typeObj);
+  if (CType::GetTypeCode(typeObj) != TYPE_function) {
     JS_ReportError(cx, "not a FunctionType.ptr");
     return false;
   }
 
-  FunctionInfo* fninfo = GetFunctionInfo(cx, typeObj);
+  FunctionInfo* fninfo = GetFunctionInfo(typeObj);
   uint32_t argcFixed = fninfo->mArgTypes.length();
 
   if ((!fninfo->mIsVariadic && argc != argcFixed) ||
       (fninfo->mIsVariadic && argc < argcFixed)) {
     JS_ReportError(cx, "Number of arguments does not match declaration");
     return false;
   }
 
   // Check if we have a Library object. If we do, make sure it's open.
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_REFERENT, &slot));
+  jsval slot = JS_GetReservedSlot(obj, SLOT_REFERENT);
   if (!JSVAL_IS_VOID(slot) && Library::IsLibrary(JSVAL_TO_OBJECT(slot))) {
-    PRLibrary* library = Library::GetLibrary(cx, JSVAL_TO_OBJECT(slot));
+    PRLibrary* library = Library::GetLibrary(JSVAL_TO_OBJECT(slot));
     if (!library) {
       JS_ReportError(cx, "library is not open");
       return false;
     }
   }
 
   // prepare the values for each argument
   AutoValueAutoArray values;
@@ -5157,40 +5110,40 @@ FunctionType::Call(JSContext* cx,
       if (JSVAL_IS_PRIMITIVE(argv[i]) ||
           !CData::IsCData(obj = JSVAL_TO_OBJECT(argv[i]))) {
         // Since we know nothing about the CTypes of the ... arguments,
         // they absolutely must be CData objects already.
         JS_ReportError(cx, "argument %d of type %s is not a CData object",
                        i, JS_GetTypeName(cx, JS_TypeOfValue(cx, argv[i])));
         return false;
       }
-      if (!(type = CData::GetCType(cx, obj)) ||
+      if (!(type = CData::GetCType(obj)) ||
           !(type = PrepareType(cx, OBJECT_TO_JSVAL(type))) ||
           // Relying on ImplicitConvert only for the limited purpose of
           // converting one CType to another (e.g., T[] to T*).
           !ConvertArgument(cx, argv[i], type, &values[i], &strings) ||
           !(fninfo->mFFITypes[i] = CType::GetFFIType(cx, type))) {
         // These functions report their own errors.
         return false;
       }
     }
     if (!PrepareCIF(cx, fninfo))
       return false;
   }
 
   // initialize a pointer to an appropriate location, for storing the result
   AutoValue returnValue;
-  TypeCode typeCode = CType::GetTypeCode(cx, fninfo->mReturnType);
+  TypeCode typeCode = CType::GetTypeCode(fninfo->mReturnType);
   if (typeCode != TYPE_void_t &&
       !returnValue.SizeToType(cx, fninfo->mReturnType)) {
     JS_ReportAllocationOverflow(cx);
     return false;
   }
 
-  uintptr_t fn = *reinterpret_cast<uintptr_t*>(CData::GetData(cx, obj));
+  uintptr_t fn = *reinterpret_cast<uintptr_t*>(CData::GetData(obj));
 
   // suspend the request before we call into the function, since the call
   // may block or otherwise take a long time to return.
   {
     JSAutoSuspendRequest suspend(cx);
     ffi_call(&fninfo->mCIF, FFI_FN(fn), returnValue.mData,
              reinterpret_cast<void**>(values.begin()));
   }
@@ -5215,102 +5168,101 @@ FunctionType::Call(JSContext* cx,
   }
 
   // prepare a JS object from the result
   return ConvertToJS(cx, fninfo->mReturnType, NULL, returnValue.mData,
                      false, true, vp);
 }
 
 FunctionInfo*
-FunctionType::GetFunctionInfo(JSContext* cx, JSObject* obj)
+FunctionType::GetFunctionInfo(JSObject* obj)
 {
   JS_ASSERT(CType::IsCType(obj));
-  JS_ASSERT(CType::GetTypeCode(cx, obj) == TYPE_function);
-
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_FNINFO, &slot));
+  JS_ASSERT(CType::GetTypeCode(obj) == TYPE_function);
+
+  jsval slot = JS_GetReservedSlot(obj, SLOT_FNINFO);
   JS_ASSERT(!JSVAL_IS_VOID(slot) && JSVAL_TO_PRIVATE(slot));
 
   return static_cast<FunctionInfo*>(JSVAL_TO_PRIVATE(slot));
 }
 
 static JSBool
 CheckFunctionType(JSContext* cx, JSObject* obj)
 {
-  if (!CType::IsCType(obj) || CType::GetTypeCode(cx, obj) != TYPE_function) {
+  if (!CType::IsCType(obj) || CType::GetTypeCode(obj) != TYPE_function) {
     JS_ReportError(cx, "not a FunctionType");
     return JS_FALSE;
   }
   return JS_TRUE;
 }
 
 JSBool
 FunctionType::ArgTypesGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CheckFunctionType(cx, obj))
     return JS_FALSE;
 
   // Check if we have a cached argTypes array.
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_ARGS_T, vp));
+  *vp = JS_GetReservedSlot(obj, SLOT_ARGS_T);
   if (!JSVAL_IS_VOID(*vp))
     return JS_TRUE;
 
-  FunctionInfo* fninfo = GetFunctionInfo(cx, obj);
+  FunctionInfo* fninfo = GetFunctionInfo(obj);
   size_t len = fninfo->mArgTypes.length();
 
   // Prepare a new array.
   Array<jsval, 16> vec;
   if (!vec.resize(len))
     return JS_FALSE;
 
   for (size_t i = 0; i < len; ++i)
     vec[i] = OBJECT_TO_JSVAL(fninfo->mArgTypes[i]);
 
   JSObject* argTypes = JS_NewArrayObject(cx, len, vec.begin());
   if (!argTypes)
     return JS_FALSE;
 
   // Seal and cache it.
-  if (!JS_FreezeObject(cx, argTypes) ||
-      !JS_SetReservedSlot(cx, obj, SLOT_ARGS_T, OBJECT_TO_JSVAL(argTypes)))
+  if (!JS_FreezeObject(cx, argTypes))
     return JS_FALSE;
+  JS_SetReservedSlot(obj, SLOT_ARGS_T, OBJECT_TO_JSVAL(argTypes));
 
   *vp = OBJECT_TO_JSVAL(argTypes);
   return JS_TRUE;
 }
 
 JSBool
 FunctionType::ReturnTypeGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CheckFunctionType(cx, obj))
     return JS_FALSE;
 
   // Get the returnType object from the FunctionInfo.
-  *vp = OBJECT_TO_JSVAL(GetFunctionInfo(cx, obj)->mReturnType);
+  *vp = OBJECT_TO_JSVAL(GetFunctionInfo(obj)->mReturnType);
   return JS_TRUE;
 }
 
 JSBool
 FunctionType::ABIGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CheckFunctionType(cx, obj))
     return JS_FALSE;
 
   // Get the abi object from the FunctionInfo.
-  *vp = OBJECT_TO_JSVAL(GetFunctionInfo(cx, obj)->mABI);
+  *vp = OBJECT_TO_JSVAL(GetFunctionInfo(obj)->mABI);
   return JS_TRUE;
 }
 
 JSBool
 FunctionType::IsVariadicGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!CheckFunctionType(cx, obj))
     return JS_FALSE;
 
-  *vp = BOOLEAN_TO_JSVAL(GetFunctionInfo(cx, obj)->mIsVariadic);
+  *vp = BOOLEAN_TO_JSVAL(GetFunctionInfo(obj)->mIsVariadic);
   return JS_TRUE;
 }
 
 /*******************************************************************************
 ** CClosure implementation
 *******************************************************************************/
 
 JSObject*
@@ -5324,74 +5276,69 @@ CClosure::Create(JSContext* cx,
   JS_ASSERT(fnObj);
 
   JSObject* result = JS_NewObject(cx, &sCClosureClass, NULL, NULL);
   if (!result)
     return NULL;
   js::AutoObjectRooter root(cx, result);
 
   // Get the FunctionInfo from the FunctionType.
-  FunctionInfo* fninfo = FunctionType::GetFunctionInfo(cx, typeObj);
+  FunctionInfo* fninfo = FunctionType::GetFunctionInfo(typeObj);
   JS_ASSERT(!fninfo->mIsVariadic);
-  JS_ASSERT(GetABICode(cx, fninfo->mABI) != ABI_WINAPI);
+  JS_ASSERT(GetABICode(fninfo->mABI) != ABI_WINAPI);
 
   AutoPtr<ClosureInfo> cinfo(cx->new_<ClosureInfo>(JS_GetRuntime(cx)));
   if (!cinfo) {
     JS_ReportOutOfMemory(cx);
     return NULL;
   }
 
   // Get the prototype of the FunctionType object, of class CTypeProto,
   // which stores our JSContext for use with the closure.
-  JSObject* proto = JS_GetPrototype(cx, typeObj);
+  JSObject* proto = JS_GetPrototype(typeObj);
   JS_ASSERT(proto);
   JS_ASSERT(CType::IsCTypeProto(proto));
 
   // Get a JSContext for use with the closure.
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, proto, SLOT_CLOSURECX, &slot));
+  jsval slot = JS_GetReservedSlot(proto, SLOT_CLOSURECX);
   if (!JSVAL_IS_VOID(slot)) {
     // Use the existing JSContext.
     cinfo->cx = static_cast<JSContext*>(JSVAL_TO_PRIVATE(slot));
     JS_ASSERT(cinfo->cx);
   } else {
     // Lazily instantiate a new JSContext, and stash it on
     // ctypes.FunctionType.prototype.
     JSRuntime* runtime = JS_GetRuntime(cx);
     cinfo->cx = JS_NewContext(runtime, 8192);
     if (!cinfo->cx) {
       JS_ReportOutOfMemory(cx);
       return NULL;
     }
 
-    if (!JS_SetReservedSlot(cx, proto, SLOT_CLOSURECX,
-           PRIVATE_TO_JSVAL(cinfo->cx))) {
-      JS_DestroyContextNoGC(cinfo->cx);
-      return NULL;
-    }
+    JS_SetReservedSlot(proto, SLOT_CLOSURECX, PRIVATE_TO_JSVAL(cinfo->cx));
   }
 
   // Prepare the error sentinel value. It's important to do this now, because
   // we might be unable to convert the value to the proper type. If so, we want
   // the caller to know about it _now_, rather than some uncertain time in the
   // future when the error sentinel is actually needed.
   if (!JSVAL_IS_VOID(errVal)) {
 
     // Make sure the callback returns something.
-    if (CType::GetTypeCode(cx, fninfo->mReturnType) == TYPE_void_t) {
+    if (CType::GetTypeCode(fninfo->mReturnType) == TYPE_void_t) {
       JS_ReportError(cx, "A void callback can't pass an error sentinel");
       return NULL;
     }
 
     // With the exception of void, the FunctionType constructor ensures that
     // the return type has a defined size.
-    JS_ASSERT(CType::IsSizeDefined(cx, fninfo->mReturnType));
+    JS_ASSERT(CType::IsSizeDefined(fninfo->mReturnType));
 
     // Allocate a buffer for the return value.
-    size_t rvSize = CType::GetSize(cx, fninfo->mReturnType);
+    size_t rvSize = CType::GetSize(fninfo->mReturnType);
     cinfo->errResult = cx->malloc_(rvSize);
     if (!cinfo->errResult)
       return NULL;
 
     // Do the value conversion. This might fail, in which case we throw.
     if (!ImplicitConvert(cx, errVal, fninfo->mReturnType, cinfo->errResult,
                          false, NULL))
       return NULL;
@@ -5417,55 +5364,48 @@ CClosure::Create(JSContext* cx,
   ffi_status status = ffi_prep_closure_loc(cinfo->closure, &fninfo->mCIF,
     CClosure::ClosureStub, cinfo.get(), code);
   if (status != FFI_OK) {
     JS_ReportError(cx, "couldn't create closure - libffi error");
     return NULL;
   }
 
   // Stash the ClosureInfo struct on our new object.
-  if (!JS_SetReservedSlot(cx, result, SLOT_CLOSUREINFO,
-         PRIVATE_TO_JSVAL(cinfo.get())))
-    return NULL;
-  cinfo.forget();
+  JS_SetReservedSlot(result, SLOT_CLOSUREINFO, PRIVATE_TO_JSVAL(cinfo.forget()));
 
   // Casting between void* and a function pointer is forbidden in C and C++.
   // Do it via an integral type.
   *fnptr = reinterpret_cast<PRFuncPtr>(reinterpret_cast<uintptr_t>(code));
   return result;
 }
 
 void
 CClosure::Trace(JSTracer* trc, JSObject* obj)
 {
-  JSContext* cx = trc->context;
-
   // Make sure our ClosureInfo slot is legit. If it's not, bail.
-  jsval slot;
-  if (!JS_GetReservedSlot(cx, obj, SLOT_CLOSUREINFO, &slot) ||
-      JSVAL_IS_VOID(slot))
+  jsval slot = JS_GetReservedSlot(obj, SLOT_CLOSUREINFO);
+  if (JSVAL_IS_VOID(slot))
     return;
 
   ClosureInfo* cinfo = static_cast<ClosureInfo*>(JSVAL_TO_PRIVATE(slot));
 
   // Identify our objects to the tracer. (There's no need to identify
   // 'closureObj', since that's us.)
   JS_CALL_OBJECT_TRACER(trc, cinfo->typeObj, "typeObj");
   JS_CALL_OBJECT_TRACER(trc, cinfo->jsfnObj, "jsfnObj");
   if (cinfo->thisObj)
     JS_CALL_OBJECT_TRACER(trc, cinfo->thisObj, "thisObj");
 }
 
 void
 CClosure::Finalize(JSContext* cx, JSObject* obj)
 {
   // Make sure our ClosureInfo slot is legit. If it's not, bail.
-  jsval slot;
-  if (!JS_GetReservedSlot(cx, obj, SLOT_CLOSUREINFO, &slot) ||
-      JSVAL_IS_VOID(slot))
+  jsval slot = JS_GetReservedSlot(obj, SLOT_CLOSUREINFO);
+  if (JSVAL_IS_VOID(slot))
     return;
 
   ClosureInfo* cinfo = static_cast<ClosureInfo*>(JSVAL_TO_PRIVATE(slot));
   cx->delete_(cinfo);
 }
 
 void
 CClosure::ClosureStub(ffi_cif* cif, void* result, void** args, void* userData)
@@ -5486,20 +5426,20 @@ CClosure::ClosureStub(ffi_cif* cif, void
 
   JSAutoRequest ar(cx);
 
   JSAutoEnterCompartment ac;
   if (!ac.enter(cx, jsfnObj))
     return;
 
   // Assert that our CIFs agree.
-  FunctionInfo* fninfo = FunctionType::GetFunctionInfo(cx, typeObj);
+  FunctionInfo* fninfo = FunctionType::GetFunctionInfo(typeObj);
   JS_ASSERT(cif == &fninfo->mCIF);
 
-  TypeCode typeCode = CType::GetTypeCode(cx, fninfo->mReturnType);
+  TypeCode typeCode = CType::GetTypeCode(fninfo->mReturnType);
 
   // Initialize the result to zero, in case something fails. Small integer types
   // are promoted to a word-sized ffi_arg, so we must be careful to zero the
   // whole word.
   size_t rvSize = 0;
   if (cif->rtype != &ffi_type_void) {
     rvSize = cif->rtype->size;
     switch (typeCode) {
@@ -5564,17 +5504,17 @@ CClosure::ClosureStub(ffi_cif* cif, void
 
     if (cinfo->errResult) {
       // Good case: we have a sentinel that we can return. Copy it in place of
       // the actual return value, and then proceed.
 
       // The buffer we're returning might be larger than the size of the return
       // type, due to libffi alignment issues (see above). But it should never
       // be smaller.
-      size_t copySize = CType::GetSize(cx, fninfo->mReturnType);
+      size_t copySize = CType::GetSize(fninfo->mReturnType);
       JS_ASSERT(copySize <= rvSize);
       memcpy(result, cinfo->errResult, copySize);
     } else {
       // Bad case: not much we can do here. The rv is already zeroed out, so we
       // just report (another) error and hope for the best. JS_ReportError will
       // actually throw an exception here, so then we have to report it. Again.
       // Ugh.
       JS_ReportError(cx, "JavaScript callback failed, and an error sentinel "
@@ -5635,124 +5575,114 @@ JSObject*
 CData::Create(JSContext* cx,
               JSObject* typeObj,
               JSObject* refObj,
               void* source,
               bool ownResult)
 {
   JS_ASSERT(typeObj);
   JS_ASSERT(CType::IsCType(typeObj));
-  JS_ASSERT(CType::IsSizeDefined(cx, typeObj));
+  JS_ASSERT(CType::IsSizeDefined(typeObj));
   JS_ASSERT(ownResult || source);
   JS_ASSERT_IF(refObj && CData::IsCData(refObj), !ownResult);
 
   // Get the 'prototype' property from the type.
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, typeObj, SLOT_PROTO, &slot));
+  jsval slot = JS_GetReservedSlot(typeObj, SLOT_PROTO);
   JS_ASSERT(!JSVAL_IS_PRIMITIVE(slot));
 
   JSObject* proto = JSVAL_TO_OBJECT(slot);
-  JSObject* parent = JS_GetParent(cx, typeObj);
+  JSObject* parent = JS_GetParent(typeObj);
   JS_ASSERT(parent);
 
   JSObject* dataObj = JS_NewObject(cx, &sCDataClass, proto, parent);
   if (!dataObj)
     return NULL;
   js::AutoObjectRooter root(cx, dataObj);
 
   // set the CData's associated type
-  if (!JS_SetReservedSlot(cx, dataObj, SLOT_CTYPE, OBJECT_TO_JSVAL(typeObj)))
-    return NULL;
+  JS_SetReservedSlot(dataObj, SLOT_CTYPE, OBJECT_TO_JSVAL(typeObj));
 
   // Stash the referent object, if any, for GC safety.
-  if (refObj &&
-      !JS_SetReservedSlot(cx, dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(refObj)))
-    return NULL;
+  if (refObj)
+    JS_SetReservedSlot(dataObj, SLOT_REFERENT, OBJECT_TO_JSVAL(refObj));
 
   // Set our ownership flag.
-  if (!JS_SetReservedSlot(cx, dataObj, SLOT_OWNS, BOOLEAN_TO_JSVAL(ownResult)))
-    return NULL;
+  JS_SetReservedSlot(dataObj, SLOT_OWNS, BOOLEAN_TO_JSVAL(ownResult));
 
   // attach the buffer. since it might not be 2-byte aligned, we need to
   // allocate an aligned space for it and store it there. :(
   char** buffer = cx->new_<char*>();
   if (!buffer) {
     JS_ReportOutOfMemory(cx);
     return NULL;
   }
 
   char* data;
   if (!ownResult) {
     data = static_cast<char*>(source);
   } else {
     // Initialize our own buffer.
-    size_t size = CType::GetSize(cx, typeObj);
+    size_t size = CType::GetSize(typeObj);
     data = cx->array_new<char>(size);
     if (!data) {
       // Report a catchable allocation error.
       JS_ReportAllocationOverflow(cx);
       Foreground::delete_(buffer);
       return NULL;
     }
 
     if (!source)
       memset(data, 0, size);
     else
       memcpy(data, source, size);
   }
 
   *buffer = data;
-  if (!JS_SetReservedSlot(cx, dataObj, SLOT_DATA, PRIVATE_TO_JSVAL(buffer))) {
-    if (ownResult)
-      Foreground::array_delete(data);
-    Foreground::delete_(buffer);
-    return NULL;
-  }
+  JS_SetReservedSlot(dataObj, SLOT_DATA, PRIVATE_TO_JSVAL(buffer));
 
   return dataObj;
 }
 
 void
 CData::Finalize(JSContext* cx, JSObject* obj)
 {
   // Delete our buffer, and the data it contains if we own it.
-  jsval slot;
-  if (!JS_GetReservedSlot(cx, obj, SLOT_OWNS, &slot) || JSVAL_IS_VOID(slot))
+  jsval slot = JS_GetReservedSlot(obj, SLOT_OWNS);
+  if (JSVAL_IS_VOID(slot))
     return;
 
   JSBool owns = JSVAL_TO_BOOLEAN(slot);
 
-  if (!JS_GetReservedSlot(cx, obj, SLOT_DATA, &slot) || JSVAL_IS_VOID(slot))
+  slot = JS_GetReservedSlot(obj, SLOT_DATA);
+  if (JSVAL_IS_VOID(slot))
     return;
   char** buffer = static_cast<char**>(JSVAL_TO_PRIVATE(slot));
 
   if (owns)
     cx->array_delete(*buffer);
   cx->delete_(buffer);
 }
 
 JSObject*
-CData::GetCType(JSContext* cx, JSObject* dataObj)
+CData::GetCType(JSObject* dataObj)
 {
   JS_ASSERT(CData::IsCData(dataObj));
 
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, dataObj, SLOT_CTYPE, &slot));
+  jsval slot = JS_GetReservedSlot(dataObj, SLOT_CTYPE);
   JSObject* typeObj = JSVAL_TO_OBJECT(slot);
   JS_ASSERT(CType::IsCType(typeObj));
   return typeObj;
 }
 
 void*
-CData::GetData(JSContext* cx, JSObject* dataObj)
+CData::GetData(JSObject* dataObj)
 {
   JS_ASSERT(CData::IsCData(dataObj));
 
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, dataObj, SLOT_DATA, &slot));
+  jsval slot = JS_GetReservedSlot(dataObj, SLOT_DATA);
 
   void** buffer = static_cast<void**>(JSVAL_TO_PRIVATE(slot));
   JS_ASSERT(buffer);
   JS_ASSERT(*buffer);
   return *buffer;
 }
 
 bool
@@ -5771,63 +5701,63 @@ JSBool
 CData::ValueGetter(JSContext* cx, JSObject* obj, jsid idval, jsval* vp)
 {
   if (!IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   // Convert the value to a primitive; do not create a new CData object.
-  if (!ConvertToJS(cx, GetCType(cx, obj), NULL, GetData(cx, obj), true, false, vp))
+  if (!ConvertToJS(cx, GetCType(obj), NULL, GetData(obj), true, false, vp))
     return JS_FALSE;
 
   return JS_TRUE;
 }
 
 JSBool
 CData::ValueSetter(JSContext* cx, JSObject* obj, jsid idval, JSBool strict, jsval* vp)
 {
   if (!IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
-  return ImplicitConvert(cx, *vp, GetCType(cx, obj), GetData(cx, obj), false, NULL);
+  return ImplicitConvert(cx, *vp, GetCType(obj), GetData(obj), false, NULL);
 }
 
 JSBool
 CData::Address(JSContext* cx, uintN argc, jsval* vp)
 {
   if (argc != 0) {
     JS_ReportError(cx, "address takes zero arguments");
     return JS_FALSE;
   }
 
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj || !IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
-  JSObject* typeObj = CData::GetCType(cx, obj);
+  JSObject* typeObj = CData::GetCType(obj);
   JSObject* pointerType = PointerType::CreateInternal(cx, typeObj);
   if (!pointerType)
     return JS_FALSE;
   js::AutoObjectRooter root(cx, pointerType);
 
   // Create a PointerType CData object containing null.
   JSObject* result = CData::Create(cx, pointerType, NULL, NULL, true);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
 
   // Manually set the pointer inside the object, so we skip the conversion step.
-  void** data = static_cast<void**>(GetData(cx, result));
-  *data = GetData(cx, obj);
+  void** data = static_cast<void**>(GetData(result));
+  *data = GetData(obj);
   return JS_TRUE;
 }
 
 JSBool
 CData::Cast(JSContext* cx, uintN argc, jsval* vp)
 {
   if (argc != 2) {
     JS_ReportError(cx, "cast takes two arguments");
@@ -5836,36 +5766,36 @@ CData::Cast(JSContext* cx, uintN argc, j
 
   jsval* argv = JS_ARGV(cx, vp);
   if (JSVAL_IS_PRIMITIVE(argv[0]) ||
       !CData::IsCData(JSVAL_TO_OBJECT(argv[0]))) {
     JS_ReportError(cx, "first argument must be a CData");
     return JS_FALSE;
   }
   JSObject* sourceData = JSVAL_TO_OBJECT(argv[0]);
-  JSObject* sourceType = CData::GetCType(cx, sourceData);
+  JSObject* sourceType = CData::GetCType(sourceData);
 
   if (JSVAL_IS_PRIMITIVE(argv[1]) ||
       !CType::IsCType(JSVAL_TO_OBJECT(argv[1]))) {
     JS_ReportError(cx, "second argument must be a CType");
     return JS_FALSE;
   }
 
   JSObject* targetType = JSVAL_TO_OBJECT(argv[1]);
   size_t targetSize;
-  if (!CType::GetSafeSize(cx, targetType, &targetSize) ||
-      targetSize > CType::GetSize(cx, sourceType)) {
+  if (!CType::GetSafeSize(targetType, &targetSize) ||
+      targetSize > CType::GetSize(sourceType)) {
     JS_ReportError(cx,
       "target CType has undefined or larger size than source CType");
     return JS_FALSE;
   }
 
   // Construct a new CData object with a type of 'targetType' and a referent
   // of 'sourceData'.
-  void* data = CData::GetData(cx, sourceData);
+  void* data = CData::GetData(sourceData);
   JSObject* result = CData::Create(cx, targetType, sourceData, data, false);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
   return JS_TRUE;
 }
 
@@ -5881,17 +5811,17 @@ CData::GetRuntime(JSContext* cx, uintN a
   if (JSVAL_IS_PRIMITIVE(argv[0]) ||
       !CType::IsCType(JSVAL_TO_OBJECT(argv[0]))) {
     JS_ReportError(cx, "first argument must be a CType");
     return JS_FALSE;
   }
 
   JSObject* targetType = JSVAL_TO_OBJECT(argv[0]);
   size_t targetSize;
-  if (!CType::GetSafeSize(cx, targetType, &targetSize) ||
+  if (!CType::GetSafeSize(targetType, &targetSize) ||
       targetSize != sizeof(void*)) {
     JS_ReportError(cx, "target CType has non-pointer size");
     return JS_FALSE;
   }
 
   void* data = static_cast<void*>(cx->runtime);
   JSObject* result = CData::Create(cx, targetType, NULL, &data, true);
   if (!result)
@@ -5913,43 +5843,43 @@ CData::ReadString(JSContext* cx, uintN a
   if (!obj || !IsCData(obj)) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   // Make sure we are a pointer to, or an array of, an 8-bit or 16-bit
   // character or integer type.
   JSObject* baseType;
-  JSObject* typeObj = GetCType(cx, obj);
-  TypeCode typeCode = CType::GetTypeCode(cx, typeObj);
+  JSObject* typeObj = GetCType(obj);
+  TypeCode typeCode = CType::GetTypeCode(typeObj);
   void* data;
   size_t maxLength = -1;
   switch (typeCode) {
   case TYPE_pointer:
-    baseType = PointerType::GetBaseType(cx, typeObj);
-    data = *static_cast<void**>(GetData(cx, obj));
+    baseType = PointerType::GetBaseType(typeObj);
+    data = *static_cast<void**>(GetData(obj));
     if (data == NULL) {
       JS_ReportError(cx, "cannot read contents of null pointer");
       return JS_FALSE;
     }
     break;
   case TYPE_array:
-    baseType = ArrayType::GetBaseType(cx, typeObj);
-    data = GetData(cx, obj);
-    maxLength = ArrayType::GetLength(cx, typeObj);
+    baseType = ArrayType::GetBaseType(typeObj);
+    data = GetData(obj);
+    maxLength = ArrayType::GetLength(typeObj);
     break;
   default:
     JS_ReportError(cx, "not a PointerType or ArrayType");
     return JS_FALSE;
   }
 
   // Convert the string buffer, taking care to determine the correct string
   // length in the case of arrays (which may contain embedded nulls).
   JSString* result;
-  switch (CType::GetTypeCode(cx, baseType)) {
+  switch (CType::GetTypeCode(baseType)) {
   case TYPE_int8_t:
   case TYPE_uint8_t:
   case TYPE_char:
   case TYPE_signed_char:
   case TYPE_unsigned_char: {
     char* bytes = static_cast<char*>(data);
     size_t length = strnlen(bytes, maxLength);
 
@@ -6004,18 +5934,18 @@ CData::ToSource(JSContext* cx, uintN arg
   if (!obj ||
       !(CData::IsCData(obj) || CData::IsCDataProto(obj))) {
     JS_ReportError(cx, "not a CData");
     return JS_FALSE;
   }
 
   JSString* result;
   if (CData::IsCData(obj)) {
-    JSObject* typeObj = CData::GetCType(cx, obj);
-    void* data = CData::GetData(cx, obj);
+    JSObject* typeObj = CData::GetCType(obj);
+    void* data = CData::GetData(obj);
 
     // Walk the types, building up the toSource() string.
     // First, we build up the type expression:
     // 't.ptr' for pointers;
     // 't.array([n])' for arrays;
     // 'n' for structs, where n = t.name, the struct's name. (We assume this is
     // bound to a variable in the current scope.)
     AutoString source;
@@ -6043,55 +5973,51 @@ CData::ToSource(JSContext* cx, uintN arg
 
 JSObject*
 Int64Base::Construct(JSContext* cx,
                      JSObject* proto,
                      uint64_t data,
                      bool isUnsigned)
 {
   JSClass* clasp = isUnsigned ? &sUInt64Class : &sInt64Class;
-  JSObject* result = JS_NewObject(cx, clasp, proto, JS_GetParent(cx, proto));
+  JSObject* result = JS_NewObject(cx, clasp, proto, JS_GetParent(proto));
   if (!result)
     return NULL;
   js::AutoObjectRooter root(cx, result);
 
   // attach the Int64's data
   uint64_t* buffer = cx->new_<uint64_t>(data);
   if (!buffer) {
     JS_ReportOutOfMemory(cx);
     return NULL;
   }
 
-  if (!JS_SetReservedSlot(cx, result, SLOT_INT64, PRIVATE_TO_JSVAL(buffer))) {
-    Foreground::delete_(buffer);
-    return NULL;
-  }
+  JS_SetReservedSlot(result, SLOT_INT64, PRIVATE_TO_JSVAL(buffer));
 
   if (!JS_FreezeObject(cx, result))
     return NULL;
 
   return result;
 }
 
 void
 Int64Base::Finalize(JSContext* cx, JSObject* obj)
 {
-  jsval slot;
-  if (!JS_GetReservedSlot(cx, obj, SLOT_INT64, &slot) || JSVAL_IS_VOID(slot))
+  jsval slot = JS_GetReservedSlot(obj, SLOT_INT64);
+  if (JSVAL_IS_VOID(slot))
     return;
 
   cx->delete_(static_cast<uint64_t*>(JSVAL_TO_PRIVATE(slot)));
 }
 
 uint64_t
-Int64Base::GetInt(JSContext* cx, JSObject* obj) {
+Int64Base::GetInt(JSObject* obj) {
   JS_ASSERT(Int64::IsInt64(obj) || UInt64::IsUInt64(obj));
 
-  jsval slot;
-  ASSERT_OK(JS_GetReservedSlot(cx, obj, SLOT_INT64, &slot));
+  jsval slot = JS_GetReservedSlot(obj, SLOT_INT64);
   return *static_cast<uint64_t*>(JSVAL_TO_PRIVATE(slot));
 }
 
 JSBool
 Int64Base::ToString(JSContext* cx,
                     JSObject* obj,
                     uintN argc,
                     jsval* vp,
@@ -6110,19 +6036,19 @@ Int64Base::ToString(JSContext* cx,
     if (!JSVAL_IS_INT(arg) || radix < 2 || radix > 36) {
       JS_ReportError(cx, "radix argument must be an integer between 2 and 36");
       return JS_FALSE;
     }
   }
 
   AutoString intString;
   if (isUnsigned) {
-    IntegerToString(GetInt(cx, obj), radix, intString);
+    IntegerToString(GetInt(obj), radix, intString);
   } else {
-    IntegerToString(static_cast<int64_t>(GetInt(cx, obj)), radix, intString);
+    IntegerToString(static_cast<int64_t>(GetInt(obj)), radix, intString);
   }
 
   JSString *result = NewUCString(cx, intString);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(result));
   return JS_TRUE;
@@ -6139,20 +6065,20 @@ Int64Base::ToSource(JSContext* cx,
     JS_ReportError(cx, "toSource takes zero arguments");
     return JS_FALSE;
   }
 
   // Return a decimal string suitable for constructing the number.
   AutoString source;
   if (isUnsigned) {
     AppendString(source, "ctypes.UInt64(\"");
-    IntegerToString(GetInt(cx, obj), 10, source);
+    IntegerToString(GetInt(obj), 10, source);
   } else {
     AppendString(source, "ctypes.Int64(\"");
-    IntegerToString(static_cast<int64_t>(GetInt(cx, obj)), 10, source);
+    IntegerToString(static_cast<int64_t>(GetInt(obj)), 10, source);
   }
   AppendString(source, "\")");
 
   JSString *result = NewUCString(cx, source);
   if (!result)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(result));
@@ -6231,18 +6157,18 @@ Int64::Compare(JSContext* cx, uintN argc
       !Int64::IsInt64(JSVAL_TO_OBJECT(argv[1]))) {
     JS_ReportError(cx, "compare takes two Int64 arguments");
     return JS_FALSE;
   }
 
   JSObject* obj1 = JSVAL_TO_OBJECT(argv[0]);
   JSObject* obj2 = JSVAL_TO_OBJECT(argv[1]);
 
-  int64_t i1 = Int64Base::GetInt(cx, obj1);
-  int64_t i2 = Int64Base::GetInt(cx, obj2);
+  int64_t i1 = Int64Base::GetInt(obj1);
+  int64_t i2 = Int64Base::GetInt(obj2);
 
   if (i1 == i2)
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(0));
   else if (i1 < i2)
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(-1));
   else
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(1));
 
@@ -6259,17 +6185,17 @@ Int64::Lo(JSContext* cx, uintN argc, jsv
   jsval* argv = JS_ARGV(cx, vp);
   if (argc != 1 || JSVAL_IS_PRIMITIVE(argv[0]) ||
       !Int64::IsInt64(JSVAL_TO_OBJECT(argv[0]))) {
     JS_ReportError(cx, "lo takes one Int64 argument");
     return JS_FALSE;
   }
 
   JSObject* obj = JSVAL_TO_OBJECT(argv[0]);
-  int64_t u = Int64Base::GetInt(cx, obj);
+  int64_t u = Int64Base::GetInt(obj);
   jsdouble d = uint32_t(INT64_LO(u));
 
   jsval result;
   if (!JS_NewNumberValue(cx, d, &result))
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, result);
   return JS_TRUE;
@@ -6281,17 +6207,17 @@ Int64::Hi(JSContext* cx, uintN argc, jsv
   jsval* argv = JS_ARGV(cx, vp);
   if (argc != 1 || JSVAL_IS_PRIMITIVE(argv[0]) ||
       !Int64::IsInt64(JSVAL_TO_OBJECT(argv[0]))) {
     JS_ReportError(cx, "hi takes one Int64 argument");
     return JS_FALSE;
   }
 
   JSObject* obj = JSVAL_TO_OBJECT(argv[0]);
-  int64_t u = Int64Base::GetInt(cx, obj);
+  int64_t u = Int64Base::GetInt(obj);
   jsdouble d = int32_t(INT64_HI(u));
 
   jsval result;
   if (!JS_NewNumberValue(cx, d, &result))
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, result);
   return JS_TRUE;
@@ -6402,18 +6328,18 @@ UInt64::Compare(JSContext* cx, uintN arg
       !UInt64::IsUInt64(JSVAL_TO_OBJECT(argv[1]))) {
     JS_ReportError(cx, "compare takes two UInt64 arguments");
     return JS_FALSE;
   }
 
   JSObject* obj1 = JSVAL_TO_OBJECT(argv[0]);
   JSObject* obj2 = JSVAL_TO_OBJECT(argv[1]);
 
-  uint64_t u1 = Int64Base::GetInt(cx, obj1);
-  uint64_t u2 = Int64Base::GetInt(cx, obj2);
+  uint64_t u1 = Int64Base::GetInt(obj1);
+  uint64_t u2 = Int64Base::GetInt(obj2);
 
   if (u1 == u2)
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(0));
   else if (u1 < u2)
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(-1));
   else
     JS_SET_RVAL(cx, vp, INT_TO_JSVAL(1));
 
@@ -6426,17 +6352,17 @@ UInt64::Lo(JSContext* cx, uintN argc, js
   jsval* argv = JS_ARGV(cx, vp);
   if (argc != 1 || JSVAL_IS_PRIMITIVE(argv[0]) ||
       !UInt64::IsUInt64(JSVAL_TO_OBJECT(argv[0]))) {
     JS_ReportError(cx, "lo takes one UInt64 argument");
     return JS_FALSE;
   }
 
   JSObject* obj = JSVAL_TO_OBJECT(argv[0]);
-  uint64_t u = Int64Base::GetInt(cx, obj);
+  uint64_t u = Int64Base::GetInt(obj);
   jsdouble d = uint32_t(INT64_LO(u));
 
   jsval result;
   if (!JS_NewNumberValue(cx, d, &result))
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, result);
   return JS_TRUE;
@@ -6448,17 +6374,17 @@ UInt64::Hi(JSContext* cx, uintN argc, js
   jsval* argv = JS_ARGV(cx, vp);
   if (argc != 1 || JSVAL_IS_PRIMITIVE(argv[0]) ||
       !UInt64::IsUInt64(JSVAL_TO_OBJECT(argv[0]))) {
     JS_ReportError(cx, "hi takes one UInt64 argument");
     return JS_FALSE;
   }
 
   JSObject* obj = JSVAL_TO_OBJECT(argv[0]);
-  uint64_t u = Int64Base::GetInt(cx, obj);
+  uint64_t u = Int64Base::GetInt(obj);
   jsdouble d = uint32_t(INT64_HI(u));
 
   jsval result;
   if (!JS_NewNumberValue(cx, d, &result))
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, result);
   return JS_TRUE;
--- a/js/src/ctypes/CTypes.h
+++ b/js/src/ctypes/CTypes.h
@@ -345,17 +345,17 @@ struct ClosureInfo
       ffi_closure_free(closure);
     if (errResult)
       rt->free_(errResult);
   };
 };
 
 bool IsCTypesGlobal(JSObject* obj);
 
-JSCTypesCallbacks* GetCallbacks(JSContext* cx, JSObject* obj);
+JSCTypesCallbacks* GetCallbacks(JSObject* obj);
 
 JSBool InitTypeClasses(JSContext* cx, JSObject* parent);
 
 JSBool ConvertToJS(JSContext* cx, JSObject* typeObj, JSObject* dataObj,
   void* data, bool wantPrimitive, bool ownResult, jsval* result);
 
 JSBool ImplicitConvert(JSContext* cx, jsval val, JSObject* targetType,
   void* buffer, bool isArgument, bool* freePointer);
@@ -451,78 +451,77 @@ namespace CType {
     TypeCode type, JSString* name, jsval size, jsval align, ffi_type* ffiType);
 
   JSObject* DefineBuiltin(JSContext* cx, JSObject* parent, const char* propName,
     JSObject* typeProto, JSObject* dataProto, const char* name, TypeCode type,
     jsval size, jsval align, ffi_type* ffiType);
 
   bool IsCType(JSObject* obj);
   bool IsCTypeProto(JSObject* obj);
-  TypeCode GetTypeCode(JSContext* cx, JSObject* typeObj);
-  bool TypesEqual(JSContext* cx, JSObject* t1, JSObject* t2);
-  size_t GetSize(JSContext* cx, JSObject* obj);
-  bool GetSafeSize(JSContext* cx, JSObject* obj, size_t* result);
-  bool IsSizeDefined(JSContext* cx, JSObject* obj);
-  size_t GetAlignment(JSContext* cx, JSObject* obj);
+  TypeCode GetTypeCode(JSObject* typeObj);
+  bool TypesEqual(JSObject* t1, JSObject* t2);
+  size_t GetSize(JSObject* obj);
+  bool GetSafeSize(JSObject* obj, size_t* result);
+  bool IsSizeDefined(JSObject* obj);
+  size_t GetAlignment(JSObject* obj);
   ffi_type* GetFFIType(JSContext* cx, JSObject* obj);
   JSString* GetName(JSContext* cx, JSObject* obj);
-  JSObject* GetProtoFromCtor(JSContext* cx, JSObject* obj, CTypeProtoSlot slot);
-  JSObject* GetProtoFromType(JSContext* cx, JSObject* obj, CTypeProtoSlot slot);
-  JSCTypesCallbacks* GetCallbacksFromType(JSContext* cx, JSObject* obj);
+  JSObject* GetProtoFromCtor(JSObject* obj, CTypeProtoSlot slot);
+  JSObject* GetProtoFromType(JSObject* obj, CTypeProtoSlot slot);
+  JSCTypesCallbacks* GetCallbacksFromType(JSObject* obj);
 }
 
 namespace PointerType {
   JSObject* CreateInternal(JSContext* cx, JSObject* baseType);
 
-  JSObject* GetBaseType(JSContext* cx, JSObject* obj);
+  JSObject* GetBaseType(JSObject* obj);
 }
 
 namespace ArrayType {
   JSObject* CreateInternal(JSContext* cx, JSObject* baseType, size_t length,
     bool lengthDefined);
 
-  JSObject* GetBaseType(JSContext* cx, JSObject* obj);
-  size_t GetLength(JSContext* cx, JSObject* obj);
-  bool GetSafeLength(JSContext* cx, JSObject* obj, size_t* result);
+  JSObject* GetBaseType(JSObject* obj);
+  size_t GetLength(JSObject* obj);
+  bool GetSafeLength(JSObject* obj, size_t* result);
   ffi_type* BuildFFIType(JSContext* cx, JSObject* obj);
 }
 
 namespace StructType {
   JSBool DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj);
 
-  const FieldInfoHash* GetFieldInfo(JSContext* cx, JSObject* obj);
+  const FieldInfoHash* GetFieldInfo(JSObject* obj);
   const FieldInfo* LookupField(JSContext* cx, JSObject* obj, JSFlatString *name);
   JSObject* BuildFieldsArray(JSContext* cx, JSObject* obj);
   ffi_type* BuildFFIType(JSContext* cx, JSObject* obj);
 }
 
 namespace FunctionType {
   JSObject* CreateInternal(JSContext* cx, jsval abi, jsval rtype,
     jsval* argtypes, jsuint arglen);
 
   JSObject* ConstructWithObject(JSContext* cx, JSObject* typeObj,
     JSObject* refObj, PRFuncPtr fnptr, JSObject* result);
 
-  FunctionInfo* GetFunctionInfo(JSContext* cx, JSObject* obj);
-  JSObject* GetLibrary(JSContext* cx, JSObject* obj);
-  void BuildSymbolName(JSContext* cx, JSString* name, JSObject* typeObj,
+  FunctionInfo* GetFunctionInfo(JSObject* obj);
+  void BuildSymbolName(JSString* name, JSObject* typeObj,
     AutoCString& result);
 }
 
 namespace CClosure {
   JSObject* Create(JSContext* cx, JSObject* typeObj, JSObject* fnObj,
     JSObject* thisObj, jsval errVal, PRFuncPtr* fnptr);
 }
 
 namespace CData {
   JSObject* Create(JSContext* cx, JSObject* typeObj, JSObject* refObj,
     void* data, bool ownResult);
 
-  JSObject* GetCType(JSContext* cx, JSObject* dataObj);
-  void* GetData(JSContext* cx, JSObject* dataObj);
+  JSObject* GetCType(JSObject* dataObj);
+  void* GetData(JSObject* dataObj);
   bool IsCData(JSObject* obj);
   bool IsCDataProto(JSObject* obj);
 
   // Attached by JSAPI as the function 'ctypes.cast'
   JSBool Cast(JSContext* cx, uintN argc, jsval* vp);
   // Attached by JSAPI as the function 'ctypes.getRuntime'
   JSBool GetRuntime(JSContext* cx, uintN argc, jsval* vp);
 }
--- a/js/src/ctypes/Library.cpp
+++ b/js/src/ctypes/Library.cpp
@@ -116,18 +116,17 @@ JSObject*
 Library::Create(JSContext* cx, jsval path, JSCTypesCallbacks* callbacks)
 {
   JSObject* libraryObj = JS_NewObject(cx, &sLibraryClass, NULL, NULL);
   if (!libraryObj)
     return NULL;
   js::AutoObjectRooter root(cx, libraryObj);
 
   // initialize the library
-  if (!JS_SetReservedSlot(cx, libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL)))
-    return NULL;
+  JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL));
 
   // attach API functions
   if (!JS_DefineFunctions(cx, libraryObj, sLibraryFunctions))
     return NULL;
 
   if (!JSVAL_IS_STRING(path)) {
     JS_ReportError(cx, "open takes a string argument");
     return NULL;
@@ -182,44 +181,41 @@ Library::Create(JSContext* cx, jsval pat
   JS_free(cx, pathBytes);
 #endif
   if (!library) {
     JS_ReportError(cx, "couldn't open library");
     return NULL;
   }
 
   // stash the library
-  if (!JS_SetReservedSlot(cx, libraryObj, SLOT_LIBRARY,
-         PRIVATE_TO_JSVAL(library)))
-    return NULL;
+  JS_SetReservedSlot(libraryObj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(library));
 
   return libraryObj;
 }
 
 bool
 Library::IsLibrary(JSObject* obj)
 {
   return JS_GetClass(obj) == &sLibraryClass;
 }
 
 PRLibrary*
-Library::GetLibrary(JSContext* cx, JSObject* obj)
+Library::GetLibrary(JSObject* obj)
 {
   JS_ASSERT(IsLibrary(obj));
 
-  jsval slot;
-  JS_GetReservedSlot(cx, obj, SLOT_LIBRARY, &slot);
+  jsval slot = JS_GetReservedSlot(obj, SLOT_LIBRARY);
   return static_cast<PRLibrary*>(JSVAL_TO_PRIVATE(slot));
 }
 
 void
 Library::Finalize(JSContext* cx, JSObject* obj)
 {
   // unload the library
-  PRLibrary* library = GetLibrary(cx, obj);
+  PRLibrary* library = GetLibrary(obj);
   if (library)
     PR_UnloadLibrary(library);
 }
 
 JSBool
 Library::Open(JSContext* cx, uintN argc, jsval *vp)
 {
   JSObject* ctypesObj = JS_THIS_OBJECT(cx, vp);
@@ -228,17 +224,17 @@ Library::Open(JSContext* cx, uintN argc,
     return JS_FALSE;
   }
 
   if (argc != 1 || JSVAL_IS_VOID(JS_ARGV(cx, vp)[0])) {
     JS_ReportError(cx, "open requires a single argument");
     return JS_FALSE;
   }
 
-  JSObject* library = Create(cx, JS_ARGV(cx, vp)[0], GetCallbacks(cx, ctypesObj));
+  JSObject* library = Create(cx, JS_ARGV(cx, vp)[0], GetCallbacks(ctypesObj));
   if (!library)
     return JS_FALSE;
 
   JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(library));
   return JS_TRUE;
 }
 
 JSBool
@@ -252,32 +248,32 @@ Library::Close(JSContext* cx, uintN argc
 
   if (argc != 0) {
     JS_ReportError(cx, "close doesn't take any arguments");
     return JS_FALSE;
   }
 
   // delete our internal objects
   Finalize(cx, obj);
-  JS_SetReservedSlot(cx, obj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL));
+  JS_SetReservedSlot(obj, SLOT_LIBRARY, PRIVATE_TO_JSVAL(NULL));
 
   JS_SET_RVAL(cx, vp, JSVAL_VOID);
   return JS_TRUE;
 }
 
 JSBool
 Library::Declare(JSContext* cx, uintN argc, jsval* vp)
 {
   JSObject* obj = JS_THIS_OBJECT(cx, vp);
   if (!obj || !IsLibrary(obj)) {
     JS_ReportError(cx, "not a library");
     return JS_FALSE;
   }
 
-  PRLibrary* library = GetLibrary(cx, obj);
+  PRLibrary* library = GetLibrary(obj);
   if (!library) {
     JS_ReportError(cx, "library not open");
     return JS_FALSE;
   }
 
   // We allow two API variants:
   // 1) library.declare(name, abi, returnType, argType1, ...)
   //    declares a function with the given properties, and resolves the symbol
@@ -317,35 +313,35 @@ Library::Declare(JSContext* cx, uintN ar
     if (!typeObj)
       return JS_FALSE;
     root.setObject(typeObj);
 
   } else {
     // Case 2).
     if (JSVAL_IS_PRIMITIVE(argv[1]) ||
         !CType::IsCType(JSVAL_TO_OBJECT(argv[1])) ||
-        !CType::IsSizeDefined(cx, JSVAL_TO_OBJECT(argv[1]))) {
+        !CType::IsSizeDefined(JSVAL_TO_OBJECT(argv[1]))) {
       JS_ReportError(cx, "second argument must be a type of defined size");
       return JS_FALSE;
     }
 
     typeObj = JSVAL_TO_OBJECT(argv[1]);
-    if (CType::GetTypeCode(cx, typeObj) == TYPE_pointer) {
-      fnObj = PointerType::GetBaseType(cx, typeObj);
-      isFunction = fnObj && CType::GetTypeCode(cx, fnObj) == TYPE_function;
+    if (CType::GetTypeCode(typeObj) == TYPE_pointer) {
+      fnObj = PointerType::GetBaseType(typeObj);
+      isFunction = fnObj && CType::GetTypeCode(fnObj) == TYPE_function;
     }
   }
 
   void* data;
   PRFuncPtr fnptr;
   JSString* nameStr = JSVAL_TO_STRING(argv[0]);
   AutoCString symbol;
   if (isFunction) {
     // Build the symbol, with mangling if necessary.
-    FunctionType::BuildSymbolName(cx, nameStr, fnObj, symbol);
+    FunctionType::BuildSymbolName(nameStr, fnObj, symbol);
     AppendString(symbol, "\0");
 
     // Look up the function symbol.
     fnptr = PR_FindFunctionSymbol(library, symbol.begin());
     if (!fnptr) {
       JS_ReportError(cx, "couldn't find function symbol in library");
       return JS_FALSE;
     }
--- a/js/src/ctypes/Library.h
+++ b/js/src/ctypes/Library.h
@@ -54,17 +54,17 @@ enum LibrarySlot {
 
 namespace Library
 {
   JSBool Name(JSContext* cx, uintN argc, jsval *vp);
 
   JSObject* Create(JSContext* cx, jsval path, JSCTypesCallbacks* callbacks);
 
   bool IsLibrary(JSObject* obj);
-  PRLibrary* GetLibrary(JSContext* cx, JSObject* obj);
+  PRLibrary* GetLibrary(JSObject* obj);
 
   JSBool Open(JSContext* cx, uintN argc, jsval* vp);
 }
 
 }
 }
 
 #endif
--- a/js/src/jsapi-tests/selfTest.cpp
+++ b/js/src/jsapi-tests/selfTest.cpp
@@ -13,12 +13,12 @@ BEGIN_TEST(selfTest_NaNsAreSame)
     EVAL("Math.sin('no')", v2.addr());  // also NaN
     CHECK_SAME(v1, v2);
     return true;
 }
 END_TEST(selfTest_NaNsAreSame)
 
 BEGIN_TEST(selfTest_globalHasNoParent)
 {
-    CHECK(JS_GetParent(cx, global) == NULL);
+    CHECK(JS_GetParent(global) == NULL);
     return true;
 }
 END_TEST(selfTest_globalHasNoParent)
--- a/js/src/jsapi-tests/testResolveRecursion.cpp
+++ b/js/src/jsapi-tests/testResolveRecursion.cpp
@@ -25,18 +25,18 @@ BEGIN_TEST(testResolveRecursion)
         JS_FinalizeStub,
         JSCLASS_NO_OPTIONAL_MEMBERS
     };
     
     obj1 = JS_NewObject(cx, &my_resolve_class, NULL, NULL);
     CHECK(obj1);
     obj2 = JS_NewObject(cx, &my_resolve_class, NULL, NULL);
     CHECK(obj2);
-    CHECK(JS_SetPrivate(cx, obj1, this));
-    CHECK(JS_SetPrivate(cx, obj2, this));
+    JS_SetPrivate(obj1, this);
+    JS_SetPrivate(obj2, this);
 
     CHECK(JS_DefineProperty(cx, global, "obj1", OBJECT_TO_JSVAL(obj1), NULL, NULL, 0));
     CHECK(JS_DefineProperty(cx, global, "obj2", OBJECT_TO_JSVAL(obj2), NULL, NULL, 0));
 
     resolveEntryCount = 0;
     resolveExitCount = 0;
 
     /* Start the essence of the test via invoking the first resolve hook. */
@@ -122,13 +122,13 @@ doResolve(JSObject *obj, jsid id, uintN 
     }
     CHECK(false);
     return false;
 }
 
 static JSBool
 my_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
 {
-    return static_cast<cls_testResolveRecursion *>(JS_GetPrivate(cx, obj))->
+    return static_cast<cls_testResolveRecursion *>(JS_GetPrivate(obj))->
            doResolve(obj, id, flags, objp);
 }
 
 END_TEST(testResolveRecursion)
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3151,60 +3151,56 @@ JS_PUBLIC_API(JSBool)
 JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
 {
     AssertNoGC(cx);
     assertSameCompartment(cx, obj, v);
     return HasInstance(cx, obj, &v, bp);
 }
 
 JS_PUBLIC_API(void *)
-JS_GetPrivate(JSContext *cx, JSObject *obj)
+JS_GetPrivate(JSObject *obj)
 {
     /* This function can be called by a finalizer. */
     return obj->getPrivate();
 }
 
-JS_PUBLIC_API(JSBool)
-JS_SetPrivate(JSContext *cx, JSObject *obj, void *data)
+JS_PUBLIC_API(void)
+JS_SetPrivate(JSObject *obj, void *data)
 {
     /* This function can be called by a finalizer. */
     obj->setPrivate(data);
-    return true;
 }
 
 JS_PUBLIC_API(void *)
 JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv)
 {
     if (!JS_InstanceOf(cx, obj, clasp, argv))
         return NULL;
     return obj->getPrivate();
 }
 
 JS_PUBLIC_API(JSObject *)
-JS_GetPrototype(JSContext *cx, JSObject *obj)
-{
-    CHECK_REQUEST(cx);
-    assertSameCompartment(cx, obj);
+JS_GetPrototype(JSObject *obj)
+{
     return obj->getProto();
 }
 
 JS_PUBLIC_API(JSBool)
 JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto)
 {
     AssertNoGC(cx);
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, proto);
     return SetProto(cx, obj, proto, JS_FALSE);
 }
 
 JS_PUBLIC_API(JSObject *)
-JS_GetParent(JSContext *cx, JSObject *obj)
+JS_GetParent(JSObject *obj)
 {
     JS_ASSERT(!obj->isScope());
-    assertSameCompartment(cx, obj);
     return obj->getParent();
 }
 
 JS_PUBLIC_API(JSBool)
 JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent)
 {
     AssertNoGC(cx);
     CHECK_REQUEST(cx);
@@ -4400,32 +4396,33 @@ JS_NewElementIterator(JSContext *cx, JSO
 
 JS_PUBLIC_API(JSObject *)
 JS_ElementIteratorStub(JSContext *cx, JSObject *obj, JSBool keysonly)
 {
     JS_ASSERT(!keysonly);
     return JS_NewElementIterator(cx, obj);
 }
 
-JS_PUBLIC_API(JSBool)
-JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp)
-{
-    /* This function can be called by a finalizer. */
-    CHECK_REQUEST(cx);
-    assertSameCompartment(cx, obj);
-    return js_GetReservedSlot(cx, obj, index, vp);
-}
-
-JS_PUBLIC_API(JSBool)
-JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval v)
-{
-    AssertNoGC(cx);
-    CHECK_REQUEST(cx);
-    assertSameCompartment(cx, obj, v);
-    return js_SetReservedSlot(cx, obj, index, v);
+JS_PUBLIC_API(jsval)
+JS_GetReservedSlot(JSObject *obj, uint32_t index)
+{
+    if (!obj->isNative())
+        return UndefinedValue();
+
+    return GetReservedSlot(obj, index);
+}
+
+JS_PUBLIC_API(void)
+JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v)
+{
+    if (!obj->isNative())
+        return;
+
+    SetReservedSlot(obj, index, v);
+    GCPoke(obj->compartment()->rt, NullValue());
 }
 
 JS_PUBLIC_API(JSObject *)
 JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector)
 {
     JS_THREADSAFE_ASSERT(cx->compartment != cx->runtime->atomsCompartment);
     AssertNoGC(cx);
     CHECK_REQUEST(cx);
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -2768,18 +2768,18 @@ struct JSCTypesCallbacks {
 typedef struct JSCTypesCallbacks JSCTypesCallbacks;
 
 /*
  * Set the callbacks on the provided 'ctypesObj' object. 'callbacks' should be a
  * pointer to static data that exists for the lifetime of 'ctypesObj', but it
  * may safely be altered after calling this function and without having
  * to call this function again.
  */
-extern JS_PUBLIC_API(JSBool)
-JS_SetCTypesCallbacks(JSContext *cx, JSObject *ctypesObj, JSCTypesCallbacks *callbacks);
+extern JS_PUBLIC_API(void)
+JS_SetCTypesCallbacks(JSObject *ctypesObj, JSCTypesCallbacks *callbacks);
 #endif
 
 typedef JSBool
 (* JSEnumerateDiagnosticMemoryCallback)(void *ptr, size_t length);
 
 /*
  * Enumerate memory regions that contain diagnostic information
  * intended to be included in crash report minidumps.
@@ -3615,33 +3615,33 @@ JS_GetClass(JSObject *obj);
 
 extern JS_PUBLIC_API(JSBool)
 JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv);
 
 extern JS_PUBLIC_API(JSBool)
 JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
 
 extern JS_PUBLIC_API(void *)
-JS_GetPrivate(JSContext *cx, JSObject *obj);
-
-extern JS_PUBLIC_API(JSBool)
-JS_SetPrivate(JSContext *cx, JSObject *obj, void *data);
+JS_GetPrivate(JSObject *obj);
+
+extern JS_PUBLIC_API(void)
+JS_SetPrivate(JSObject *obj, void *data);
 
 extern JS_PUBLIC_API(void *)
 JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp,
                       jsval *argv);
 
 extern JS_PUBLIC_API(JSObject *)
-JS_GetPrototype(JSContext *cx, JSObject *obj);
+JS_GetPrototype(JSObject *obj);
 
 extern JS_PUBLIC_API(JSBool)
 JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto);
 
 extern JS_PUBLIC_API(JSObject *)
-JS_GetParent(JSContext *cx, JSObject *obj);
+JS_GetParent(JSObject *obj);
 
 extern JS_PUBLIC_API(JSBool)
 JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent);
 
 extern JS_PUBLIC_API(JSObject *)
 JS_GetConstructor(JSContext *cx, JSObject *proto);
 
 /*
@@ -4020,21 +4020,21 @@ JS_NewElementIterator(JSContext *cx, JSO
  */
 extern JS_PUBLIC_API(JSObject *)
 JS_ElementIteratorStub(JSContext *cx, JSObject *obj, JSBool keysonly);
 
 extern JS_PUBLIC_API(JSBool)
 JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
                jsval *vp, uintN *attrsp);
 
-extern JS_PUBLIC_API(JSBool)
-JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp);
-
-extern JS_PUBLIC_API(JSBool)
-JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, jsval v);
+extern JS_PUBLIC_API(jsval)
+JS_GetReservedSlot(JSObject *obj, uint32_t index);
+
+extern JS_PUBLIC_API(void)
+JS_SetReservedSlot(JSObject *obj, uint32_t index, jsval v);
 
 /************************************************************************/
 
 /*
  * Security protocol.
  */
 struct JSPrincipals {
     char *codebase;
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -190,33 +190,33 @@ GetGCKindSlots(AllocKind thingKind, Clas
      */
     if (clasp == &FunctionClass)
         nslots = 0;
 
     return nslots;
 }
 
 static inline void
-GCPoke(JSContext *cx, Value oldval)
+GCPoke(JSRuntime *rt, Value oldval)
 {
     /*
      * Since we're forcing a GC from JS_GC anyway, don't bother wasting cycles
      * loading oldval.  XXX remove implied force, fix jsinterp.c's "second arg
      * ignored", etc.
      */
 #if 1
-    cx->runtime->gcPoke = JS_TRUE;
+    rt->gcPoke = true;
 #else
-    cx->runtime->gcPoke = oldval.isGCThing();
+    rt->gcPoke = oldval.isGCThing();
 #endif
 
 #ifdef JS_GC_ZEAL
     /* Schedule a GC to happen "soon" after a GC poke. */
-    if (cx->runtime->gcZeal() >= js::gc::ZealPokeThreshold)
-        cx->runtime->gcNextScheduled = 1;
+    if (rt->gcZeal() >= js::gc::ZealPokeThreshold)
+        rt->gcNextScheduled = 1;
 #endif
 }
 
 /*
  * Invoke ArenaOp and CellOp on every arena and cell in a compartment which
  * have the specified thing kind.
  */
 template <class ArenaOp, class CellOp>
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3590,42 +3590,41 @@ DefineStandardSlot(JSContext *cx, JSObje
          * reserved slot. Otherwise, go through the normal property path.
          */
         JS_ASSERT(obj->isGlobal());
         JS_ASSERT(obj->isNative());
 
         const Shape *shape = obj->nativeLookup(cx, id);
         if (!shape) {
             uint32_t slot = 2 * JSProto_LIMIT + key;
-            if (!js_SetReservedSlot(cx, obj, slot, v))
-                return false;
+            SetReservedSlot(obj, slot, v);
             if (!obj->addProperty(cx, id, JS_PropertyStub, JS_StrictPropertyStub, slot, attrs, 0, 0))
                 return false;
             AddTypePropertyId(cx, obj, id, v);
 
             named = true;
             return true;
         }
     }
 
     named = obj->defineGeneric(cx, id, v, JS_PropertyStub, JS_StrictPropertyStub, attrs);
     return named;
 }
 
 namespace js {
 
-static bool
-SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key, JSObject *cobj, JSObject *proto)
+static void
+SetClassObject(JSObject *obj, JSProtoKey key, JSObject *cobj, JSObject *proto)
 {
     JS_ASSERT(!obj->getParent());
     if (!obj->isGlobal())
-        return true;
-
-    return js_SetReservedSlot(cx, obj, key, ObjectOrNullValue(cobj)) &&
-           js_SetReservedSlot(cx, obj, JSProto_LIMIT + key, ObjectOrNullValue(proto));
+        return;
+
+    SetReservedSlot(obj, key, ObjectOrNullValue(cobj));
+    SetReservedSlot(obj, JSProto_LIMIT + key, ObjectOrNullValue(proto));
 }
 
 static void
 ClearClassObject(JSContext *cx, JSObject *obj, JSProtoKey key)
 {
     JS_ASSERT(!obj->getParent());
     if (!obj->isGlobal())
         return;
@@ -3717,18 +3716,17 @@ DefineConstructorAndPrototype(JSContext 
         fun->setConstructorClass(clasp);
 
         /*
          * Set the class object early for standard class constructors. Type
          * inference may need to access these, and js_GetClassPrototype will
          * fail if it tries to do a reentrant reconstruction of the class.
          */
         if (key != JSProto_Null) {
-            if (!SetClassObject(cx, obj, key, fun, proto))
-                goto bad;
+            SetClassObject(obj, key, fun, proto);
             cached = true;
         }
 
         AutoValueRooter tvr2(cx, ObjectValue(*fun));
         if (!DefineStandardSlot(cx, obj, key, atom, tvr2.value(), 0, named))
             goto bad;
 
         /*
@@ -3756,18 +3754,18 @@ DefineConstructorAndPrototype(JSContext 
         JS_ASSERT_IF(ctor == proto, !(clasp->flags & JSCLASS_FREEZE_CTOR));
         if (proto && (clasp->flags & JSCLASS_FREEZE_PROTO) && !proto->freeze(cx))
             goto bad;
         if (ctor && (clasp->flags & JSCLASS_FREEZE_CTOR) && !ctor->freeze(cx))
             goto bad;
     }
 
     /* If this is a standard class, cache its prototype. */
-    if (!cached && key != JSProto_Null && !SetClassObject(cx, obj, key, ctor, proto))
-        goto bad;
+    if (!cached && key != JSProto_Null)
+        SetClassObject(obj, key, ctor, proto);
 
     if (ctorp)
         *ctorp = ctor;
     return proto;
 
 bad:
     if (named) {
         Value rval;
@@ -5774,17 +5772,17 @@ js_DeleteGeneric(JSContext *cx, JSObject
         if (strict)
             return obj->reportNotConfigurable(cx, id);
         rval->setBoolean(false);
         return true;
     }
 
     if (shape->hasSlot()) {
         const Value &v = obj->nativeGetSlot(shape->slot());
-        GCPoke(cx, v);
+        GCPoke(cx->runtime, v);
 
         /*
          * Delete is rare enough that we can take the hit of checking for an
          * active cloned method function object that must be homed to a callee
          * slot on the active stack frame before this delete completes, in case
          * someone saved the clone and checks it against foo.caller for a foo
          * called from the active method.
          *
@@ -6350,41 +6348,16 @@ js_ClearNative(JSContext *cx, JSObject *
             shape->hasDefaultSetter() &&
             shape->hasSlot()) {
             obj->nativeSetSlot(shape->slot(), UndefinedValue());
         }
     }
     return true;
 }
 
-bool
-js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t slot, Value *vp)
-{
-    if (!obj->isNative()) {
-        vp->setUndefined();
-        return true;
-    }
-
-    JS_ASSERT(slot < JSSLOT_FREE(obj->getClass()));
-    *vp = obj->getSlot(slot);
-    return true;
-}
-
-bool
-js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t slot, const Value &v)
-{
-    if (!obj->isNative())
-        return true;
-
-    JS_ASSERT(slot < JSSLOT_FREE(obj->getClass()));
-    obj->setSlot(slot, v);
-    GCPoke(cx, NullValue());
-    return true;
-}
-
 static ObjectElements emptyObjectHeader(0, 0);
 HeapValue *js::emptyObjectElements =
     (HeapValue *) (uintptr_t(&emptyObjectHeader) + sizeof(ObjectElements));
 
 JSBool
 js_ReportGetterOnlyAssignment(JSContext *cx)
 {
     return JS_ReportErrorFlagsAndNumber(cx,
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1985,22 +1985,16 @@ extern JSBool
 js_XDRObject(JSXDRState *xdr, JSObject **objp);
 
 extern void
 js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize);
 
 extern bool
 js_ClearNative(JSContext *cx, JSObject *obj);
 
-extern bool
-js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, js::Value *vp);
-
-extern bool
-js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32_t index, const js::Value &v);
-
 extern JSBool
 js_ReportGetterOnlyAssignment(JSContext *cx);
 
 extern uintN
 js_InferFlags(JSContext *cx, uintN defaultFlags);
 
 /* Object constructor native. Exposed only so the JIT can know its address. */
 JSBool
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -7713,18 +7713,17 @@ js_GetAnyName(JSContext *cx, jsid *idp)
 
         JS_ASSERT(!obj->getProto());
 
         JSRuntime *rt = cx->runtime;
         if (!InitXMLQName(cx, obj, rt->emptyString, rt->emptyString, rt->atomState.starAtom))
             return false;
 
         v.setObject(*obj);
-        if (!js_SetReservedSlot(cx, global, JSProto_AnyName, v))
-            return false;
+        SetReservedSlot(global, JSProto_AnyName, v);
     }
     *idp = OBJECT_TO_JSID(&v.toObject());
     return true;
 }
 
 JSBool
 js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *idp)
 {
--- a/js/src/perf/jsperf.cpp
+++ b/js/src/perf/jsperf.cpp
@@ -66,25 +66,25 @@ pm_construct(JSContext* cx, uintN argc, 
         return JS_FALSE;
 
     PerfMeasurement* p = cx->new_<PerfMeasurement>(PerfMeasurement::EventMask(mask));
     if (!p) {
         JS_ReportOutOfMemory(cx);
         return JS_FALSE;
     }
 
-    JS_SetPrivate(cx, obj, p);
+    JS_SetPrivate(obj, p);
     *vp = OBJECT_TO_JSVAL(obj);
     return JS_TRUE;
 }
 
 static void
 pm_finalize(JSContext* cx, JSObject* obj)
 {
-    cx->delete_((PerfMeasurement*) JS_GetPrivate(cx, obj));
+    cx->delete_((PerfMeasurement*) JS_GetPrivate(obj));
 }
 
 // Property access
 
 #define GETTER(name)                                                    \
     static JSBool                                                       \
     pm_get_##name(JSContext* cx, JSObject* obj, jsid /*unused*/, jsval* vp) \
     {                                                                   \
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1625,17 +1625,17 @@ ValueToScript(JSContext *cx, jsval v, JS
     JSScript *script = NULL;
     JSFunction *fun = NULL;
 
     if (!JSVAL_IS_PRIMITIVE(v)) {
         JSObject *obj = JSVAL_TO_OBJECT(v);
         JSClass *clasp = JS_GetClass(obj);
 
         if (clasp == Jsvalify(&GeneratorClass)) {
-            if (JSGenerator *gen = (JSGenerator *) JS_GetPrivate(cx, obj)) {
+            if (JSGenerator *gen = (JSGenerator *) JS_GetPrivate(obj)) {
                 fun = gen->floatingFrame()->fun();
                 script = fun->script();
             }
         }
     }
 
     if (!script) {
         fun = JS_ValueToFunction(cx, v);
@@ -2782,17 +2782,17 @@ Clone(JSContext *cx, uintN argc, jsval *
             return JS_FALSE;
         }
     }
 
     if (argc > 1) {
         if (!JS_ValueToObject(cx, argv[1], &parent))
             return JS_FALSE;
     } else {
-        parent = JS_GetParent(cx, JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
+        parent = JS_GetParent(JSVAL_TO_OBJECT(JS_CALLEE(cx, vp)));
     }
 
     clone = JS_CloneFunctionObject(cx, funobj, parent);
     if (!clone)
         return JS_FALSE;
     *vp = OBJECT_TO_JSVAL(clone);
     return JS_TRUE;
 }
@@ -3209,26 +3209,24 @@ CopyProperty(JSContext *cx, JSObject *ob
     *objp = obj;
     return !!DefineNativeProperty(cx, obj, id, desc.value, desc.getter, desc.setter,
                                   desc.attrs, propFlags, desc.shortid);
 }
 
 static JSBool
 resolver_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
 {
-    jsval v;
-    JS_ALWAYS_TRUE(JS_GetReservedSlot(cx, obj, 0, &v));
+    jsval v = JS_GetReservedSlot(obj, 0);
     return CopyProperty(cx, obj, JSVAL_TO_OBJECT(v), id, flags, objp);
 }
 
 static JSBool
 resolver_enumerate(JSContext *cx, JSObject *obj)
 {
-    jsval v;
-    JS_ALWAYS_TRUE(JS_GetReservedSlot(cx, obj, 0, &v));
+    jsval v = JS_GetReservedSlot(obj, 0);
     JSObject *referent = JSVAL_TO_OBJECT(v);
 
     AutoIdArray ida(cx, JS_Enumerate(cx, referent));
     bool ok = !!ida;
     JSObject *ignore;
     for (size_t i = 0; ok && i < ida.length(); i++)
         ok = CopyProperty(cx, obj, referent, ida[i], JSRESOLVE_QUALIFIED, &ignore);
     return ok;
@@ -3249,21 +3247,21 @@ static JSBool
 Resolver(JSContext *cx, uintN argc, jsval *vp)
 {
     JSObject *referent, *proto = NULL;
     if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o/o", &referent, &proto))
         return false;
 
     JSObject *result = (argc > 1
                         ? JS_NewObjectWithGivenProto
-                        : JS_NewObject)(cx, &resolver_class, proto, JS_GetParent(cx, referent));
+                        : JS_NewObject)(cx, &resolver_class, proto, JS_GetParent(referent));
     if (!result)
         return false;
 
-    JS_ALWAYS_TRUE(JS_SetReservedSlot(cx, result, 0, OBJECT_TO_JSVAL(referent)));
+    JS_SetReservedSlot(result, 0, OBJECT_TO_JSVAL(referent));
     JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(result));
     return true;
 }
 
 #ifdef JS_THREADSAFE
 
 /*
  * Check that t1 comes strictly before t2. The function correctly deals with
@@ -3576,17 +3574,17 @@ Parent(JSContext *cx, uintN argc, jsval 
     }
 
     jsval v = JS_ARGV(cx, vp)[0];
     if (JSVAL_IS_PRIMITIVE(v)) {
         JS_ReportError(cx, "Only objects have parents!");
         return JS_FALSE;
     }
 
-    JSObject *parent = JS_GetParent(cx, JSVAL_TO_OBJECT(v));
+    JSObject *parent = JS_GetParent(JSVAL_TO_OBJECT(v));
     *vp = OBJECT_TO_JSVAL(parent);
 
     /* Outerize if necessary.  Embrace the ugliness! */
     if (parent) {
         if (JSObjectOp op = parent->getClass()->ext.outerObject)
             *vp = OBJECT_TO_JSVAL(op(cx, parent));
     }
 
@@ -4521,73 +4519,69 @@ its_convert(JSContext *cx, JSObject *obj
 }
 
 static void
 its_finalize(JSContext *cx, JSObject *obj)
 {
     jsval *rootedVal;
     if (its_noisy)
         fprintf(gOutFile, "finalizing it\n");
-    rootedVal = (jsval *) JS_GetPrivate(cx, obj);
+    rootedVal = (jsval *) JS_GetPrivate(obj);
     if (rootedVal) {
       JS_RemoveValueRoot(cx, rootedVal);
-      JS_SetPrivate(cx, obj, NULL);
+      JS_SetPrivate(obj, NULL);
       delete rootedVal;
     }
 }
 
 static JSClass its_class = {
     "It", JSCLASS_NEW_RESOLVE | JSCLASS_NEW_ENUMERATE | JSCLASS_HAS_PRIVATE,
     its_addProperty,  its_delProperty,  its_getProperty,  its_setProperty,
     (JSEnumerateOp)its_enumerate, (JSResolveOp)its_resolve,
     its_convert,      its_finalize,
     JSCLASS_NO_OPTIONAL_MEMBERS
 };
 
 static JSBool
 its_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
 {
     if (JS_GetClass(obj) == &its_class) {
-        jsval *val = (jsval *) JS_GetPrivate(cx, obj);
+        jsval *val = (jsval *) JS_GetPrivate(obj);
         *vp = val ? *val : JSVAL_VOID;
     } else {
         *vp = JSVAL_VOID;
     }
 
     return JS_TRUE;
 }
 
 static JSBool
 its_setter(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
 {
     if (JS_GetClass(obj) != &its_class)
         return JS_TRUE;
 
-    jsval *val = (jsval *) JS_GetPrivate(cx, obj);
+    jsval *val = (jsval *) JS_GetPrivate(obj);
     if (val) {
         *val = *vp;
         return JS_TRUE;
     }
 
     val = new jsval;
     if (!val) {
         JS_ReportOutOfMemory(cx);
         return JS_FALSE;
     }
 
     if (!JS_AddValueRoot(cx, val)) {
         delete val;
         return JS_FALSE;
     }
 
-    if (!JS_SetPrivate(cx, obj, (void*)val)) {
-        JS_RemoveValueRoot(cx, val);
-        delete val;
-        return JS_FALSE;
-    }
+    JS_SetPrivate(obj, (void*)val);
 
     *val = *vp;
     return JS_TRUE;
 }
 
 JSErrorFormatString jsShell_ErrorFormatString[JSShellErr_Limit] = {
 #define MSG_DEF(name, number, count, exception, format) \
     { format, count, JSEXN_ERR } ,
@@ -4890,17 +4884,17 @@ env_enumerate(JSContext *cx, JSObject *o
     static JSBool reflected;
     char **evp, *name, *value;
     JSString *valstr;
     JSBool ok;
 
     if (reflected)
         return JS_TRUE;
 
-    for (evp = (char **)JS_GetPrivate(cx, obj); (name = *evp) != NULL; evp++) {
+    for (evp = (char **)JS_GetPrivate(obj); (name = *evp) != NULL; evp++) {
         value = strchr(name, '=');
         if (!value)
             continue;
         *value++ = '\0';
         valstr = JS_NewStringCopyZ(cx, value);
         if (!valstr) {
             ok = JS_FALSE;
         } else {
@@ -5193,18 +5187,19 @@ Shell(JSContext *cx, OptionParser *op, c
 
     JSAutoEnterCompartment ac;
     if (!ac.enter(cx, glob))
         return 1;
 
     JS_SetGlobalObject(cx, glob);
 
     JSObject *envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
-    if (!envobj || !JS_SetPrivate(cx, envobj, envp))
+    if (!envobj)
         return 1;
+    JS_SetPrivate(envobj, envp);
 
 #ifdef JSDEBUGGER
     /*
     * XXX A command line option to enable debugging (or not) would be good
     */
     jsdc = JSD_DebuggerOnForUser(rt, NULL, NULL);
     if (!jsdc)
         return 1;
--- a/js/src/shell/jsworkers.cpp
+++ b/js/src/shell/jsworkers.cpp
@@ -484,20 +484,21 @@ class ThreadPool
     static ThreadPool *create(JSContext *cx, WorkerHooks *hooks) {
         ThreadPool *tp = new ThreadPool(hooks);
         if (!tp) {
             JS_ReportOutOfMemory(cx);
             return NULL;
         }
 
         JSObject *obj = JS_NewObject(cx, &jsClass, NULL, NULL);
-        if (!obj || !JS_SetPrivate(cx, obj, tp)) {
+        if (!obj) {
             delete tp;
             return NULL;
         }
+        JS_SetPrivate(obj, tp);
         tp->obj = obj;
         return tp;
     }
 
     JSObject *asObject() { return obj; }
     WorkerHooks *getHooks() { return hooks; }
     WorkerQueue *getWorkerQueue() { return wq; }
     MainQueue *getMainQueue() { return mq; }
@@ -561,33 +562,33 @@ class ThreadPool
         mq->disposeChildren();
         mq->destroy(cx);
         mq = NULL;
         terminating = 0;
     }
 
   private:
     static void jsTraceThreadPool(JSTracer *trc, JSObject *obj) {
-        ThreadPool *tp = unwrap(trc->context, obj);
+        ThreadPool *tp = unwrap(obj);
         if (tp->mq) {
             tp->mq->traceChildren(trc);
             tp->wq->trace(trc);
         }
     }
 
 
     static void jsFinalize(JSContext *cx, JSObject *obj) {
-        if (ThreadPool *tp = unwrap(cx, obj))
+        if (ThreadPool *tp = unwrap(obj))
             delete tp;
     }
 
   public:
-    static ThreadPool *unwrap(JSContext *cx, JSObject *obj) {
+    static ThreadPool *unwrap(JSObject *obj) {
         JS_ASSERT(JS_GetClass(obj) == &jsClass);
-        return (ThreadPool *) JS_GetPrivate(cx, obj);
+        return (ThreadPool *) JS_GetPrivate(obj);
     }
 };
 
 /*
  * A Worker is always in one of 4 states, except when it is being initialized
  * or destroyed, or its lock is held:
  *   - idle       (!terminated && current == NULL && events.empty())
  *   - enqueued   (!terminated && current == NULL && !events.empty())
@@ -621,20 +622,20 @@ class Worker MOZ_FINAL : public WorkerPa
         JS_ASSERT(!threadPool && !this->parent && !object && !lock);
 
         if (!initWorkerParent() || !parent->addChild(this))
             return false;
         threadPool = parent->getThreadPool();
         this->parent = parent;
         this->object = obj;
         lock = PR_NewLock();
-        return lock &&
-               createRuntime(parentcx) &&
-               createContext(parentcx, parent) &&
-               JS_SetPrivate(parentcx, obj, this);
+        if (!lock || !createRuntime(parentcx) || !createContext(parentcx, parent))
+            return false;
+        JS_SetPrivate(obj, this);
+        return true;
     }
 
     bool createRuntime(JSContext *parentcx) {
         runtime = JS_NewRuntime(1L * 1024L * 1024L);
         if (!runtime) {
             JS_ReportOutOfMemory(parentcx);
             return false;
         }
@@ -696,28 +697,28 @@ class Worker MOZ_FINAL : public WorkerPa
         JS_EndRequest(context);
         JS_DestroyContext(context);
         context = NULL;
         return false;
     }
 
     static void jsTraceWorker(JSTracer *trc, JSObject *obj) {
         JS_ASSERT(JS_GetClass(obj) == &jsWorkerClass);
-        if (Worker *w = (Worker *) JS_GetPrivate(trc->context, obj)) {
+        if (Worker *w = (Worker *) JS_GetPrivate(obj)) {
             w->parent->trace(trc);
             w->events.trace(trc);
             if (w->current)
                 w->current->trace(trc);
             JS_CALL_OBJECT_TRACER(trc, JS_GetGlobalObject(w->context), "Worker global");
         }
     }
 
     static void jsFinalize(JSContext *cx, JSObject *obj) {
         JS_ASSERT(JS_GetClass(obj) == &jsWorkerClass);
-        if (Worker *w = (Worker *) JS_GetPrivate(cx, obj))
+        if (Worker *w = (Worker *) JS_GetPrivate(obj))
             delete w;
     }
 
     static JSBool jsOperationCallback(JSContext *cx) {
         Worker *w = (Worker *) JS_GetContextPrivate(cx);
         JSAutoSuspendRequest suspend(cx);  // avoid nesting w->lock in a request
         return !w->checkTermination();
     }
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -2632,21 +2632,19 @@ DebuggerFrame_getArguments(JSContext *cx
     if (fp->hasArgs()) {
         /* Create an arguments object. */
         RootedVar<GlobalObject*> global(cx);
         global = &args.callee().global();
         JSObject *proto;
         if (!js_GetClassPrototype(cx, global, JSProto_Array, &proto))
             return false;
         argsobj = NewObjectWithGivenProto(cx, &DebuggerArguments_class, proto, global);
-        if (!argsobj ||
-            !js_SetReservedSlot(cx, argsobj, JSSLOT_DEBUGARGUMENTS_FRAME, ObjectValue(*thisobj)))
-        {
+        if (!argsobj)
             return false;
-        }
+        SetReservedSlot(argsobj, JSSLOT_DEBUGARGUMENTS_FRAME, ObjectValue(*thisobj));
 
         JS_ASSERT(fp->numActualArgs() <= 0x7fffffff);
         int32_t fargc = int32_t(fp->numActualArgs());
         if (!DefineNativeProperty(cx, argsobj, ATOM_TO_JSID(cx->runtime->atomState.lengthAtom),
                                   Int32Value(fargc), NULL, NULL,
                                   JSPROP_PERMANENT | JSPROP_READONLY, 0, 0))
         {
             return false;
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -820,17 +820,17 @@ Parent(JSContext *cx, uintN argc, jsval 
     }
 
     jsval v = JS_ARGV(cx, vp)[0];
     if (JSVAL_IS_PRIMITIVE(v)) {
         JS_ReportError(cx, "Only objects have parents!");
         return false;
     }
 
-    *vp = OBJECT_TO_JSVAL(JS_GetParent(cx, JSVAL_TO_OBJECT(v)));
+    *vp = OBJECT_TO_JSVAL(JS_GetParent(JSVAL_TO_OBJECT(v)));
     return true;
 }
 
 static JSFunctionSpec glob_functions[] = {
     {"print",           Print,          0,0},
     {"readline",        ReadLine,       1,0},
     {"load",            Load,           1,0},
     {"quit",            Quit,           0,0},
@@ -918,17 +918,17 @@ env_enumerate(JSContext *cx, JSObject *o
     static JSBool reflected;
     char **evp, *name, *value;
     JSString *valstr;
     JSBool ok;
 
     if (reflected)
         return true;
 
-    for (evp = (char **)JS_GetPrivate(cx, obj); (name = *evp) != NULL; evp++) {
+    for (evp = (char **)JS_GetPrivate(obj); (name = *evp) != NULL; evp++) {
         value = strchr(name, '=');
         if (!value)
             continue;
         *value++ = '\0';
         valstr = JS_NewStringCopyZ(cx, value);
         if (!valstr) {
             ok = false;
         } else {
@@ -1229,17 +1229,17 @@ ProcessArgs(JSContext *cx, JSObject *obj
             break;
         case 'x':
             JS_ToggleOptions(cx, JSOPTION_XML);
             break;
         case 'd':
             xpc_ActivateDebugMode();
             break;
         case 'P':
-            if (JS_GetClass(JS_GetPrototype(cx, obj)) != &global_class) {
+            if (JS_GetClass(JS_GetPrototype(obj)) != &global_class) {
                 JSObject *gobj;
 
                 if (!JS_DeepFreezeObject(cx, obj))
                     return false;
                 gobj = JS_NewGlobalObject(cx, &global_class);
                 if (!gobj || !JS_SplicePrototype(cx, gobj, obj))
                     return false;
                 JS_SetParent(cx, gobj, NULL);
@@ -1972,21 +1972,23 @@ main(int argc, char **argv, char **envp)
 
             if (!JS_DefineFunctions(cx, glob, glob_functions) ||
                 !JS_DefineProfilingFunctions(cx, glob)) {
                 JS_EndRequest(cx);
                 return 1;
             }
 
             envobj = JS_DefineObject(cx, glob, "environment", &env_class, NULL, 0);
-            if (!envobj || !JS_SetPrivate(cx, envobj, envp)) {
+            if (!envobj) {
                 JS_EndRequest(cx);
                 return 1;
             }
 
+            JS_SetPrivate(envobj, envp);
+
             nsAutoString workingDirectory;
             if (GetCurrentWorkingDirectory(workingDirectory))
                 gWorkingDirectory = &workingDirectory;
 
             JS_DefineProperty(cx, glob, "__LOCATION__", JSVAL_VOID,
                               GetLocationProperty, NULL, 0);
 
             argc--;
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -2620,17 +2620,17 @@ nsXPCComponents_Utils::LookupMethod(cons
     JSAutoRequest ar(cx);
 
     // first param must be a JSObject
     if (JSVAL_IS_PRIMITIVE(object))
         return NS_ERROR_XPC_BAD_CONVERT_JS;
 
     JSObject* obj = JSVAL_TO_OBJECT(object);
     while (obj && !js::IsWrapper(obj) && !IS_WRAPPER_CLASS(js::GetObjectClass(obj)))
-        obj = JS_GetPrototype(cx, obj);
+        obj = JS_GetPrototype(obj);
 
     if (!obj)
         return NS_ERROR_XPC_BAD_CONVERT_JS;
 
     JSObject* unwrappedObject;
     nsresult rv = nsXPConnect::GetXPConnect()->GetJSObjectOfWrapper(cx, obj, &unwrappedObject);
     if (NS_FAILED(rv))
         return rv;
@@ -3029,19 +3029,17 @@ xpc_CreateSandboxObject(JSContext * cx, 
             }
 
             ok = JS_SetPrototype(cx, sandbox, proto);
             if (!ok)
                 return NS_ERROR_XPC_UNEXPECTED;
         }
 
         // Pass on ownership of sop to |sandbox|.
-        if (!JS_SetPrivate(cx, sandbox, sop.forget().get())) {
-            return NS_ERROR_XPC_UNEXPECTED;
-        }
+        JS_SetPrivate(sandbox, sop.forget().get());
 
         rv = xpc->InitClasses(cx, sandbox);
         if (NS_SUCCEEDED(rv) &&
             !JS_DefineFunctions(cx, sandbox, SandboxFunctions)) {
             rv = NS_ERROR_FAILURE;
         }
         if (NS_FAILED(rv))
             return NS_ERROR_XPC_UNEXPECTED;
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -994,27 +994,27 @@ WrappedJSShutdownMarker(JSDHashTable *ta
 
 static JSDHashOperator
 DetachedWrappedNativeProtoShutdownMarker(JSDHashTable *table, JSDHashEntryHdr *hdr,
                                          uint32_t number, void *arg)
 {
     XPCWrappedNativeProto* proto =
         (XPCWrappedNativeProto*)((JSDHashEntryStub*)hdr)->key;
 
-    proto->SystemIsBeingShutDown((JSContext*)arg);
+    proto->SystemIsBeingShutDown();
     return JS_DHASH_NEXT;
 }
 
-void XPCJSRuntime::SystemIsBeingShutDown(JSContext* cx)
+void XPCJSRuntime::SystemIsBeingShutDown()
 {
     DOM_ClearInterfaces();
 
     if (mDetachedWrappedNativeProtoMap)
         mDetachedWrappedNativeProtoMap->
-            Enumerate(DetachedWrappedNativeProtoShutdownMarker, cx);
+            Enumerate(DetachedWrappedNativeProtoShutdownMarker, nsnull);
 }
 
 JSContext *
 XPCJSRuntime::GetJSCycleCollectionContext()
 {
     if (!mJSCycleCollectionContext) {
         mJSCycleCollectionContext = JS_NewContext(mJSRuntime, 0);
         if (!mJSCycleCollectionContext)
--- a/js/xpconnect/src/XPCQuickStubs.cpp
+++ b/js/xpconnect/src/XPCQuickStubs.cpp
@@ -147,32 +147,32 @@ PropertyOpForwarder(JSContext *cx, uintN
     JSObject *callee = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return false;
 
     jsval v = js::GetFunctionNativeReserved(callee, 0);
 
     JSObject *ptrobj = JSVAL_TO_OBJECT(v);
-    Op *popp = static_cast<Op *>(JS_GetPrivate(cx, ptrobj));
+    Op *popp = static_cast<Op *>(JS_GetPrivate(ptrobj));
 
     v = js::GetFunctionNativeReserved(callee, 1);
 
     jsval argval = (argc > 0) ? JS_ARGV(cx, vp)[0] : JSVAL_VOID;
     jsid id;
     if (!JS_ValueToId(cx, argval, &id))
         return false;
     JS_SET_RVAL(cx, vp, argval);
     return ApplyPropertyOp<Op>(cx, *popp, obj, id, vp);
 }
 
 static void
 PointerFinalize(JSContext *cx, JSObject *obj)
 {
-    JSPropertyOp *popp = static_cast<JSPropertyOp *>(JS_GetPrivate(cx, obj));
+    JSPropertyOp *popp = static_cast<JSPropertyOp *>(JS_GetPrivate(obj));
     delete popp;
 }
 
 static JSClass
 PointerHolderClass = {
     "Pointer", JSCLASS_HAS_PRIVATE,
     JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, PointerFinalize,
@@ -198,17 +198,17 @@ GeneratePropertyOp(JSContext *cx, JSObje
     // second object to work around this.
     JSObject *ptrobj = JS_NewObject(cx, &PointerHolderClass, nsnull, funobj);
     if (!ptrobj)
         return nsnull;
     Op *popp = new Op;
     if (!popp)
         return nsnull;
     *popp = pop;
-    JS_SetPrivate(cx, ptrobj, popp);
+    JS_SetPrivate(ptrobj, popp);
 
     js::SetFunctionNativeReserved(funobj, 0, OBJECT_TO_JSVAL(ptrobj));
     js::SetFunctionNativeReserved(funobj, 1, js::IdToJsval(id));
     return funobj;
 }
 
 static JSBool
 ReifyPropertyOps(JSContext *cx, JSObject *obj, jsid id, uintN orig_attrs,
--- a/js/xpconnect/src/XPCThreadContext.cpp
+++ b/js/xpconnect/src/XPCThreadContext.cpp
@@ -234,21 +234,17 @@ XPCJSContextStack::GetSafeJSContext()
             // Make sure the context is associated with a proper compartment
             // and not the default compartment.
             JS_SetGlobalObject(mSafeJSContext, glob);
 
             // Note: make sure to set the private before calling
             // InitClasses
             nsIScriptObjectPrincipal* priv = nsnull;
             sop.swap(priv);
-            if (!JS_SetPrivate(mSafeJSContext, glob, priv)) {
-                // Drop the whole thing
-                NS_RELEASE(priv);
-                glob = nsnull;
-            }
+            JS_SetPrivate(glob, priv);
         }
 
         // After this point either glob is null and the
         // nsIScriptObjectPrincipal ownership is either handled by the
         // nsCOMPtr or dealt with, or we'll release in the finalize
         // hook.
         if (glob && NS_FAILED(xpc->InitClasses(mSafeJSContext, glob))) {
             glob = nsnull;
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -702,17 +702,17 @@ XPCWrappedNative::Morph(XPCCallContext& 
     // *seen* this happen.
     AutoMarkingWrappedNativePtr wrapper(ccx);
 
 #if DEBUG
     // FIXME Can't assert this until
     //       https://bugzilla.mozilla.org/show_bug.cgi?id=343141 is fixed.
 #if 0
     if (proto->GetScriptableInfo()->GetFlags().WantPreCreate()) {
-        JSObject* parent = JS_GetParent(ccx, existingJSObject);
+        JSObject* parent = JS_GetParent(existingJSObject);
         JSObject* plannedParent = parent;
         nsresult rv =
             proto->GetScriptableInfo()->GetCallback()->PreCreate(identity, ccx,
                                                                  parent,
                                                                  &parent);
         if (NS_FAILED(rv))
             return rv;
 
@@ -1122,43 +1122,28 @@ XPCWrappedNative::Init(XPCCallContext& c
     if (!protoJSObject) {
         return false;
     }
 
     mFlatJSObject = xpc_NewSystemInheritingJSObject(ccx, jsclazz, protoJSObject, false, parent);
     if (!mFlatJSObject)
         return false;
 
-    // In the current JS engine JS_SetPrivate can't fail. But if it *did*
-    // fail then we would not receive our finalizer call and would not be
-    // able to properly cleanup. So, if it fails we null out mFlatJSObject
-    // to indicate the invalid state of this object and return false.
-    if (!JS_SetPrivate(ccx, mFlatJSObject, this)) {
-        mFlatJSObject = nsnull;
-        return false;
-    }
+    JS_SetPrivate(mFlatJSObject, this);
 
     return FinishInit(ccx);
 }
 
 JSBool
 XPCWrappedNative::Init(XPCCallContext &ccx, JSObject *existingJSObject)
 {
-    // In the current JS engine JS_SetPrivate can't fail. But if it *did*
-    // fail then we would not receive our finalizer call and would not be
-    // able to properly cleanup. So, if it fails we null out mFlatJSObject
-    // to indicate the invalid state of this object and return false.
-    if (!JS_SetPrivate(ccx, existingJSObject, this)) {
-        mFlatJSObject = nsnull;
-        return false;
-    }
+    JS_SetPrivate(existingJSObject, this);
 
     // Morph the existing object.
-    if (!JS_SetReservedSlot(ccx, existingJSObject, 0, JSVAL_VOID))
-        return false;
+    JS_SetReservedSlot(existingJSObject, 0, JSVAL_VOID);
 
     mScriptableInfo = GetProto()->GetScriptableInfo();
     mFlatJSObject = existingJSObject;
 
     SLIM_LOG(("----- %i morphed slim wrapper (mFlatJSObject: %p, %p)\n",
               ++sMorphedSlimWrappers, mFlatJSObject,
               static_cast<nsISupports*>(xpc_GetJSPrivate(mFlatJSObject))));
 
@@ -1255,34 +1240,34 @@ NS_IMPL_THREADSAFE_RELEASE(XPCWrappedNat
  *    mJSObject we set it's parent to be mFlatJSObject. This way we know that
  *    when mFlatJSObject get's collected there are no outstanding reachable
  *    tearoff mJSObjects. Note that we must clear the private of any lingering
  *    mJSObjects at this point because we have no guarentee of the *order* of
  *    finalization within a given gc cycle.
  */
 
 void
-XPCWrappedNative::FlatJSObjectFinalized(JSContext *cx)
+XPCWrappedNative::FlatJSObjectFinalized()
 {
     if (!IsValid())
         return;
 
     // Iterate the tearoffs and null out each of their JSObject's privates.
     // This will keep them from trying to access their pointers to the
     // dying tearoff object. We can safely assume that those remaining
     // JSObjects are about to be finalized too.
 
     XPCWrappedNativeTearOffChunk* chunk;
     for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
         XPCWrappedNativeTearOff* to = chunk->mTearOffs;
         for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
             JSObject* jso = to->GetJSObject();
             if (jso) {
                 NS_ASSERTION(JS_IsAboutToBeFinalized(jso), "bad!");
-                JS_SetPrivate(cx, jso, nsnull);
+                JS_SetPrivate(jso, nsnull);
                 to->JSObjectFinalized();
             }
 
             // We also need to release any native pointers held...
             nsISupports* obj = to->GetNative();
             if (obj) {
 #ifdef XP_WIN
                 // Try to detect free'd pointer
@@ -1327,17 +1312,17 @@ XPCWrappedNative::FlatJSObjectFinalized(
 
     // Note that it's not safe to touch mNativeWrapper here since it's
     // likely that it has already been finalized.
 
     Release();
 }
 
 void
-XPCWrappedNative::SystemIsBeingShutDown(JSContext* cx)
+XPCWrappedNative::SystemIsBeingShutDown()
 {
 #ifdef DEBUG_xpc_hacker
     {
         printf("Removing root for still-live XPCWrappedNative %p wrapping:\n",
                static_cast<void*>(this));
         for (PRUint16 i = 0, i_end = mSet->GetInterfaceCount(); i < i_end; ++i) {
             nsXPIDLCString name;
             mSet->GetInterfaceAt(i)->GetInterfaceInfo()
@@ -1353,38 +1338,38 @@ XPCWrappedNative::SystemIsBeingShutDown(
 
     // The long standing strategy is to leak some objects still held at shutdown.
     // The general problem is that propagating release out of xpconnect at
     // shutdown time causes a world of problems.
 
     // We leak mIdentity (see above).
 
     // short circuit future finalization
-    JS_SetPrivate(cx, mFlatJSObject, nsnull);
+    JS_SetPrivate(mFlatJSObject, nsnull);
     mFlatJSObject = nsnull; // This makes 'IsValid()' return false.
 
     XPCWrappedNativeProto* proto = GetProto();
 
     if (HasProto())
-        proto->SystemIsBeingShutDown(cx);
+        proto->SystemIsBeingShutDown();
 
     if (mScriptableInfo &&
         (!HasProto() ||
          (proto && proto->GetScriptableInfo() != mScriptableInfo))) {
         delete mScriptableInfo;
     }
 
     // cleanup the tearoffs...
 
     XPCWrappedNativeTearOffChunk* chunk;
     for (chunk = &mFirstChunk; chunk; chunk = chunk->mNextChunk) {
         XPCWrappedNativeTearOff* to = chunk->mTearOffs;
         for (int i = XPC_WRAPPED_NATIVE_TEAROFFS_PER_CHUNK-1; i >= 0; i--, to++) {
             if (to->GetJSObject()) {
-                JS_SetPrivate(cx, to->GetJSObject(), nsnull);
+                JS_SetPrivate(to->GetJSObject(), nsnull);
                 to->SetJSObject(nsnull);
             }
             // We leak the tearoff mNative
             // (for the same reason we leak mIdentity - see above).
             to->SetNative(nsnull);
             to->SetInterface(nsnull);
         }
     }
@@ -1528,17 +1513,17 @@ XPCWrappedNative::ReparentWrapperIfFound
 
             if (crosscompartment) {
                 JSObject *newobj = JS_CloneObject(ccx, flat,
                                                   newProto->GetJSProtoObject(),
                                                   aNewParent);
                 if (!newobj)
                     return NS_ERROR_FAILURE;
 
-                JS_SetPrivate(ccx, flat, nsnull);
+                JS_SetPrivate(flat, nsnull);
 
                 JSObject *propertyHolder =
                     JS_NewObjectWithGivenProto(ccx, NULL, NULL, aNewParent);
                 if (!propertyHolder || !JS_CopyPropertiesFrom(ccx, propertyHolder, flat))
                     return NS_ERROR_OUT_OF_MEMORY;
 
                 JSObject *ww = wrapper->GetWrapper();
                 if (ww) {
@@ -1580,21 +1565,21 @@ XPCWrappedNative::ReparentWrapperIfFound
                         return NS_ERROR_FAILURE;
                     }
                 } else {
                     NS_WARNING("Moving XPConnect wrappedNative to new scope, "
                                "but can't fixup __proto__");
                 }
             }
         } else {
-            if (!JS_SetReservedSlot(ccx, flat, 0,
-                                    PRIVATE_TO_JSVAL(newProto.get())) ||
-                !JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject())) {
+            JS_SetReservedSlot(flat, 0,
+                               PRIVATE_TO_JSVAL(newProto.get()));
+            if (!JS_SetPrototype(ccx, flat, newProto->GetJSProtoObject())) {
                 // this is bad, very bad
-                JS_SetReservedSlot(ccx, flat, 0, JSVAL_NULL);
+                JS_SetReservedSlot(flat, 0, JSVAL_NULL);
                 NS_ERROR("JS_SetPrototype failed");
                 return NS_ERROR_FAILURE;
             }
         }
     }
 
     // Now we can just fix up the parent and return the wrapper
 
@@ -2024,19 +2009,20 @@ XPCWrappedNative::InitTearOffJSObject(XP
 {
     // This is only called while locked (during XPCWrappedNative::FindTearOff).
 
     JSObject* obj =
         xpc_NewSystemInheritingJSObject(ccx, Jsvalify(&XPC_WN_Tearoff_JSClass),
                                         GetScope()->GetPrototypeJSObject(),
                                         false, mFlatJSObject);
 
-    if (!obj || !JS_SetPrivate(ccx, obj, to))
+    if (!obj)
         return false;
 
+    JS_SetPrivate(obj, to);
     to->SetJSObject(obj);
     return true;
 }
 
 /***************************************************************************/
 
 static JSBool Throw(uintN errNum, XPCCallContext& ccx)
 {
@@ -3708,21 +3694,22 @@ ConstructSlimWrapper(XPCCallContext &ccx
     XPCNativeScriptableInfo* si = xpcproto->GetScriptableInfo();
     JSClass* jsclazz = si->GetSlimJSClass();
     if (!jsclazz)
         return false;
 
     wrapper = xpc_NewSystemInheritingJSObject(ccx, jsclazz,
                                               xpcproto->GetJSProtoObject(),
                                               false, parent);
-    if (!wrapper ||
-        !JS_SetPrivate(ccx, wrapper, identityObj) ||
-        !JS_SetReservedSlot(ccx, wrapper, 0, PRIVATE_TO_JSVAL(xpcproto.get())))
+    if (!wrapper)
         return false;
 
+    JS_SetPrivate(wrapper, identityObj);
+    JS_SetReservedSlot(wrapper, 0, PRIVATE_TO_JSVAL(xpcproto.get()));
+
     // Transfer ownership to the wrapper's private.
     aHelper.forgetCanonical();
 
     cache->SetWrapper(wrapper);
 
     SLIM_LOG(("+++++ %i created slim wrapper (%p, %p, %p)\n", ++sSlimWrappers,
               wrapper, p, xpcScope));
 
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -632,17 +632,17 @@ XPC_WN_NoHelper_Finalize(JSContext *cx, 
         XPCJSRuntime *rt = nsXPConnect::GetRuntimeInstance();
         if(rt)
             rt->DeferredRelease(p);
         else
             NS_RELEASE(p);
         return;
     }
 
-    static_cast<XPCWrappedNative*>(p)->FlatJSObjectFinalized(cx);
+    static_cast<XPCWrappedNative*>(p)->FlatJSObjectFinalized();
 }
 
 static void
 TraceScopeJSObjects(JSTracer *trc, XPCWrappedNativeScope* scope)
 {
     NS_ASSERTION(scope, "bad scope");
 
     JSObject* obj;
@@ -1053,17 +1053,17 @@ XPC_WN_Helper_Finalize(JSContext *cx, JS
         NS_RELEASE(p);
         return;
     }
 
     XPCWrappedNative* wrapper = (XPCWrappedNative*)p;
     if (!wrapper)
         return;
     wrapper->GetScriptableCallback()->Finalize(wrapper, cx, obj);
-    wrapper->FlatJSObjectFinalized(cx);
+    wrapper->FlatJSObjectFinalized();
 }
 
 static JSBool
 XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsid id, uintN flags,
                          JSObject **objp)
 {
     nsresult rv = NS_OK;
     bool retval = true;
--- a/js/xpconnect/src/XPCWrappedNativeProto.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeProto.cpp
@@ -123,25 +123,28 @@ XPCWrappedNativeProto::Init(XPCCallConte
 
     JSObject *parent = mScope->GetGlobalJSObject();
 
     mJSProtoObject =
         xpc_NewSystemInheritingJSObject(ccx, js::Jsvalify(jsclazz),
                                         mScope->GetPrototypeJSObject(),
                                         true, parent);
 
-    JSBool ok = mJSProtoObject && JS_SetPrivate(ccx, mJSProtoObject, this);
+    JSBool ok = !!mJSProtoObject;
 
-    if (ok && callback) {
-        nsresult rv = callback->PostCreatePrototype(ccx, mJSProtoObject);
-        if (NS_FAILED(rv)) {
-            JS_SetPrivate(ccx, mJSProtoObject, nsnull);
-            mJSProtoObject = nsnull;
-            XPCThrower::Throw(rv, ccx);
-            return false;
+    if (ok) {
+        JS_SetPrivate(mJSProtoObject, this);
+        if (callback) {
+            nsresult rv = callback->PostCreatePrototype(ccx, mJSProtoObject);
+            if (NS_FAILED(rv)) {
+                JS_SetPrivate(mJSProtoObject, nsnull);
+                mJSProtoObject = nsnull;
+                XPCThrower::Throw(rv, ccx);
+                return false;
+            }
         }
     }
 
     DEBUG_ReportShadowedMembers(mSet, nsnull, this);
 
     return ok;
 }
 
@@ -160,33 +163,33 @@ XPCWrappedNativeProto::JSProtoObjectFina
 
     GetRuntime()->GetDetachedWrappedNativeProtoMap()->Remove(this);
     GetRuntime()->GetDyingWrappedNativeProtoMap()->Add(this);
 
     mJSProtoObject.finalize(cx);
 }
 
 void
-XPCWrappedNativeProto::SystemIsBeingShutDown(JSContext* cx)
+XPCWrappedNativeProto::SystemIsBeingShutDown()
 {
     // Note that the instance might receive this call multiple times
     // as we walk to here from various places.
 
 #ifdef XPC_TRACK_PROTO_STATS
     static bool DEBUG_DumpedStats = false;
     if (!DEBUG_DumpedStats) {
         printf("%d XPCWrappedNativeProto(s) alive at shutdown\n",
                gDEBUG_LiveProtoCount);
         DEBUG_DumpedStats = true;
     }
 #endif
 
     if (mJSProtoObject) {
         // short circuit future finalization
-        JS_SetPrivate(cx, mJSProtoObject, nsnull);
+        JS_SetPrivate(mJSProtoObject, nsnull);
         mJSProtoObject = nsnull;
     }
 }
 
 // static
 XPCWrappedNativeProto*
 XPCWrappedNativeProto::GetNewOrUsed(XPCCallContext& ccx,
                                     XPCWrappedNativeScope* scope,
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -122,19 +122,19 @@ XPCWrappedNativeScope::GetNewOrUsed(XPCC
         // We need to call SetGlobal in order to refresh our cached
         // mPrototypeJSObject and to clear mPrototypeNoHelper (so we get a new
         // new one if requested in the new scope) in the case where the global
         // object is being reused (JS_ClearScope has been called).  NOTE: We are
         // only called by nsXPConnect::InitClasses.
         scope->SetGlobal(ccx, aGlobal);
     }
     if (js::GetObjectClass(aGlobal)->flags & JSCLASS_XPCONNECT_GLOBAL)
-        JS_ALWAYS_TRUE(JS_SetReservedSlot(ccx, aGlobal,
-                                          JSCLASS_GLOBAL_SLOT_COUNT,
-                                          PRIVATE_TO_JSVAL(scope)));
+        JS_SetReservedSlot(aGlobal,
+                           JSCLASS_GLOBAL_SLOT_COUNT,
+                           PRIVATE_TO_JSVAL(scope));
     return scope;
 }
 
 XPCWrappedNativeScope::XPCWrappedNativeScope(XPCCallContext& ccx,
                                              JSObject* aGlobal)
     :   mRuntime(ccx.GetRuntime()),
         mWrappedNativeMap(Native2WrappedNativeMap::newMap(XPC_NATIVE_MAP_SIZE)),
         mWrappedNativeProtoMap(ClassInfo2WrappedNativeProtoMap::newMap(XPC_NATIVE_PROTO_MAP_SIZE)),
@@ -550,59 +550,58 @@ XPCWrappedNativeScope::KillDyingScopes()
         delete cur;
         cur = next;
     }
     gDyingScopes = nsnull;
 }
 
 struct ShutdownData
 {
-    ShutdownData(JSContext* acx)
-        : cx(acx), wrapperCount(0),
+    ShutdownData()
+        : wrapperCount(0),
           protoCount(0) {}
-    JSContext* cx;
     int wrapperCount;
     int protoCount;
 };
 
 static JSDHashOperator
 WrappedNativeShutdownEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr,
                                 uint32_t number, void *arg)
 {
     ShutdownData* data = (ShutdownData*) arg;
     XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
 
     if (wrapper->IsValid()) {
-        wrapper->SystemIsBeingShutDown(data->cx);
+        wrapper->SystemIsBeingShutDown();
         data->wrapperCount++;
     }
     return JS_DHASH_REMOVE;
 }
 
 static JSDHashOperator
 WrappedNativeProtoShutdownEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr,
                                      uint32_t number, void *arg)
 {
     ShutdownData* data = (ShutdownData*) arg;
     ((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value->
-        SystemIsBeingShutDown(data->cx);
+        SystemIsBeingShutDown();
     data->protoCount++;
     return JS_DHASH_REMOVE;
 }
 
 //static
 void
-XPCWrappedNativeScope::SystemIsBeingShutDown(JSContext* cx)
+XPCWrappedNativeScope::SystemIsBeingShutDown()
 {
     DEBUG_TrackScopeTraversal();
     DEBUG_TrackScopeShutdown();
 
     int liveScopeCount = 0;
 
-    ShutdownData data(cx);
+    ShutdownData data;
 
     XPCWrappedNativeScope* cur;
 
     // First move all the scopes to the dying list.
 
     cur = gScopes;
     while (cur) {
         XPCWrappedNativeScope* next = cur->mNext;
@@ -615,22 +614,16 @@ XPCWrappedNativeScope::SystemIsBeingShut
 
     // Walk the unified dying list and call shutdown on all wrappers and protos
 
     for (cur = gDyingScopes; cur; cur = cur->mNext) {
         // Give the Components object a chance to try to clean up.
         if (cur->mComponents)
             cur->mComponents->SystemIsBeingShutDown();
 
-        JSAutoEnterCompartment ac;
-
-        // XXX: What if we have no global in the scope???
-        if (cur->mGlobalJSObject)
-            ac.enter(cx, cur->mGlobalJSObject);
-
         // Walk the protos first. Wrapper shutdown can leave dangling
         // proto pointers in the proto map.
         cur->mWrappedNativeProtoMap->
                 Enumerate(WrappedNativeProtoShutdownEnumerator,  &data);
         cur->mMainThreadWrappedNativeProtoMap->
                 Enumerate(WrappedNativeProtoShutdownEnumerator,  &data);
         cur->mWrappedNativeMap->
                 Enumerate(WrappedNativeShutdownEnumerator,  &data);
--- a/js/xpconnect/src/dombindings.cpp
+++ b/js/xpconnect/src/dombindings.cpp
@@ -409,17 +409,17 @@ interface_hasInstance(JSContext *cx, JSO
         JSObject *other = &vp->toObject();
         if (instanceIsProxy(other)) {
             ProxyHandler *handler = static_cast<ProxyHandler*>(js::GetProxyHandler(other));
             if (handler->isInstanceOf(JSVAL_TO_OBJECT(prototype))) {
                 *bp = true;
             } else {
                 JSObject *protoObj = JSVAL_TO_OBJECT(prototype);
                 JSObject *proto = other;
-                while ((proto = JS_GetPrototype(cx, proto))) {
+                while ((proto = JS_GetPrototype(proto))) {
                     if (proto == protoObj) {
                         *bp = true;
                         return true;
                     }
                 }
                 *bp = false;
             }
 
@@ -754,17 +754,17 @@ ListBase<LC>::ensureExpandoObject(JSCont
 
         JSCompartment *compartment = js::GetObjectCompartment(obj);
         xpc::CompartmentPrivate *priv =
             static_cast<xpc::CompartmentPrivate *>(js_GetCompartmentPrivate(compartment));
         if (!priv->RegisterDOMExpandoObject(expando))
             return NULL;
 
         js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));
-        JS_SetPrivate(cx, expando, js::GetProxyPrivate(obj).toPrivate());
+        JS_SetPrivate(expando, js::GetProxyPrivate(obj).toPrivate());
     }
     return expando;
 }
 
 template<class LC>
 bool
 ListBase<LC>::defineProperty(JSContext *cx, JSObject *proxy, jsid id, JSPropertyDescriptor *desc)
 {
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -133,24 +133,20 @@ nsXPConnect::~nsXPConnect()
         // And do this before calling CleanupAllThreads, so that we
         // don't create an extra xpcPerThreadData.
         cx = JS_NewContext(mRuntime->GetJSRuntime(), 8192);
     }
 
     XPCPerThreadData::CleanupAllThreads();
     mShuttingDown = true;
     if (cx) {
-        JS_BeginRequest(cx);
-
         // XXX Call even if |mRuntime| null?
-        XPCWrappedNativeScope::SystemIsBeingShutDown(cx);
-
-        mRuntime->SystemIsBeingShutDown(cx);
-
-        JS_EndRequest(cx);
+        XPCWrappedNativeScope::SystemIsBeingShutDown();
+
+        mRuntime->SystemIsBeingShutDown();
         JS_DestroyContext(cx);
     }
 
     NS_IF_RELEASE(mDefaultSecurityManager);
 
     gScriptSecurityManager = nsnull;
 
     // shutdown the logging system
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -757,17 +757,17 @@ public:
     nsresult AddJSHolder(void* aHolder, nsScriptObjectTracer* aTracer);
     nsresult RemoveJSHolder(void* aHolder);
 
     static void SuspectWrappedNative(JSContext *cx, XPCWrappedNative *wrapper,
                                      nsCycleCollectionTraversalCallback &cb);
 
     void DebugDump(PRInt16 depth);
 
-    void SystemIsBeingShutDown(JSContext* cx);
+    void SystemIsBeingShutDown();
 
     PRThread* GetThreadRunningGC() const {return mThreadRunningGC;}
 
     ~XPCJSRuntime();
 
 #ifdef XPC_CHECK_WRAPPERS_AT_SHUTDOWN
    void DEBUG_AddWrappedNative(nsIXPConnectWrappedNative* wrapper)
         {XPCAutoLock lock(GetMapLock());
@@ -1540,17 +1540,17 @@ public:
     FindInJSObjectScope(XPCCallContext& ccx, JSObject* obj,
                         JSBool OKIfNotInitialized = false)
     {
         return FindInJSObjectScope(ccx, obj, OKIfNotInitialized,
                                    ccx.GetRuntime());
     }
 
     static void
-    SystemIsBeingShutDown(JSContext* cx);
+    SystemIsBeingShutDown();
 
     static void
     TraceJS(JSTracer* trc, XPCJSRuntime* rt);
 
     static void
     SuspectAllWrappers(XPCJSRuntime* rt, JSContext* cx,
                        nsCycleCollectionTraversalCallback &cb);
 
@@ -2276,17 +2276,17 @@ public:
     XPCLock* GetLock() const
         {return ClassIsThreadSafe() ? GetRuntime()->GetMapLock() : nsnull;}
 
     void SetScriptableInfo(XPCNativeScriptableInfo* si)
         {NS_ASSERTION(!mScriptableInfo, "leak here!"); mScriptableInfo = si;}
 
     void JSProtoObjectFinalized(JSContext *cx, JSObject *obj);
 
-    void SystemIsBeingShutDown(JSContext* cx);
+    void SystemIsBeingShutDown();
 
     void DebugDump(PRInt16 depth);
 
     void TraceJS(JSTracer* trc)
     {
         if (mJSProtoObject) {
             JS_CALL_OBJECT_TRACER(trc, mJSProtoObject,
                                   "XPCWrappedNativeProto::mJSProtoObject");
@@ -2627,19 +2627,19 @@ public:
     static nsresult
     ReparentWrapperIfFound(XPCCallContext& ccx,
                            XPCWrappedNativeScope* aOldScope,
                            XPCWrappedNativeScope* aNewScope,
                            JSObject* aNewParent,
                            nsISupports* aCOMObj,
                            XPCWrappedNative** aWrapper);
 
-    void FlatJSObjectFinalized(JSContext *cx);
-
-    void SystemIsBeingShutDown(JSContext* cx);
+    void FlatJSObjectFinalized();
+
+    void SystemIsBeingShutDown();
 
     enum CallMode {CALL_METHOD, CALL_GETTER, CALL_SETTER};
 
     static JSBool CallMethod(XPCCallContext& ccx,
                              CallMode mode = CALL_METHOD);
 
     static JSBool GetAttribute(XPCCallContext& ccx)
         {return CallMethod(ccx, CALL_GETTER);}
--- a/js/xpconnect/wrappers/WrapperFactory.cpp
+++ b/js/xpconnect/wrappers/WrapperFactory.cpp
@@ -451,15 +451,15 @@ WrapperFactory::WaiveXrayAndWrap(JSConte
     *vp = OBJECT_TO_JSVAL(obj);
     return JS_WrapValue(cx, vp);
 }
 
 JSObject *
 WrapperFactory::WrapSOWObject(JSContext *cx, JSObject *obj)
 {
     JSObject *wrapperObj =
-        Wrapper::New(cx, obj, JS_GetPrototype(cx, obj), JS_GetGlobalForObject(cx, obj),
+        Wrapper::New(cx, obj, JS_GetPrototype(obj), JS_GetGlobalForObject(cx, obj),
                      &FilteringWrapper<SameCompartmentSecurityWrapper,
                      OnlyIfSubjectIsSystem>::singleton);
     return wrapperObj;
 }
 
 }
--- a/security/manager/ssl/src/nsCrypto.cpp
+++ b/security/manager/ssl/src/nsCrypto.cpp
@@ -2017,17 +2017,17 @@ nsCrypto::GenerateCRMFRequest(nsIDOMCRMF
   NS_ENSURE_TRUE(principals, NS_ERROR_UNEXPECTED);
   
   nsCryptoRunArgs *args = new nsCryptoRunArgs();
   if (!args)
     return NS_ERROR_OUT_OF_MEMORY;
 
   args->m_cx         = cx;
   args->m_kungFuDeathGrip = GetISupportsFromContext(cx);
-  args->m_scope      = JS_GetParent(cx, script_obj);
+  args->m_scope      = JS_GetParent(script_obj);
 
   args->m_jsCallback.Adopt(!!jsCallback ? nsCRT::strdup(jsCallback.ptr()) : 0);
   args->m_principals = principals;
   
   nsCryptoRunnable *cryptoRunnable = new nsCryptoRunnable(args);
   if (!cryptoRunnable)
     return NS_ERROR_OUT_OF_MEMORY;
 
--- a/toolkit/components/ctypes/ctypes.cpp
+++ b/toolkit/components/ctypes/ctypes.cpp
@@ -114,20 +114,21 @@ static JSBool
 InitAndSealCTypesClass(JSContext* cx, JSObject* global)
 {
   // Init the ctypes object.
   if (!JS_InitCTypesClass(cx, global))
     return false;
 
   // Set callbacks for charset conversion and such.
   jsval ctypes;
-  if (!JS_GetProperty(cx, global, "ctypes", &ctypes) ||
-      !JS_SetCTypesCallbacks(cx, JSVAL_TO_OBJECT(ctypes), &sCallbacks))
+  if (!JS_GetProperty(cx, global, "ctypes", &ctypes))
     return false;
 
+  JS_SetCTypesCallbacks(JSVAL_TO_OBJECT(ctypes), &sCallbacks);
+
   // Seal up Object, Function, Array and Error and their prototypes.  (This
   // single object instance is shared amongst everyone who imports the ctypes
   // module.)
   if (!SealObjectAndPrototype(cx, global, "Object") ||
       !SealObjectAndPrototype(cx, global, "Function") ||
       !SealObjectAndPrototype(cx, global, "Array") ||
       !SealObjectAndPrototype(cx, global, "Error"))
     return false;
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -281,34 +281,34 @@ JSHistogram_Add(JSContext *cx, uintN arg
   }
 
   if (TelemetryImpl::CanRecord()) {
     JSObject *obj = JS_THIS_OBJECT(cx, vp);
     if (!obj) {
       return JS_FALSE;
     }
 
-    Histogram *h = static_cast<Histogram*>(JS_GetPrivate(cx, obj));
+    Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
     if (h->histogram_type() == Histogram::BOOLEAN_HISTOGRAM)
       h->Add(!!value);
     else
       h->Add(value);
   }
   return JS_TRUE;
 }
 
 JSBool
 JSHistogram_Snapshot(JSContext *cx, uintN argc, jsval *vp)
 {
   JSObject *obj = JS_THIS_OBJECT(cx, vp);
   if (!obj) {
     return JS_FALSE;
   }
 
-  Histogram *h = static_cast<Histogram*>(JS_GetPrivate(cx, obj));
+  Histogram *h = static_cast<Histogram*>(JS_GetPrivate(obj));
   JSObject *snapshot = JS_NewObject(cx, NULL, NULL, NULL);
   if (!snapshot)
     return JS_FALSE;
 
   switch (ReflectHistogramSnapshot(cx, snapshot, h)) {
   case REFLECT_FAILURE:
     return JS_FALSE;
   case REFLECT_CORRUPT:
@@ -333,18 +333,18 @@ WrapAndReturnHistogram(Histogram *h, JSC
     JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
     JSCLASS_NO_OPTIONAL_MEMBERS
   };
 
   JSObject *obj = JS_NewObject(cx, &JSHistogram_class, NULL, NULL);
   if (!obj)
     return NS_ERROR_FAILURE;
   *ret = OBJECT_TO_JSVAL(obj);
-  return (JS_SetPrivate(cx, obj, h)
-          && JS_DefineFunction (cx, obj, "add", JSHistogram_Add, 1, 0)
+  JS_SetPrivate(obj, h);
+  return (JS_DefineFunction (cx, obj, "add", JSHistogram_Add, 1, 0)
           && JS_DefineFunction (cx, obj, "snapshot", JSHistogram_Snapshot, 1, 0)) ? NS_OK : NS_ERROR_FAILURE;
 }
 
 TelemetryImpl::TelemetryImpl():
 mCanRecord(XRE_GetProcessType() == GeckoProcessType_Default),
 mHashMutex("Telemetry::mHashMutex")
 {
   // A whitelist to prevent Telemetry reporting on Addon & Thunderbird DBs