Bug 711491. Remove WriteTag. r=bgirard
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 16 Dec 2011 09:12:46 -0500
changeset 84751 8f6dbb41479e0824b039ae01f8004b87040319b9
parent 84750 c0f11bea9cff4d881250c4441ff10f9beefbecca
child 84752 87fe97c8123bbb7145a1eb9d8e18d45737991cc5
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard
bugs711491
milestone12.0a1
Bug 711491. Remove WriteTag. r=bgirard Just use .TagToString() and fwrite that instead of having a separate function.
tools/profiler/sps/TableTicker.cpp
--- a/tools/profiler/sps/TableTicker.cpp
+++ b/tools/profiler/sps/TableTicker.cpp
@@ -111,17 +111,16 @@ public:
 
   ProfileEntry(char aTagName, float aTagFloat)
     : mTagFloat(aTagFloat)
     , mLeafAddress(0)
     , mTagName(aTagName)
   { }
 
   string TagToString(Profile *profile);
-  void WriteTag(Profile *profile, FILE* stream);
 
 private:
   union {
     const char* mTagData;
     float mTagFloat;
   };
   Address mLeafAddress;
   char mTagName;
@@ -181,17 +180,18 @@ public:
     if (mNeedsSharedLibraryInfo) {
       // Can't be called from signal because
       // getting the shared library information can call non-reentrant functions.
       mSharedLibraryInfo = SharedLibraryInfo::GetInfoForSelf();
     }
 
     int oldReadPos = mReadPos;
     while (mReadPos != mWritePos) {
-      mEntries[mReadPos].WriteTag(this, stream);
+      string tag = mEntries[mReadPos].TagToString(this);
+      fwrite(tag.data(), 1, tag.length(), stream);
       mReadPos = (mReadPos + 1) % mEntrySize;
     }
     mReadPos = oldReadPos;
   }
 
   SharedLibraryInfo& getSharedLibraryInfo()
   {
     return mSharedLibraryInfo;
@@ -372,43 +372,16 @@ string ProfileEntry::TagToString(Profile
       snprintf(tagBuff, 1024, "l-???@%llu\n", pc);
       tag += string(tagBuff);
     }
   }
 #endif
   return tag;
 }
 
-void ProfileEntry::WriteTag(Profile *profile, FILE *stream)
-{
-  fprintf(stream, "%c-%s\n", mTagName, mTagData);
-
-#ifdef ENABLE_SPS_LEAF_DATA
-  if (mLeafAddress) {
-    bool found = false;
-    SharedLibraryInfo& shlibInfo = profile->getSharedLibraryInfo();
-    unsigned long pc = (unsigned long)mLeafAddress;
-    // TODO Use binary sort (STL)
-    for (size_t i = 0; i < shlibInfo.GetSize(); i++) {
-      SharedLibrary &e = shlibInfo.GetEntry(i);
-      if (pc > e.GetStart() && pc < e.GetEnd()) {
-        if (e.GetName()) {
-          found = true;
-          fprintf(stream, "l-%s@%li\n", e.GetName(), pc - e.GetStart());
-          break;
-        }
-      }
-    }
-    if (!found) {
-      fprintf(stream, "l-???@%li\n", pc);
-    }
-  }
-#endif
-}
-
 #define PROFILE_DEFAULT_ENTRY 100000
 #define PROFILE_DEFAULT_INTERVAL 10
 
 void mozilla_sampler_init()
 {
   // TODO linux port: Use TLS with ifdefs
   if (!mozilla::tls::create(&pkey_stack) ||
       !mozilla::tls::create(&pkey_ticker)) {