Bug 1624993 - Transfer all the Android markers to platform side while capturing the profile r=gerald

Differential Revision: https://phabricator.services.mozilla.com/D79124
This commit is contained in:
Nazım Can Altınova 2020-06-25 14:29:29 +00:00
Родитель 43599d0362
Коммит 8e7aefa97e
1 изменённых файлов: 51 добавлений и 1 удалений

Просмотреть файл

@ -2523,6 +2523,10 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) {
// locked_profiler_start uses sample count is 1000 for Java thread.
// This entry size is enough now, but we might have to estimate it
// if we can customize it
// Pass the samples
// FIXME(bug 1618560): We are currently only profiling the Java main thread.
constexpr int threadId = 0;
int sampleId = 0;
while (true) {
// Gets the data from the java main thread only.
@ -2531,7 +2535,7 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) {
break;
}
aProfileBuffer.AddThreadIdEntry(0);
aProfileBuffer.AddThreadIdEntry(threadId);
aProfileBuffer.AddEntry(ProfileBufferEntry::Time(sampleTime));
int frameId = 0;
while (true) {
@ -2549,6 +2553,52 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) {
}
sampleId++;
}
// Pass the markers now
while (true) {
// Gets the data from the java main thread only.
java::GeckoJavaSampler::Marker::LocalRef marker =
java::GeckoJavaSampler::PollNextMarker();
if (!marker) {
// All markers are transferred.
break;
}
// Get all the marker information from the Java thread using JNI.
nsCString markerName = marker->GetMarkerName()->ToCString();
jni::String::LocalRef text = marker->GetMarkerText();
TimeStamp startTime =
CorePS::ProcessStartTime() +
TimeDuration::FromMilliseconds(marker->GetStartTime());
double endTimeMs = marker->GetEndTime();
// A marker can be either a duration with start and end, or a point in time
// with only startTime. If endTime is 0, this means it's a point in time.
TimeStamp endTime = endTimeMs == 0
? startTime
: CorePS::ProcessStartTime() +
TimeDuration::FromMilliseconds(endTimeMs);
// Text field is optional, create different type of payloads depending on
// this.
if (!text) {
// This marker doesn't have a text
const TimingMarkerPayload payload(startTime, endTime);
// Put the marker inside the buffer
StoreMarker(aProfileBuffer, threadId, markerName.get(),
JS::ProfilingCategoryPair::JAVA_ANDROID, &payload, startTime);
} else {
// This marker has a text
nsCString textString = text->ToCString();
const TextMarkerPayload payload(textString, startTime, endTime, Nothing(),
nullptr);
// Put the marker inside the buffer
StoreMarker(aProfileBuffer, threadId, markerName.get(),
JS::ProfilingCategoryPair::JAVA_ANDROID, &payload, startTime);
}
}
}
#endif