Bug 1330185 - Remove main-thread-only assertions.
This sets up the IOInterposer on the wrong thread. We are interested in IO on
the main thread, not on whatever thread started the profiler.
MozReview-Commit-ID: 9EI195QsizN
--- a/tools/profiler/core/platform-linux-android.cpp
+++ b/tools/profiler/core/platform-linux-android.cpp
@@ -287,18 +287,16 @@ SamplerThread::SamplerThread(PSLockRef a
: mActivityGeneration(aActivityGeneration)
, mIntervalMicroseconds(
std::max(1, int(floor(aIntervalMilliseconds * 1000 + 0.5))))
, mMyPid(getpid())
// We don't know what the sampler thread's ID will be until it runs, so set
// mSamplerTid to a dummy value and fill it in for real in ThreadEntry().
, mSamplerTid(-1)
{
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
-
#if defined(USE_EHABI_STACKWALK)
mozilla::EHABIStackWalkInit();
#elif defined(USE_LUL_STACKWALK)
bool createdLUL = false;
lul::LUL* lul = CorePS::Lul(aLock);
if (!lul) {
lul = new lul::LUL(logging_sink_for_LUL);
CorePS::SetLul(aLock, lul);
--- a/tools/profiler/core/platform-macos.cpp
+++ b/tools/profiler/core/platform-macos.cpp
@@ -85,33 +85,30 @@ ThreadEntry(void* aArg)
}
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
double aIntervalMilliseconds)
: mActivityGeneration(aActivityGeneration)
, mIntervalMicroseconds(
std::max(1, int(floor(aIntervalMilliseconds * 1000 + 0.5))))
{
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
-
pthread_attr_t* attr_ptr = nullptr;
if (pthread_create(&mThread, attr_ptr, ThreadEntry, this) != 0) {
MOZ_CRASH("pthread_create failed");
}
}
SamplerThread::~SamplerThread()
{
pthread_join(mThread, nullptr);
}
void
SamplerThread::Stop(PSLockRef aLock)
{
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
}
void
SamplerThread::SuspendAndSampleAndResumeThread(PSLockRef aLock,
TickSample& aSample)
{
thread_act_t samplee_thread = aSample.mPlatformData->ProfiledThread();
--- a/tools/profiler/core/platform-win32.cpp
+++ b/tools/profiler/core/platform-win32.cpp
@@ -99,18 +99,16 @@ ThreadEntry(void* aArg)
}
SamplerThread::SamplerThread(PSLockRef aLock, uint32_t aActivityGeneration,
double aIntervalMilliseconds)
: mActivityGeneration(aActivityGeneration)
, mIntervalMicroseconds(
std::max(1, int(floor(aIntervalMilliseconds * 1000 + 0.5))))
{
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
-
// By default we'll not adjust the timer resolution which tends to be
// around 16ms. However, if the requested interval is sufficiently low
// we'll try to adjust the resolution to match.
if (mIntervalMicroseconds < 10*1000) {
::timeBeginPeriod(mIntervalMicroseconds / 1000);
}
// Create a new thread. It is important to use _beginthreadex() instead of
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -1330,17 +1330,16 @@ StreamNameAndThreadId(JSONWriter& aWrite
aWriter.EndObject();
}
#endif
static void
StreamTaskTracer(PSLockRef aLock, SpliceableJSONWriter& aWriter)
{
#ifdef MOZ_TASK_TRACER
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
aWriter.StartArrayProperty("data");
{
UniquePtr<nsTArray<nsCString>> data =
mozilla::tasktracer::GetLoggedData(CorePS::ProcessStartTime(aLock));
for (uint32_t i = 0; i < data->Length(); ++i) {
aWriter.StringElement((data->ElementAt(i)).get());
@@ -1514,17 +1513,16 @@ BuildJavaThreadJSObject(SpliceableJSONWr
static void
locked_profiler_stream_json_for_this_process(PSLockRef aLock,
SpliceableJSONWriter& aWriter,
double aSinceTime)
{
LOG("locked_profiler_stream_json_for_this_process");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
// Put shared library info
aWriter.StartArrayProperty("libs");
AppendSharedLibraries(aWriter);
aWriter.EndArray();
// Put meta data
@@ -1579,17 +1577,16 @@ locked_profiler_stream_json_for_this_pro
aWriter.EndArray();
}
bool
profiler_stream_json_for_this_process(SpliceableJSONWriter& aWriter, double aSinceTime)
{
LOG("profiler_stream_json_for_this_process");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
PSAutoLock lock(gPSMutex);
if (!ActivePS::Exists(lock)) {
return false;
}
@@ -2132,17 +2129,16 @@ profiler_shutdown()
}
}
UniquePtr<char[]>
profiler_get_profile(double aSinceTime)
{
LOG("profiler_get_profile");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
SpliceableChunkedJSONWriter b;
b.Start(SpliceableJSONWriter::SingleLineStyle);
{
if (!profiler_stream_json_for_this_process(b, aSinceTime)) {
return nullptr;
}
@@ -2156,17 +2152,16 @@ profiler_get_profile(double aSinceTime)
return b.WriteFunc()->CopyData();
}
void
profiler_get_start_params(int* aEntries, double* aInterval, uint32_t* aFeatures,
mozilla::Vector<const char*>* aFilters)
{
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
if (NS_WARN_IF(!aEntries) || NS_WARN_IF(!aInterval) ||
NS_WARN_IF(!aFeatures) || NS_WARN_IF(!aFilters)) {
return;
}
PSAutoLock lock(gPSMutex);
@@ -2232,17 +2227,16 @@ profiler_save_profile_to_file(const char
}
locked_profiler_save_profile_to_file(lock, aFilename);
}
uint32_t
profiler_get_available_features()
{
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
uint32_t features = 0;
#define ADD_FEATURE(n_, str_, Name_) ProfilerFeature::Set##Name_(features);
// Add all the possible features.
PROFILER_FOR_EACH_FEATURE(ADD_FEATURE)
@@ -2304,17 +2298,16 @@ locked_profiler_start(PSLockRef aLock, i
#undef LOG_FEATURE
for (uint32_t i = 0; i < aFilterCount; i++) {
LOG("- threads = %s", aFilters[i]);
}
}
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists() && !ActivePS::Exists(aLock));
// Fall back to the default values if the passed-in values are unreasonable.
int entries = aEntries > 0 ? aEntries : PROFILER_DEFAULT_ENTRIES;
double interval = aInterval > 0 ? aInterval : PROFILER_DEFAULT_INTERVAL;
ActivePS::Create(aLock, entries, interval, aFeatures, aFilters, aFilterCount);
@@ -2361,17 +2354,16 @@ locked_profiler_start(PSLockRef aLock, i
}
void
profiler_start(int aEntries, double aInterval, uint32_t aFeatures,
const char** aFilters, uint32_t aFilterCount)
{
LOG("profiler_start");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
SamplerThread* samplerThread = nullptr;
{
PSAutoLock lock(gPSMutex);
// Initialize if necessary.
if (!CorePS::Exists()) {
profiler_init(nullptr);
@@ -2396,17 +2388,16 @@ profiler_start(int aEntries, double aInt
aFilters, aFilterCount);
}
static MOZ_MUST_USE SamplerThread*
locked_profiler_stop(PSLockRef aLock)
{
LOG("locked_profiler_stop");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
#ifdef MOZ_TASK_TRACER
if (ActivePS::FeatureTaskTracer(aLock)) {
mozilla::tasktracer::StopLogging();
}
#endif
@@ -2444,17 +2435,16 @@ locked_profiler_stop(PSLockRef aLock)
return samplerThread;
}
void
profiler_stop()
{
LOG("profiler_stop");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
SamplerThread* samplerThread;
{
PSAutoLock lock(gPSMutex);
if (!ActivePS::Exists(lock)) {
return;
@@ -2478,34 +2468,32 @@ profiler_stop()
// in a way that's safe with respect to other gPSMutex-locking operations
// that may have occurred in the meantime.
delete samplerThread;
}
bool
profiler_is_paused()
{
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
PSAutoLock lock(gPSMutex);
if (!ActivePS::Exists(lock)) {
return false;
}
return ActivePS::IsPaused(lock);
}
void
profiler_pause()
{
LOG("profiler_pause");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
{
PSAutoLock lock(gPSMutex);
if (!ActivePS::Exists(lock)) {
return;
}
@@ -2517,17 +2505,16 @@ profiler_pause()
NotifyObservers("profiler-paused");
}
void
profiler_resume()
{
LOG("profiler_resume");
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());
PSAutoLock lock(gPSMutex);
{
if (!ActivePS::Exists(lock)) {
return;
}