diff options
Diffstat (limited to 'xpcom/base')
-rw-r--r-- | xpcom/base/CycleCollectedJSContext.cpp | 6 | ||||
-rw-r--r-- | xpcom/base/CycleCollectedJSContext.h | 12 | ||||
-rw-r--r-- | xpcom/base/nsDebugImpl.cpp | 8 | ||||
-rw-r--r-- | xpcom/base/nsMemoryReporterManager.cpp | 83 | ||||
-rw-r--r-- | xpcom/base/nsTraceRefcnt.cpp | 2 |
5 files changed, 94 insertions, 17 deletions
diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 206984656..e16c15455 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -468,10 +468,8 @@ CycleCollectedJSContext::~CycleCollectedJSContext() MOZ_ASSERT(mDebuggerPromiseMicroTaskQueue.empty()); MOZ_ASSERT(mPromiseMicroTaskQueue.empty()); -#ifdef SPIDERMONKEY_PROMISE mUncaughtRejections.reset(); mConsumedRejections.reset(); -#endif // SPIDERMONKEY_PROMISE JS_DestroyContext(mJSContext); mJSContext = nullptr; @@ -544,12 +542,10 @@ CycleCollectedJSContext::Initialize(JSContext* aParentContext, JS::SetGetIncumbentGlobalCallback(mJSContext, GetIncumbentGlobalCallback); -#ifdef SPIDERMONKEY_PROMISE JS::SetEnqueuePromiseJobCallback(mJSContext, EnqueuePromiseJobCallback, this); JS::SetPromiseRejectionTrackerCallback(mJSContext, PromiseRejectionTrackerCallback, this); mUncaughtRejections.init(mJSContext, JS::GCVector<JSObject*, 0, js::SystemAllocPolicy>(js::SystemAllocPolicy())); mConsumedRejections.init(mJSContext, JS::GCVector<JSObject*, 0, js::SystemAllocPolicy>(js::SystemAllocPolicy())); -#endif // SPIDERMONKEY_PROMISE JS::dbg::SetDebuggerMallocSizeOf(mJSContext, moz_malloc_size_of); @@ -975,7 +971,6 @@ CycleCollectedJSContext::EnqueuePromiseJobCallback(JSContext* aCx, return true; } -#ifdef SPIDERMONKEY_PROMISE /* static */ void CycleCollectedJSContext::PromiseRejectionTrackerCallback(JSContext* aCx, @@ -995,7 +990,6 @@ CycleCollectedJSContext::PromiseRejectionTrackerCallback(JSContext* aCx, PromiseDebugging::AddConsumedRejection(aPromise); } } -#endif // SPIDERMONKEY_PROMISE struct JsGcTracer : public TraceCallbacks { diff --git a/xpcom/base/CycleCollectedJSContext.h b/xpcom/base/CycleCollectedJSContext.h index 9415634b8..ac4cf4361 100644 --- a/xpcom/base/CycleCollectedJSContext.h +++ b/xpcom/base/CycleCollectedJSContext.h @@ -224,12 +224,10 @@ private: JS::HandleObject aAllocationSite, JS::HandleObject aIncumbentGlobal, void* aData); -#ifdef SPIDERMONKEY_PROMISE static void PromiseRejectionTrackerCallback(JSContext* aCx, JS::HandleObject aPromise, PromiseRejectionHandlingState state, void* aData); -#endif // SPIDERMONKEY_PROMISE virtual void TraceNativeBlackRoots(JSTracer* aTracer) { }; void TraceNativeGrayRoots(JSTracer* aTracer); @@ -406,7 +404,7 @@ public: // Storage for watching rejected promises waiting for some client to // consume their rejection. -#ifdef SPIDERMONKEY_PROMISE + // Promises in this list have been rejected in the last turn of the // event loop without the rejection being handled. // Note that this can contain nullptrs in place of promises removed because @@ -417,13 +415,7 @@ public: // (because they were in the above list), but the rejection was handled // in the last turn of the event loop. JS::PersistentRooted<JS::GCVector<JSObject*, 0, js::SystemAllocPolicy>> mConsumedRejections; -#else - // We store values as `nsISupports` to avoid adding compile-time dependencies - // from xpcom to dom/promise, but they can really only have a single concrete - // type. - nsTArray<nsCOMPtr<nsISupports /* Promise */>> mUncaughtRejections; - nsTArray<nsCOMPtr<nsISupports /* Promise */ >> mConsumedRejections; -#endif // SPIDERMONKEY_PROMISE + nsTArray<nsCOMPtr<nsISupports /* UncaughtRejectionObserver */ >> mUncaughtRejectionObservers; private: diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index a81eb3d71..84ba150db 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -450,6 +450,12 @@ RealBreak() ".object_arch armv4t\n" #endif "BKPT #0"); +#elif defined(__sun) +#if defined (__i386__) || defined(__i386) || defined(__x86_64__) + asm("int $3"); +#else + raise(SIGTRAP); +#endif #else #warning do not know how to break on this platform #endif @@ -524,6 +530,8 @@ Break(const char* aMsg) RealBreak(); #elif defined(__arm__) RealBreak(); +#elif defined(__sun) + RealBreak(); #else #warning do not know how to break on this platform #endif diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 88964f9b5..dcbad171e 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -317,6 +317,85 @@ VsizeMaxContiguousDistinguishedAmount(int64_t* aN) } #endif // FreeBSD +#elif defined(XP_SOLARIS) + +#include <procfs.h> +#include <fcntl.h> +#include <unistd.h> + +static void +XMappingIter(int64_t& aVsize, int64_t& aResident) +{ + aVsize = -1; + aResident = -1; + int mapfd = open("/proc/self/xmap", O_RDONLY); + struct stat st; + prxmap_t* prmapp = nullptr; + if (mapfd >= 0) { + if (!fstat(mapfd, &st)) { + int nmap = st.st_size / sizeof(prxmap_t); + while (1) { + // stat(2) on /proc/<pid>/xmap returns an incorrect value, + // prior to the release of Solaris 11. + // Here is a workaround for it. + nmap *= 2; + prmapp = (prxmap_t*)malloc((nmap + 1) * sizeof(prxmap_t)); + if (!prmapp) { + // out of memory + break; + } + int n = pread(mapfd, prmapp, (nmap + 1) * sizeof(prxmap_t), 0); + if (n < 0) { + break; + } + if (nmap >= n / sizeof(prxmap_t)) { + aVsize = 0; + aResident = 0; + for (int i = 0; i < n / sizeof(prxmap_t); i++) { + aVsize += prmapp[i].pr_size; + aResident += prmapp[i].pr_rss * prmapp[i].pr_pagesize; + } + break; + } + free(prmapp); + } + free(prmapp); + } + close(mapfd); + } +} + +#define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 +static MOZ_MUST_USE nsresult +VsizeDistinguishedAmount(int64_t* aN) +{ + int64_t vsize, resident; + XMappingIter(vsize, resident); + if (vsize == -1) { + return NS_ERROR_FAILURE; + } + *aN = vsize; + return NS_OK; +} + +static MOZ_MUST_USE nsresult +ResidentDistinguishedAmount(int64_t* aN) +{ + int64_t vsize, resident; + XMappingIter(vsize, resident); + if (resident == -1) { + return NS_ERROR_FAILURE; + } + *aN = resident; + return NS_OK; +} + +static MOZ_MUST_USE nsresult +ResidentFastDistinguishedAmount(int64_t* aN) +{ + return ResidentDistinguishedAmount(aN); +} + #elif defined(XP_MACOSX) #include <mach/mach_init.h> @@ -1066,9 +1145,13 @@ ResidentPeakDistinguishedAmount(int64_t* aN) if (0 == getrusage(RUSAGE_SELF, &usage)) { // The units for ru_maxrrs: // - Mac: bytes + // - Solaris: pages? But some sources it actually always returns 0, so + // check for that // - Linux, {Net/Open/Free}BSD, DragonFly: KiB #ifdef XP_MACOSX *aN = usage.ru_maxrss; +#elif defined(XP_SOLARIS) + *aN = usage.ru_maxrss * getpagesize(); #else *aN = usage.ru_maxrss * 1024; #endif diff --git a/xpcom/base/nsTraceRefcnt.cpp b/xpcom/base/nsTraceRefcnt.cpp index da51305a9..48448dbd9 100644 --- a/xpcom/base/nsTraceRefcnt.cpp +++ b/xpcom/base/nsTraceRefcnt.cpp @@ -657,7 +657,7 @@ InitLog(const char* aEnvVar, const char* aMsg, FILE** aResult) fname.Append('_'); fname.Append((char*)XRE_ChildProcessTypeToString(XRE_GetProcessType())); fname.AppendLiteral("_pid"); - fname.AppendInt((uint32_t)getpid()); + fname.AppendInt(getpid()); if (hasLogExtension) { fname.AppendLiteral(".log"); } |