Backed out changeset a913dca49e73 (bug 1145824) for mochitest-other failure

This commit is contained in:
Tooru Fujisawa 2015-04-25 13:50:25 +09:00
parent 52fd2bad2c
commit 6081421830
12 changed files with 56 additions and 101 deletions

View File

@ -158,13 +158,10 @@ static inline void profiler_responsiveness(const mozilla::TimeStamp& aTime) {}
static inline void profiler_set_frame_number(int frameNumber) {}
// Get the profile encoded as a JSON string.
static inline char* profiler_get_profile(float aSinceTime = 0) { return nullptr; }
static inline char* profiler_get_profile() { return nullptr; }
// Get the profile encoded as a JSON object.
static inline JSObject* profiler_get_profile_jsobject(JSContext* aCx,
float aSinceTime = 0) {
return nullptr;
}
static inline JSObject* profiler_get_profile_jsobject(JSContext* aCx) { return nullptr; }
// Get the profile and write it into a file
static inline void profiler_save_profile_to_file(char* aFilename) { }

View File

@ -53,9 +53,9 @@ const double* mozilla_sampler_get_responsiveness();
void mozilla_sampler_save();
char* mozilla_sampler_get_profile(float aSinceTime);
char* mozilla_sampler_get_profile();
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx, float aSinceTime);
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx);
// Make this function easily callable from a debugger in a build without
// debugging information (work around http://llvm.org/bugs/show_bug.cgi?id=22211)

View File

@ -144,15 +144,15 @@ void profiler_set_frame_number(int frameNumber)
}
static inline
char* profiler_get_profile(float aSinceTime = 0)
char* profiler_get_profile()
{
return mozilla_sampler_get_profile(aSinceTime);
return mozilla_sampler_get_profile();
}
static inline
JSObject* profiler_get_profile_jsobject(JSContext* aCx, float aSinceTime = 0)
JSObject* profiler_get_profile_jsobject(JSContext* aCx)
{
return mozilla_sampler_get_profile_data(aCx, aSinceTime);
return mozilla_sampler_get_profile_data(aCx);
}
static inline

View File

@ -393,30 +393,18 @@ void UniqueJITOptimizations::stream(JSStreamWriter& b, JSRuntime* rt)
}
}
void ProfileBuffer::StreamSamplesToJSObject(JSStreamWriter& b, int aThreadId,
float aSinceTime, JSRuntime* rt,
void ProfileBuffer::StreamSamplesToJSObject(JSStreamWriter& b, int aThreadId, JSRuntime* rt,
UniqueJITOptimizations& aUniqueOpts)
{
bool sample = false;
int readPos = mReadPos;
int currentThreadID = -1;
float currentTime = 0;
bool hasCurrentTime = false;
while (readPos != mWritePos) {
ProfileEntry entry = mEntries[readPos];
if (entry.mTagName == 'T') {
currentThreadID = entry.mTagInt;
hasCurrentTime = false;
int readAheadPos = (readPos + 1) % mEntrySize;
if (readAheadPos != mWritePos) {
ProfileEntry readAheadEntry = mEntries[readAheadPos];
if (readAheadEntry.mTagName == 't') {
currentTime = readAheadEntry.mTagFloat;
hasCurrentTime = true;
}
}
}
if (currentThreadID == aThreadId && (!hasCurrentTime || currentTime >= aSinceTime)) {
if (currentThreadID == aThreadId) {
switch (entry.mTagName) {
case 'r':
{
@ -455,13 +443,7 @@ void ProfileBuffer::StreamSamplesToJSObject(JSStreamWriter& b, int aThreadId,
break;
case 't':
{
// FIXMEshu: this case is only needed because filtering by
// aSinceTime is broken if the unwinder thread is used, due to
// its placement of 't' tags.
//
// UnwinderTick is slated for removal in bug 1141712. Remove
// this case once it lands.
if (sample && (currentTime != entry.mTagFloat)) {
if (sample) {
b.NameValue("time", entry.mTagFloat);
}
}
@ -477,10 +459,6 @@ void ProfileBuffer::StreamSamplesToJSObject(JSStreamWriter& b, int aThreadId,
sample = true;
if (hasCurrentTime) {
b.NameValue("time", currentTime);
}
// Seek forward through the entire sample, looking for frames
// this is an easier approach to reason about than adding more
// control variables and cases to the loop that goes through the buffer once
@ -557,7 +535,7 @@ void ProfileBuffer::StreamSamplesToJSObject(JSStreamWriter& b, int aThreadId,
}
}
void ProfileBuffer::StreamMarkersToJSObject(JSStreamWriter& b, int aThreadId, float aSinceTime)
void ProfileBuffer::StreamMarkersToJSObject(JSStreamWriter& b, int aThreadId)
{
int readPos = mReadPos;
int currentThreadID = -1;
@ -566,10 +544,7 @@ void ProfileBuffer::StreamMarkersToJSObject(JSStreamWriter& b, int aThreadId, fl
if (entry.mTagName == 'T') {
currentThreadID = entry.mTagInt;
} else if (currentThreadID == aThreadId && entry.mTagName == 'm') {
const ProfilerMarker* marker = entry.getMarker();
if (marker->GetTime() >= aSinceTime) {
marker->StreamJSObject(b);
}
entry.getMarker()->StreamJSObject(b);
}
readPos = (readPos + 1) % mEntrySize;
}
@ -675,13 +650,13 @@ void ThreadProfile::IterateTags(IterateTagsCallback aCallback)
mBuffer->IterateTagsForThread(aCallback, mThreadId);
}
void ThreadProfile::ToStreamAsJSON(std::ostream& stream, float aSinceTime)
void ThreadProfile::ToStreamAsJSON(std::ostream& stream)
{
JSStreamWriter b(stream);
StreamJSObject(b, aSinceTime);
StreamJSObject(b);
}
void ThreadProfile::StreamJSObject(JSStreamWriter& b, float aSinceTime)
void ThreadProfile::StreamJSObject(JSStreamWriter& b)
{
b.BeginObject();
// Thread meta data
@ -702,22 +677,16 @@ void ThreadProfile::StreamJSObject(JSStreamWriter& b, float aSinceTime)
b.Name("samples");
b.BeginArray();
if (!mSavedStreamedSamples.empty()) {
// We would only have saved streamed samples during shutdown
// streaming, which cares about dumping the entire buffer, and thus
// should have passed in 0 for aSinceTime.
MOZ_ASSERT(aSinceTime == 0);
b.SpliceArrayElements(mSavedStreamedSamples.c_str());
mSavedStreamedSamples.clear();
}
mBuffer->StreamSamplesToJSObject(b, mThreadId, aSinceTime, mPseudoStack->mRuntime,
uniqueOpts);
mBuffer->StreamSamplesToJSObject(b, mThreadId, mPseudoStack->mRuntime, uniqueOpts);
b.EndArray();
// Having saved streamed optimizations implies the JS engine has
// shutdown. If the JS engine is gone, we shouldn't have any new JS
// samples, and thus no optimizations.
if (!mSavedStreamedOptimizations.empty()) {
MOZ_ASSERT(aSinceTime == 0);
MOZ_ASSERT(uniqueOpts.empty());
b.Name("optimizations");
b.BeginArray();
@ -734,11 +703,10 @@ void ThreadProfile::StreamJSObject(JSStreamWriter& b, float aSinceTime)
b.Name("markers");
b.BeginArray();
if (!mSavedStreamedMarkers.empty()) {
MOZ_ASSERT(aSinceTime == 0);
b.SpliceArrayElements(mSavedStreamedMarkers.c_str());
mSavedStreamedMarkers.clear();
}
mBuffer->StreamMarkersToJSObject(b, mThreadId, aSinceTime);
mBuffer->StreamMarkersToJSObject(b, mThreadId);
b.EndArray();
b.EndObject();
}
@ -757,7 +725,7 @@ void ThreadProfile::FlushSamplesAndMarkers()
JSStreamWriter b(ss);
UniqueJITOptimizations uniqueOpts;
b.BeginBareList();
mBuffer->StreamSamplesToJSObject(b, mThreadId, 0, mPseudoStack->mRuntime, uniqueOpts);
mBuffer->StreamSamplesToJSObject(b, mThreadId, mPseudoStack->mRuntime, uniqueOpts);
b.EndBareList();
mSavedStreamedSamples = ss.str();
@ -777,7 +745,7 @@ void ThreadProfile::FlushSamplesAndMarkers()
ss.clear();
b.BeginBareList();
mBuffer->StreamMarkersToJSObject(b, mThreadId, 0);
mBuffer->StreamMarkersToJSObject(b, mThreadId);
b.EndBareList();
mSavedStreamedMarkers = ss.str();
@ -786,7 +754,7 @@ void ThreadProfile::FlushSamplesAndMarkers()
mBuffer->reset();
}
JSObject* ThreadProfile::ToJSObject(JSContext *aCx, float aSinceTime)
JSObject* ThreadProfile::ToJSObject(JSContext *aCx)
{
JS::RootedValue val(aCx);
std::stringstream ss;
@ -794,7 +762,7 @@ JSObject* ThreadProfile::ToJSObject(JSContext *aCx, float aSinceTime)
// Define a scope to prevent a moving GC during ~JSStreamWriter from
// trashing the return value.
JSStreamWriter b(ss);
StreamJSObject(b, aSinceTime);
StreamJSObject(b);
NS_ConvertUTF8toUTF16 js_string(nsDependentCString(ss.str().c_str()));
JS_ParseJSON(aCx, static_cast<const char16_t*>(js_string.get()),
js_string.Length(), &val);

View File

@ -102,9 +102,9 @@ public:
void addTag(const ProfileEntry& aTag);
void IterateTagsForThread(IterateTagsCallback aCallback, int aThreadId);
void StreamSamplesToJSObject(JSStreamWriter& b, int aThreadId, float aSinceTime,
JSRuntime* rt, UniqueJITOptimizations& aUniqueOpts);
void StreamMarkersToJSObject(JSStreamWriter& b, int aThreadId, float aSinceTime);
void StreamSamplesToJSObject(JSStreamWriter& b, int aThreadId, JSRuntime* rt,
UniqueJITOptimizations& aUniqueOpts);
void StreamMarkersToJSObject(JSStreamWriter& b, int aThreadId);
void DuplicateLastSample(int aThreadId);
void addStoredMarker(ProfilerMarker* aStoredMarker);
@ -155,11 +155,11 @@ public:
void addStoredMarker(ProfilerMarker *aStoredMarker);
void IterateTags(IterateTagsCallback aCallback);
void ToStreamAsJSON(std::ostream& stream, float aSinceTime = 0);
JSObject *ToJSObject(JSContext *aCx, float aSinceTime = 0);
void ToStreamAsJSON(std::ostream& stream);
JSObject *ToJSObject(JSContext *aCx);
PseudoStack* GetPseudoStack();
mozilla::Mutex* GetMutex();
void StreamJSObject(JSStreamWriter& b, float aSinceTime = 0);
void StreamJSObject(JSStreamWriter& b);
/**
* Call this method when the JS entries inside the buffer are about to

View File

@ -30,7 +30,7 @@ ProfilerMarkerPayload::~ProfilerMarkerPayload()
void
ProfilerMarkerPayload::streamCommonProps(const char* aMarkerType,
JSStreamWriter& b)
JSStreamWriter& b)
{
MOZ_ASSERT(aMarkerType);
b.NameValue("type", aMarkerType);

View File

@ -97,7 +97,7 @@ public:
return mGenID + 2 <= aGenID;
}
float GetTime() const;
float GetTime();
private:
char* mMarkerName;

View File

@ -218,13 +218,13 @@ void TableTicker::StreamMetaJSCustomObject(JSStreamWriter& b)
b.EndObject();
}
void TableTicker::ToStreamAsJSON(std::ostream& stream, float aSinceTime)
void TableTicker::ToStreamAsJSON(std::ostream& stream)
{
JSStreamWriter b(stream);
StreamJSObject(b, aSinceTime);
StreamJSObject(b);
}
JSObject* TableTicker::ToJSObject(JSContext *aCx, float aSinceTime)
JSObject* TableTicker::ToJSObject(JSContext *aCx)
{
JS::RootedValue val(aCx);
std::stringstream ss;
@ -232,7 +232,7 @@ JSObject* TableTicker::ToJSObject(JSContext *aCx, float aSinceTime)
// Define a scope to prevent a moving GC during ~JSStreamWriter from
// trashing the return value.
JSStreamWriter b(ss);
StreamJSObject(b, aSinceTime);
StreamJSObject(b);
NS_ConvertUTF8toUTF16 js_string(nsDependentCString(ss.str().c_str()));
JS_ParseJSON(aCx, static_cast<const char16_t*>(js_string.get()),
js_string.Length(), &val);
@ -316,7 +316,7 @@ void BuildJavaThreadJSObject(JSStreamWriter& b)
}
#endif
void TableTicker::StreamJSObject(JSStreamWriter& b, float aSinceTime)
void TableTicker::StreamJSObject(JSStreamWriter& b)
{
b.BeginObject();
// Put shared library info
@ -351,7 +351,7 @@ void TableTicker::StreamJSObject(JSStreamWriter& b, float aSinceTime)
MutexAutoLock lock(*sRegisteredThreads->at(i)->Profile()->GetMutex());
sRegisteredThreads->at(i)->Profile()->StreamJSObject(b, aSinceTime);
sRegisteredThreads->at(i)->Profile()->StreamJSObject(b);
}
}
@ -979,11 +979,6 @@ void TableTicker::InplaceTick(TickSample* sample)
currThreadProfile.addTag(ProfileEntry('T', currThreadProfile.ThreadId()));
if (sample) {
mozilla::TimeDuration delta = sample->timestamp - sStartTime;
currThreadProfile.addTag(ProfileEntry('t', static_cast<float>(delta.ToMilliseconds())));
}
PseudoStack* stack = currThreadProfile.GetPseudoStack();
#if defined(USE_NS_STACKWALK) || defined(USE_EHABI_STACKWALK) || \
@ -1013,6 +1008,11 @@ void TableTicker::InplaceTick(TickSample* sample)
currThreadProfile.addTag(ProfileEntry('r', static_cast<float>(delta.ToMilliseconds())));
}
if (sample) {
mozilla::TimeDuration delta = sample->timestamp - sStartTime;
currThreadProfile.addTag(ProfileEntry('t', static_cast<float>(delta.ToMilliseconds())));
}
// rssMemory is equal to 0 when we are not recording.
if (sample && sample->rssMemory != 0) {
currThreadProfile.addTag(ProfileEntry('R', static_cast<float>(sample->rssMemory)));

View File

@ -192,8 +192,8 @@ class TableTicker: public Sampler {
return mPrimaryThreadProfile;
}
void ToStreamAsJSON(std::ostream& stream, float aSinceTime = 0);
virtual JSObject *ToJSObject(JSContext *aCx, float aSinceTime = 0);
void ToStreamAsJSON(std::ostream& stream);
virtual JSObject *ToJSObject(JSContext *aCx);
void StreamMetaJSCustomObject(JSStreamWriter& b);
void StreamTaskTracer(JSStreamWriter& b);
void FlushOnJSShutdown(JSRuntime* aRuntime);
@ -219,7 +219,7 @@ protected:
// Not implemented on platforms which do not support backtracing
void doNativeBacktrace(ThreadProfile &aProfile, TickSample* aSample);
void StreamJSObject(JSStreamWriter& b, float aSinceTime);
void StreamJSObject(JSStreamWriter& b);
// This represent the application's main thread (SAMPLER_INIT)
ThreadProfile* mPrimaryThreadProfile;

View File

@ -12,7 +12,7 @@ class nsCString;
[ref] native StringArrayRef(const nsTArray<nsCString>);
[scriptable, uuid(9f3e7c97-abcf-425c-83fd-34d354eb95e8)]
[scriptable, uuid(9c3c0534-ef4b-4a6e-a1a6-4522d4824ac8)]
interface nsIProfiler : nsISupports
{
void StartProfiler(in uint32_t aEntries, in double aInterval,
@ -25,19 +25,9 @@ interface nsIProfiler : nsISupports
void PauseSampling();
void ResumeSampling();
void AddMarker(in string aMarker);
/*
* Returns the JSON string of the profile. If aSinceTime is passed, only
* report samples taken at >= aSinceTime.
*/
string GetProfile([optional] in float aSinceTime);
/*
* Returns a JS object of the profile. If aSinceTime is passed, only report
* samples taken at >= aSinceTime.
*/
string GetProfile();
[implicit_jscontext]
jsval getProfileData([optional] in float aSinceTime);
jsval getProfileData();
boolean IsActive();
void GetFeatures(out uint32_t aCount, [retval, array, size_is(aCount)] out string aFeatures);

View File

@ -117,9 +117,9 @@ nsProfiler::AddMarker(const char *aMarker)
}
NS_IMETHODIMP
nsProfiler::GetProfile(float aSinceTime, char **aProfile)
nsProfiler::GetProfile(char **aProfile)
{
char *profile = profiler_get_profile(aSinceTime);
char *profile = profiler_get_profile();
if (profile) {
size_t len = strlen(profile);
char *profileStr = static_cast<char *>
@ -202,10 +202,10 @@ nsProfiler::DumpProfileToFile(const char* aFilename)
}
NS_IMETHODIMP
nsProfiler::GetProfileData(float aSinceTime, JSContext* aCx,
nsProfiler::GetProfileData(JSContext* aCx,
JS::MutableHandle<JS::Value> aResult)
{
JS::RootedObject obj(aCx, profiler_get_profile_jsobject(aCx, aSinceTime));
JS::RootedObject obj(aCx, profiler_get_profile_jsobject(aCx));
if (!obj) {
return NS_ERROR_FAILURE;
}

View File

@ -201,7 +201,7 @@ ProfilerMarker::SetGeneration(uint32_t aGenID) {
}
float
ProfilerMarker::GetTime() const {
ProfilerMarker::GetTime() {
return mTime;
}
@ -551,7 +551,7 @@ void mozilla_sampler_save()
t->HandleSaveRequest();
}
char* mozilla_sampler_get_profile(float aSinceTime)
char* mozilla_sampler_get_profile()
{
TableTicker *t = tlsTicker.get();
if (!t) {
@ -559,19 +559,19 @@ char* mozilla_sampler_get_profile(float aSinceTime)
}
std::stringstream stream;
t->ToStreamAsJSON(stream, aSinceTime);
t->ToStreamAsJSON(stream);
char* profile = strdup(stream.str().c_str());
return profile;
}
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx, float aSinceTime)
JSObject *mozilla_sampler_get_profile_data(JSContext *aCx)
{
TableTicker *t = tlsTicker.get();
if (!t) {
return nullptr;
}
return t->ToJSObject(aCx, aSinceTime);
return t->ToJSObject(aCx);
}
void mozilla_sampler_save_profile_to_file(const char* aFilename)