PRBool ok; ok = ::JS_AddNamedRoot(cx, aScriptObjectRef, aName); if (! ok) return NS_ERROR_OUT_OF_MEMORY;  if (gScriptRuntimeRefcnt++ == 0) { nsServiceManager::GetService("@mozilla.org/js/xpc/RuntimeService;1", NS_GET_IID(nsIJSRuntimeService), (nsISupports**) &gJSRuntimeService);  if (! gJSRuntimeService)
if (++gScriptRuntimeRefcnt == 1 || !gScriptRuntime) { CallGetService("@mozilla.org/js/xpc/RuntimeService;1", &gJSRuntimeService); if (! gJSRuntimeService) { NS_NOTREACHED("couldn't add GC root");
AddJSGCRoot(JSContext* cx, void* aScriptObjectRef, const char* aName){    PRBool ok;    ok = ::JS_AddNamedRoot(cx, aScriptObjectRef, aName);    if (! ok) return NS_ERROR_OUT_OF_MEMORY;    if (gScriptRuntimeRefcnt++ == 0) {        nsServiceManager::GetService("@mozilla.org/js/xpc/RuntimeService;1", // contractid                                     NS_GET_IID(nsIJSRuntimeService),                                     (nsISupports**) &gJSRuntimeService);        if (! gJSRuntimeService)            return NS_ERROR_FAILURE;        gJSRuntimeService->GetRuntime(&gScriptRuntime);    }    return NS_OK;}