Bug 1468789 - Part 3: Serialize innerWindowID for js/jit frames. r=gerald
authorNazım Can Altınova <canaltinova@gmail.com>
Thu, 14 Nov 2019 14:15:03 +0000
changeset 502165 e4ed5d091e3dd498dbeb416ece8399ffcf13d52e
parent 502164 1c3c775faf994b0cb12be28fc5afca9f444569af
child 502166 cde2ca39e32b7e344ebd4f6eac900c7ac1dee26a
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1468789
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1468789 - Part 3: Serialize innerWindowID for js/jit frames. r=gerald Differential Revision: https://phabricator.services.mozilla.com/D51861
mozglue/baseprofiler/core/ProfileBufferEntry.cpp
mozglue/baseprofiler/core/ProfileBufferEntry.h
mozglue/baseprofiler/core/ProfiledThreadData.cpp
mozglue/baseprofiler/core/platform.cpp
tools/profiler/core/ProfileBufferEntry.cpp
tools/profiler/core/ProfileBufferEntry.h
tools/profiler/core/ProfiledThreadData.cpp
tools/profiler/core/platform.cpp
--- a/mozglue/baseprofiler/core/ProfileBufferEntry.cpp
+++ b/mozglue/baseprofiler/core/ProfileBufferEntry.cpp
@@ -297,29 +297,35 @@ void UniqueStacks::StreamStack(const Sta
 }
 
 void UniqueStacks::StreamNonJITFrame(const FrameKey& aFrame) {
   using NormalFrameData = FrameKey::NormalFrameData;
 
   enum Schema : uint32_t {
     LOCATION = 0,
     RELEVANT_FOR_JS = 1,
-    IMPLEMENTATION = 2,
-    OPTIMIZATIONS = 3,
-    LINE = 4,
-    COLUMN = 5,
-    CATEGORY = 6,
-    SUBCATEGORY = 7
+    INNER_WINDOW_ID = 2,
+    IMPLEMENTATION = 3,
+    OPTIMIZATIONS = 4,
+    LINE = 5,
+    COLUMN = 6,
+    CATEGORY = 7,
+    SUBCATEGORY = 8
   };
 
   AutoArraySchemaWriter writer(mFrameTableWriter, *mUniqueStrings);
 
   const NormalFrameData& data = aFrame.mData.as<NormalFrameData>();
   writer.StringElement(LOCATION, data.mLocation.c_str());
   writer.BoolElement(RELEVANT_FOR_JS, data.mRelevantForJS);
+
+  // It's okay to convert uint64_t to double here because DOM always creates IDs
+  // that are convertible to double.
+  writer.DoubleElement(INNER_WINDOW_ID, data.mInnerWindowID);
+
   if (data.mLine.isSome()) {
     writer.IntElement(LINE, *data.mLine);
   }
   if (data.mColumn.isSome()) {
     writer.IntElement(COLUMN, *data.mColumn);
   }
   if (data.mCategoryPair.isSome()) {
     const ProfilingCategoryPairInfo& info =
--- a/mozglue/baseprofiler/core/ProfileBufferEntry.h
+++ b/mozglue/baseprofiler/core/ProfileBufferEntry.h
@@ -360,22 +360,23 @@ class UniqueStacks {
 //   },
 //
 //   "frameTable":
 //   {
 //     "schema":
 //     {
 //       "location": 0,       /* index into stringTable */
 //       "relevantForJS": 1,  /* bool */
-//       "implementation": 2, /* index into stringTable */
-//       "optimizations": 3,  /* arbitrary JSON */
-//       "line": 4,           /* number */
-//       "column": 5,         /* number */
-//       "category": 6        /* index into profile.meta.categories */
-//       "subcategory": 7     /* index into
+//       "innerWindowID": 2,  /* inner window ID of global JS `window` object */
+//       "implementation": 3, /* index into stringTable */
+//       "optimizations": 4,  /* arbitrary JSON */
+//       "line": 5,           /* number */
+//       "column": 6,         /* number */
+//       "category": 7,       /* index into profile.meta.categories */
+//       "subcategory": 8     /* index into
 //       profile.meta.categories[category].subcategories */
 //     },
 //     "data":
 //     [
 //       [ 0 ],               /* { location: '(root)' } */
 //       [ 1, 2 ]             /* { location: 'foo.js',
 //                                 implementation: 'baseline' } */
 //     ]
--- a/mozglue/baseprofiler/core/ProfiledThreadData.cpp
+++ b/mozglue/baseprofiler/core/ProfiledThreadData.cpp
@@ -54,16 +54,17 @@ void ProfiledThreadData::StreamJSON(cons
     aWriter.EndObject();
 
     aWriter.StartObjectProperty("frameTable");
     {
       {
         JSONSchemaWriter schema(aWriter);
         schema.WriteField("location");
         schema.WriteField("relevantForJS");
+        schema.WriteField("innerWindowID");
         schema.WriteField("implementation");
         schema.WriteField("optimizations");
         schema.WriteField("line");
         schema.WriteField("column");
         schema.WriteField("category");
         schema.WriteField("subcategory");
       }
 
--- a/mozglue/baseprofiler/core/platform.cpp
+++ b/mozglue/baseprofiler/core/platform.cpp
@@ -1615,17 +1615,17 @@ static void StreamCategories(SpliceableJ
 
 static int64_t MicrosecondsSince1970();
 
 static void StreamMetaJSCustomObject(PSLockRef aLock,
                                      SpliceableJSONWriter& aWriter,
                                      bool aIsShuttingDown) {
   MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
 
-  aWriter.IntProperty("version", 18);
+  aWriter.IntProperty("version", 19);
 
   // The "startTime" field holds the number of milliseconds since midnight
   // January 1, 1970 GMT. This grotty code computes (Now - (Now -
   // ProcessStartTime)) to convert CorePS::ProcessStartTime() into that form.
   TimeDuration delta = TimeStamp::NowUnfuzzed() - CorePS::ProcessStartTime();
   aWriter.DoubleProperty(
       "startTime", MicrosecondsSince1970() / 1000.0 - delta.ToMilliseconds());
 
--- a/tools/profiler/core/ProfileBufferEntry.cpp
+++ b/tools/profiler/core/ProfileBufferEntry.cpp
@@ -458,29 +458,35 @@ void UniqueStacks::StreamStack(const Sta
 }
 
 void UniqueStacks::StreamNonJITFrame(const FrameKey& aFrame) {
   using NormalFrameData = FrameKey::NormalFrameData;
 
   enum Schema : uint32_t {
     LOCATION = 0,
     RELEVANT_FOR_JS = 1,
-    IMPLEMENTATION = 2,
-    OPTIMIZATIONS = 3,
-    LINE = 4,
-    COLUMN = 5,
-    CATEGORY = 6,
-    SUBCATEGORY = 7
+    INNER_WINDOW_ID = 2,
+    IMPLEMENTATION = 3,
+    OPTIMIZATIONS = 4,
+    LINE = 5,
+    COLUMN = 6,
+    CATEGORY = 7,
+    SUBCATEGORY = 8
   };
 
   AutoArraySchemaWriter writer(mFrameTableWriter, *mUniqueStrings);
 
   const NormalFrameData& data = aFrame.mData.as<NormalFrameData>();
   writer.StringElement(LOCATION, data.mLocation.get());
   writer.BoolElement(RELEVANT_FOR_JS, data.mRelevantForJS);
+
+  // It's okay to convert uint64_t to double here because DOM always creates IDs
+  // that are convertible to double.
+  writer.DoubleElement(INNER_WINDOW_ID, data.mInnerWindowID);
+
   if (data.mLine.isSome()) {
     writer.IntElement(LINE, *data.mLine);
   }
   if (data.mColumn.isSome()) {
     writer.IntElement(COLUMN, *data.mColumn);
   }
   if (data.mCategoryPair.isSome()) {
     const JS::ProfilingCategoryPairInfo& info =
@@ -579,29 +585,35 @@ static void StreamJITFrameOptimizations(
 }
 
 static void StreamJITFrame(JSContext* aContext, SpliceableJSONWriter& aWriter,
                            UniqueJSONStrings& aUniqueStrings,
                            const JS::ProfiledFrameHandle& aJITFrame) {
   enum Schema : uint32_t {
     LOCATION = 0,
     RELEVANT_FOR_JS = 1,
-    IMPLEMENTATION = 2,
-    OPTIMIZATIONS = 3,
-    LINE = 4,
-    COLUMN = 5,
-    CATEGORY = 6,
-    SUBCATEGORY = 7
+    INNER_WINDOW_ID = 2,
+    IMPLEMENTATION = 3,
+    OPTIMIZATIONS = 4,
+    LINE = 5,
+    COLUMN = 6,
+    CATEGORY = 7,
+    SUBCATEGORY = 8
   };
 
   AutoArraySchemaWriter writer(aWriter, aUniqueStrings);
 
   writer.StringElement(LOCATION, aJITFrame.label());
   writer.BoolElement(RELEVANT_FOR_JS, false);
 
+  // It's okay to convert uint64_t to double here because DOM always creates IDs
+  // that are convertible to double.
+  // Realm ID is the name of innerWindowID inside JS code.
+  writer.DoubleElement(INNER_WINDOW_ID, aJITFrame.realmID());
+
   JS::ProfilingFrameIterator::FrameKind frameKind = aJITFrame.frameKind();
   MOZ_ASSERT(frameKind == JS::ProfilingFrameIterator::Frame_Ion ||
              frameKind == JS::ProfilingFrameIterator::Frame_Baseline);
   writer.StringElement(
       IMPLEMENTATION,
       frameKind == JS::ProfilingFrameIterator::Frame_Ion ? "ion" : "baseline");
 
   if (aJITFrame.hasTrackedOptimizations()) {
--- a/tools/profiler/core/ProfileBufferEntry.h
+++ b/tools/profiler/core/ProfileBufferEntry.h
@@ -497,22 +497,23 @@ class UniqueStacks {
 //   },
 //
 //   "frameTable":
 //   {
 //     "schema":
 //     {
 //       "location": 0,       /* index into stringTable */
 //       "relevantForJS": 1,  /* bool */
-//       "implementation": 2, /* index into stringTable */
-//       "optimizations": 3,  /* arbitrary JSON */
-//       "line": 4,           /* number */
-//       "column": 5,         /* number */
-//       "category": 6        /* index into profile.meta.categories */
-//       "subcategory": 7     /* index into
+//       "innerWindowID": 2,  /* inner window ID of global JS `window` object */
+//       "implementation": 3, /* index into stringTable */
+//       "optimizations": 4,  /* arbitrary JSON */
+//       "line": 5,           /* number */
+//       "column": 6,         /* number */
+//       "category": 7,       /* index into profile.meta.categories */
+//       "subcategory": 8     /* index into
 //       profile.meta.categories[category].subcategories */
 //     },
 //     "data":
 //     [
 //       [ 0 ],               /* { location: '(root)' } */
 //       [ 1, 2 ]             /* { location: 'foo.js',
 //                                 implementation: 'baseline' } */
 //     ]
--- a/tools/profiler/core/ProfiledThreadData.cpp
+++ b/tools/profiler/core/ProfiledThreadData.cpp
@@ -76,16 +76,17 @@ void ProfiledThreadData::StreamJSON(cons
     aWriter.EndObject();
 
     aWriter.StartObjectProperty("frameTable");
     {
       {
         JSONSchemaWriter schema(aWriter);
         schema.WriteField("location");
         schema.WriteField("relevantForJS");
+        schema.WriteField("innerWindowID");
         schema.WriteField("implementation");
         schema.WriteField("optimizations");
         schema.WriteField("line");
         schema.WriteField("column");
         schema.WriteField("category");
         schema.WriteField("subcategory");
       }
 
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2042,17 +2042,17 @@ static void StreamCategories(SpliceableJ
 #undef CATEGORY_JSON_END_CATEGORY
 }
 
 static void StreamMetaJSCustomObject(PSLockRef aLock,
                                      SpliceableJSONWriter& aWriter,
                                      bool aIsShuttingDown) {
   MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
 
-  aWriter.IntProperty("version", 18);
+  aWriter.IntProperty("version", 19);
 
   // The "startTime" field holds the number of milliseconds since midnight
   // January 1, 1970 GMT. This grotty code computes (Now - (Now -
   // ProcessStartTime)) to convert CorePS::ProcessStartTime() into that form.
   TimeDuration delta = TimeStamp::NowUnfuzzed() - CorePS::ProcessStartTime();
   aWriter.DoubleProperty(
       "startTime",
       static_cast<double>(PR_Now() / 1000.0 - delta.ToMilliseconds()));